Files
scratchpkg/extra/depinstall
2018-01-12 10:08:53 +08:00

73 lines
1.1 KiB
Bash
Executable File

#!/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
echo "Please specify package name to install."
exit 1
fi
checkinstalled() {
if [ -d $INDEX_DIR/$1 ]; then
msg "Package ${color_green}$1${color_reset} already installed"
else
depinst $1
fi
}
checkpkg() {
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
}
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 "$@"
while [ $1 ]; do
checkinstalled $1
shift
done
exit 0