Files
scratchpkg/extra/depinstall
2017-12-08 22:00:00 +08:00

58 lines
987 B
Bash
Executable File

#!/bin/bash -e
INDEX_DIR="/var/lib/scratchpkg/index"
CONF_FILE="/etc/scratchpkg.conf"
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
source "$CONF_FILE"
source "/usr/share/scratchpkg/color"
source "/usr/share/scratchpkg/message"
pkgname=$1
checkpkg() {
for repo in ${PORT_REPO[@]}; do
if [ -f $repo/$pkgname/spkgbuild ]; then
PORT_EXIST=yes
break
fi
done
[ "$PORT_EXIST" ] || (msgerr "Port '$pkgname' not exist" && exit 1)
}
depinst() {
for i in $(deplist $1 | awk '{print $1}'); do
if [ -d $INDEX_DIR/$i ]; then
continue
else
msg "Installing $i..."
if [ $UID != 0 ]; then
sudo scratch -p $i -i
else
scratch -p $i -i
fi
if [ ! -d $INDEX_DIR/$i ]; then
msgerr "Failed installing $i."
msgerr "Press ENTER to skip and continue, press CTRL + C to cancel."
read
fi
fi
done
}
checkpkg
depinst "$@"
exit 0