From 0cab9c540cee2ebf5b4e441c25a8f23cabb2508d Mon Sep 17 00:00:00 2001 From: fake Date: Fri, 24 Dec 2004 02:43:22 +0000 Subject: [PATCH] fake: small draft: add option -missing to misc/archive/showdeps.sh shows packages missing for a specific package, more like a fun hack than a real implementation [2004122202403616065] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@5330 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- misc/archive/showdeps.sh | 49 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/misc/archive/showdeps.sh b/misc/archive/showdeps.sh index ff95b1b9d..5a40d6da3 100644 --- a/misc/archive/showdeps.sh +++ b/misc/archive/showdeps.sh @@ -13,8 +13,9 @@ usage: $0 [ -usedby | -uses ] PKG [ SOURCE_TREE ] check \$SOURCE_TREE/scripts/dep_db.txt and print dependencies and dependants of given package. - -usedby: show only packages that depend on this package - -uses : show only packages this package depends on + -usedby : show only packages that depend on this package + -uses : show only packages this package depends on + -missing: show only packages missing for this package EOF exit 1 @@ -22,23 +23,31 @@ exit 1 uses=1 usedby=1 +missing=1 while [ ${1:0:1} == "-" ] ; do case $1 in -usedby) uses=0 + missing=0 shift ;; -uses) usedby=0 + missing=0 + shift + ;; + -missing) + usedby=0 + uses=0 shift ;; esac done -if [ $usedby == 0 -a $uses == 0 ] ; then usedby=1 ; uses=1 ; fi - +if [ $usedby == 0 -a $uses == 0 -a $missing == 0 ] ; then usedby=1 ; uses=1 ; missing=0 ; fi +# auto-find sourcetree if none was given if [ -n "$2" ] ; then SOURCE_TREE=$2 if [ ! -f $SOURCE_TREE/scripts/dep_db.txt ] ; then @@ -83,5 +92,37 @@ if [ $usedby == 1 ] ; then echo "packages depending on $1:" print_nice `grep "\<$1\>" ./scripts/dep_db.txt | cut -d: -f1` fi + +list_missing_pkgs() { + MISSING_PKGS=""; + for i in `grep "^$1: " ./scripts/dep_db.txt | cut -d" " -f4-` ; do + [ $i == $1 -o $i == "x11" -o $i == "xfree86" ] && continue + if [ ! -f "/var/adm/packages/$i" -a ! -f "/var/adm/packages/$i:dev" ] ; then + MISSING_PKGS="$MISSING_PKGS $i" + fi + done + echo $MISSING_PKGS +} + +# recursive function +show_missing_pkgs() { + MISSING_I=`list_missing_pkgs $1`; + [ -z "$MISSING_I" ] && return ; + # already shown ? + [ "${SHOWNLIST/ $1 /}" != "$SHOWNLIST" ] && continue; + SHOWNLIST="${SHOWNLIST}$1 " + echo + echo "packages missing for $1:" + print_nice $MISSING_I + for i in $MISSING_I ; do + [ -z "$i" ] && continue ; + show_missing_pkgs $i + done +} + +if [ $missing == 1 ] ; then + SHOWNLIST=" " + show_missing_pkgs $1 +fi echo