mirror of
https://github.com/outbackdingo/scratchpkg.git
synced 2026-02-06 09:26:35 +00:00
58 lines
987 B
Bash
Executable File
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
|