From 63fb6ae94b704763b004d1ae4ada6ce6435391ec Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Sat, 9 Aug 2008 03:04:38 +0000 Subject: [PATCH] add two new features: ability to clear the cache directory and ability to display a list of all installed SBo packages; toss in a few minor cleanups --- src/usr/bin/sbopkg | 58 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index 1a3e4fe..d7dc93b 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -147,6 +147,23 @@ else fi } +get_sbo_packages () { +# Get a list of SBo packages +SBOPKGLIST=$TMP/sbopkg_pkglist +rm -rf $SBOPKGLIST +cd /var/log/packages +PKGS=$(ls *SBo*) +for i in $PKGS; do + echo $i >> $SBOPKGLIST +done +if [ "$DIAG" = 1 ]; then + dialog --title "Installed SBo Packages" --textbox \ +$SBOPKGLIST 0 0 +else + ${PAGER:-more} $SBOPKGLIST +fi +} + check_for_updates () { # Check to see if there are any updates to installed SBo pkgs. This # is is pretty ugly code and is not really 100% reliable due to the @@ -440,6 +457,25 @@ view_cache_dir () { ls -la $SRCDIR > $TMP/sbopkg_cache_dir dialog --title "Displaying $SRCDIR" \ --textbox $TMP/sbopkg_cache_dir 0 0 +dialog --title "Keep Cache?" --yesno "Would you like to keep the \ +files in the cache directory? Select YES to keep or NO to \ +delete." 10 30 +if [ $? = 1 ]; then + check_root + if [ $ROOT = "false" ]; then + dialog --title "ERROR" --msgbox "Sorry, only the root \ +user can clear the cache directory." 8 30 + continue + else + rm -rf $SRCDIR/* + dialog --title "Done" --msgbox "The cache directory has been \ +cleared." 8 30 + continue + fi +else + continue +fi + } view_perm_log () { @@ -720,10 +756,11 @@ while [ 0 ]; do dialog --title "SlackBuilds.org Package Browser \ (sbopkg version $SBOVER)" --menu \ "\nChoose one of the following or press to exit\n" \ - 15 65 9 \ + 19 69 10 \ "Rsync" "Rsync with SlackBuilds.org" \ "ChangeLog" "View the SlackBuilds.org ChangeLog" \ -"Updates" "List potential updates to installed packages" \ +"Packages" "List installed SBo packages" \ +"Updates" "List potential updates to installed SBo packages" \ "Browse" "Browse the local SlackBuilds.org repo" \ "Search" "Search the local SlackBuilds.org repo" \ "Cache" "View the contents of the cache directory" \ @@ -747,6 +784,10 @@ if [ "$R" = "ChangeLog" ]; then show_changelog fi +if [ "$R" = "Packages" ]; then + get_sbo_packages +fi + if [ "$R" = "Updates" ]; then check_for_updates fi @@ -806,7 +847,7 @@ if [ $# -eq 0 ]; then fi # This is the command line options and help. -while getopts ":b:cd:f:hlq:rs:v:" OPT; do +while getopts ":b:cd:f:hlpq:rs:v:" OPT; do case $OPT in b ) BUILD="$OPTARG" ;; @@ -818,6 +859,8 @@ while getopts ":b:cd:f:hlq:rs:v:" OPT; do ;; l ) CHANGELOG=1 ;; + p ) GETPKGS=1 + ;; q ) GENSEARCH="$OPTARG" ;; r ) RSYNC=1 @@ -833,7 +876,8 @@ while getopts ":b:cd:f:hlq:rs:v:" OPT; do echo "Usage: $SCRIPT [OPTIONS] " echo "Options are:" echo " -b package Build a package." - echo " -c Check for updates." + echo " -c Check for updates to installed \ +SlackBuilds.org packages." echo " -d localdir Location of local copy of \ SlackBuilds.org repository" echo " -f Override default configuration file" @@ -841,6 +885,7 @@ SlackBuilds.org repository" echo " -h Display this help message." echo " -l Display the SlackBuilds.org \ ChangeLog.txt and then quit." + echo " -p List installed SlackBuilds.org packages." echo " -q package Query for packages matching string." echo " -r Rsync the SlackBuilds.org repository with" echo " the local mirror and then quit." @@ -905,6 +950,11 @@ if [ -n "$CHANGELOG" ]; then exit 0 fi +if [ -n "$GETPKGS" ]; then + get_sbo_packages + exit 0 +fi + if [ -n "$RSYNC" ]; then echo "Rsyncing with Slackbuilds.org repository into \ $LOCALREPO/$SLACKVER."