mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-06 01:16:34 +00:00
updated
This commit is contained in:
@@ -3,30 +3,41 @@
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
CONF_FILE="/etc/scratchpkg.conf"
|
||||
|
||||
source "$CONF_FILE"
|
||||
source "/usr/share/scratchpkg/color"
|
||||
source "/usr/share/scratchpkg/message"
|
||||
|
||||
if [ ! "$1" ]; then
|
||||
echo "Please specify package name to install."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d $INDEX_DIR/$1 ]; then
|
||||
echo "Package $1 already installed" && exit 0
|
||||
fi
|
||||
checkinstalled() {
|
||||
|
||||
source "$CONF_FILE"
|
||||
source "/usr/share/scratchpkg/color"
|
||||
source "/usr/share/scratchpkg/message"
|
||||
if [ -d $INDEX_DIR/$1 ]; then
|
||||
msg "Package ${color_green}$1${color_reset} already installed"
|
||||
else
|
||||
depinst $1
|
||||
fi
|
||||
|
||||
pkgname=$1
|
||||
}
|
||||
|
||||
|
||||
checkpkg() {
|
||||
|
||||
for repo in ${PORT_REPO[@]}; do
|
||||
if [ -f $repo/$pkgname/spkgbuild ]; then
|
||||
PORT_EXIST=yes
|
||||
break
|
||||
for arg in "$@"; do
|
||||
for repo in ${PORT_REPO[@]}; do
|
||||
if [ -f $repo/$arg/spkgbuild ]; then
|
||||
PORT_EXIST=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ ! "$PORT_EXIST" ]; then
|
||||
msgerr "Port ${color_red}$arg${color_reset} not exist"
|
||||
exit 1
|
||||
fi
|
||||
unset PORT_EXIST
|
||||
done
|
||||
[ "$PORT_EXIST" ] || (msgerr "Port '$pkgname' not exist" && exit 1)
|
||||
}
|
||||
|
||||
depinst() {
|
||||
@@ -51,7 +62,11 @@ depinst() {
|
||||
|
||||
}
|
||||
|
||||
checkpkg
|
||||
depinst "$@"
|
||||
checkpkg "$@"
|
||||
|
||||
while [ $1 ]; do
|
||||
checkinstalled $1
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
CONF_FILE="/etc/scratchpkg.conf"
|
||||
|
||||
source "$CONF_FILE"
|
||||
source "/usr/share/scratchpkg/color"
|
||||
source "/usr/share/scratchpkg/message"
|
||||
|
||||
if [ ! "$1" ]; then
|
||||
msgerr "Please specify package name to list its dependencies."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
calcdep() {
|
||||
|
||||
dep=$(scratch -d $1 | grep -v "port not exist" | awk '{print $3}')
|
||||
@@ -31,32 +43,33 @@ checkpkg() {
|
||||
break
|
||||
fi
|
||||
done
|
||||
[ "$PORT_EXIST" ] || (echo "Port $pkgname not exist" && exit 1)
|
||||
if [ ! "$PORT_EXIST" ]; then
|
||||
msgerr "Port ${color_red}$pkgname${color_reset} not exist."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
INDEX_DIR="/var/lib/scratchpkg/index"
|
||||
CONF_FILE="/etc/scratchpkg.conf"
|
||||
start() {
|
||||
pkgname=$1
|
||||
|
||||
if [ ! "$1" ]; then
|
||||
echo "Please specify package name to list its dependencies"
|
||||
exit 1
|
||||
fi
|
||||
checkpkg # check for existence port
|
||||
calcdep $pkgname # calculate dependencies
|
||||
loop # loop through all dependencies
|
||||
|
||||
source "$CONF_FILE"
|
||||
source "/usr/share/scratchpkg/color"
|
||||
pkgname=$1
|
||||
# filter all same dependencies and sort backwards
|
||||
for i in $(echo $deps | tr ' ' '\n'); do
|
||||
[ $(echo $filterdep | tr ' ' '\n' | grep -x $i) ] || filterdep="$filterdep $i"
|
||||
done
|
||||
|
||||
checkpkg # check for existence port
|
||||
calcdep $pkgname # calculate dependencies
|
||||
loop # loop through all dependencies
|
||||
filterdep="$filterdep $pkgname" # add package to install to final dependency list
|
||||
|
||||
# filter all same dependencies and sort backwards
|
||||
for i in $(echo $deps | tr ' ' '\n'); do
|
||||
[ $(echo $filterdep | tr ' ' '\n' | grep -x $i) ] || filterdep="$filterdep $i"
|
||||
}
|
||||
|
||||
while [ $1 ]; do
|
||||
start $1
|
||||
shift
|
||||
done
|
||||
|
||||
filterdep="$filterdep $pkgname" # add package to install to final dependency list
|
||||
|
||||
for alldep in $(echo $filterdep | tr ' ' '\n'); do
|
||||
if [ -d $INDEX_DIR/$alldep ]; then
|
||||
echo -e "$alldep ${color_green}[installed]${color_reset}"
|
||||
|
||||
@@ -65,7 +65,7 @@ allpkg() {
|
||||
|
||||
if [ "$1" ]; then
|
||||
if [ ! -d "$INDEX_DIR/$1" ]; then
|
||||
msgerr "Package '$1' not installed"
|
||||
msgerr "Package ${color_red}$1${color_reset} not installed."
|
||||
exit 1
|
||||
else
|
||||
onepkg $1
|
||||
|
||||
@@ -45,13 +45,17 @@ fi
|
||||
|
||||
if [ "${#successuppkg[@]}" -gt 0 ]; then
|
||||
echo "Successfully update this package(s):"
|
||||
echo ${successuppkg[@]} | tr ' ' '\n'
|
||||
echo
|
||||
for ok in ${successuppkg[@]}; do
|
||||
${color_green}>>>${color_reset} $ok
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${#faileduppkg[@]}" -gt 0 ]; then
|
||||
echo
|
||||
echo "Failed update this package(s):"
|
||||
echo ${faileduppkg[@]} | tr ' ' '\n'
|
||||
for ko in ${successuppkg[@]}; do
|
||||
${color_red}>>>${color_reset} $ko
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user