You neither need sh, nor bash -x. Especially the second is only for debugging purpose. Unless you feel like reading a lot. If you 'chmod +x' the script, you need neither of "sh", "bash", ... either. That's what the first line is for.salix@chat.meticul.eu wrote:(10:41:20 PM) zachary: shador: this script is only checking for new/missing deps, it won't install them automatically, am I right?
(10:41:49 PM) shador: yes, it will
(10:41:55 PM) shador: but it runs slapt-get with --prompt
(10:42:03 PM) shador: so you can choose
Code: Select all
sh <path to script>
Code: Select all
bash -x <path to script>
Code: Select all
#!/bin/sh
unset TMP new newpkgs line
quit() {
rm -rf $TMP
exit $@
}
trap 'echo "Killed by signal"; quit 2' INT TERM
TMP=`mktemp -d` || quit 1
# list of installed, (still) available pkgs
LANG=C slapt-get --available | grep 'inst=yes' | awk '{ print $1 }' >$TMP/reinst
if egrep -q '^ *$' $TMP/reinst; then
echo "Nothing to install"
quit
fi
# missing deps will be listed as new pkgs
LANG=C slapt-get -s --reinstall -i $(cat $TMP/reinst) >$TMP/sget || quit 1
# extract new pkgs
while read line; do
if [ "x$new" == "xtrue" ]; then
newpkgs="$newpkgs$line "
fi
if [ "x$line" != "xThe following packages will be upgraded:" ]; then
new="false"
fi
if [ "x$line" == "xThe following NEW packages will be installed:" ]; then
new="true"
fi
done <$TMP/sget
if echo "$newpkgs" | egrep -q '^ *$'; then
echo "Nothing to install"
quit
fi
# install new pkgs (i.e. missing deps)
slapt-get -p -i $newpkgs || quit 1
quit