From da9511b1971236384ac9aa14c2763ed8f585b79d Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Tue, 20 Jan 2009 02:16:19 +0000 Subject: [PATCH] commit a large whitespace patch, which does several things, including adding the 'crunch' functions to eliminate extra spaces, reformats the entire script around 78 columns, and improves the formatting of functions and comments; thanks to slakmagik for the patch. --- src/usr/bin/sbopkg | 3396 ++++++++++++++++++++++---------------------- 1 file changed, 1725 insertions(+), 1671 deletions(-) diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index 5b7afba..16d89f6 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -5,21 +5,20 @@ # sbopkg - The SlackBuilds.org Package Browser # Copyright 2007-2009 Chess Griffin # -# Redistribution and use of this script, with or without modification, -# is permitted provided that the following conditions are met: +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: # -# 1. Redistributions of this script must retain the above copyright -# notice, this list of conditions and the following disclaimer. +# 1. Redistributions of this script must retain the above copyright notice, +# this list of conditions and the following disclaimer. # -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS -# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # @@ -27,14 +26,13 @@ # Linux is a registered trademark of Linus Torvalds. # # Other contributors: Bob Lounsbury, Robby Workman, Alan Hicks, Paul -# Wisehart, slakmagik, Eric Hameleers, Michiel van Wessem, hba, Erik -# Hanson, Antoine, ktabic, Ken Roberts, samac, Bert Babington, Murat -# D. Kadirov, The-spiki, David Somero, LukenShiro, Drew Ames, nille, -# acidchild, mancha, macavity, Zordrak, Joao Felipe Santos, -# cotterochan, necropresto, Pierre Cazenave, Mauro Giachero, -# The-Croupier, and Wade Grant. This script would not be where it is -# without the help of these folks. If I left anyone out, I -# apologize. Thank you! +# Wisehart, slakmagik, Eric Hameleers, Michiel van Wessem, hba, Erik Hanson, +# Antoine, ktabic, Ken Roberts, samac, Bert Babington, Murat D. Kadirov, +# The-spiki, David Somero, LukenShiro, Drew Ames, nille, acidchild, mancha, +# macavity, Zordrak, Joao Felipe Santos, cotterochan, necropresto, Pierre +# Cazenave, Mauro Giachero, The-Croupier, and Wade Grant. This script would +# not be where it is without the help of these folks. If I left anyone out, +# I apologize. Thank you! # #set -x @@ -49,192 +47,203 @@ CWD="$(pwd)" SBOVER=svn_r$(cat ${0} | grep '$Id: ' | head -1 | \ sed -e 's/^.*Id: sbopkg \([0-9.]*\) .*$/\1/') +# the inspiration for these two functions comes from the crunch() in +# installpkg. Both take one argument - the first reduces runs of spaces to one +# and the second does that and reformats to 78 columns. +crunch() { + echo "$@" | tr -s ' ' +} + +crunch_fmt() { + echo "$@" | tr -s ' ' | fmt -78 +} + config_check () { -# Check if config file is there and if so check that it has all -# needed variables with any value, and set them. -if [ ! -e $SBOPKG_CONF ]; then - echo "$SCRIPT: No $SBOPKG_CONF file was found." - echo "Please create it and run $SCRIPT again." 1>&2 - exit 1 -else - . $SBOPKG_CONF - for VAR in RSYNCMIRROR SLACKVER LOCALREPO SRCDIR TMP OUTPUT KEEPLOG DEBUG RSYNCFLAGS WGETFLAGS; do - if [ -z "${!VAR}" ]; then - MISSING+="$VAR " + # Check if config file is there and if so check that it has all + # needed variables with any value, and set them. + if [ ! -e $SBOPKG_CONF ]; then + echo "$SCRIPT: No $SBOPKG_CONF file was found." + echo "Please create it and run $SCRIPT again." 1>&2 + exit 1 + else + . $SBOPKG_CONF + for VAR in RSYNCMIRROR SLACKVER LOCALREPO SRCDIR TMP OUTPUT KEEPLOG \ + DEBUG RSYNCFLAGS WGETFLAGS; do + if [ -z "${!VAR}" ]; then + MISSING+="$VAR " + fi + done + if [ "$MISSING" ]; then + echo + echo "ERROR" + echo "$SCRIPT: Can't find a value for variable(s):" + echo "$MISSING" + echo + echo "If you have recently upgraded sbopkg there may be" + echo "new variables in the sbopkg.conf file. Please" + echo "merge the sbopkg.conf.new file with your existing" + echo "sbopkg.conf file. Please see the sbopkg.conf(5)" + echo "man page for more details." + echo + echo "Please correct this error and run $SCRIPT again." + exit 1 + fi + if [ -e $HOME/.sbopkg.conf ]; then + . $HOME/.sbopkg.conf fi - done - if [ "$MISSING" ]; then - echo - echo "ERROR" - echo "$SCRIPT: Can't find a value for variable(s):" - echo "$MISSING" - echo - echo "If you have recently upgraded sbopkg there may be" - echo "new variables in the sbopkg.conf file. Please" - echo "merge the sbopkg.conf.new file with your existing" - echo "sbopkg.conf file. Please see the sbopkg.conf(5)" - echo "man page for more details." - echo - echo "Please correct this error and run $SCRIPT again." - exit 1 fi - if [ -e $HOME/.sbopkg.conf ]; then - . $HOME/.sbopkg.conf - fi -fi } directory_checks () { -# Check and make sure certain sbopkg-related directories exist. -# If not, create them. -if [ ! -d "$LOCALREPO/$SLACKVER" ]; then - echo - echo "Creating local repository directory $LOCALREPO/$SLACKVER" - echo "for the rsync mirror." - echo - read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." - echo - # One of these days, I'll see about implementing a cleaner way of - # exiting with a nice error message if the user does not have - # sufficient permissions to create these directories. For now, - # the || exit 1 will suffice. - mkdir -p $LOCALREPO/$SLACKVER || exit 1 -else - cd $LOCALREPO -fi -if [ ! -d "$SRCDIR" ]; then - echo - echo "Creating local cache directory $SRCDIR to keep \ -downloaded sources." - echo - read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." - echo - mkdir -p $SRCDIR || exit 1 -fi -if [ ! -d "$TMP" ]; then - echo - echo "Creating local TMP directory $TMP." - echo - read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." - echo - mkdir -p $TMP || exit 1 -fi -if [ ! -d "$OUTPUT" ]; then - echo - echo "Creating local package output directory $OUTPUT." - echo - read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." - echo - mkdir -p $OUTPUT || exit 1 -fi -# Let's catch Control-C and try to exit cleanly. Please see the -# comment to the control_c function, below. -trap 'control_c' 2 14 15 + # Check and make sure certain sbopkg-related directories exist. + # If not, create them. + if [ ! -d "$LOCALREPO/$SLACKVER" ]; then + echo + echo "Creating local repository directory $LOCALREPO/$SLACKVER" + echo "for the rsync mirror." + echo + read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." + echo + # One of these days, I'll see about implementing a cleaner way of + # exiting with a nice error message if the user does not have + # sufficient permissions to create these directories. For now, + # the || exit 1 will suffice. + mkdir -p $LOCALREPO/$SLACKVER || exit 1 + else + cd $LOCALREPO + fi + if [ ! -d "$SRCDIR" ]; then + echo + crunch "Creating local cache directory $SRCDIR to keep \ + downloaded sources." + echo + read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." + echo + mkdir -p $SRCDIR || exit 1 + fi + if [ ! -d "$TMP" ]; then + echo + echo "Creating local TMP directory $TMP." + echo + read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." + echo + mkdir -p $TMP || exit 1 + fi + if [ ! -d "$OUTPUT" ]; then + echo + echo "Creating local package output directory $OUTPUT." + echo + read -s -n 1 -p "Press any key to continue or Ctrl-C to exit." + echo + mkdir -p $OUTPUT || exit 1 + fi + # Let's catch Control-C and try to exit cleanly. Please see the + # comment to the control_c function, below. + trap 'control_c' 2 14 15 } pid_check () { -# Set and check for pid file. -PIDFILE=$TMP/sbopkg.pid -if [ -e $PIDFILE ]; then - echo - echo "Another instance of sbopkg appears to be running" - echo "with process id $(cat $PIDFILE). Running more than" - echo "one instance of sbopkg is not recommended." - echo - echo "If this is incorrect, you can delete the lockfile" - echo "'${PIDFILE}' and restart. Exiting now." - exit 1 -else - cleanup - echo $$ > $PIDFILE -fi + # Set and check for pid file. + PIDFILE=$TMP/sbopkg.pid + if [ -e $PIDFILE ]; then + echo + echo "Another instance of sbopkg appears to be running" + echo "with process id $(cat $PIDFILE). Running more than" + echo "one instance of sbopkg is not recommended." + echo + echo "If this is incorrect, you can delete the lockfile" + echo "'${PIDFILE}' and restart. Exiting now." + exit 1 + else + cleanup + echo $$ > $PIDFILE + fi } check_root () { -# Check to see whether the user is root or not. -if [ ! $(id -u) = "0" ]; then - ROOT="false" -else - ROOT="true" -fi + # Check to see whether the user is root or not. + if [ ! $(id -u) = "0" ]; then + ROOT="false" + else + ROOT="true" + fi } check_write () { -# Check to see whether the user has write permissions on the -# directory. -if [ ! -w $1 ]; then - WRITE="false" -else - WRITE="true" -fi + # Check to see whether the user has write permissions on the + # directory. + if [ ! -w $1 ]; then + WRITE="false" + else + WRITE="true" + fi } check_if_repo_exists () { -# Check to see if $LOCALREPO/$SLACKVER exists and not empty -if [ ! -d $LOCALREPO/$SLACKVER/academic ]; then - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "The directory \ -$LOCALREPO/$SLACKVER was not found or is empty. Please make \ -sure your repository directory is set correctly and that you \ -have done an rsync first." 12 30 - continue - else - echo - echo "ERROR" - echo "The directory $LOCALREPO/$SLACKVER was not found" - echo "or is empty. Please make sure your respository" - echo "directory is set correctly and that you have done" - echo "an rsync first." - cleanup - exit 0 + # Check to see if $LOCALREPO/$SLACKVER exists and not empty + if [ ! -d $LOCALREPO/$SLACKVER/academic ]; then + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox "$(crunch "The directory \ + $LOCALREPO/$SLACKVER was not found or is empty. Please make \ + sure your repository directory is set correctly and that you \ + have done an rsync first.")" 12 30 + continue + else + echo + echo "ERROR" + echo "The directory $LOCALREPO/$SLACKVER was not found" + echo "or is empty. Please make sure your respository" + echo "directory is set correctly and that you have done" + echo "an rsync first." + cleanup + exit 0 + fi fi -fi } show_changelog () { -# Show the SlackBuilds.org changelog. -check_if_repo_exists -cd $LOCALREPO/$SLACKVER -if [ ! -e ./ChangeLog.txt ]; then - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "No ChangeLog.txt \ -found. Please make sure your repository directory is set \ -correctly and that you have done an rsync first." 10 30 - continue + # Show the SlackBuilds.org changelog. + check_if_repo_exists + cd $LOCALREPO/$SLACKVER + if [ ! -e ./ChangeLog.txt ]; then + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox "$(crunch "No ChangeLog.txt \ + found. Please make sure your repository directory is set \ + correctly and that you have done an rsync first.")" 10 30 + continue + else + echo + echo "ERROR" + echo "No ChangeLog.txt found. Please make sure your" + echo "repository directory is set correctly and that" + echo "you have done an rsync first. Exiting." + cleanup + exit 0 + fi else - echo - echo "ERROR" - echo "No ChangeLog.txt found. Please make sure your" - echo "repository directory is set correctly and that" - echo "you have done an rsync first. Exiting." - cleanup - exit 0 + if [ "$DIAG" = 1 ]; then + dialog --title "SlackBuilds.org ChangeLog.txt" \ + --textbox ./ChangeLog.txt 0 0 + else + ${PAGER:-more} ./ChangeLog.txt + fi fi -else - if [ "$DIAG" = 1 ]; then - dialog --title "SlackBuilds.org ChangeLog.txt" --textbox \ -./ChangeLog.txt 0 0 - else - ${PAGER:-more} ./ChangeLog.txt - fi -fi } get_sbo_packages () { -# Get a list of SBo packages. -SBOPKGLIST=$TMP/sbopkg_pkglist -rm -f $SBOPKGLIST -cd /var/log/packages -PKGS=$(ls *SBo* 2>/dev/null) -for i in $PKGS; do - echo $i >> $SBOPKGLIST -done -if [ "$DIAG" = 1 ]; then - dialog --title "Installed SBo Packages" --textbox \ -$SBOPKGLIST 20 65 -else - ${PAGER:-more} $SBOPKGLIST -fi + # Get a list of SBo packages. + SBOPKGLIST=$TMP/sbopkg_pkglist + rm -f $SBOPKGLIST + cd /var/log/packages + PKGS=$(ls *SBo* 2>/dev/null) + for i in $PKGS; do + echo $i >> $SBOPKGLIST + done + if [ "$DIAG" = 1 ]; then + dialog --title "Installed SBo Packages" --textbox $SBOPKGLIST 20 65 + else + ${PAGER:-more} $SBOPKGLIST + fi } check_for_updates () { @@ -450,62 +459,62 @@ fi } get_category_list () { -# This function displays the list of SBo categories in the dialog. -check_if_repo_exists -cd $LOCALREPO/$SLACKVER -rm -f $TMP/sbopkg_category_list 2> /dev/null -DIR=( */ ) -if [ -n "$DIR" ]; then - for i in ${DIR[*]%/}; do - echo "$i \"Browse the $i category\"" >> \ - $TMP/sbopkg_category_list - done -fi + # This function displays the list of SBo categories in the dialog. + check_if_repo_exists + cd $LOCALREPO/$SLACKVER + rm -f $TMP/sbopkg_category_list 2> /dev/null + DIR=( */ ) + if [ -n "$DIR" ]; then + for i in ${DIR[*]%/}; do + echo "$i \"Browse the $i category\"" >> $TMP/sbopkg_category_list + done + fi } get_category_items_list () { -# This function makes and displays a list of all the package items in -# the selected category. Ideally, it would be nice to have this be a -# checklist where the user can select multiple applications to build -# in a queue. -CATEGORY="$(cat $TMP/sbopkg_category_selection)" -cd $LOCALREPO/$SLACKVER/$CATEGORY -rm -f $TMP/sbopkg_category_items_list 2> /dev/null -DIR=( */ ) -if [ -n "$DIR" ]; then - for i in ${DIR[*]%/}; do - j=$(echo $i | sed 's/-plus/+/') - DESC=$(grep -hZm1 ^$j ./$i/slack-desc* 2>/dev/null | - sed 's/^[^(]*( *\(.*\) *)[^)]*$/\1/') - echo "\"$i\" \"$DESC\"" >> $TMP/sbopkg_category_items_list - done -fi -cd $LOCALREPO/$SLACKVER + # This function makes and displays a list of all the package items in + # the selected category. Ideally, it would be nice to have this be a + # checklist where the user can select multiple applications to build + # in a queue. + CATEGORY="$(cat $TMP/sbopkg_category_selection)" + cd $LOCALREPO/$SLACKVER/$CATEGORY + rm -f $TMP/sbopkg_category_items_list 2> /dev/null + DIR=( */ ) + if [ -n "$DIR" ]; then + for i in ${DIR[*]%/}; do + j=$(echo $i | sed 's/-plus/+/') + DESC=$(grep -hZm1 ^$j ./$i/slack-desc* 2>/dev/null | + sed 's/^[^(]*( *\(.*\) *)[^)]*$/\1/') + echo "\"$i\" \"$DESC\"" >> $TMP/sbopkg_category_items_list + done + fi + cd $LOCALREPO/$SLACKVER } select_version () { -# Create menu and list the SBo-supported versions of Slackware for -# user to choose from. -while [ 0 ]; do - dialog --cancel-label "Back" --title "Choose a Slackware version" \ ---menu "You are currently using sbopkg to browse a local copy of SBo \ -for Slackware version $SLACKVER. If you would like to change \ -it, please select another version below or press to \ -go back." 15 50 4 \ -"12.2" "Slackware version 12.2" \ -"12.1" "Slackware version 12.1" \ -"12.0" "Slackware version 12.0" \ -"11.0" "Slackware version 11.0" 2>$TMP/sbopkg_version_selection - if [ $? != 0 ]; then - break - fi - SLACKVER="$(cat $TMP/sbopkg_version_selection)" - dialog --title "Save this setting?" --defaultno --yesno "Would \ -you like to save this Slackware version setting in the user's \ -$HOME/.sbopkg.conf file? (One will be created if it is not \ -found).\n\nPress to save in the user's $HOME/.sbopkg.conf or \ -press to continue without saving, making this a temporary \ -change only." 12 60 + # Create menu and list the SBo-supported versions of Slackware for + # user to choose from. + while [ 0 ]; do + dialog --cancel-label "Back" --title \ + "Choose a Slackware version" \ + --menu "$(crunch "You are currently using sbopkg to browse a \ + local copy of SBo for Slackware version $SLACKVER. If you would \ + like to change it, please select another version below or press \ + to go back.")" 15 50 4 \ + "12.2" "Slackware version 12.2" \ + "12.1" "Slackware version 12.1" \ + "12.0" "Slackware version 12.0" \ + "11.0" "Slackware version 11.0" 2>$TMP/sbopkg_version_selection + if [ $? != 0 ]; then + break + fi + SLACKVER="$(cat $TMP/sbopkg_version_selection)" + dialog --title "Save this setting?" --defaultno --yesno \ + "$(crunch "Would you like to save this Slackware version setting \ + in the user's $HOME/.sbopkg.conf file? (One will be created if \ + it is not found).\n\nPress to save in the user's \ + $HOME/.sbopkg.conf or press to continue without saving, \ + making this a temporary change only.")" 12 60 if [ $? != 0 ]; then break fi @@ -515,433 +524,416 @@ change only." 12 60 echo "SLACKVER=$SLACKVER" > $HOME/.sbopkg.conf fi - break -done -rm -f $TMP/sbopkg_version_selection + break + done + rm -f $TMP/sbopkg_version_selection } info_item () { -# This function shows the menu for each package where the user can see -# certain information or build the package if he is root. -APP="$(cat $TMP/sbopkg_item_selection)" -CATEGORY="$(cat $TMP/sbopkg_category_selection)" -RVERSION=$(grep VERSION $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info | cut -d= -f2 | sed s/\"//g) -RARCH=$(egrep -m1 "^ARCH" $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild | sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') -RBUILD=$(egrep -m1 "^BUILD" $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild | sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') -U="README" -while [ 0 ]; do -CURAPP=$(ls /var/log/packages/*SBo* 2>/dev/null | grep $APP) -KPACKAGE="" -for i in $CURAPP; do - LONGAPP=$(echo $i | sed 's/_SBo$//;s/-[^-]*-[^-]*-[^-]*$//') - SHORTAPP=$(echo $LONGAPP | sed -e 's/^.*\///g') - if [ "$SHORTAPP" == "$APP" ]; then - # Again, code from pkgtool - STRING=$(basename $i _SBo) - INDEX="$(echo $STRING | tr -d -c -)" - INDEX="$(expr length $INDEX + 1)" - NAME=$(expr $INDEX - 3) - NAME="$(echo $STRING | cut -f 1-$NAME -d -)" - VER=$(expr $INDEX - 2) - VER="$(echo $STRING | cut -f $VER -d -)" - #VER="$(echo $STRING | cut -f $VER -d - | sed -e 's/_.*$//')" - ARCH=$(expr $INDEX - 1) - ARCH="$(echo $STRING | cut -f $ARCH -d -)" - BUILD="$(echo $STRING | cut -f $INDEX -d -)" - KPACKAGE=$NAME-$VER-$ARCH-$BUILD - fi -done -if $(echo $(ls -1 $OUTPUT) | grep -E -q "$APP.*$RVERSION"); then - IPACKAGE="$(basename $(ls -1 $OUTPUT/${APP}*${RVERSION}*${RBUILD}*tgz | head -n 1))" -else - IPACKAGE="" -fi -if [ "$IPACKAGE" = "" ]; then - JPACKAGE="" -else - JPACKAGE="Install $IPACKAGE" -fi -if [ "$KPACKAGE" = "" ]; then - LPACKAGE="$APP (Not Installed)" -else - LPACKAGE="$APP (Installed: $KPACKAGE)" -fi -dialog --default-item "$U" --title "$APP ($RVERSION-$RARCH-$RBUILD)" \ ---backtitle "$LPACKAGE" --extra-button --extra-label "Back" --cancel-label \ -"Main Menu" --menu \ -"Please choose an item or press to go back or press \ -
to return to the main menu.\n" 18 60 10 \ -"README" "View the README file" \ -"Info" "View the .info file" \ -"Slack-desc" "View the slack-desc file" \ -"SlackBuild" "View the SlackBuild file" \ -"Custom" "Customize the .info or SlackBuild" \ -"Remove" "Remove $APP sources in cache" \ -"Options" "Edit Build Options/Flavors" \ -"Queue" "Add $APP to build queue" \ -"Build" "Build a package for $APP" \ -$JPACKAGE 2>$TMP/sbopkg_info_selection -CHOICE=$? -if [ $CHOICE = 1 ]; then - rm -f $TMP/sbopkg_* - break -elif [ $CHOICE = 3 ]; then - return 0 -elif [ $CHOICE = 0 ]; then - U="$(cat $TMP/sbopkg_info_selection)" + # This function shows the menu for each package where the user can see + # certain information or build the package if he is root. + APP="$(cat $TMP/sbopkg_item_selection)" CATEGORY="$(cat $TMP/sbopkg_category_selection)" - if [ "$U" = "README" ]; then - dialog --title "Viewing README" \ - --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/README 0 0 - fi - if [ "$U" = "Info" ]; then - dialog --title "Viewing .info" \ - --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info 0 0 - fi - if [ "$U" = "Slack-desc" ]; then - PARSED_SLACK_DESC=$(mktemp $TMP/sbopkg_parsed_slack_desc.XXXXXX) - sed -n "/^$APP: /s///p" $LOCALREPO/$SLACKVER/$CATEGORY/$APP/slack-desc > $PARSED_SLACK_DESC - dialog --title "Viewing Slack-desc" --textbox $PARSED_SLACK_DESC 0 0 - fi - if [ "$U" = "SlackBuild" ]; then - dialog --title "Viewing SlackBuild" \ - --textbox $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild 0 0 - fi - if [ "$U" = "Custom" ]; then - customize_item - fi - if [ "$U" = "Remove" ]; then - remove_sources $APP - fi - if [ "$U" = "Options" ]; then - add_options $APP - fi - if [ "$U" = "Queue" ]; then - if $(cat $TMP/sbopkg-tmp-queue | grep -q "^$APP "); then - dialog --title "ERROR" --msgbox "$APP is already in the \ -queue." 8 30 + local SHORTPATH=$LOCALREPO/$SLACKVER/$CATEGORY/$APP + RVERSION=$(grep VERSION $SHORTPATH/$APP.info | + cut -d= -f2 | sed s/\"//g) + RARCH=$(egrep -m1 "^ARCH" $SHORTPATH/$APP.SlackBuild | + sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') + RBUILD=$(egrep -m1 "^BUILD" $SHORTPATH/$APP.SlackBuild | + sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') + U="README" + while [ 0 ]; do + CURAPP=$(ls /var/log/packages/*SBo* 2>/dev/null | grep $APP) + KPACKAGE="" + for i in $CURAPP; do + LONGAPP=$(echo $i | sed 's/_SBo$//;s/-[^-]*-[^-]*-[^-]*$//') + SHORTAPP=$(echo $LONGAPP | sed -e 's/^.*\///g') + if [ "$SHORTAPP" == "$APP" ]; then + # Again, code from pkgtool + STRING=$(basename $i _SBo) + INDEX="$(echo $STRING | tr -d -c -)" + INDEX="$(expr length $INDEX + 1)" + NAME=$(expr $INDEX - 3) + NAME="$(echo $STRING | cut -f 1-$NAME -d -)" + VER=$(expr $INDEX - 2) + VER="$(echo $STRING | cut -f $VER -d -)" + #VER="$(echo $STRING | cut -f $VER -d - | sed -e 's/_.*$//')" + ARCH=$(expr $INDEX - 1) + ARCH="$(echo $STRING | cut -f $ARCH -d -)" + BUILD="$(echo $STRING | cut -f $INDEX -d -)" + KPACKAGE=$NAME-$VER-$ARCH-$BUILD + fi + done + if $(echo $(ls -1 $OUTPUT) | grep -E -q "$APP.*$RVERSION"); then + IPACKAGE="$( + basename $(ls -1 $OUTPUT/${APP}*${RVERSION}*${RBUILD}*tgz | + head -n 1) + )" else - echo "$APP $RVERSION-$RBUILD ON" >> $TMP/sbopkg-tmp-queue - dialog --title "Done" --msgbox "$APP has been added to the \ -build queue." 8 30 + IPACKAGE="" fi - fi - if [ "$U" = "Build" ]; then - echo "$APP" > $TMP/sbopkg-start-queue - process_queue - fi - if [ "$U" = "Install" ]; then - SBOPKGINSTALLOUTPUT=$TMP/sbopkg_install_output - install_package $IPACKAGE | tee $SBOPKGINSTALLOUTPUT - read -n 1 -p "Press any key to continue." - if [ "$KEEPLOG" = "YES" ]; then - cat $SBOPKGINSTALLOUTPUT >> $TMP/sbopkg-build-log + if [ "$IPACKAGE" = "" ]; then + JPACKAGE="" + else + JPACKAGE="Install $IPACKAGE" fi - rm -f $SBOPKGINSTALLOUTPUT - fi -else # ESC - rm -f $TMP/sbopkg_* - break -fi -done + if [ "$KPACKAGE" = "" ]; then + LPACKAGE="$APP (Not Installed)" + else + LPACKAGE="$APP (Installed: $KPACKAGE)" + fi + dialog --default-item "$U" --title "$APP ($RVERSION-$RARCH-$RBUILD)" \ + --backtitle "$LPACKAGE" --extra-button --extra-label "Back" \ + --cancel-label "Main Menu" --menu \ + "$(crunch "Please choose an item or press to go back or \ + press
to return to the main menu.\n")" 18 60 10 \ + "README" "View the README file" \ + "Info" "View the .info file" \ + "Slack-desc" "View the slack-desc file" \ + "SlackBuild" "View the SlackBuild file" \ + "Custom" "Customize the .info or SlackBuild" \ + "Remove" "Remove $APP sources in cache" \ + "Options" "Edit Build Options/Flavors" \ + "Queue" "Add $APP to build queue" \ + "Build" "Build a package for $APP" \ + $JPACKAGE 2>$TMP/sbopkg_info_selection + CHOICE=$? + if [ $CHOICE = 1 ]; then + rm -f $TMP/sbopkg_* + break + elif [ $CHOICE = 3 ]; then + return 0 + elif [ $CHOICE = 0 ]; then + U="$(cat $TMP/sbopkg_info_selection)" + CATEGORY="$(cat $TMP/sbopkg_category_selection)" + if [ "$U" = "README" ]; then + dialog --title "Viewing README" \ + --textbox $SHORTPATH/README 0 0 + fi + if [ "$U" = "Info" ]; then + dialog --title "Viewing .info" \ + --textbox $SHORTPATH/$APP.info 0 0 + fi + if [ "$U" = "Slack-desc" ]; then + PARSED_SLACK_DESC=$( + mktemp $TMP/sbopkg_parsed_slack_desc.XXXXXX) + sed -n "/^$APP: /s///p" $SHORTPATH/slack-desc > \ + $PARSED_SLACK_DESC + dialog --title "Viewing Slack-desc" \ + --textbox $PARSED_SLACK_DESC 0 0 + fi + if [ "$U" = "SlackBuild" ]; then + dialog --title "Viewing SlackBuild" \ + --textbox $SHORTPATH/$APP.SlackBuild 0 0 + fi + if [ "$U" = "Custom" ]; then + customize_item + fi + if [ "$U" = "Remove" ]; then + remove_sources $APP + fi + if [ "$U" = "Options" ]; then + add_options $APP + fi + if [ "$U" = "Queue" ]; then + if $(cat $TMP/sbopkg-tmp-queue | grep -q "^$APP "); then + dialog --title "ERROR" --msgbox \ + "$APP is already in the queue." 8 30 + else + echo "$APP $RVERSION-$RBUILD ON" >> $TMP/sbopkg-tmp-queue + dialog --title "Done" --msgbox \ + "$APP has been added to the build queue." 8 30 + fi + fi + if [ "$U" = "Build" ]; then + echo "$APP" > $TMP/sbopkg-start-queue + process_queue + fi + if [ "$U" = "Install" ]; then + SBOPKGINSTALLOUTPUT=$TMP/sbopkg_install_output + install_package $IPACKAGE | tee $SBOPKGINSTALLOUTPUT + read -n 1 -p "Press any key to continue." + if [ "$KEEPLOG" = "YES" ]; then + cat $SBOPKGINSTALLOUTPUT >> $TMP/sbopkg-build-log + fi + rm -f $SBOPKGINSTALLOUTPUT + fi + else # ESC + rm -f $TMP/sbopkg_* + break + fi + done } customize_item () { -# This function shows the menu for customizing the SlackBuild -# and .info file. -V="Edit" -while [ 0 ]; do -dialog --default-item "$V" --title "$APP Customization" \ ---cancel-label "Back" --menu \ -"Please choose an item or press to go back.\n" 15 75 4 \ -"Edit SlackBuild" "Create and edit a local copy of the SlackBuild" \ -"Delete SlackBuild" "Delete the local copy of the SlackBuild" \ -"Edit Info" "Create and edit a local copy of the .info file" \ -"Delete Info" "Delete the local copy of the .info file" \ -2>$TMP/sbopkg_custom_selection -CCHOICE=$? -if [ $CCHOICE = 0 ]; then - V="$(cat $TMP/sbopkg_custom_selection)" - if [ "$V" = "Edit SlackBuild" ]; then - edit_local_slackbuild $APP + # This function shows the menu for customizing the SlackBuild + # and .info file. + V="Edit" + while [ 0 ]; do + dialog --default-item "$V" --title "$APP Customization" \ + --cancel-label "Back" --menu \ + "Please choose an item or press to go back.\n" 15 75 4 \ + "Edit SlackBuild" "Create and edit a local copy of the SlackBuild" \ + "Delete SlackBuild" "Delete the local copy of the SlackBuild" \ + "Edit Info" "Create and edit a local copy of the .info file" \ + "Delete Info" "Delete the local copy of the .info file" \ + 2>$TMP/sbopkg_custom_selection + CCHOICE=$? + if [ $CCHOICE = 0 ]; then + V="$(cat $TMP/sbopkg_custom_selection)" + if [ "$V" = "Edit SlackBuild" ]; then + edit_local_slackbuild $APP + fi + if [ "$V" = "Delete SlackBuild" ]; then + delete_local_slackbuild $APP + fi + if [ "$V" = "Edit Info" ]; then + edit_local_info $APP + fi + if [ "$V" = "Delete Info" ]; then + delete_local_info $APP + fi + else # Cancel or ESC + rm -f $TMP/sbopkg_custom_selection + break fi - if [ "$V" = "Delete SlackBuild" ]; then - delete_local_slackbuild $APP - fi - if [ "$V" = "Edit Info" ]; then - edit_local_info $APP - fi - if [ "$V" = "Delete Info" ]; then - delete_local_info $APP - fi -else # Cancel or ESC - rm -f $TMP/sbopkg_custom_selection - break -fi -done + done } browse_items () { -# This function iterates through the list of software packages until -# one is chosen. -get_category_items_list -if [ -z "$T" ]; then T="aaa"; fi -while [ 0 ]; do - dialog --default-item "$T" --cancel-label "Back" --title \ -"Browsing the $CATEGORY category" --backtitle "Currently using the \ -SlackBuilds.org $SLACKVER repository." --menu \ -"Please select a software package or press to go back." \ -20 70 14 --file $TMP/sbopkg_category_items_list \ -2>$TMP/sbopkg_item_selection - if [ $? != 0 ]; then - break + # This function iterates through the list of software packages until + # one is chosen. + get_category_items_list + if [ -z "$T" ]; then + T="aaa" fi - info_item - T="$(cat $TMP/sbopkg_item_selection)" -done + while [ 0 ]; do + dialog --default-item "$T" --cancel-label "Back" \ + --title "Browsing the $CATEGORY category" --backtitle \ + "Currently using the SlackBuilds.org $SLACKVER repository." \ + --menu "$(crunch "Please select a software package or press \ + to go back.")" \ + 20 70 14 --file $TMP/sbopkg_category_items_list \ + 2>$TMP/sbopkg_item_selection + if [ $? != 0 ]; then + break + fi + info_item + T="$(cat $TMP/sbopkg_item_selection)" + done } browse_categories () { -# This function iterates through the category list until one is -# chosen. -get_category_list -if [ -z "$S" ]; then S="Academic"; fi -while [ 0 ]; do - dialog --default-item "$S" --cancel-label "Back" --title \ -"Choose a category" --backtitle "Currently using the SlackBuilds.org \ -$SLACKVER repository." --menu "Please select a category or press \ - to go back." 20 70 14 --file $TMP/sbopkg_category_list \ -2>$TMP/sbopkg_category_selection - if [ $? != 0 ]; then - break + # This function iterates through the category list until one is + # chosen. + get_category_list + if [ -z "$S" ]; then + S="Academic" fi - browse_items - S="$(cat $TMP/sbopkg_category_selection)" -done + while [ 0 ]; do + dialog --default-item "$S" --cancel-label "Back" \ + --title "Choose a category" --backtitle \ + "Currently using the SlackBuilds.org $SLACKVER repository." \ + --menu "Please select a category or press to go back." \ + 20 70 14 --file $TMP/sbopkg_category_list \ + 2>$TMP/sbopkg_category_selection + if [ $? != 0 ]; then + break + fi + browse_items + S="$(cat $TMP/sbopkg_category_selection)" + done } view_cache_dir () { -# This function displays the contents of $SRCDIR. -if [ "$(ls -A $SRCDIR 2>/dev/null)" ]; then - ls -la $SRCDIR > $TMP/sbopkg_cache_dir - dialog --title "Displaying $SRCDIR" \ ---textbox $TMP/sbopkg_cache_dir 0 0 - dialog --title "Keep Cache?" --yes-label "Keep" --no-label "Delete" \ ---yesno "Would you like to keep the files in the cache directory?" 5 60 - 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 + # This function displays the contents of $SRCDIR. + if [ "$(ls -A $SRCDIR 2>/dev/null)" ]; then + ls -la $SRCDIR > $TMP/sbopkg_cache_dir + dialog --title "Displaying $SRCDIR" \ + --textbox $TMP/sbopkg_cache_dir 0 0 + dialog --title "Keep Cache?" --yes-label "Keep" --no-label "Delete" \ + --yesno "$(crunch "Would you like to keep the files in the cache \ + directory?")" 5 60 + if [ $? = 1 ]; then + check_root + if [ $ROOT = "false" ]; then + dialog --title "ERROR" --msgbox "$(crunch "Sorry, only the \ + root user can clear the cache directory.")" 8 30 + continue + else + rm -f $SRCDIR/* + dialog --title "Done" --msgbox \ + "The cache directory has been cleared." 8 30 + continue + fi else - rm -f $SRCDIR/* - dialog --title "Done" --msgbox "The cache directory has been \ -cleared." 8 30 continue fi else - continue + dialog --title "ERROR" --msgbox \ + "It appears the cache directory is empty." 8 30 fi -else - dialog --title "ERROR" --msgbox "It appears the cache \ -directory is empty." 8 30 -fi } view_perm_log () { -# This function displays the contents of the permanent build log, -# which is kept if KEEPLOG is set to YES in the config file. -if [ ! -e $TMP/sbopkg-build-log ]; then - dialog --title "ERROR" --msgbox "No permanent log \ -found. Please make sure KEEPLOG is set to YES \ -in the configuration file." 10 30 - continue -else - dialog --title "Displaying $TMP/sbopkg-build-log" \ ---textbox $TMP/sbopkg-build-log 0 0 - dialog --title "Keep Log?" --yes-label "Keep" --no-label "Delete" \ ---yesno "Would you like to keep the permanent build log $TMP/sbopkg-build-log?" 6 50 - if [ $? = 1 ]; then - check_root - if [ $ROOT = "false" ]; then - dialog --title "ERROR" --msgbox "Sorry, only the root \ -user can delete the build log." 8 30 - continue + # This function displays the contents of the permanent build log, + # which is kept if KEEPLOG is set to YES in the config file. + if [ ! -e $TMP/sbopkg-build-log ]; then + dialog --title "ERROR" --msgbox "$(crunch "No permanent log \ + found. Please make sure KEEPLOG is set to YES \ + in the configuration file.")" 10 30 + continue + else + dialog --title "Displaying $TMP/sbopkg-build-log" \ + --textbox $TMP/sbopkg-build-log 0 0 + dialog --title "Keep Log?" --yes-label "Keep" --no-label "Delete" \ + --yesno "$(crunch "Would you like to keep the permanent build \ + log $TMP/sbopkg-build-log?")" 6 50 + if [ $? = 1 ]; then + check_root + if [ $ROOT = "false" ]; then + dialog --title "ERROR" --msgbox \ + "Sorry, only the root user can delete the build log." 8 30 + continue + else + rm -f $TMP/sbopkg-build-log + dialog --title "Done" --msgbox \ + "The build log has been deleted." 8 30 + continue + fi else - rm -f $TMP/sbopkg-build-log - dialog --title "Done" --msgbox "The build log has been \ -deleted." 8 30 continue fi - else - continue fi -fi } sort_queue () { -# This function sorts the build queue in $TMPQUEUE. Thanks to Mauro -# Giachero for this contribution (and the reverse sorting). -local PARTIALSORT=$(tempfile -d $TMP) -local CHOICE -local SELECTED -local PKGSCOUNT=$(cat $TMPQUEUE |wc -l) -local DEFAULTITEM=1 -local TMPSORTQUEUE=$TMP/sbopkg-tmp-sort-queue -cp $TMPQUEUE $TMPSORTQUEUE -while :; do - dialog --title "Sort Queue" --ok-label "Up" \ - --extra-button --extra-label "Down" \ - --cancel-label "OK" \ - --help-button --help-label "Cancel" \ - --default-item $DEFAULTITEM \ - --menu "Use the buttons to sort the queue items, \ -press when done, or press to abort changes." 30 50 14 \ - $(cat -n $TMPSORTQUEUE |rev |cut -d" " -f3 |rev) \ - 2>$TMP/sbopkg-ans-sort - CHOICE=$? - SELECTED=$(cat $TMP/sbopkg-ans-sort) - DEFAULTITEM=$SELECTED - case $CHOICE in - 0 ) # Up - if [ $SELECTED -eq 1 ]; then continue; fi - head -n $(($SELECTED-2)) $TMPSORTQUEUE >$PARTIALSORT - head -n $(($SELECTED)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT - head -n $(($SELECTED-1)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT - tail -n $(($PKGSCOUNT-$SELECTED)) $TMPSORTQUEUE >>$PARTIALSORT - mv $PARTIALSORT $TMPSORTQUEUE - DEFAULTITEM=$(($SELECTED-1)) - continue - ;; - 1 ) # OK - mv $TMPSORTQUEUE $TMPQUEUE - break - ;; - 3 ) # Down - if [ $SELECTED -eq $PKGSCOUNT ]; then continue; fi - head -n $(($SELECTED-1)) $TMPSORTQUEUE >$PARTIALSORT - head -n $(($SELECTED+1)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT - head -n $(($SELECTED)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT - tail -n $(($PKGSCOUNT-$SELECTED-1)) $TMPSORTQUEUE >>$PARTIALSORT - mv $PARTIALSORT $TMPSORTQUEUE - DEFAULTITEM=$(($SELECTED+1)) - continue - ;; - * ) # Cancel or ESC - rm -f $TMPSORTQUEUE - break - ;; - esac -done -rm -f $TMP/sbopkg-ans-sort -continue + # This function sorts the build queue in $TMPQUEUE. Thanks to Mauro + # Giachero for this contribution (and the reverse sorting). + local PARTIALSORT=$(tempfile -d $TMP) + local CHOICE + local SELECTED + local PKGSCOUNT=$(cat $TMPQUEUE |wc -l) + local DEFAULTITEM=1 + local TMPSORTQUEUE=$TMP/sbopkg-tmp-sort-queue + cp $TMPQUEUE $TMPSORTQUEUE + while :; do + dialog --title "Sort Queue" --ok-label "Up" \ + --extra-button --extra-label "Down" \ + --cancel-label "OK" \ + --help-button --help-label "Cancel" \ + --default-item $DEFAULTITEM \ + --menu "$(crunch "Use the buttons to sort the queue \ + items, press when done, or press to abort \ + changes.")" 30 50 14 \ + $(cat -n $TMPSORTQUEUE |rev |cut -d" " -f3 |rev) \ + 2>$TMP/sbopkg-ans-sort + CHOICE=$? + SELECTED=$(cat $TMP/sbopkg-ans-sort) + DEFAULTITEM=$SELECTED + case $CHOICE in + 0 ) # Up + if [ $SELECTED -eq 1 ]; then continue; fi + head -n $(($SELECTED-2)) $TMPSORTQUEUE >$PARTIALSORT + head -n $(($SELECTED)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT + head -n $(($SELECTED-1)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT + tail -n $(($PKGSCOUNT-$SELECTED)) $TMPSORTQUEUE >>$PARTIALSORT + mv $PARTIALSORT $TMPSORTQUEUE + DEFAULTITEM=$(($SELECTED-1)) + continue + ;; + 1 ) # OK + mv $TMPSORTQUEUE $TMPQUEUE + break + ;; + 3 ) # Down + if [ $SELECTED -eq $PKGSCOUNT ]; then continue; fi + head -n $(($SELECTED-1)) $TMPSORTQUEUE >$PARTIALSORT + head -n $(($SELECTED+1)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT + head -n $(($SELECTED)) $TMPSORTQUEUE |tail -n 1 >>$PARTIALSORT + tail -n $(($PKGSCOUNT-$SELECTED-1)) $TMPSORTQUEUE >>$PARTIALSORT + mv $PARTIALSORT $TMPSORTQUEUE + DEFAULTITEM=$(($SELECTED+1)) + continue + ;; + * ) # Cancel or ESC + rm -f $TMPSORTQUEUE + break + ;; + esac + done + rm -f $TMP/sbopkg-ans-sort + continue } delete_backup_queue () { -# This function is not used but is being saved for the time being. -# This function deletes any backup queues. -PERMQUEUE=$TMP/sbopkg-savedqueue -if [ -e $PERMQUEUE ]; then - dialog --title "Delete Backup Queue?" --yesno "An \ -automatically-saved backup build queue was found. Would you like \ -to delete it? Press to delete the backup queue, or press \ - to cancel." 9 65 - if [ $? = 0 ]; then - rm -f $PERMQUEUE - rm -f $TMP/sbopkg_backup_queue.lck - dialog --title "Done" --msgbox "The backup queue has been \ -deleted." 8 30 + # This function is not used but is being saved for the time being. + # This function deletes any backup queues. + PERMQUEUE=$TMP/sbopkg-savedqueue + if [ -e $PERMQUEUE ]; then + dialog --title "Delete Backup Queue?" --yesno "$(crunch "An \ + automatically-saved backup build queue was found. Would you \ + like to delete it? Press to delete the backup queue, or \ + press to cancel.")" 9 65 + if [ $? = 0 ]; then + rm -f $PERMQUEUE + rm -f $TMP/sbopkg_backup_queue.lck + dialog --title "Done" --msgbox \ + "The backup queue has been deleted." 8 30 + fi + else + dialog --title "Error" --msgbox "No backup queue was found." 8 30 fi -else - dialog --title "Error" --msgbox "No backup queue was found." 8 30 -fi } load_backup_queue () { -# This function loads any backup queue and merges it with any -# current $TMPQUEUE. -TMPQUEUE=$TMP/sbopkg-tmp-queue -PERMQUEUE=$TMP/sbopkg-savedqueue -if [ -e $PERMQUEUE ]; then - dialog --title "Load Temporary Backup Queue?" --yesno "A \ -temporary backup queue was found. Would you like to load it? \ -Either way, the temporary backup queue will be deleted. A new \ -temporary backup queue will be automatically created if you quit \ -sbopkg with items in the build queue.\n\nPress to load the \ -temporary backup queue into the build queue, or press to \ -cancel." 11 65 - if [ $? = 0 ]; then - mv $PERMQUEUE $TMPQUEUE - touch $TMP/sbopkg_backup_queue.lck - dialog --title "Done" --msgbox "The backup queue has been \ -loaded." 8 30 - else - rm -f $PERMQUEUE + # This function loads any backup queue and merges it with any + # current $TMPQUEUE. + TMPQUEUE=$TMP/sbopkg-tmp-queue + PERMQUEUE=$TMP/sbopkg-savedqueue + if [ -e $PERMQUEUE ]; then + dialog --title "Load Temporary Backup Queue?" --yesno "$(crunch "A \ + temporary backup queue was found. Would you like to load it? \ + Either way, the temporary backup queue will be deleted. A new \ + temporary backup queue will be automatically created if you quit \ + sbopkg with items in the build queue.\n\nPress to load the \ + temporary backup queue into the build queue, or press to \ + cancel.")" 11 65 + if [ $? = 0 ]; then + mv $PERMQUEUE $TMPQUEUE + touch $TMP/sbopkg_backup_queue.lck + dialog --title "Done" --msgbox \ + "The backup queue has been loaded." 8 30 + else + rm -f $PERMQUEUE + fi fi -fi } save_backup_queue () { -# This function saves the build queue and merges it with any current -# $TMPQUEUE. -TMPQUEUE=$TMP/sbopkg-tmp-queue -PERMQUEUE=$TMP/sbopkg-savedqueue -if [ -e $TMPQUEUE ]; then - cp $TMPQUEUE $PERMQUEUE - dialog --title "Saving Temporary Backup Queue" --msgbox "Since \ -the queue was not empty upon exiting sbopkg, it has been \ -automatically saved to a temporary backup file. If you do not want \ -this to happen next time, please be sure the build queue is cleared \ -before exiting sbopkg." 9 65 -fi + # This function saves the build queue and merges it with any current + # $TMPQUEUE. + TMPQUEUE=$TMP/sbopkg-tmp-queue + PERMQUEUE=$TMP/sbopkg-savedqueue + if [ -e $TMPQUEUE ]; then + cp $TMPQUEUE $PERMQUEUE + dialog --title "Saving Temporary Backup Queue" --msgbox \ + "$(crunch "Since the queue was not empty upon exiting sbopkg, \ + it has been automatically saved to a temporary backup file. If \ + you do not want this to happen next time, please be sure the \ + build queue is cleared before exiting sbopkg.")" 9 65 + fi } load_user_queue () { -# This function loads a user's specified saved queue and merges it -# with any current $TMPQUEUE. -TMPQUEUE=$TMP/sbopkg-tmp-queue -WORKINGQUEUE=$TMP/sbopkg-working-queue -dialog --title "Load Saved Queue" --inputbox "Please enter the path \ -and filename to a saved build queue (if no path is specified, then \ -your queue will be saved to $TMP):" 10 50 2>/$TMP/sbopkg_user_queue -if [ $? = 0 ]; then - USERQUEUE="$(cat $TMP/sbopkg_user_queue)" - if [ ! "$USERQUEUE" = "" ]; then - if $(echo $USERQUEUE | grep -q \/); then - USERQUEUE=$USERQUEUE - else - USERQUEUE=$TMP/$USERQUEUE - fi - if [ -e $USERQUEUE ]; then - rm -f $WORKINGQUEUE - cat $TMPQUEUE >> $WORKINGQUEUE - cat $USERQUEUE >> $WORKINGQUEUE - sort $WORKINGQUEUE | uniq > $TMPQUEUE - rm -f $WORKINGQUEUE - dialog --title "Done" --msgbox "The saved queue has been \ -loaded." 8 30 - else - dialog --title "Error" --msgbox "No saved queue was \ -found." 8 30 - fi - fi -fi -} - -save_user_queue () { -# This function saves the build queue to a location the user -# specifies. -TMPQUEUE=$TMP/sbopkg-tmp-queue -if [ ! -e $TMPQUEUE ]; then - dialog --title "Empty Queue" --msgbox "The build \ -queue is empty." 8 30 - continue -else - dialog --title "Save Queue" --inputbox "Please enter the path \ -and filename where you would like to save the queue (if no path is \ -specified, your queue will be saved to $TMP):" 10 50 \ -2>/$TMP/sbopkg_user_queue + # This function loads a user's specified saved queue and merges it + # with any current $TMPQUEUE. + TMPQUEUE=$TMP/sbopkg-tmp-queue + WORKINGQUEUE=$TMP/sbopkg-working-queue + dialog --title "Load Saved Queue" --inputbox "$(crunch "Please enter the \ + path and filename to a saved build queue (if no path is specified, \ + then your queue will be saved to $TMP):")" \ + 10 50 2>/$TMP/sbopkg_user_queue if [ $? = 0 ]; then USERQUEUE="$(cat $TMP/sbopkg_user_queue)" if [ ! "$USERQUEUE" = "" ]; then @@ -951,379 +943,428 @@ specified, your queue will be saved to $TMP):" 10 50 \ USERQUEUE=$TMP/$USERQUEUE fi if [ -e $USERQUEUE ]; then - dialog --title "Error" --yesno "Another file with \ -that name already exists. Press to continue and overwrite the \ -other file, or press to cancel." 10 50 - if [ $? != 0 ]; then - dialog --title "Not saved" --msgbox "The build \ -queue has not been saved." 8 30 - continue - fi + rm -f $WORKINGQUEUE + cat $TMPQUEUE >> $WORKINGQUEUE + cat $USERQUEUE >> $WORKINGQUEUE + sort $WORKINGQUEUE | uniq > $TMPQUEUE + rm -f $WORKINGQUEUE + dialog --title "Done" --msgbox \ + "The saved queue has been loaded." 8 30 + else + dialog --title "Error" --msgbox \ + "No saved queue was found." 8 30 + fi + fi + fi +} + +save_user_queue () { + # This function saves the build queue to a location the user + # specifies. + TMPQUEUE=$TMP/sbopkg-tmp-queue + if [ ! -e $TMPQUEUE ]; then + dialog --title "Empty Queue" --msgbox \ + "The build queue is empty." 8 30 + continue + else + dialog --title "Save Queue" --inputbox "$(crunch "Please enter the \ + path and filename where you would like to save the queue (if no \ + path is specified, your queue will be saved to $TMP):")" 10 50 \ + 2>/$TMP/sbopkg_user_queue + if [ $? = 0 ]; then + USERQUEUE="$(cat $TMP/sbopkg_user_queue)" + if [ ! "$USERQUEUE" = "" ]; then + if $(echo $USERQUEUE | grep -q \/); then + USERQUEUE=$USERQUEUE + else + USERQUEUE=$TMP/$USERQUEUE + fi + if [ -e $USERQUEUE ]; then + dialog --title "Error" --yesno "$(crunch "Another file \ + with that name already exists. Press to \ + continue and overwrite the other file, or press \ + to cancel.")" 10 50 + if [ $? != 0 ]; then + dialog --title "Not saved" --msgbox \ + "The build queue has not been saved." 8 30 + continue + fi + fi + rm -f $USERQUEUE + touch $USERQUEUE + sort $TMPQUEUE | uniq > $USERQUEUE + dialog --title "Done" --msgbox \ + "The build queue has been saved." 8 30 fi - rm -f $USERQUEUE - touch $USERQUEUE - sort $TMPQUEUE | uniq > $USERQUEUE - dialog --title "Done" --msgbox "The build queue has been \ -saved." 8 30 fi fi -fi } clear_build_queue () { -# This function clears the build queue. -TMPQUEUE=$TMP/sbopkg-tmp-queue -if [ ! -e $TMPQUEUE ]; then - dialog --title "Empty Queue" --msgbox "The build \ -queue is empty." 8 30 - continue -else - dialog --title "Clear Build Queue?" --yesno "Do you want to \ -clear the build queue? Press to clear the build queue, or \ -press to cancel." 9 65 - if [ $? = 0 ]; then - rm -f $TMPQUEUE - dialog --title "Done" --msgbox "The build queue has been \ -cleared." 8 30 + # This function clears the build queue. + TMPQUEUE=$TMP/sbopkg-tmp-queue + if [ ! -e $TMPQUEUE ]; then + dialog --title "Empty Queue" --msgbox \ + "The build queue is empty." 8 30 + continue + else + dialog --title "Clear Build Queue?" --yesno "$(crunch "Do you want \ + to clear the build queue? Press to clear the build queue, \ + or press to cancel.")" 9 65 + if [ $? = 0 ]; then + rm -f $TMPQUEUE + dialog --title "Done" --msgbox \ + "The build queue has been cleared." 8 30 + fi fi -fi } view_queue () { -# This function displays the contents of the build queue. -TMPQUEUE=$TMP/sbopkg-tmp-queue -WORKINGQUEUE=$TMP/sbopkg-working-queue -while :; do - if [ ! -e $TMPQUEUE ]; then - dialog --title "Empty Queue" --msgbox "The build \ -queue is empty." 8 30 - break - else - dialog --title "Viewing Build Queue" --separate-output \ - --extra-button --extra-label "Reverse" \ - --help-button --help-label "Cancel" --cancel-label "Sort" \ - --checklist "The following packages are currently in the \ -build queue. Please note that when the build queue is processed, \ -the packages selected below will be built, and optionally installed, \ -in the order listed from top to bottom.\n\nPlease select or unselect \ -those packages you wish to keep in the build queue and then press \ - to continue or press to exit." 30 50 8 \ - --file $TMPQUEUE 2>$TMP/sbopkg-ans-queue - CHOICE=$? # 0 = OK, 1 = Sort, 2 = Cancel, 3 = Reverse - if [ $CHOICE = 0 ]; then - if [ ! -s $TMP/sbopkg-ans-queue ]; then - rm -f $TMP/sbopkg-*-queue - return 0 - else - rm -f $WORKINGQUEUE - for PICK in $(cat $TMP/sbopkg-ans-queue); do - echo $(grep -m1 "^$PICK " $TMPQUEUE) >> \ - $WORKINGQUEUE - done - mv $WORKINGQUEUE $TMPQUEUE - if [ "$BUILDPKGS" = 1 ]; then - mv $TMP/sbopkg-ans-queue $TMP/sbopkg-start-queue - fi - return 0 - fi - elif [ $CHOICE = 1 ]; then - sort_queue $TMPQUEUE - continue - elif [ $CHOICE = 3 ]; then - tac $TMPQUEUE >$TMP/sbopkg-reversed-queue - mv $TMP/sbopkg-reversed-queue $TMPQUEUE - continue - else # Cancel or ESC - rm -f $TMP/sbopkg-ans-queue + # This function displays the contents of the build queue. + TMPQUEUE=$TMP/sbopkg-tmp-queue + WORKINGQUEUE=$TMP/sbopkg-working-queue + while :; do + if [ ! -e $TMPQUEUE ]; then + dialog --title "Empty Queue" --msgbox \ + "The build queue is empty." 8 30 break + else + dialog --title "Viewing Build Queue" --separate-output \ + --extra-button --extra-label "Reverse" \ + --help-button --help-label "Cancel" --cancel-label "Sort" \ + --checklist "$(crunch "The following packages are currently \ + in the build queue. Please note that when the build queue \ + is processed, the packages selected below will be built, and \ + optionally installed, in the order listed from top to \ + bottom.\n\nPlease select or unselect those packages you wish \ + to keep in the build queue and then press to continue \ + or press to exit.")" 30 50 8 \ + --file $TMPQUEUE 2>$TMP/sbopkg-ans-queue + CHOICE=$? # 0 = OK, 1 = Sort, 2 = Cancel, 3 = Reverse + if [ $CHOICE = 0 ]; then + if [ ! -s $TMP/sbopkg-ans-queue ]; then + rm -f $TMP/sbopkg-*-queue + return 0 + else + rm -f $WORKINGQUEUE + for PICK in $(cat $TMP/sbopkg-ans-queue); do + echo $(grep -m1 "^$PICK " $TMPQUEUE) >> \ + $WORKINGQUEUE + done + mv $WORKINGQUEUE $TMPQUEUE + if [ "$BUILDPKGS" = 1 ]; then + mv $TMP/sbopkg-ans-queue $TMP/sbopkg-start-queue + fi + return 0 + fi + elif [ $CHOICE = 1 ]; then + sort_queue $TMPQUEUE + continue + elif [ $CHOICE = 3 ]; then + tac $TMPQUEUE >$TMP/sbopkg-reversed-queue + mv $TMP/sbopkg-reversed-queue $TMPQUEUE + continue + else # Cancel or ESC + rm -f $TMP/sbopkg-ans-queue + break + fi fi - fi -done -continue + done + continue } rsync_command () { -# This function holds the rsync command. -# We do not use -z as this causes heavy CPU load on the server -# and has very limited effect when most of the pull is .gz files. -/usr/bin/rsync --archive --delete --no-owner --exclude="*.sbopkg" \ -$RSYNCFLAGS $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ -RSYNC_RETVAL=$? -rm -f $TMP/sbopkg_rsync.lck -if [ ! $RSYNC_RETVAL = 0 ]; then - case $RSYNC_RETVAL in - 35) - echo - echo "The connection to $RSYNCMIRROR timed out." - echo "You can modify the TIMEOUT value in sbopkg.conf" - echo "if this problem persists." - echo "(TIMEOUT is currently set to: $TIMEOUT seconds)". - echo - ;; - 30) - echo - echo "Rsync reported a timeout while waiting for data." - echo "$RSYNCMIRROR may under a heavy load." - echo "Please try again later." - echo - ;; - 10) - echo - echo "Rsync reported a socket error which may be due to" - echo "a problem with the RSYNCMIRROR value in sbopkg.conf." - echo "(RSYNCMIRROR is currently set to: $RSYNCMIRROR)." - echo "Please check your settings and try again later." - echo - ;; - *) - echo - echo "Rsync with SlackBuilds.org failed." - echo "Please try again." - echo - ;; - esac -else - echo - echo "Rsync with SlackBuilds.org complete." - echo -fi + # This function holds the rsync command. + # We do not use -z as this causes heavy CPU load on the server + # and has very limited effect when most of the pull is .gz files. + /usr/bin/rsync --archive --delete --no-owner --exclude="*.sbopkg" \ + $RSYNCFLAGS $RSYNCMIRROR/$SLACKVER/ $LOCALREPO/$SLACKVER/ + RSYNC_RETVAL=$? + rm -f $TMP/sbopkg_rsync.lck + if [ ! $RSYNC_RETVAL = 0 ]; then + case $RSYNC_RETVAL in + 35) + echo + echo "The connection to $RSYNCMIRROR timed out." + echo "You can modify the TIMEOUT value in sbopkg.conf" + echo "if this problem persists." + echo "(TIMEOUT is currently set to: $TIMEOUT seconds)". + echo + ;; + 30) + echo + echo "Rsync reported a timeout while waiting for data." + echo "$RSYNCMIRROR may under a heavy load." + echo "Please try again later." + echo + ;; + 10) + echo + echo "Rsync reported a socket error which may be due to" + echo "a problem with the RSYNCMIRROR value in sbopkg.conf." + echo "(RSYNCMIRROR is currently set to: $RSYNCMIRROR)." + echo "Please check your settings and try again later." + echo + ;; + *) + echo + echo "Rsync with SlackBuilds.org failed." + echo "Please try again." + echo + ;; + esac + else + echo + echo "Rsync with SlackBuilds.org complete." + echo + fi } rsync_repo () { -# This function does the rsync with SBo. -directory_checks -check_write $LOCALREPO/$SLACKVER/ -if [ "$WRITE" = "false" ]; then - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "You do not have write \ -permissions on the target directory." 8 30 - continue - else - echo "You do not have write permissons on the target directory." - cleanup - exit 0 + # This function does the rsync with SBo. + directory_checks + check_write $LOCALREPO/$SLACKVER/ + if [ "$WRITE" = "false" ]; then + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox \ + "You do not have write permissions on the target directory." \ + 8 30 + continue + else + echo "You do not have write permissons on the target directory." + cleanup + exit 0 + fi + fi + if [ "$DIAG" = 1 ]; then + rm -f $TMP/sbopkg_rsync.lck + touch $TMP/sbopkg_rsync.lck + SBOPKGOUTPUT=$TMP/sbopkg_output + ( rsync_command >> $SBOPKGOUTPUT & ) 2>>$SBOPKGOUTPUT + while [ -f $TMP/sbopkg_rsync.lck ]; do + dialog --backtitle "Rsyncing with SlackBuilds.org" \ + --tailbox $SBOPKGOUTPUT 18 70 + done + rm -f $SBOPKGOUTPUT + else + rsync_command fi -fi -if [ "$DIAG" = 1 ]; then - rm -f $TMP/sbopkg_rsync.lck - touch $TMP/sbopkg_rsync.lck - SBOPKGOUTPUT=$TMP/sbopkg_output - ( rsync_command >> $SBOPKGOUTPUT & ) 2>>$SBOPKGOUTPUT - while [ -f $TMP/sbopkg_rsync.lck ]; do - dialog --backtitle "Rsyncing with SlackBuilds.org" \ ---tailbox $SBOPKGOUTPUT 18 70 - done - rm -f $SBOPKGOUTPUT -else - rsync_command -fi } search_package () { -# Search for package name and exit if not found. If it is found, -# populate various variables with data about the package for -# displaying information and building. -cd $LOCALREPO/$SLACKVER -PKG=$1 -PKGPATH=$(find -type d -mindepth 2 -name $PKG) -if [ ! $(find -type d -mindepth 2 -name "$PKG") ]; then - if [ "$BUILDPKGS" = 1 ]; then - echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG - echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG - continue - else - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "Package $PKG not found" 0 0 + # Search for package name and exit if not found. If it is found, + # populate various variables with data about the package for + # displaying information and building. + cd $LOCALREPO/$SLACKVER + PKG=$1 + PKGPATH=$(find -type d -mindepth 2 -name $PKG) + if [ ! $(find -type d -mindepth 2 -name "$PKG") ]; then + if [ "$BUILDPKGS" = 1 ]; then + echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG + echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG continue else - echo "ERROR: Package \"$PKG\" not found." 1>&2 - continue + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox "Package $PKG not found" 0 0 + continue + else + echo "ERROR: Package \"$PKG\" not found." 1>&2 + continue + fi fi fi -fi } gen_search_package () { -# Search for package name glob generally using grep. In dialog -# interface, jump to selected package. -cd $LOCALREPO/$SLACKVER -PKG=$1 -RESULTS=$(find . -mindepth 2 -maxdepth 2 -type d -iname "*$PKG*" | sed -e 's/.\///') -if [ -n "$RESULTS" ]; then - if [ "$DIAG" = 1 ]; then - for i in $RESULTS; do - DESC=$(grep -hZm1 ^$(echo "$i" | cut -d/ -f2) ./$i/slack-desc* | cut -d\( -f2- | cut -d\) -f1) - echo "\"$i\" \"$DESC\"" >> $TMP/sbopkg_search_results - done - while [ -f $TMP/sbopkg_search_results ]; do - dialog --title "Matches for $PKG" --extra-button \ - --extra-label "Add to Queue" --menu "Please select an \ -item you wish to view or press to exit." 20 70 14 --file \ - $TMP/sbopkg_search_results 2>$TMP/sbopkg_search_choice - CHOICE=$? - if [ $CHOICE = 1 ]; then - rm -f $TMP/sbopkg_search_results - return 0 - fi - SRCHPICK="$(cat $TMP/sbopkg_search_choice)" - SRCHCAT=$(echo $SRCHPICK | sed -e 's/\/.*$//') - SRCHPKG=$(echo $SRCHPICK | sed -e 's/^.*\///') - RVERSION=$(grep VERSION $LOCALREPO/$SLACKVER/$SRCHCAT/$SRCHPKG/$SRCHPKG.info | cut -d= -f2 | sed s/\"//g) - RBUILD=$(egrep -m1 "^BUILD" $LOCALREPO/$SLACKVER/$SRCHCAT/$SRCHPKG/$SRCHPKG.SlackBuild | sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') - if [ $CHOICE = 0 ]; then - echo $SRCHCAT > $TMP/sbopkg_category_selection - echo $SRCHPKG > $TMP/sbopkg_item_selection - cd $LOCALREPO/$SLACKVER - info_item - elif [ $CHOICE = 3 ]; then - if [ ! -e $TMP/sbopkg-tmp-queue ]; then - touch $TMP/sbopkg-tmp-queue + # Search for package name glob generally using grep. In dialog + # interface, jump to selected package. + cd $LOCALREPO/$SLACKVER + PKG=$1 + RESULTS=$(find . -mindepth 2 -maxdepth 2 -type d -iname "*$PKG*" | + sed -e 's/.\///') + if [ -n "$RESULTS" ]; then + if [ "$DIAG" = 1 ]; then + for i in $RESULTS; do + DESC=$(grep -hZm1 ^$(echo "$i" | + cut -d/ -f2) ./$i/slack-desc* | cut -d\( -f2- | + cut -d\) -f1) + echo "\"$i\" \"$DESC\"" >> $TMP/sbopkg_search_results + done + while [ -f $TMP/sbopkg_search_results ]; do + dialog --title "Matches for $PKG" --extra-button \ + --extra-label "Add to Queue" --menu "$(crunch "Please \ + select an item you wish to view or press to \ + exit.")" 20 70 14 --file \ + $TMP/sbopkg_search_results 2>$TMP/sbopkg_search_choice + CHOICE=$? + if [ $CHOICE = 1 ]; then + rm -f $TMP/sbopkg_search_results + return 0 fi - if $(cat $TMP/sbopkg-tmp-queue | \ - grep -q "^$SRCHPKG "); then - dialog --title "ERROR" --msgbox \ - "$SRCHPKG is already in the queue." 8 30 + SRCHPICK="$(cat $TMP/sbopkg_search_choice)" + SRCHCAT=$(echo $SRCHPICK | sed -e 's/\/.*$//') + SRCHPKG=$(echo $SRCHPICK | sed -e 's/^.*\///') + local SHORTPATH=$LOCALREPO/$SLACKVER/$SRCHCAT/$SRCHPKG + RVERSION=$(grep VERSION $SHORTPATH/$SRCHPKG.info | + cut -d= -f2 | sed s/\"//g) + RBUILD=$(egrep -m1 "^BUILD" $SHORTPATH/$SRCHPKG.SlackBuild | + sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') + if [ $CHOICE = 0 ]; then + echo $SRCHCAT > $TMP/sbopkg_category_selection + echo $SRCHPKG > $TMP/sbopkg_item_selection + cd $LOCALREPO/$SLACKVER + info_item + elif [ $CHOICE = 3 ]; then + if [ ! -e $TMP/sbopkg-tmp-queue ]; then + touch $TMP/sbopkg-tmp-queue + fi + if $(cat $TMP/sbopkg-tmp-queue | \ + grep -q "^$SRCHPKG "); then + dialog --title "ERROR" --msgbox \ + "$SRCHPKG is already in the queue." 8 30 + else + echo "$SRCHPKG $RVERSION-$RBUILD ON" >> \ + $TMP/sbopkg-tmp-queue + dialog --title "Done" --msgbox \ + "$SRCHPKG has been added to the build queue." 8 30 + fi + continue else - echo "$SRCHPKG $RVERSION-$RBUILD ON" >> \ - $TMP/sbopkg-tmp-queue - dialog --title "Done" --msgbox \ - "$SRCHPKG has been added to the build queue." 8 30 + rm -f $TMP/sbopkg_search_results + return 0 fi - continue - else - rm -f $TMP/sbopkg_search_results - return 0 - fi - done - continue + done + continue + else + echo "Found the following matches for $PKG:" + for i in $RESULTS; do + echo $i + done + continue + fi else - echo "Found the following matches for $PKG:" - for i in $RESULTS; do - echo $i - done - continue + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox "No match for $PKG found" 8 30 + continue + else + echo "$SCRIPT: No match for $PKG found." 1>&2 + continue + fi fi -else - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "No match for $PKG found" 8 30 - continue - else - echo "$SCRIPT: No match for $PKG found." 1>&2 - continue - fi -fi } show_readme () { -# Show the package's text files. -cd $LOCALREPO/$SLACKVER -${PAGER:-more} $PKGPATH/{README,$PKGNAME.SlackBuild,\ -$PKGNAME.info.build,slack-desc} -rm -f $PKGPATH/$PKGNAME.info.build -return 0 + # Show the package's text files. + cd $LOCALREPO/$SLACKVER + ${PAGER:-more} $PKGPATH/{README,$PKGNAME.SlackBuild,\ + $PKGNAME.info.build,slack-desc} + rm -f $PKGPATH/$PKGNAME.info.build + return 0 } get_source () { -# Check to see if the source tarball exists in the local cache -# directory. If it does, make a symlink to the package directory in -# the local mirror. If it does not, download it and make the link. -if [ ! -e $PKGPATH/$SRCNAME ]; then - if [ -e $SRCDIR/$SRCNAME ]; then - ln -s $SRCDIR/$SRCNAME $LOCALREPO/$SLACKVER/$PKGPATH/$SRCNAME - else - mkdir -p $SRCDIR/download - cd $SRCDIR/download - wget $WGETFLAGS $DOWNLOAD >> $SBOPKGOUTPUT & echo "$!" >> $TMP/sbopkgpidlist 2>>$SBOPKGOUTPUT - wait - DOWNLOADFILE=$(ls *) - CORRECTED_DOWNLOADFILE=$(echo $DOWNLOADFILE | sed -e \ - 's/\?e=.*$//') # for Virtualbox where wget adds a '?=' at end - mv $DOWNLOADFILE $CORRECTED_DOWNLOADFILE - mv $CORRECTED_DOWNLOADFILE $SRCDIR/ - cd - - rm -rf $SRCDIR/download - ln -s $SRCDIR/$SRCNAME $LOCALREPO/$SLACKVER/$PKGPATH/$SRCNAME + # Check to see if the source tarball exists in the local cache + # directory. If it does, make a symlink to the package directory in + # the local mirror. If it does not, download it and make the link. + if [ ! -e $PKGPATH/$SRCNAME ]; then + if [ -e $SRCDIR/$SRCNAME ]; then + ln -s $SRCDIR/$SRCNAME $LOCALREPO/$SLACKVER/$PKGPATH/$SRCNAME + else + mkdir -p $SRCDIR/download + cd $SRCDIR/download + wget $WGETFLAGS $DOWNLOAD >> $SBOPKGOUTPUT & echo "$!" >> \ + $TMP/sbopkgpidlist 2>>$SBOPKGOUTPUT + wait + DOWNLOADFILE=$(ls *) + CORRECTED_DOWNLOADFILE=$(echo $DOWNLOADFILE | sed -e \ + 's/\?e=.*$//') # for Virtualbox where wget adds a '?=' at end + mv $DOWNLOADFILE $CORRECTED_DOWNLOADFILE + mv $CORRECTED_DOWNLOADFILE $SRCDIR/ + cd - + rm -rf $SRCDIR/download + ln -s $SRCDIR/$SRCNAME $LOCALREPO/$SLACKVER/$PKGPATH/$SRCNAME + fi fi -fi } remove_sources () { -# Remove sources from $SRCDIR for a particular $APP -if $(echo $(ls -la $SRCDIR) | grep -q "$APP"); then - ls -la $SRCDIR | grep $APP > $TMP/sbopkg_app_sources - dialog --title "Displaying $APP sources" \ ---textbox $TMP/sbopkg_app_sources 0 0 - dialog --title "Keep $APP sources?" --yesno "Would you like to \ -keep the $APP sources in the cache directory $SRCDIR? Select YES \ -to keep or NO to delete." 8 40 + # Remove sources from $SRCDIR for a particular $APP + if $(echo $(ls -la $SRCDIR) | grep -q "$APP"); then + ls -la $SRCDIR | grep $APP > $TMP/sbopkg_app_sources + dialog --title "Displaying $APP sources" \ + --textbox $TMP/sbopkg_app_sources 0 0 + dialog --title "Keep $APP sources?" --yesno "$(crunch "Would you \ + like to keep the $APP sources in the cache directory $SRCDIR? \ + Select YES to keep or NO to delete.")" 8 40 if [ $? = 1 ]; then check_root if [ $ROOT = "false" ]; then - dialog --title "ERROR" --msgbox "Sorry, only the \ -root user can delete the sources in the cache directory." 8 30 + dialog --title "ERROR" --msgbox "$(crunch "Sorry, only the \ + root user can delete the sources in the cache \ + directory.")" 8 30 else for i in $(cat $TMP/sbopkg_app_sources); do rm -f $SRCDIR/$i done - dialog --title "Done" --msgbox "The $APP \ -sources have been cleared." 8 30 + dialog --title "Done" --msgbox \ + "The $APP sources have been cleared." 8 30 fi else continue fi -else - dialog --title "ERROR" --msgbox "It appears there are no \ -$APP sources in the cache directory." 8 30 -fi + else + dialog --title "ERROR" --msgbox "$(crunch "It appears there are no \ + $APP sources in the cache directory.")" 8 30 + fi } add_options () { -# Adds pre-build options to SlackBuild -OPTIONPKG=$1 -OPTIONFILE=$LOCALREPO/$SLACKVER/$CATEGORY/$APP/options.sbopkg -if [ ! -e $OPTIONFILE ]; then - CUROPTIONS="" -else - CUROPTIONS=$(cat $OPTIONFILE) -fi -dialog --cancel-label "Clear Options" --inputbox "Some SlackBuild \ -scripts offer the ability to pass \ -variables, or options, or flavors to the SlackBuild scripts before \ -they are run. This is often noted in the README or the SlackBuild \ -script itself.\n\nIf you would like to set \ -or edit these variables for the $1 SlackBuild, please enter that \ -information below, or press to clear the options." \ -0 0 $CUROPTIONS 2>/$TMP/sbopkg_add_options -CHOICE=$? -CUSTOMOPTS="$(cat $TMP/sbopkg_add_options)" -if [ $CHOICE = 1 ] || [ $CHOICE = 0 -a "$CUSTOMOPTS" = "" ]; then - rm -f $OPTIONFILE - continue -elif [ $CHOICE = 0 ]; then - cp $TMP/sbopkg_add_options $OPTIONFILE -fi + # Adds pre-build options to SlackBuild + OPTIONPKG=$1 + OPTIONFILE=$LOCALREPO/$SLACKVER/$CATEGORY/$APP/options.sbopkg + if [ ! -e $OPTIONFILE ]; then + CUROPTIONS="" + else + CUROPTIONS=$(cat $OPTIONFILE) + fi + dialog --cancel-label "Clear Options" --inputbox \ + "$(crunch "Some SlackBuild scripts offer the ability to pass \ + variables, or options, or flavors to the SlackBuild scripts before \ + they are run. This is often noted in the README or the SlackBuild \ + script itself.\n\nIf you would like to set \ + or edit these variables for the $1 SlackBuild, please enter that \ + information below, or press to clear the options.")" \ + 0 0 $CUROPTIONS 2>/$TMP/sbopkg_add_options + CHOICE=$? + CUSTOMOPTS="$(cat $TMP/sbopkg_add_options)" + if [ $CHOICE = 1 ] || [ $CHOICE = 0 -a "$CUSTOMOPTS" = "" ]; then + rm -f $OPTIONFILE + continue + elif [ $CHOICE = 0 ]; then + cp $TMP/sbopkg_add_options $OPTIONFILE + fi } install_package () { -# Install the package. -INSTPKG=$1 -if [ "$INSTALLPKGS" = "1" ]; then - upgradepkg --reinstall --install-new $OUTPUT/* -else - upgradepkg --reinstall --install-new $OUTPUT/$INSTPKG - echo "Done upgrading/installing package." -fi + # Install the package. + INSTPKG=$1 + if [ "$INSTALLPKGS" = "1" ]; then + upgradepkg --reinstall --install-new $OUTPUT/* + else + upgradepkg --reinstall --install-new $OUTPUT/$INSTPKG + echo "Done upgrading/installing package." + fi } checksum_fail () { -# Offer to remove source if MD5SUM check fails. -RMSRC=$1 -echo -echo "Would you like to delete the downloaded $PKG source: " -echo "$RMSRC in $SRCDIR?" -echo -echo "Press (Y)es to delete or (N)o to continue." -read ANS + # Offer to remove source if MD5SUM check fails. + RMSRC=$1 + echo + echo "Would you like to delete the downloaded $PKG source: " + echo "$RMSRC in $SRCDIR?" + echo + echo "Press (Y)es to delete or (N)o to continue." + read ANS case $ANS in y* | Y* ) rm -f $SRCDIR/$RMSRC ; echo "Source deleted." ;; @@ -1335,848 +1376,862 @@ read ANS } build_package () { -MD5CHK="" -MD5SUM="" -# Start fetching and building the package. -echo ; echo "Building $PKG" -OLDOUTPUT=$OUTPUT -NEWOUTPUT=$TMP/sbooutput -if [ ! -d "$NEWOUTPUT" ]; then - mkdir -p $NEWOUTPUT -fi -SUMMARYLOG=$TMP/sbopkg_summary -OUTPUT=$NEWOUTPUT -cd $LOCALREPO/$SLACKVER/$PKGPATH -. $PKG.info.build -PKGNAME=${PKG##*/} -SRCNAME=${DOWNLOAD##*/} -SRCNAME=$(echo $SRCNAME | sed -e 's/\%2B/\+/g') # TiMidity fix for '+' -if [ "$PKG" = "django" ]; then - SRCNAME="Django-$VERSION.tar.gz" -fi -get_source $PKG -echo "Checking MD5SUM for "$SRCNAME"..." -MD5CHK=$(md5sum $SRCNAME | cut -d' ' -f1) -if [ "$MD5CHK" == $MD5SUM ]; then - echo "OK" -else - echo "MD5SUM check failed." - echo "$PKG:" >> $SUMMARYLOG - echo "MD5SUM check failed." >> $SUMMARYLOG - echo >> $SUMMARYLOG - checksum_fail $SRCNAME + MD5CHK="" + MD5SUM="" + # Start fetching and building the package. + echo ; echo "Building $PKG" + OLDOUTPUT=$OUTPUT + NEWOUTPUT=$TMP/sbooutput + if [ ! -d "$NEWOUTPUT" ]; then + mkdir -p $NEWOUTPUT + fi + SUMMARYLOG=$TMP/sbopkg_summary + OUTPUT=$NEWOUTPUT + cd $LOCALREPO/$SLACKVER/$PKGPATH + . $PKG.info.build + PKGNAME=${PKG##*/} + SRCNAME=${DOWNLOAD##*/} + SRCNAME=$(echo $SRCNAME | sed -e 's/\%2B/\+/g') # TiMidity fix for '+' + if [ "$PKG" = "django" ]; then + SRCNAME="Django-$VERSION.tar.gz" + fi + get_source $PKG + echo "Checking MD5SUM for "$SRCNAME"..." + MD5CHK=$(md5sum $SRCNAME | cut -d' ' -f1) + if [ "$MD5CHK" == $MD5SUM ]; then + echo "OK" + else + echo "MD5SUM check failed." + echo "$PKG:" >> $SUMMARYLOG + echo "MD5SUM check failed." >> $SUMMARYLOG + echo >> $SUMMARYLOG + checksum_fail $SRCNAME + rm $SRCNAME + rm -f $PKG.info.build + rm -f $PKG.SlackBuild.build + cd $LOCALREPO/$SLACKVER + if [ "$BUILDPKGS" = 1 ]; then + echo + echo "Would you like to continue processing the rest of the" + echo "build queue or would you like to abort? If this failed" + echo "package is a dependency of another package in the queue" + echo "then it may not make sense to continue." + echo + echo "Press (Y)es to continue or (N)o to abort." + read ANS + case $ANS in + y* | Y* ) continue + ;; + n* | N* ) rm -f $TMP/sbopkg_build.lck && return + ;; + * ) echo "Unknown response." + ;; + esac + fi + continue + fi + echo "Building Slackware package for $PKG..." + export $BUILDOPTIONS + sh $PKG.SlackBuild.build + cd $OUTPUT + if [ ! -e *.tgz ]; then + echo "$PKG:" >> $SUMMARYLOG + echo "Error occurred with build. Please check the log." \ + >> $SUMMARYLOG + echo >> $SUMMARYLOG + if [ "$BUILDPKGS" = 1 ]; then + echo + echo "Would you like to continue processing the rest of the" + echo "build queue or would you like to abort? If this failed" + echo "package is a dependency of another package in the queue" + echo "then it may not make sense to continue." + echo + echo "Press (Y)es to continue or (N)o to abort." + read ANS + case $ANS in + y* | Y* ) continue + ;; + n* | N* ) rm -f $TMP/sbopkg_build.lck && return + ;; + * ) echo "Unknown response." + ;; + esac + fi + else + echo "Done building package for $PKG." + NEWPACKAGE=$(ls -1 *.tgz) + echo "$PKG:" >> $SUMMARYLOG + echo "Built package: $NEWPACKAGE" >> $SUMMARYLOG + echo "Built package: $NEWPACKAGE" + if [ "$INSTALLPKGS" = "1" ]; then + install_package $SRCNAME + echo "Done installing/upgrading package for $PKG." + echo "Installed package: $NEWPACKAGE" >> $SUMMARYLOG + fi + mv $OUTPUT/* $OLDOUTPUT/ + echo >> $SUMMARYLOG + fi + cd - >/dev/null rm $SRCNAME rm -f $PKG.info.build rm -f $PKG.SlackBuild.build + OUTPUT=$OLDOUTPUT cd $LOCALREPO/$SLACKVER - if [ "$BUILDPKGS" = 1 ]; then - echo - echo "Would you like to continue processing the rest of the" - echo "build queue or would you like to abort? If this failed" - echo "package is a dependency of another package in the queue" - echo "then it may not make sense to continue." - echo - echo "Press (Y)es to continue or (N)o to abort." - read ANS - case $ANS in - y* | Y* ) continue - ;; - n* | N* ) rm -f $TMP/sbopkg_build.lck && return - ;; - * ) echo "Unknown response." - ;; - esac - fi - continue -fi -echo "Building Slackware package for $PKG..." -export $BUILDOPTIONS -sh $PKG.SlackBuild.build -cd $OUTPUT -if [ ! -e *.tgz ]; then - echo "$PKG:" >> $SUMMARYLOG - echo "Error occurred with build. Please check the log." \ - >> $SUMMARYLOG - echo >> $SUMMARYLOG - if [ "$BUILDPKGS" = 1 ]; then - echo - echo "Would you like to continue processing the rest of the" - echo "build queue or would you like to abort? If this failed" - echo "package is a dependency of another package in the queue" - echo "then it may not make sense to continue." - echo - echo "Press (Y)es to continue or (N)o to abort." - read ANS - case $ANS in - y* | Y* ) continue - ;; - n* | N* ) rm -f $TMP/sbopkg_build.lck && return - ;; - * ) echo "Unknown response." - ;; - esac - fi -else - echo "Done building package for $PKG." - NEWPACKAGE=$(ls -1 *.tgz) - echo "$PKG:" >> $SUMMARYLOG - echo "Built package: $NEWPACKAGE" >> $SUMMARYLOG - echo "Built package: $NEWPACKAGE" - if [ "$INSTALLPKGS" = "1" ]; then - install_package $SRCNAME - echo "Done installing/upgrading package for $PKG." - echo "Installed package: $NEWPACKAGE" >> $SUMMARYLOG - fi - mv $OUTPUT/* $OLDOUTPUT/ - echo >> $SUMMARYLOG -fi -cd - >/dev/null -rm $SRCNAME -rm -f $PKG.info.build -rm -f $PKG.SlackBuild.build -OUTPUT=$OLDOUTPUT -cd $LOCALREPO/$SLACKVER } edit_local_slackbuild () { -# This function allows the user to create and edit a local copy of the -# SlackBuild. -check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP -if [ "$WRITE" = "false" ]; then - dialog --title "ERROR" --msgbox "You do not have write \ -permissions on the target directory." 8 30 - continue -fi -if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg ]; then - cp $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild \ - $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg -fi -${EDITOR:-vi} $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg + # This function allows the user to create and edit a local copy of the + # SlackBuild. + local SHORTPATH=$LOCALREPO/$SLACKVER/$CATEGORY/$APP + check_write $SHORTPATH + if [ "$WRITE" = "false" ]; then + dialog --title "ERROR" --msgbox "You do not have write \ + permissions on the target directory." 8 30 + continue + fi + if [ ! -e $SHORTPATH/$APP.SlackBuild.sbopkg ]; then + cp $SHORTPATH/$APP.SlackBuild $SHORTPATH/$APP.SlackBuild.sbopkg + fi + ${EDITOR:-vi} $SHORTPATH/$APP.SlackBuild.sbopkg } delete_local_slackbuild () { -# This function allows the user to delete the local SlackBuild. -check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP -if [ "$WRITE" = "false" ]; then - dialog --title "ERROR" --msgbox "You do not have write \ -permissions on the target directory." 8 30 - continue -fi -if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg ]; then - dialog --title "ERROR" --msgbox "There is no local copy of the \ -SlackBuild to delete." 8 30 - continue -else - rm $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.SlackBuild.sbopkg - dialog --title "DONE" --msgbox "The local copy of the SlackBuild \ -has been deleted." 8 30 -fi + # This function allows the user to delete the local SlackBuild. + local SHORTPATH=$LOCALREPO/$SLACKVER/$CATEGORY/$APP + check_write $SHORTPATH + if [ "$WRITE" = "false" ]; then + dialog --title "ERROR" --msgbox \ + "You do not have write permissions on the target directory." 8 30 + continue + fi + if [ ! -e $SHORTPATH/$APP.SlackBuild.sbopkg ]; then + dialog --title "ERROR" --msgbox \ + "There is no local copy of the SlackBuild to delete." 8 30 + continue + else + rm $SHORTPATH/$APP.SlackBuild.sbopkg + dialog --title "DONE" --msgbox \ + "The local copy of the SlackBuild has been deleted." 8 30 + fi } pick_slackbuild () { -# This function checks to see if there is a locally-edited -# SlackBuild (which has the *.sbopkg" suffix) and then asks the -# user which one he wants to use to build a package. -SLACKBUILD="" -if [ ! -e $PKGPATH/$PKGNAME.SlackBuild.sbopkg ]; then - SLACKBUILD="original" -else - if [ "$DIAG" = 1 ]; then - while [ 0 ]; do - dialog --title "Choose $PKG SlackBuild" --menu "A local \ -SlackBuild for $PKG was found in addition to the original \ -SlackBuild. Which one would you like to use?" 10 60 2 \ -"Original" "Use the original SlackBuild" \ -"Local" "Use the local SlackBuild" 2>$TMP/sbopkg_bld_selection - if [ $? = 1 ]; then - # Need this to get back to $APP info menu - SLACKBUILD="cancel" - rm -f $PKGPATH/$PKGNAME*.build - QUITBUILD=1 - return 0 - fi - B="$(cat $TMP/sbopkg_bld_selection)" - if [ "$B" = "Original" ]; then - SLACKBUILD="original" - break - fi - if [ "$B" = "Local" ]; then - SLACKBUILD="local" - break - fi - done + # This function checks to see if there is a locally-edited + # SlackBuild (which has the *.sbopkg" suffix) and then asks the + # user which one he wants to use to build a package. + SLACKBUILD="" + if [ ! -e $PKGPATH/$PKGNAME.SlackBuild.sbopkg ]; then + SLACKBUILD="original" else - while true; do - echo "A local SlackBuild for $PKGNAME was found in \ -addition to the original SlackBuild." - echo "Which one would you like to use?" - echo "Please enter 'O' for original, 'L' for local, or 'C' to cancel." - read ANS - case $ANS in - o* | O* ) SLACKBUILD="original" ; break - ;; - l* | L* ) SLACKBUILD="local" ; break - ;; - c* | C* ) SLACKBUILD="cancel" ; cleanup; exit 0 - ;; - * ) echo "Unknown response." - ;; - esac - done - echo + if [ "$DIAG" = 1 ]; then + while [ 0 ]; do + dialog --title "Choose $PKG SlackBuild" --menu \ + "$(crunch "A local SlackBuild for $PKG was found in \ + addition to the original SlackBuild. Which one would \ + you like to use?")" 10 60 2 \ + "Original" "Use the original SlackBuild" \ + "Local" "Use the local SlackBuild" 2> \ + $TMP/sbopkg_bld_selection + if [ $? = 1 ]; then + # Need this to get back to $APP info menu + SLACKBUILD="cancel" + rm -f $PKGPATH/$PKGNAME*.build + QUITBUILD=1 + return 0 + fi + B="$(cat $TMP/sbopkg_bld_selection)" + if [ "$B" = "Original" ]; then + SLACKBUILD="original" + break + fi + if [ "$B" = "Local" ]; then + SLACKBUILD="local" + break + fi + done + else + while true; do + crunch_fmt "A local SlackBuild for $PKGNAME was found in \ + addition to the original SlackBuild." + echo "Which one would you like to use?" + crunch_fmt "Please enter 'O' for original, 'L' for local, \ + or 'C' to cancel." + read ANS + case $ANS in + o* | O* ) SLACKBUILD="original" ; break + ;; + l* | L* ) SLACKBUILD="local" ; break + ;; + c* | C* ) SLACKBUILD="cancel" ; cleanup; exit 0 + ;; + * ) echo "Unknown response." + ;; + esac + done + echo + fi + fi + if [ "$SLACKBUILD" = "original" ]; then + cp $PKGPATH/$PKG.SlackBuild $PKGPATH/$PKG.SlackBuild.build + elif [ "$SLACKBUILD" = "local" ]; then + cp $PKGPATH/$PKG.SlackBuild.sbopkg $PKGPATH/$PKG.SlackBuild.build fi -fi -if [ "$SLACKBUILD" = "original" ]; then - cp $PKGPATH/$PKG.SlackBuild $PKGPATH/$PKG.SlackBuild.build -elif [ "$SLACKBUILD" = "local" ]; then - cp $PKGPATH/$PKG.SlackBuild.sbopkg $PKGPATH/$PKG.SlackBuild.build -fi } edit_local_info () { -# This function allows the user to create and edit a local copy of the -# .info file. -check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP -if [ "$WRITE" = "false" ]; then - dialog --title "ERROR" --msgbox "You do not have write \ -permissions on the target directory." 8 30 - continue -fi -if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg ]; then - cp $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info \ - $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg -fi -${EDITOR:-vi} $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg + # This function allows the user to create and edit a local copy of the + # .info file. + check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP + if [ "$WRITE" = "false" ]; then + dialog --title "ERROR" --msgbox "You do not have write \ + permissions on the target directory." 8 30 + continue + fi + if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg ]; then + cp $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info \ + $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg + fi + ${EDITOR:-vi} $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg } delete_local_info () { -# This function allows the user to delete the local .info file. -check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP -if [ "$WRITE" = "false" ]; then - dialog --title "ERROR" --msgbox "You do not have write \ -permissions on the target directory." 8 30 - continue -fi -if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg ]; then - dialog --title "ERROR" --msgbox "There is no local copy of the \ -.info file to delete." 8 30 - continue -else - rm $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg - dialog --title "DONE" --msgbox "The local copy of the .info file \ -has been deleted." 8 30 -fi + # This function allows the user to delete the local .info file. + check_write $LOCALREPO/$SLACKVER/$CATEGORY/$APP + if [ "$WRITE" = "false" ]; then + dialog --title "ERROR" --msgbox \ + "You do not have write permissions on the target directory." 8 30 + continue + fi + if [ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg ]; then + dialog --title "ERROR" --msgbox \ + "There is no local copy of the .info file to delete." 8 30 + continue + else + rm $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg + dialog --title "DONE" --msgbox \ + "The local copy of the .info file has been deleted." 8 30 + fi } pick_info () { -# This function checks to see if there is a locally-edited -# .info file (which has the *.sbopkg" suffix) and then asks the -# user which one he wants to use to build a package. -DOTINFO="" -if [ ! -e $PKGPATH/$PKG.info.sbopkg ]; then - DOTINFO="original" -else - if [ "$DIAG" = 1 ]; then - while [ 0 ]; do - dialog --title "Choose $PKG .info file" --menu "A local \ -.info file for $PKG was found in addition to the original .info file. \ -Which one would you like to use?" 10 60 2 \ -"Original" "Use the original .info" \ -"Local" "Use the local .info" 2>$TMP/sbopkg_info_selection - if [ $? != 0 ]; then - rm -f $PKGPATH/$PKGNAME*.build - QUITBUILD=1 - return 0 - fi - I="$(cat $TMP/sbopkg_info_selection)" - if [ "$I" = "Original" ]; then - DOTINFO="original" - break - fi - if [ "$I" = "Local" ]; then - DOTINFO="local" - break - fi - done + # This function checks to see if there is a locally-edited + # .info file (which has the *.sbopkg" suffix) and then asks the + # user which one he wants to use to build a package. + DOTINFO="" + if [ ! -e $PKGPATH/$PKG.info.sbopkg ]; then + DOTINFO="original" else - while true; do - echo "A local .info file for $PKG was found in \ -addition to the original .info file." - echo "Which one would you like to use?" - echo "Please enter 'O' for original, 'L' for local, or 'C' to cancel." - read ANS - case $ANS in - o* | O* ) DOTINFO="original" ; break - ;; - l* | L* ) DOTINFO="local" ; break - ;; - c* | C* ) DOTINFO="cancel" ; cleanup; exit 0 - ;; - * ) echo "Unknown response." - ;; - esac - done - echo + if [ "$DIAG" = 1 ]; then + while [ 0 ]; do + dialog --title "Choose $PKG .info file" --menu \ + "$(crunch "A local .info file for $PKG was found in \ + addition to the original .info file. Which one would you \ + like to use?")" 10 60 2 \ + "Original" "Use the original .info" \ + "Local" "Use the local .info" 2>$TMP/sbopkg_info_selection + if [ $? != 0 ]; then + rm -f $PKGPATH/$PKGNAME*.build + QUITBUILD=1 + return 0 + fi + I="$(cat $TMP/sbopkg_info_selection)" + if [ "$I" = "Original" ]; then + DOTINFO="original" + break + fi + if [ "$I" = "Local" ]; then + DOTINFO="local" + break + fi + done + else + while true; do + crunch_fmt "A local .info file for $PKG was found in \ + addition to the original .info file." + echo "Which one would you like to use?" + crunch_fmt "Please enter 'O' for original, 'L' for local, \ + or 'C' to cancel." + read ANS + case $ANS in + o* | O* ) DOTINFO="original" ; break + ;; + l* | L* ) DOTINFO="local" ; break + ;; + c* | C* ) DOTINFO="cancel" ; cleanup; exit 0 + ;; + * ) echo "Unknown response." + ;; + esac + done + echo + fi fi -fi -if [ "$DOTINFO" = "original" ]; then - cp $PKGPATH/$PKG.info $PKGPATH/$PKG.info.build -elif [ "$DOTINFO" = "local" ]; then - cp $PKGPATH/$PKG.info.sbopkg $PKGPATH/$PKG.info.build -fi -. $PKGPATH/$PKG.info.build -PKGNAME=${PKG##*/} + if [ "$DOTINFO" = "original" ]; then + cp $PKGPATH/$PKG.info $PKGPATH/$PKG.info.build + elif [ "$DOTINFO" = "local" ]; then + cp $PKGPATH/$PKG.info.sbopkg $PKGPATH/$PKG.info.build + fi + . $PKGPATH/$PKG.info.build + PKGNAME=${PKG##*/} } use_options () { -OPTAPP=$1 -# Ask if user wants to use options.sbopkg if found -if [ ! -e $PKGPATH/options.sbopkg ]; then - BUILDOPTIONS="" -else - TMPOPTIONS=$(cat $PKGPATH/options.sbopkg) - if [ "$DIAG" = 1 ]; then - dialog --title "Use Options for $OPTAPP" --yesno "Custom \ -options for \ -the $OPTAPP SlackBuild were found:\n\n$TMPOPTIONS\n\nWould you like to \ -use these options for this build?" 12 50 - if [ $? = 0 ]; then - BUILDOPTIONS=$TMPOPTIONS - else - BUILDOPTIONS="" - fi + OPTAPP=$1 + # Ask if user wants to use options.sbopkg if found + if [ ! -e $PKGPATH/options.sbopkg ]; then + BUILDOPTIONS="" else - while true; do - echo "Custom options for the $OPTAPP SlackBuild" - echo "script were found:" + TMPOPTIONS=$(cat $PKGPATH/options.sbopkg) + if [ "$DIAG" = 1 ]; then + dialog --title "Use Options for $OPTAPP" --yesno \ + "$(crunch "Custom options for the $OPTAPP SlackBuild were \ + found:\n\n$TMPOPTIONS\n\nWould you like to use these options \ + for this build?")" 12 50 + if [ $? = 0 ]; then + BUILDOPTIONS=$TMPOPTIONS + else + BUILDOPTIONS="" + fi + else + while true; do + echo "Custom options for the $OPTAPP SlackBuild" + echo "script were found:" + echo + echo $TMPOPTIONS + echo + echo "Would you like to use these options for this" + echo "build? Press (Y)es to use these options or" + echo "(N)o to skip them." + echo + read ANS + case $ANS in + y* | Y* ) BUILDOPTIONS=$TMPOPTIONS + ;; + n* | N* ) BUILDOPTIONS="" + ;; + * ) echo "Unknown response." + ;; + esac + done echo - echo $TMPOPTIONS - echo - echo "Would you like to use these options for this" - echo "build? Press (Y)es to use these options or" - echo "(N)o to skip them." - echo - read ANS - case $ANS in - y* | Y* ) BUILDOPTIONS=$TMPOPTIONS - ;; - n* | N* ) BUILDOPTIONS="" - ;; - * ) echo "Unknown response." - ;; - esac - done - echo + fi fi -fi } process_queue () { -# Iterate throught the process queue to build, and optionally -# install, the selected packages. -SBOPKGOUTPUT=$TMP/sbopkg_output -SBOPKGTMPOUTPUT=$TMP/sbopkg_tmpoutput -STARTQUEUE=$TMP/sbopkg-start-queue -FINALQUEUE=$TMP/sbopkg-final-queue -PRECHECKLOG=$TMP/sbopkg_precheck_log -SUMMARYLOG=$TMP/sbopkg_summary -QUITBUILD="" -rm -f $SBOPKGTMPOUTPUT $FINALQUEUE $PRECHECKLOG $SUMMARYLOG -check_root -if [ $ROOT = "false" ]; then - if [ "$DIAG" = 1 ]; then - dialog --title "ERROR" --msgbox "You must run this script \ -as the root user in order to build packages." 8 30 - rm -f $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG - continue - else - echo "You must run this script as the root user in order \ -to build packages." - cleanup - exit 0 - fi -fi -if [[ "$DIAG" = 1 && "$BUILDPKGS" = 1 ]]; then - view_queue -fi -if [ "$DIAG" = 1 ]; then - dialog --title "Install Package(s)" --yes-label "Build" \ ---no-label "Build and Install" --yesno "Would you like to build the \ -package(s) only, or build and install the package(s)? (Press \ -ESC to exit)." 8 50 - V=$? - if [ $V = 255 ]; then - return 0 - fi - if [ $V = 1 ]; then - INSTALLPKGS=1 - fi -fi -touch $SUMMARYLOG -echo >> $SUMMARYLOG -echo "******************************************" >> $SUMMARYLOG -echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG -echo "Using SlackBuilds.org $SLACKVER repository" >> $SUMMARYLOG -echo >> $SUMMARYLOG -if [ "$BUILDPKGS" = 1 ]; then - touch $PRECHECKLOG - echo >> $PRECHECKLOG - echo "******************************************" >> $PRECHECKLOG - echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG - echo "Using SlackBuilds.org $SLACKVER repository" >> $PRECHECKLOG - echo >> $PRECHECKLOG - if [ "$DIAG" = 1 ]; then - dialog --title "Pre-Check" --msgbox "Checking for valid \ -package names and processing local .info and .SlackBuild \ -edits." 8 30 - else - echo "Checking for valid package names and processing" - echo "local .info and .SlackBuild edits..." - echo - fi - for CHKBUILD in $(cat $STARTQUEUE); do - PKG="" - search_package $CHKBUILD - pick_info $CHKBUILD - if [ "$QUITBUILD" = 1 ]; then - return 0 - fi - pick_slackbuild - if [ "$QUITBUILD" = 1 ]; then - return 0 - fi - use_options $CHKBUILD - echo $PKGNAME >> $FINALQUEUE - echo "$PKGNAME Found" >> $PRECHECKLOG - echo "Name: $PKGNAME" >> $PRECHECKLOG - echo "Version: $VERSION" >> $PRECHECKLOG - if [ "$BUILDOPTIONS" = "" ]; then - echo "Options: None" >> $PRECHECKLOG - else - echo "Options: $BUILDOPTIONS" >> $PRECHECKLOG - fi - echo >> $PRECHECKLOG - done - echo "******************************************" >> $PRECHECKLOG - if [ "$DIAG" = 1 ]; then - dialog --title "Pre-Check Log" --textbox $PRECHECKLOG 0 0 - dialog --title "Begin?" --yes-label "Ok" --no-label "Cancel" \ ---yesno "The build queue is ready to process. Press to \ -continue or to return to the main menu." 8 40 - if [ $? != 0 ]; then + # Iterate throught the process queue to build, and optionally + # install, the selected packages. + SBOPKGOUTPUT=$TMP/sbopkg_output + SBOPKGTMPOUTPUT=$TMP/sbopkg_tmpoutput + STARTQUEUE=$TMP/sbopkg-start-queue + FINALQUEUE=$TMP/sbopkg-final-queue + PRECHECKLOG=$TMP/sbopkg_precheck_log + SUMMARYLOG=$TMP/sbopkg_summary + QUITBUILD="" + rm -f $SBOPKGTMPOUTPUT $FINALQUEUE $PRECHECKLOG $SUMMARYLOG + check_root + if [ $ROOT = "false" ]; then + if [ "$DIAG" = 1 ]; then + dialog --title "ERROR" --msgbox "$(crunch "You must run this \ + script as the root user in order to build packages.")" 8 30 rm -f $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG continue + else + crunch_fmt "You must run this script as the root user in order \ + to build packages." + cleanup + exit 0 + fi + fi + if [[ "$DIAG" = 1 && "$BUILDPKGS" = 1 ]]; then + view_queue + fi + if [ "$DIAG" = 1 ]; then + dialog --title "Install Package(s)" --yes-label "Build" \ + --no-label "Build and Install" --yesno \ + "$(crunch "Would you like to build the package(s) only, or \ + build and install the package(s)? (Press ESC to exit).")" 8 50 + V=$? + if [ $V = 255 ]; then + return 0 + fi + if [ $V = 1 ]; then + INSTALLPKGS=1 + fi + fi + touch $SUMMARYLOG + echo >> $SUMMARYLOG + echo "******************************************" >> $SUMMARYLOG + echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG + echo "Using SlackBuilds.org $SLACKVER repository" >> $SUMMARYLOG + echo >> $SUMMARYLOG + if [ "$BUILDPKGS" = 1 ]; then + touch $PRECHECKLOG + echo >> $PRECHECKLOG + echo "******************************************" >> $PRECHECKLOG + echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG + echo "Using SlackBuilds.org $SLACKVER repository" >> $PRECHECKLOG + echo >> $PRECHECKLOG + if [ "$DIAG" = 1 ]; then + dialog --title "Pre-Check" --msgbox "$(crunch "Checking for \ + valid package names and processing local .info and \ + .SlackBuild edits.")" 8 30 + else + echo "Checking for valid package names and processing" + echo "local .info and .SlackBuild edits..." + echo + fi + for CHKBUILD in $(cat $STARTQUEUE); do + PKG="" + search_package $CHKBUILD + pick_info $CHKBUILD + if [ "$QUITBUILD" = 1 ]; then + return 0 + fi + pick_slackbuild + if [ "$QUITBUILD" = 1 ]; then + return 0 + fi + use_options $CHKBUILD + echo $PKGNAME >> $FINALQUEUE + echo "$PKGNAME Found" >> $PRECHECKLOG + echo "Name: $PKGNAME" >> $PRECHECKLOG + echo "Version: $VERSION" >> $PRECHECKLOG + if [ "$BUILDOPTIONS" = "" ]; then + echo "Options: None" >> $PRECHECKLOG + else + echo "Options: $BUILDOPTIONS" >> $PRECHECKLOG + fi + echo >> $PRECHECKLOG + done + echo "******************************************" >> $PRECHECKLOG + if [ "$DIAG" = 1 ]; then + dialog --title "Pre-Check Log" --textbox $PRECHECKLOG 0 0 + dialog --title "Begin?" --yes-label "Ok" --no-label "Cancel" \ + --yesno "$(crunch "The build queue is ready to process. \ + Press to continue or to return to the main \ + menu.")" 8 40 + if [ $? != 0 ]; then + rm -f $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG + continue + fi + else + while true; do + cat $PRECHECKLOG + echo + echo "Pre-check complete." + echo + echo "Do you wish to proceed based on the search results above?" + echo "Packages not found will be skipped during the process." + echo + echo "Press (Y)es to proceed or (N)o to quit." + read ANS + case $ANS in + y* | Y* ) break + ;; + n* | N* ) cleanup; exit 0 + ;; + * ) echo "Unknown response." + ;; + esac + done + echo fi else - while true; do - cat $PRECHECKLOG - echo - echo "Pre-check complete." - echo - echo "Do you wish to proceed based on the search results above?" - echo "Packages not found will be skipped during the process." - echo - echo "Press (Y)es to proceed or (N)o to quit." + for CHKBUILD in $(cat $STARTQUEUE); do + search_package $CHKBUILD + pick_info $CHKBUILD + if [ "$QUITBUILD" = 1 ]; then + return 0 + fi + pick_slackbuild + if [ "$QUITBUILD" = 1 ]; then + return 0 + fi + use_options $CHKBUILD + echo $CHKBUILD >> $FINALQUEUE + done + fi + rm -f $TMP/sbopkg_build.lck + touch $TMP/sbopkg_build.lck + for PKGBUILD in $(cat $FINALQUEUE); do + search_package $PKGBUILD + if [ -e $TMP/sbopkg_build.lck ]; then + build_package $PKGBUILD 2>&1 | tee $SBOPKGTMPOUTPUT + cat $SBOPKGTMPOUTPUT >> $SBOPKGOUTPUT + else + echo "$PKG:" >> $SUMMARYLOG + echo "Not processed - build queue aborted." >> $SUMMARYLOG + echo >> $SUMMARYLOG + fi + done + rm -f $TMP/sbopkg_build.lck + echo "******************************************" >> $SUMMARYLOG + cat $SUMMARYLOG + if [ "$DIAG" = 1 ]; then + read -n 1 -p "Press any key to continue." + fi + if [ -e $TMP/sbopkg-tmp-queue ]; then + dialog --title "Clear Queue?" --yes-label "Keep" --no-label \ + "Clear" --yesno "$(crunch "Would you like to keep the build \ + queue or would you like to clear it?")" 8 35 + if [ $? = 1 ]; then + rm -f $TMP/sbopkg-tmp-queue + dialog --title "Done" --msgbox \ + "The build queue has been cleared." 8 35 + fi + fi + if [ "$KEEPLOG" = "YES" ]; then + cat $SBOPKGOUTPUT >> $TMP/sbopkg-build-log + cat $SUMMARYLOG >> $TMP/sbopkg-build-log + fi + BUILDPKGS="" + INSTALLPKGS="" + rm -f $SBOPKGOUTPUT $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG +} + +check_for_latest () { + # Check for an update to sbopkg. This code is borrowed with + # permission from the superb mirror-slackware-current.sh + # by Eric Hameleers which you can find at + # http://www.slackware.com/~alien. Thanks, Eric! + ORIGSCR=http://www.sbopkg.org/version.php + CVRS=$SBOVER + NVRS=$(wget -T 10 -q -O - ${ORIGSCR}) + SBOPKGUP="" + NEWPKG=http://www.sbopkg.org/pkg.php + NEWSBOPKG=$(wget -T 10 -q -O - ${NEWPKG}) + NEWDLPKG=http://sbopkg.googlecode.com/files/$NEWSBOPKG + if [ -z "$CVRS" -o -z "$NVRS" ]; then + if [ -z "$NVRS" ]; then + MSG="$(crunch "Cannot determine if there is an update \ + since the remote version cannot be retrieved. \ + Please try again later.")" + fi + elif [ "$CVRS" != "$NVRS" ]; then + if $(echo $CVRS | grep -q "svn_r"); then + MSG="$(crunch "You are running sbopkg from SVN and not using \ + a regular package. Therefore, package versions cannot be \ + compared.")" + else + SBOPKGUP=1 + if [ "$DIAG" = 1 ]; then + MSG="$(crunch "Different versions reported. Press to \ + continue.")" + else + MSG="$(crunch "Different versions reported. Press (Y)es to \ + download the update package or press (N)o to quit.")" + fi + fi + elif [ "$CVRS" == "$NVRS" ]; then + MSG="It appears your version of sbopkg is up to date." + fi + if [ "$DIAG" = 1 ]; then + dialog --title "Done" --msgbox "$(crunch "Checking \ + http://www.sbopkg.org for an update...\n\nYour version of \ + sbopkg: $CVRS\n\nLatest version of sbopkg found on \ + sbopkg.org: $NVRS\n\n$MSG")" 16 40 + if [ $? != 0 ]; then + return 0 + fi + if [ "$SBOPKGUP" = 1 ]; then + NEWPKG=http://www.sbopkg.org/pkg.php + NEWSBOPKG=$(wget -T 10 -q -O - ${NEWPKG}) + NEWDLPKG=http://sbopkg.googlecode.com/files/$NEWSBOPKG + dialog --title "Download new package?" --yesno "$(crunch "Would \ + you like to download the new sbopkg \ + package:\n\n$NEWSBOPKG\n\nThe new sbopkg package will saved \ + to your OUTPUT directory: $OUTPUT")" 13 50 + W=$? + if [ $W = 1 ]; then + return 0 + fi + fi + else + echo + echo "Checking http://www.sbopkg.org for an update..." + echo + echo "Your version of sbopkg: "$CVRS + echo + echo "Latest version of sbopkg found on sbopkg.org: "$NVRS + echo + echo $MSG + if [ "$SBOPKGUP" = 1 ]; then read ANS case $ANS in - y* | Y* ) break + y* | Y* ) continue ;; n* | N* ) cleanup; exit 0 ;; * ) echo "Unknown response." ;; esac - done + fi + fi + if [ "$SBOPKGUP" = 1 ]; then + cd $OUTPUT + wget $WGETFLAGS $NEWDLPKG + cd $CWD + echo "######################################################" + echo "Download complete. The downloaded file is located at:" + echo + echo "$TMP/$NEWSBOPKG" + echo + echo "You can now quit sbopkg and upgrade sbopkg manually." + echo + echo "Once you have upgraded sbopkg, please be sure to check the" + echo "/etc/sbopkg/sbopkg.conf.new file for any changes that may" + crunch_fmt "need to be merged into your existing \ + /etc/sbopkg/sbopkg.conf file." + echo + echo "You can also view a complete ChangeLog.txt in the" + echo "/usr/share/doc/sbopkg-$NVRS/ directory or online at:" + echo "http://www.sbopkg.org/files/ChangeLog.txt" echo - fi -else - for CHKBUILD in $(cat $STARTQUEUE); do - search_package $CHKBUILD - pick_info $CHKBUILD - if [ "$QUITBUILD" = 1 ]; then - return 0 - fi - pick_slackbuild - if [ "$QUITBUILD" = 1 ]; then - return 0 - fi - use_options $CHKBUILD - echo $CHKBUILD >> $FINALQUEUE - done -fi -rm -f $TMP/sbopkg_build.lck -touch $TMP/sbopkg_build.lck -for PKGBUILD in $(cat $FINALQUEUE); do - search_package $PKGBUILD - if [ -e $TMP/sbopkg_build.lck ]; then - build_package $PKGBUILD 2>&1 | tee $SBOPKGTMPOUTPUT - cat $SBOPKGTMPOUTPUT >> $SBOPKGOUTPUT - else - echo "$PKG:" >> $SUMMARYLOG - echo "Not processed - build queue aborted." >> $SUMMARYLOG - echo >> $SUMMARYLOG - fi -done -rm -f $TMP/sbopkg_build.lck -echo "******************************************" >> $SUMMARYLOG -cat $SUMMARYLOG -if [ "$DIAG" = 1 ]; then - read -n 1 -p "Press any key to continue." -fi -if [ -e $TMP/sbopkg-tmp-queue ]; then - dialog --title "Clear Queue?" --yes-label "Keep" --no-label \ - "Clear" --yesno "Would you like to keep the build queue or \ -would you like to clear it?" 8 35 - if [ $? = 1 ]; then - rm -f $TMP/sbopkg-tmp-queue - dialog --title "Done" --msgbox "The build queue has been \ -cleared." 8 35 - fi -fi -if [ "$KEEPLOG" = "YES" ]; then - cat $SBOPKGOUTPUT >> $TMP/sbopkg-build-log - cat $SUMMARYLOG >> $TMP/sbopkg-build-log -fi -BUILDPKGS="" -INSTALLPKGS="" -rm -f $SBOPKGOUTPUT $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG -} - -check_for_latest () { -# Check for an update to sbopkg. This code is borrowed with -# permission from the superb mirror-slackware-current.sh -# by Eric Hameleers which you can find at -# http://www.slackware.com/~alien. Thanks, Eric! -ORIGSCR=http://www.sbopkg.org/version.php -CVRS=$SBOVER -NVRS=$(wget -T 10 -q -O - ${ORIGSCR}) -SBOPKGUP="" -NEWPKG=http://www.sbopkg.org/pkg.php -NEWSBOPKG=$(wget -T 10 -q -O - ${NEWPKG}) -NEWDLPKG=http://sbopkg.googlecode.com/files/$NEWSBOPKG -if [ -z "$CVRS" -o -z "$NVRS" ]; then - if [ -z "$NVRS" ]; then - MSG="Cannot determine if there is an update \ -since the remote version cannot be retrieved. \ -Please try again later." - fi -elif [ "$CVRS" != "$NVRS" ]; then - if $(echo $CVRS | grep -q "svn_r"); then - MSG="You are running sbopkg from SVN and not using a regular \ -package. Therefore, package versions cannot be compared." - else - SBOPKGUP=1 if [ "$DIAG" = 1 ]; then - MSG="Different versions reported. Press to \ -continue." - else - MSG="Different versions reported. Press (Y)es to \ -download the update package or press (N)o to quit." + read -n 1 -p "Press any key to continue." fi fi -elif [ "$CVRS" == "$NVRS" ]; then - MSG="It appears your version of sbopkg is up to date." -fi -if [ "$DIAG" = 1 ]; then - dialog --title "Done" --msgbox "Checking http://www.sbopkg.org \ -for an update...\n\nYour version of sbopkg: $CVRS\n\nLatest version \ -of sbopkg found on sbopkg.org: $NVRS\n\n$MSG" 16 40 - if [ $? != 0 ]; then - return 0 - fi - if [ "$SBOPKGUP" = 1 ]; then - NEWPKG=http://www.sbopkg.org/pkg.php - NEWSBOPKG=$(wget -T 10 -q -O - ${NEWPKG}) - NEWDLPKG=http://sbopkg.googlecode.com/files/$NEWSBOPKG - dialog --title "Download new package?" --yesno "Would you like to -download the new sbopkg package:\n\n$NEWSBOPKG\n\nThe new sbopkg package -will saved to your OUTPUT directory: $OUTPUT" 13 50 - W=$? - if [ $W = 1 ]; then - return 0 - fi - fi -else - echo - echo "Checking http://www.sbopkg.org for an update..." - echo - echo "Your version of sbopkg: "$CVRS - echo - echo "Latest version of sbopkg found on sbopkg.org: "$NVRS - echo - echo $MSG - if [ "$SBOPKGUP" = 1 ]; then - read ANS - case $ANS in - y* | Y* ) continue - ;; - n* | N* ) cleanup; exit 0 - ;; - * ) echo "Unknown response." - ;; - esac - fi -fi -if [ "$SBOPKGUP" = 1 ]; then - cd $OUTPUT - wget $WGETFLAGS $NEWDLPKG - cd $CWD - echo "######################################################" - echo "Download complete. The downloaded file is located at:" - echo - echo "$TMP/$NEWSBOPKG" - echo - echo "You can now quit sbopkg and upgrade sbopkg manually." - echo - echo "Once you have upgraded sbopkg, please be sure to \ -check the" - echo "/etc/sbopkg/sbopkg.conf.new file for any changes \ -that may" - echo "need to be merged into your existing \ -/etc/sbopkg/sbopkg.conf file." - echo - echo "You can also view a complete ChangeLog.txt in the" - echo "/usr/share/doc/sbopkg-$NVRS/ directory or online at:" - echo "http://www.sbopkg.org/files/ChangeLog.txt" - echo - if [ "$DIAG" = 1 ]; then - read -n 1 -p "Press any key to continue." - fi -fi } queue_menu () { -# Separate menu for queue functions. -if [ -z "$Q" ] ; then Q="View" ; fi -while [ 0 ]; do -dialog --default-item "$Q" --title "Build Queue Menu" --backtitle \ -"Currently using the SlackBuilds.org $SLACKVER repository." \ ---cancel-label "Back" --menu \ -"\nChoose one of the following or press to go back.\n" \ - 15 60 5 \ -"View" "View the build queue" \ -"Clear" "Clear the build queue" \ -"Process" "Process the build queue" \ -"Load" "Load a saved build queue" \ -"Save" "Save a build queue" \ -2>$TMP/sbopkg_queue_menu_answer + # Separate menu for queue functions. + if [ -z "$Q" ]; then + Q="View" + fi + while [ 0 ]; do + dialog --default-item "$Q" --title "Build Queue Menu" --backtitle \ + "Currently using the SlackBuilds.org $SLACKVER repository." \ + --cancel-label "Back" --menu \ + "\nChoose one of the following or press to go back.\n" \ + 15 60 5 \ + "View" "View the build queue" \ + "Clear" "Clear the build queue" \ + "Process" "Process the build queue" \ + "Load" "Load a saved build queue" \ + "Save" "Save a build queue" \ + 2>$TMP/sbopkg_queue_menu_answer -if [ $? != 0 ]; then - Q="" - rm -f $TMP/sbopkg_queue_menu_answer - return -fi + if [ $? != 0 ]; then + Q="" + rm -f $TMP/sbopkg_queue_menu_answer + return + fi -Q="$(cat $TMP/sbopkg_queue_menu_answer)" + Q="$(cat $TMP/sbopkg_queue_menu_answer)" -if [ "$Q" = "View" ]; then - view_queue -fi + if [ "$Q" = "View" ]; then + view_queue + fi -if [ "$Q" = "Clear" ]; then - clear_build_queue -fi + if [ "$Q" = "Clear" ]; then + clear_build_queue + fi -if [ "$Q" = "Process" ]; then - BUILDPKGS=1 - process_queue -fi + if [ "$Q" = "Process" ]; then + BUILDPKGS=1 + process_queue + fi -if [ "$Q" = "Load" ]; then - load_user_queue -fi + if [ "$Q" = "Load" ]; then + load_user_queue + fi -if [ "$Q" = "Save" ]; then - save_user_queue -fi + if [ "$Q" = "Save" ]; then + save_user_queue + fi -#if [ "$Q" = "Delete" ]; then -# delete_backup_queue -#fi - -done + #if [ "$Q" = "Delete" ]; then + # delete_backup_queue + #fi + done } utilities_menu () { -# Separate menu for various utilities. -if [ -z "$G" ] ; then G="Cache" ; fi -while [ 0 ]; do -dialog --default-item "$G" --title "Utilities" --backtitle \ -"Currently using the SlackBuilds.org $SLACKVER repository." \ ---cancel-label "Back" --menu \ -"\nChoose one of the following or press to go back.\n" \ - 15 69 5 \ -"Cache" "View the contents of the cache directory" \ -"Log" "View the permanent build log" \ -"Version" "Select Slackware version (currently: $SLACKVER)" \ -"Latest" "Check for an update to sbopkg" \ -2>$TMP/sbopkg_utilities_menu_answer + # Separate menu for various utilities. + if [ -z "$G" ] ; then G="Cache" ; fi + while [ 0 ]; do + dialog --default-item "$G" --title "Utilities" --backtitle \ + "Currently using the SlackBuilds.org $SLACKVER repository." \ + --cancel-label "Back" --menu \ + "\nChoose one of the following or press to go back.\n" \ + 15 69 5 \ + "Cache" "View the contents of the cache directory" \ + "Log" "View the permanent build log" \ + "Version" "Select Slackware version (currently: $SLACKVER)" \ + "Latest" "Check for an update to sbopkg" \ + 2>$TMP/sbopkg_utilities_menu_answer -if [ $? != 0 ]; then - G="" - rm -f $TMP/sbopkg_utilities_menu_answer - return -fi + if [ $? != 0 ]; then + G="" + rm -f $TMP/sbopkg_utilities_menu_answer + return + fi -G="$(cat $TMP/sbopkg_utilities_menu_answer)" + G="$(cat $TMP/sbopkg_utilities_menu_answer)" -if [ "$G" = "Cache" ]; then - view_cache_dir -fi + if [ "$G" = "Cache" ]; then + view_cache_dir + fi -if [ "$G" = "Log" ]; then - view_perm_log -fi + if [ "$G" = "Log" ]; then + view_perm_log + fi -if [ "$G" = "Version" ]; then - select_version -fi + if [ "$G" = "Version" ]; then + select_version + fi -if [ "$G" = "Latest" ]; then - check_for_latest -fi + if [ "$G" = "Latest" ]; then + check_for_latest + fi -done + done } cleanup () { -# Clean up cruft and remove temporary files. -check_write $TMP -if [ $WRITE = "false" ]; then - echo - echo "ERROR" - echo "Sbopkg attempted to clean out leftover files in \$TMP," - echo "which is set to $TMP in sbopkg.conf, but" - echo "it appears that you do not have sufficient permissions to" - echo "do so. Please check your \$TMP setting in sbopkg.conf," - echo "verify that your permissions are correct, or manually" - echo "delete any leftover files in \$TMP. Some features of" - echo "sbopkg are generally available only to the root user," - echo "so running sbopkg as root may be advisable. Exiting." - echo - exit 0 -else - rm -f $TMP/sbopkg_* - rm -f $TMP/sbopkgpidlist - rm -rf $TMP/sbooutput - rm -f $TMP/sbopkg-*-queue - rm -f $PIDFILE -fi -cd $CWD + # Clean up cruft and remove temporary files. + check_write $TMP + if [ $WRITE = "false" ]; then + echo + echo "ERROR" + echo "Sbopkg attempted to clean out leftover files in \$TMP," + echo "which is set to $TMP in sbopkg.conf, but" + echo "it appears that you do not have sufficient permissions to" + echo "do so. Please check your \$TMP setting in sbopkg.conf," + echo "verify that your permissions are correct, or manually" + echo "delete any leftover files in \$TMP. Some features of" + echo "sbopkg are generally available only to the root user," + echo "so running sbopkg as root may be advisable. Exiting." + echo + exit 0 + else + rm -f $TMP/sbopkg_* + rm -f $TMP/sbopkgpidlist + rm -rf $TMP/sbooutput + rm -f $TMP/sbopkg-*-queue + rm -f $PIDFILE + fi + cd $CWD } control_c () { -# This function holds the commands that will be executed when the user -# presses Control-C. The $TMP/sbopkgpidlist file is the file to which -# various PID's are written to as certain background processes etc. -# are executed. -echo "Control-C detected. Trying to exit cleanly..."; -if [ -e $TMP/sbopkgpidlist ]; then - for pid in $(cat $TMP/sbopkgpidlist); do - echo "killing $pid" - kill -9 $pid; - done; - rm -f $TMP/sbopkgpidlist -fi -if [ "$DIAG" = 1 ]; then - break -else - cleanup - exit 0 -fi + # This function holds the commands that will be executed when the user + # presses Control-C. The $TMP/sbopkgpidlist file is the file to which + # various PID's are written to as certain background processes etc. + # are executed. + echo "Control-C detected. Trying to exit cleanly..."; + if [ -e $TMP/sbopkgpidlist ]; then + for pid in $(cat $TMP/sbopkgpidlist); do + echo "killing $pid" + kill -9 $pid; + done; + rm -f $TMP/sbopkgpidlist + fi + if [ "$DIAG" = 1 ]; then + break + else + cleanup + exit 0 + fi } main_menu () { -# This is the main dialog menu. -if [ -z "$R" ] ; then R="Rsync" ; fi -while [ 0 ]; do -dialog --default-item "$R" --title "SlackBuilds.org Package Browser \ -(sbopkg version $SBOVER)" --backtitle "Currently using the \ -SlackBuilds.org $SLACKVER repository." --menu \ -"\nChoose one of the following or press to exit.\n" \ - 17 69 9 \ -"Rsync" "Rsync with SlackBuilds.org" \ -"ChangeLog" "View the SlackBuilds.org ChangeLog" \ -"Packages" "List installed SBo packages" \ -"Updates" "List potential updates to installed SBo packages" \ -"Browse" "Browse the local SlackBuilds.org repository" \ -"Search" "Search the local SlackBuilds.org repository" \ -"Queue" "Manage the build queue" \ -"Utilities" "Go to the utilities menu" \ -"Exit" "Exit sbopkg" 2>$TMP/sbopkg_main_menu_answer + # This is the main dialog menu. + if [ -z "$R" ]; then + R="Rsync" + fi + while [ 0 ]; do + dialog --default-item "$R" --title \ + "SlackBuilds.org Package Browser (sbopkg version $SBOVER)" \ + --backtitle \ + "Currently using the SlackBuilds.org $SLACKVER repository." \ + --menu \ + "\nChoose one of the following or press to exit.\n" \ + 17 69 9 \ + "Rsync" "Rsync with SlackBuilds.org" \ + "ChangeLog" "View the SlackBuilds.org ChangeLog" \ + "Packages" "List installed SBo packages" \ + "Updates" "List potential updates to installed SBo packages" \ + "Browse" "Browse the local SlackBuilds.org repository" \ + "Search" "Search the local SlackBuilds.org repository" \ + "Queue" "Manage the build queue" \ + "Utilities" "Go to the utilities menu" \ + "Exit" "Exit sbopkg" 2>$TMP/sbopkg_main_menu_answer -if [ $? != 0 ]; then - save_backup_queue - clear - cleanup - exit 0 -fi - -R="$(cat $TMP/sbopkg_main_menu_answer)" - -if [ "$R" = "Rsync" ]; then - rsync_repo -fi - -if [ "$R" = "ChangeLog" ]; then - show_changelog -fi - -if [ "$R" = "Packages" ]; then - get_sbo_packages -fi - -if [ "$R" = "Updates" ]; then - rm -f $TMP/sbopkg-update-queue - check_for_updates - if [ -e $TMP/sbopkg-update-queue ]; then - dialog --title "Add Updates to Queue?" --yesno \ -"Would you like to add the flagged updates to the build queue?" \ -8 35 - if [ $? = 0 ]; then - cat $TMP/sbopkg-update-queue >> $TMP/sbopkg-tmp-queue - rm -f $TMP/sbopkg-update-queue - dialog --title "Done" --msgbox "The flagged updates \ -have been added to the build queue." 8 30 + if [ $? != 0 ]; then + save_backup_queue + clear + cleanup + exit 0 fi - fi -fi -if [ "$R" = "Browse" ]; then - browse_categories -fi + R="$(cat $TMP/sbopkg_main_menu_answer)" -if [ "$R" = "Search" ]; then - check_if_repo_exists - dialog --inputbox "Enter the name of a package you would like \ -to search for:" 9 40 2>/$TMP/sbopkg_search_request - if [ $? != 0 ]; then - continue - fi - SRCH="$(cat $TMP/sbopkg_search_request)" - if [ ! "$SRCH" = "" ]; then - gen_search_package $SRCH - fi -fi + if [ "$R" = "Rsync" ]; then + rsync_repo + fi -if [ "$R" = "Queue" ]; then - if [ ! -e $TMP/sbopkg_backup_queue.lck ]; then - load_backup_queue - fi - queue_menu -fi + if [ "$R" = "ChangeLog" ]; then + show_changelog + fi -if [ "$R" = "Utilities" ]; then - utilities_menu -fi + if [ "$R" = "Packages" ]; then + get_sbo_packages + fi -if [ "$R" = "Exit" ]; then - save_backup_queue - clear - cleanup - exit 0 -fi -done + if [ "$R" = "Updates" ]; then + rm -f $TMP/sbopkg-update-queue + check_for_updates + if [ -e $TMP/sbopkg-update-queue ]; then + dialog --title "Add Updates to Queue?" --yesno \ + "$(crunch "Would you like to add the flagged updates to \ + the build queue?")" 8 35 + if [ $? = 0 ]; then + cat $TMP/sbopkg-update-queue >> $TMP/sbopkg-tmp-queue + rm -f $TMP/sbopkg-update-queue + dialog --title "Done" --msgbox "$(crunch "The flagged \ + updates have been added to the build queue.")" 8 30 + fi + fi + fi + + if [ "$R" = "Browse" ]; then + browse_categories + fi + + if [ "$R" = "Search" ]; then + check_if_repo_exists + dialog --inputbox \ + "Enter the name of a package you would like to search for:" \ + 9 40 2>/$TMP/sbopkg_search_request + if [ $? != 0 ]; then + continue + fi + SRCH="$(cat $TMP/sbopkg_search_request)" + if [ ! "$SRCH" = "" ]; then + gen_search_package $SRCH + fi + fi + + if [ "$R" = "Queue" ]; then + if [ ! -e $TMP/sbopkg_backup_queue.lck ]; then + load_backup_queue + fi + queue_menu + fi + + if [ "$R" = "Utilities" ]; then + utilities_menu + fi + + if [ "$R" = "Exit" ]; then + save_backup_queue + clear + cleanup + exit 0 + fi + done } # END OF FUNCTIONS. What comes below is the actual start of the @@ -2299,8 +2354,7 @@ if [ -n "$GETPKGS" ]; then fi if [ -n "$RSYNC" ]; then - echo "Rsyncing with Slackbuilds.org repository into \ -$LOCALREPO/$SLACKVER." + echo "Rsyncing with Slackbuilds.org repository into $LOCALREPO/$SLACKVER." rsync_repo echo "Finished rsync." fi