From 97a7e8464438e173a357ea9a272f91e26a789ac5 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 7 Apr 2015 18:11:06 -0400 Subject: initial commit --- sbodeps | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100755 sbodeps (limited to 'sbodeps') diff --git a/sbodeps b/sbodeps new file mode 100755 index 0000000..9eeb692 --- /dev/null +++ b/sbodeps @@ -0,0 +1,133 @@ +#!/bin/bash + +# This really is a bash script, please don't change to #!/bin/sh + +SBOROOT=${SBOROOT:-/home/urchlay/slackbuilds/sbo/14.1/} +if [ ! -d $SBOROOT ]; then + SBOROOT=. +fi + +SELF="$( echo "$0" | sed 's,.*/,,' )" + +usage() { + cat </dev/null && echo " (installed)" || echo " (NOT installed)" +} + +find_deps() { + local i + local req + local REQUIRES + local info=$(/bin/ls $SBOROOT/*/$2/$2.info 2>/dev/null | head -1) + + if [ -z "$info" ]; then + echo "$SELF: $2: no such package" 1>&2 + RETVAL=1 + return; + fi + + eval $(grep ^REQUIRES= $info) + if [ "$REQUIRES" = "" ]; then + return + fi + for req in $REQUIRES; do + for i in $(seq 1 $1 ); do + echo -n " " + done + echo -n $req + if [ "$req" = "%README%" ]; then + echo + else + print_installed_status $req + if [ "$QUEUE" = "yes" ]; then + if [ "$IGNORE" = "yes" ] || ! pkg_is_installed $req ; then + echo $1 $req >> $QTMPFILE + fi + fi + find_deps $(( $1 + 1 )) $req + fi + done +} + +while [ "$argsdone" != "yes" ]; do + case "$1" in + ''|-h|-help|--help) usage; exit 0 ;; + -iq|-qi) QUEUE=yes ; IGNORE=yes ; shift ;; + -q) QUEUE=yes ; shift ;; + -i) IGNORE=yes ; shift ;; + -*) echo "Unknown option $1"; usage; exit 1 ;; + *) argsdone=yes ;; + esac +done + +if [ "$QUEUE" = "yes" ]; then + QTMPFILE=${TMP:-/tmp}/sbodeps.$$.$RANDOM + rm -f $QTMPFILE + + # save old stdout to fd 3, suppress stdout since we don't print our tree + exec 3>&1 1>/dev/null +fi + +if [ ! -e "$SBOROOT/system" ]; then + echo "$SELF: path \"$SBOROOT\" doesn't look like an SBo repo, set SBOROOT in environment" 1>&2 + exit 1 +fi + +RETVAL=0 + +for arg; do + echo -n $arg + print_installed_status $arg + [ "$QUEUE" = "yes" ] && ! pkg_is_installed $arg && echo 0 $arg >> $QTMPFILE + find_deps 1 $arg +done + +# The queue temp file contains the same info as the regular +# tree, though less human-readable (depth numbers instead of indents). + +# To turn it into a .sqf, sort it depth-first, and remove any duplicates +# (can't use sort -u or uniq, as dups might occur at different depths & +# thus not be on consecutive lines). + +if [ "$QUEUE" = "yes" -a -e "$QTMPFILE" ]; then + exec 1>&3 # restore old stdout + for q in $(sort -nr $QTMPFILE | cut -d' ' -f2); do + r=seen_$(echo $q | sed 's,[^A-Za-z0-9_],_,g') + s=${!r} # bash indirect variable ref, yay + if [ "$s" != "yes" ]; then + echo $q + eval $r="yes" + fi + done + rm -f $QTMPFILE +fi + +exit $RETVAL -- cgit v1.2.3