From 07c263c203feb00bf068ddcebb83d73d97975e8c Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Thu, 14 May 2009 14:06:44 +0000 Subject: [PATCH] rework the whole process_queue and related functions; this patch attempts to properly handle certain items by the caller instead of in the called function; it also does away with the INSTALLPKGS and BUILDPKGS toggles; the logging is cleaned up and improved; and various other FIXMEs and tweaks are made along the way. --- src/usr/sbin/sbopkg | 595 ++++++++++++++++++++------------------------ 1 file changed, 274 insertions(+), 321 deletions(-) diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index 1e80e24..cf42b02 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -852,7 +852,7 @@ info_item() { local CURAPP LONGAPP SHORTAPP local STRING INDEX NAME VER BUILD DEFAULTITEM local CURPACKAGE INSTALLEDPACKAGE MENUPACKAGE TITLEPACKAGE RENAMEDPACKAGE - local CHOICE PARSED_SLACK_DESC SBOPKGINSTALLOUTPUT + local CHOICE PARSED_SLACK_DESC local APP="$(< $SBOPKGTMP/sbopkg_item_selection)" # We need to check and see if the APP has ever been renamed. @@ -966,18 +966,17 @@ info_item() { Queue ) add_item_to_queue $APP $CURVERSION-$CURBUILD ON ;; Build ) echo "$APP" > $SBOPKGTMP/sbopkg-start-queue - process_queue ;; + start_dialog_queue ;; Install ) - SBOPKGINSTALLOUTPUT=$SBOPKGTMP/sbopkg_install_output if [[ ! -e $OUTPUT/$CURPACKAGE ]]; then continue; fi - install_package $CURPACKAGE | tee $SBOPKGINSTALLOUTPUT + install_package $OUTPUT $CURPACKAGE | tee $TMPLOG read -n 1 -p "Press any key to continue." if [[ $KEEPLOG ]]; then - cat $SBOPKGINSTALLOUTPUT >> $LOGFILE + cat $TMPLOG >> $LOGFILE fi - rm -f $SBOPKGINSTALLOUTPUT + rm $TMPLOG ;; esac ;; @@ -1094,8 +1093,6 @@ view_perm_log() { empty_queue() { # This function tests whether the temporary build queue is empty. - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue - if [[ ! -e $TMPQUEUE ]]; then if [[ $DIAG ]]; then dialog --title "Empty Queue" --msgbox \ @@ -1183,7 +1180,6 @@ load_backup_queue() { # This function loads any backup queue and merges it with any current # $TMPQUEUE. - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue local PERMQUEUE=$SBOPKGTMP/sbopkg-savedqueue local BACKUPQUEUE_LOCK=$SBOPKGTMP/sbopkg_backup_queue.lck @@ -1216,8 +1212,8 @@ queue_dir_lister() { # takes two arguments - the title and the text of the widget - and makes # the selected item(s) from the listing available as USERQUEUE - local QFS=$SBOPKGTMP/sbopkg-queue-files-selection - local QFM=$SBOPKGTMP/sbopkg-queue-files-menu + local QFS=$SBOPKGTMP/sbopkg_queue_files_selection + local QFM=$SBOPKGTMP/sbopkg_queue_files_menu if [[ -z $(ls -A $QUEUEDIR 2> /dev/null) ]]; then if [[ $DIAG ]]; then @@ -1361,7 +1357,6 @@ save_user_queue() { # queue. In that case, show the filename dialog only if there actually is # an active queue, and return silently otherwise. - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue local USERQUEUE=$SBOPKGTMP/sbopkg-user-queue local DEFAULT MSG USERQUEUE_NAME i local USERQUEUE_NAME @@ -1429,7 +1424,6 @@ edit_build_queue() { # This function deletes items in the build queue. local ANSQUEUE=$SBOPKGTMP/sbopkg-ans-queue - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue local REMOVEQUEUE=$SBOPKGTMP/sbopkg-remove-queue local WORKINGQUEUE=$SBOPKGTMP/sbopkg-working-queue local CHOICE REMOVE REMOVED @@ -1500,7 +1494,6 @@ add_item_to_queue() { local VERSIONBUILD=$2 local ONOFF=$3 local BACKUPQUEUE_LOCK=$SBOPKGTMP/sbopkg_backup_queue.lck - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue local USERQUEUE_LOCK=$SBOPKGTMP/sbopkg_user_queue.lck local UPDATEQUEUE=$SBOPKGTMP/sbopkg-update-queue local OLDVER="$(awk '/^'$APP'/{ print $2 }' $TMPQUEUE 2> /dev/null)" @@ -1533,8 +1526,6 @@ view_queue() { local ANSQUEUE=$SBOPKGTMP/sbopkg-ans-queue local REVERSEDQUEUE=$SBOPKGTMP/sbopkg-reversed-queue - local STARTQUEUE=$SBOPKGTMP/sbopkg-start-queue - local TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue local WORKINGQUEUE=$SBOPKGTMP/sbopkg-working-queue empty_queue && return @@ -1563,9 +1554,6 @@ view_queue() { fi done < $TMPQUEUE mv $WORKINGQUEUE $TMPQUEUE - if [[ $BUILDPKGS == 1 ]]; then - mv $ANSQUEUE $STARTQUEUE - fi return 0 ;; 1) @@ -1670,7 +1658,6 @@ sync_repo() { # This function does the sync with SBo. local SYNC_LOCK=$SBOPKGTMP/sbopkg_sync.lck - local SBOPKGOUTPUT=$SBOPKGTMP/sbopkg_output if [[ $REPO_TOOL == "" ]]; then if [[ $DIAG ]]; then @@ -1719,35 +1706,16 @@ sync_repo() { } 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. + # Search for package name and return error if not found. cd $LOCALREPO/$SLACKVER PKG="$1" PKGPATH=( $(find -type d -mindepth 2 -name "$PKG") ) if [[ -z $PKGPATH ]]; then - if [[ $SINGLE == yes ]]; then - echo "ERROR: Package or queuefile \"$PKG\" not found. Exiting." \ - >&2 - exit 1 - fi - if [[ $BUILDPKGS == 1 ]]; then - echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG - echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG - echo >> $PRECHECKLOG - echo >> $SUMMARYLOG - continue - else - if [[ $DIAG ]]; then - dialog --title "ERROR" --msgbox "Package $PKG not found" 0 0 - continue - else - echo "ERROR: Package \"$PKG\" not found." >&2 - continue - fi - fi + return 1 + else + return 0 fi } @@ -2020,7 +1988,7 @@ get_source() { local BUILD_LOCK=$SBOPKGTMP/sbopkg_build.lck local DLDIR=$SBOPKGTMP/download local PIDLIST=$SBOPKGTMP/sbopkgpidlist - local SUMMARYLOG=$SBOPKGTMP/sbopkg_summary + local TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog local SRCNAME DL FAILURE ANS MD5CHK # Don't pollute the environment with the .info content... local PRGNAM VERSION HOMEPAGE DOWNLOAD MD5SUM MAINTAINER EMAIL APPROVED @@ -2042,9 +2010,9 @@ get_source() { mv "$DL" "$SRCDIR/$SRCNAME" else FAILURE=download - echo "$PKG:" >> $SUMMARYLOG - echo "Download failed." >> $SUMMARYLOG - echo >> $SUMMARYLOG + echo "$PKG:" >> $TMPSUMMARYLOG + echo "Download failed." >> $TMPSUMMARYLOG + echo >> $TMPSUMMARYLOG fi cd $SRCDIR rm -rf $DLDIR @@ -2055,10 +2023,11 @@ get_source() { if [[ $MD5CHK == $MD5SUM ]]; then echo "OK" else - echo "$PKG:" >> $SUMMARYLOG - echo "MD5SUM check failed." | tee -a $SUMMARYLOG - echo "Expected: $MD5SUM" | tee -a $SUMMARYLOG - echo "Found: $MD5CHK" | tee -a $SUMMARYLOG + echo >> $TMPSUMMARYLOG + echo "$PKG:" >> $TMPSUMMARYLOG + echo "MD5SUM check failed." | tee -a $TMPSUMMARYLOG + echo "Expected: $MD5SUM" | tee -a $TMPSUMMARYLOG + echo "Found: $MD5CHK" | tee -a $TMPSUMMARYLOG # Ask the user what to do with the bad source while :; do cat << EOF @@ -2082,7 +2051,7 @@ EOF y* | Y* ) MD5SUM=$(tr / _ <<< "$MD5CHK") echo "Keeping the source and continuing." | - tee -a $SUMMARYLOG + tee -a $TMPSUMMARYLOG break ;; * ) @@ -2100,23 +2069,21 @@ EOF if [[ $FAILURE ]]; then rm -f $PKG.info.build rm -f $PKG.SlackBuild.build - if [[ $BUILDPKGS == 1 ]]; then - while :; do - 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." - error_read ANS - case $ANS in - y* | Y* ) return 1 ;; - n* | N* ) rm -f $BUILD_LOCK && return 2 ;; - * ) echo "Unknown response." ;; - esac - done - fi + while :; do + 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." + error_read ANS + case $ANS in + y* | Y* ) return 1 ;; + n* | N* ) rm -f $BUILD_LOCK && return 2 ;; + * ) echo "Unknown response." ;; + esac + done return 2 else ln -s "$SRCDIR/$SRCNAME" "$SRCNAME" @@ -2303,16 +2270,17 @@ do_install() { install_package() { # Install the package. - local INSTPKG=$1 - local OWNER=$(stat -c %U $OUTPUT/$INSTPKG) - local GROUP=$(stat -c %G $OUTPUT/$INSTPKG) + local INSTDIR=$1 + local INSTPKG=$2 + local OWNER=$(stat -c %U $INSTDIR/$INSTPKG) + local GROUP=$(stat -c %G $INSTDIR/$INSTPKG) if [[ $OWNER != root && $GROUP != root ]]; then crunch_fmt "WARNING: The file $INSTPKG is not set with root:root \ permissions! Do you want to proceed? Here is the \ output of ls -l:" echo - ls -l $OUTPUT/$INSTPKG + ls -l $INSTDIR/$INSTPKG echo echo "Press (Y)es to proceed or (N)o to abort." read ANS @@ -2322,12 +2290,8 @@ install_package() { * ) echo "Unknown response."; break ;; esac fi - if [[ $INSTALLPKGS ]]; then - do_install $SB_OUTPUT/* - else - do_install $OUTPUT/$INSTPKG - echo "Done upgrading/installing package." - fi + do_install $INSTDIR/$INSTPKG + echo "Done upgrading/installing package." } error_read() { @@ -2360,8 +2324,6 @@ build_package() { local PKGPATH=$1 local PKGNAME=$2 - local SB_OUTPUT=$SBOPKGTMP/sbooutput - local SUMMARYLOG=$SBOPKGTMP/sbopkg_summary echo echo "Building $PKGNAME" @@ -2381,6 +2343,7 @@ build_package() { esac # Start the actual build + echo >> $TMPSUMMARYLOG echo "Building package for $PKGNAME..." ( # Run the build in a subshell, to avoid namespace pollution [[ $BUILDOPTIONS ]] && eval "export $BUILDOPTIONS" @@ -2395,47 +2358,37 @@ build_package() { # Let's see the result cd $SB_OUTPUT if [ ! -f *.t?z ]; then - echo "$PKGNAME:" >> $SUMMARYLOG + echo "$PKGNAME:" >> $TMPSUMMARYLOG echo "Error occurred with build. Please check the log." \ - >> $SUMMARYLOG - echo >> $SUMMARYLOG - if [[ $BUILDPKGS ]]; 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." - while :; do - error_read ANS - case $ANS in - y* | Y* ) # Continue - return 0 - ;; - n* | N* ) # Abort - rm -f $SBOPKGTMP/sbopkg_build.lck - return 1 - ;; - * ) # Huh? - echo "Unknown response." - ;; - esac - done - fi + >> $TMPSUMMARYLOG + 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." + while :; do + error_read ANS + case $ANS in + y* | Y* ) # Continue + return 0 + ;; + n* | N* ) # Abort + rm -f $SBOPKGTMP/sbopkg_build.lck + return 1 + ;; + * ) # Huh? + echo "Unknown response." + ;; + esac + done else echo "Done building package for $PKG." NEWPACKAGE=$(ls -1 *.t?z) - echo "$PKGNAME:" >> $SUMMARYLOG - echo "Built package: $NEWPACKAGE" >> $SUMMARYLOG + echo "$PKGNAME:" >> $TMPSUMMARYLOG + echo "Built package: $NEWPACKAGE" >> $TMPSUMMARYLOG echo "Built package: $NEWPACKAGE" - if [[ $INSTALLPKGS ]]; then - install_package $NEWPACKAGE - echo "Done installing/upgrading package for $PKG." - echo "Installed package: $NEWPACKAGE" >> $SUMMARYLOG - fi - mv $SB_OUTPUT/* $OUTPUT/ - echo >> $SUMMARYLOG fi } @@ -2448,12 +2401,6 @@ edit_local_slackbuild() { local SHORTPATH=$1 local APP=$2 - # FIXME is this check really necessary? - if ! check_write $SHORTPATH; then - dialog --title "ERROR" --msgbox "You do not have write \ - permissions on the target directory." 8 30 - return 1 - fi if [[ ! -e $SHORTPATH/$APP.SlackBuild.sbopkg ]]; then cp $SHORTPATH/$APP.SlackBuild $SHORTPATH/$APP.SlackBuild.sbopkg fi @@ -2469,12 +2416,6 @@ delete_local_slackbuild() { local SHORTPATH=$1 local APP=$2 - # FIXME is this check really necessary? - if ! check_write $SHORTPATH; then - dialog --title "ERROR" --msgbox \ - "You do not have write permissions on the target directory." 8 30 - return 1 - fi # FIXME should be checked on the caller side? if [[ ! -e $SHORTPATH/$APP.SlackBuild.sbopkg ]]; then dialog --title "ERROR" --msgbox \ @@ -2496,10 +2437,6 @@ pick_slackbuild() { local PKGNAME=$2 if pick_file SlackBuild $PKGPATH $PKGNAME; then - # FIXME this BUILD assignment is a non-obvious side effect, the caller - # should do this - BUILD=$(egrep -m1 "^BUILD" $PKGPATH/$PKG.SlackBuild.build | - sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') return 0 else return 1 @@ -2515,12 +2452,6 @@ edit_local_info() { local SHORTPATH=$1 local APP=$2 - # FIXME is this check really necessary? - if ! check_write $SHORTPATH; then - dialog --title "ERROR" --msgbox "You do not have write \ - permissions on the target directory." 8 30 - return 1 - fi if [[ ! -e $LOCALREPO/$SLACKVER/$CATEGORY/$APP/$APP.info.sbopkg ]]; then cp $SHORTPATH/$APP.info $SHORTPATH/$APP.info.sbopkg fi @@ -2536,12 +2467,6 @@ delete_local_info() { local SHORTPATH=$1 local APP=$2 - # FIXME is this check really necessary? - if ! check_write $SHORTPATH; then - dialog --title "ERROR" --msgbox \ - "You do not have write permissions on the target directory." 8 30 - return 1 - fi # FIXME should be checked on the caller side? if [[ ! -e $SHORTPATH/$APP.info.sbopkg ]]; then dialog --title "ERROR" --msgbox \ @@ -2563,8 +2488,6 @@ pick_info() { local PKGNAME=$2 if pick_file info $PKGPATH $PKGNAME; then - # FIXME the caller should do this - . $PKGPATH/$PKGNAME.info.build return 0 else return 1 @@ -2583,10 +2506,10 @@ pick_file() { # $3 = the package name # Returns 0 if the user did his choice, 1 if ESC was pressed. - local FILE=$1 + FILE=$1 local PKGPATH=$2 local PKG=$3 - local PICKFILE=original + PICKFILE=original local ANS ITEM rm -f $SBOPKGTMP/sbopkg_file_selection $SBOPKGTMP/sbopkg_diff @@ -2652,8 +2575,8 @@ pick_file() { crunch_fmt "A local $FILE file for $PKG was found in \ addition to the original $FILE file." echo "Which one would you like to use?" - crunch_fmt "Please enter 'O' for original, 'L' for local, \ - 'D' to view a diff of the two, or 'C' to cancel." + echo + crunch_fmt "(O)riginal, (L)ocal, (D)iff, (C)ancel:" read ANS case $ANS in o* | O* ) @@ -2687,8 +2610,6 @@ pick_file() { elif [[ $PICKFILE == local ]]; then cp $PKGPATH/$PKG.$FILE.sbopkg $PKGPATH/$PKG.$FILE.build fi - echo "Using $PICKFILE $FILE file" >> $SBOPKGTMP/sbopkg_tmp_prechecklog - return 0 } @@ -2746,179 +2667,191 @@ use_options() { } process_queue() { - # Iterate through the process queue to build, and optionally - # install, the selected packages. - # The package(s) to be built are listed in $SBOPKGTMP/sbopkg-start-queue. - # $1 = if set, assume that we're a building a queue and perform some - # additional checks. - # FIXME This is a horrible interface... + local QUEUETYPE=$1 # build|buildinstall - local BUILDPKGS=$1 - # TODO Some of these should really be global... - local SBOPKGOUTPUT=$SBOPKGTMP/sbopkg_output - local SBOPKGTMPOUTPUT=$SBOPKGTMP/sbopkg_tmpoutput - local STARTQUEUE=$SBOPKGTMP/sbopkg-start-queue - local FINALQUEUE=$SBOPKGTMP/sbopkg-final-queue - local PRECHECKLOG=$SBOPKGTMP/sbopkg_precheck_log - local SUMMARYLOG=$SBOPKGTMP/sbopkg_summary - local TMPPRECHECKLOG=$SBOPKGTMP/sbopkg_tmp_prechecklog - local PKG SINGLE PKGPATH CHKBUILD ANS + # need to check the following before uncommenting + #local PKG PKGBUILD SINGLE PKGPATH CHKBUILD ANS + local CHKBUILD ANS - rm -f $SBOPKGTMPOUTPUT $FINALQUEUE $PRECHECKLOG $SUMMARYLOG $PRECHECKLOG - if [[ $DIAG && $BUILDPKGS ]]; then - # If there are no packages queued to be built, exit now - empty_queue && return - # Show the queued packages - view_queue - fi - # Ask the user if he also wants to install the built packages - if [[ $DIAG ]]; 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 - case $? in - 255|-1 ) # The user pressed ESC - return 0 - ;; - 1 ) # Build and install - INSTALLPKGS=1 - ;; - #0 ) # Build only (there's nothing to do in this case) - esac - fi - > $SUMMARYLOG - echo >> $SUMMARYLOG - echo "******************************************" >> $SUMMARYLOG - echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG - echo "Using the $REPO_DESC" >> $SUMMARYLOG - echo >> $SUMMARYLOG - if [[ $BUILDPKGS ]]; then - > $PRECHECKLOG - echo >> $PRECHECKLOG - echo "******************************************" >> $PRECHECKLOG - echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG - echo "Using the $REPO_DESC" >> $PRECHECKLOG - echo >> $PRECHECKLOG - for CHKBUILD in $(< $STARTQUEUE); do - unset PKG - # FIXME This SINGLE assignment should be a parameter to - # search_package(). Better yet, deciding what to do if the - # package is not found should be dealt with by the caller. - if [[ $(wc -l < $STARTQUEUE) == 1 ]]; then - SINGLE=yes - fi - search_package $CHKBUILD - if ! pick_info $PKGPATH $CHKBUILD; then - rm -f $PKGPATH/$PKG*.build - return 0 - fi - if ! pick_slackbuild $PKGPATH $CHKBUILD; then - rm -f $PKGPATH/$PKG*.build - return 0 - fi - use_options $PKGPATH $CHKBUILD - echo $CHKBUILD >> $FINALQUEUE - echo "Found $CHKBUILD $VERSION-$BUILD" >> $PRECHECKLOG - if [[ $BUILDOPTIONS ]]; then - echo "Options: $BUILDOPTIONS" >> $PRECHECKLOG - else - echo "Options: None" >> $PRECHECKLOG - fi - cat $TMPPRECHECKLOG >> $PRECHECKLOG - rm -f $TMPPRECHECKLOG - echo >> $PRECHECKLOG - done - echo "******************************************" >> $PRECHECKLOG - if [[ $DIAG ]]; then - dialog --title "Pre-Check Log" --ok-label "Start Build" \ - --extra-button --extra-label "Back" --no-cancel \ - --textbox $PRECHECKLOG 0 0 - if [[ $? != 0 ]]; then - rm -f $PKGPATH/$PKG*.build - rm -f $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG - return 0 - fi + rm -f $TMPLOG $TMPBUILDLOG $TMPSUMMARYLOG $FINALQUEUE + # Start the precheck + echo >> $TMPLOG + echo "++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG + echo " New queue process started on" >> $TMPLOG + echo " $(date)" >> $TMPLOG + echo "++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG + echo >> $TMPLOG + echo "------------------------------------------" >> $TMPLOG + echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $TMPLOG + echo "Using the $REPO_DESC" >> $TMPLOG + echo >> $TMPLOG + for CHKBUILD in $(< $STARTQUEUE); do + # FIXME: This section still needs to be reviewed + unset PKG PKGPATH PKGNAME VERSION BUILD PICKFILE FILE + if ! search_package $CHKBUILD; then + echo "$CHKBUILD not found!" >> $TMPLOG + continue else - while :; do - cat $PRECHECKLOG - echo - echo "Pre-check complete." - echo - crunch_fmt "Do you wish to proceed based on the search\ - results above? 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* ) - # FIXME Again, the fact that in this case the program - # terminates is a caller's decision. - rm -f $PKGPATH/$PKG*.build - cleanup - exit 0 - ;; - * ) - echo "Unknown response." - ;; - esac - done - echo + echo $CHKBUILD >> $FINALQUEUE + fi + if ! pick_info $PKGPATH $CHKBUILD; then + rm -f $PKGPATH/$PKG*.build + return 0 + else + . $PKGPATH/$PKG.info.build + echo "Using $PICKFILE $FILE file" >> $TMPLOG-info + fi + if ! pick_slackbuild $PKGPATH $CHKBUILD; then + rm -f $PKGPATH/$PKG*.build + return 0 + else + BUILD=$(egrep -m1 "^BUILD" $PKGPATH/$PKG.SlackBuild.build | + sed -e 's/^.*[=-]//;s/\"//;s/[ #}\t].*$//g;s/\"//g') + echo "Using $PICKFILE $FILE file" >> $TMPLOG-SB + fi + echo "Found $CHKBUILD $VERSION-$BUILD" >> $TMPLOG + cat $TMPLOG-info >> $TMPLOG + cat $TMPLOG-SB >> $TMPLOG + rm $TMPLOG-info $TMPLOG-SB + use_options $PKGPATH $CHKBUILD + if [[ $BUILDOPTIONS ]]; then + echo "Options: $BUILDOPTIONS" >> $TMPLOG + else + echo "Options: None" >> $TMPLOG + fi + echo >> $TMPLOG + done + echo "------------------------------------------" >> $TMPLOG + if [[ ! -e $FINALQUEUE ]]; then + echo "No valid file names in the queue. Exiting." + cleanup + exit 1 + fi + if [[ $DIAG ]]; then + dialog --title "Pre-Check Log" --ok-label "Start Build" \ + --extra-button --extra-label "Back" --no-cancel \ + --textbox $TMPLOG 0 0 + if [[ $? != 0 ]]; then + rm -f $PKGPATH/$PKG*.build + return 0 fi else - for CHKBUILD in $(< $STARTQUEUE); do - search_package $CHKBUILD - if ! pick_info $PKGPATH $CHKBUILD; then - rm -f $PKGPATH/$PKG*.build - return 1 - fi - if ! pick_slackbuild $PKGPATH $CHKBUILD; then - rm -f $PKGPATH/$PKG*.build - return 1 - fi - use_options $PKGPATH $CHKBUILD - echo $CHKBUILD >> $FINALQUEUE + while :; do + cat $TMPLOG + echo + echo "Pre-check complete." + echo + crunch_fmt "Do you wish to proceed based on the search\ + results above? 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* ) + return 0 + ;; + * ) + echo "Unknown response." + ;; + esac done + echo fi + if [[ $KEEPLOG ]]; then + cat $TMPLOG >> $LOGFILE + fi + rm $TMPLOG + # Okay, precheck done, now start the actual queue processing (build or + # build+install) > $SBOPKGTMP/sbopkg_build.lck for PKGBUILD in $(< $FINALQUEUE); do - search_package $PKGBUILD + if ! search_package $PKGBUILD; then + echo "$CHKBUILD not found!" >> $TMPLOG + continue + fi if [[ -f $SBOPKGTMP/sbopkg_build.lck ]]; then - build_package $PKGPATH $PKGBUILD 2>&1 | tee $SBOPKGTMPOUTPUT || + build_package $PKGPATH $PKGBUILD 2>&1 | tee $TMPBUILDLOG || break - cat $SBOPKGTMPOUTPUT >> $SBOPKGOUTPUT + if [[ $QUEUETYPE == "buildinstall" ]]; then + if [[ $SB_OUTPUT/*.t?z ]]; then + #install_package $SB_OUTPUT *.t?z + cd $SB_OUTPUT + NEWPACKAGE=$(ls -1t *.t?z | head -n1) + install_package $SB_OUTPUT $NEWPACKAGE + echo "Installed package: $NEWPACKAGE" >> $TMPSUMMARYLOG + fi + fi + if [[ $SB_OUTPUT/*.t?z ]]; then + mv $SB_OUTPUT/*.t?z $OUTPUT/ + fi else - echo "$PKG:" >> $SUMMARYLOG - echo "Not processed - build queue aborted." >> $SUMMARYLOG - echo >> $SUMMARYLOG + echo "$PKG:" >> $TMPSUMMARYLOG + echo "Not processed - build queue aborted." >> $TMPSUMMARYLOG + echo >> $TMPSUMMARYLOG fi done - rm -f $SBOPKGTMP/sbopkg_build.lck - echo "******************************************" >> $SUMMARYLOG - cat $SUMMARYLOG - if [[ $DIAG ]]; then - read -n 1 -p "Press any key to continue." + if [[ $KEEPLOG ]]; then + cat $TMPBUILDLOG >> $LOGFILE + rm $TMPBUILDLOG fi - if [[ $BUILDPKGS && -f $SBOPKGTMP/sbopkg-tmp-queue ]]; then + rm -f $SBOPKGTMP/sbopkg_build.lck + echo >> $TMPLOG + echo "------------------------------------------" >> $TMPLOG + echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $TMPLOG + echo "Using the $REPO_DESC" >> $TMPLOG + cat $TMPSUMMARYLOG >> $TMPLOG + rm $TMPSUMMARYLOG + echo >> $TMPLOG + echo "------------------------------------------" >> $TMPLOG + echo >> $TMPLOG + echo "++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG + echo " Queue process complete" >> $TMPLOG + echo "++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG + echo >> $TMPLOG + cat $TMPLOG + read -n 1 -p "Press any key to continue." + if [[ $KEEPLOG ]]; then + cat $TMPLOG >> $LOGFILE + fi + rm $TMPLOG + if [[ -f $TMPQUEUE ]]; 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 $SBOPKGTMP/sbopkg-tmp-queue + rm $TMPQUEUE dialog --title "Done" --msgbox \ "The build queue has been cleared." 8 35 fi fi - if [[ $KEEPLOG ]]; then - [[ -f $PRECHECKLOG ]] && cat $PRECHECKLOG >> $LOGFILE - [[ -f $SBOPKGOUTPUT ]] && cat $SBOPKGOUTPUT >> $LOGFILE - cat $SUMMARYLOG >> $LOGFILE - fi - rm -f $SBOPKGOUTPUT $STARTQUEUE $FINALQUEUE $PRECHECKLOG $SUMMARYLOG + rm -f $SBOPKGTMP/sbopkg-ans-queue + rm -f $FINALQUEUE +} + +start_dialog_queue() { + # This kick-starts the queue processing when using the dialog interface. + # When using cli, the -b or -i option will determine whether we build or + # build and install. + + 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 + case $? in + 255|-1 ) # The user pressed ESC + return 0 + ;; + 1 ) # Build and install + process_queue buildinstall + ;; + 0 ) # Build only + process_queue build + ;; + esac } check_for_latest() { @@ -3047,13 +2980,17 @@ queue_menu() { DEFAULTITEM=$(< $ANSWERFILE) case "$DEFAULTITEM" in - "View") view_queue ;; + "View") #empty_queue && return + view_queue ;; "Load") load_user_queue ;; "Save") save_user_queue ;; "Edit") edit_build_queue ;; "Rename") rename_user_queue ;; "Delete") delete_user_queue ;; - "Process") process_queue 1 ;; + "Process") #empty_queue && return + view_queue + cp $SBOPKGTMP/sbopkg-ans-queue $STARTQUEUE + start_dialog_queue ;; *) break ;; esac done @@ -3105,6 +3042,7 @@ cleanup() { rm -f $SBOPKGTMP/sbopkgpidlist rm -rf $SBOPKGTMP/sbooutput rm -f $SBOPKGTMP/sbopkg-*-queue + rm -f $SBOPKGTMP/sbopkg-tmp-* rm -f $PIDFILE # Back to the directory the user started sbopkg in @@ -3309,8 +3247,6 @@ unset DIAG # When set, run in dialog mode (instead of CLI mode) unset QUIET # When set, suppress less important output in CLI mode unset ON_ERROR # The policy used in error conditions (see "-e") unset LAST_USER_QUEUE_ON_DISK # The name of the last loaded/saved user queue -unset BUILDPKGS # TODO -unset INSTALLPKGS # TODO unset BUILDOPTIONS # TODO unset SBOPKG_RENAMES_D # Directory containing files tracking package renames # SBOPKG_CONF # Configuration file @@ -3345,7 +3281,7 @@ while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do case $OPT in b ) # Build BFLAG=1 - BUILDPKGS=1 + TYPE="build" BUILD="$OPTARG" unset DIAG ;; @@ -3369,8 +3305,7 @@ while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do ;; i ) # Build and install IFLAG=1 - BUILDPKGS=1 - INSTALLPKGS=1 + TYPE="buildinstall" BUILD="$OPTARG" unset DIAG ;; @@ -3464,6 +3399,14 @@ fi # Check for a good config file and set initial variables config_check +STARTQUEUE=$SBOPKGTMP/sbopkg-start-queue +TMPLOG=$SBOPKGTMP/sbopkg_tmplog +TMPQUEUE=$SBOPKGTMP/sbopkg-tmp-queue +FINALQUEUE=$SBOPKGTMP/sbopkg-final-queue +SB_OUTPUT=$SBOPKGTMP/sbooutput +SBOPKGOUTPUT=$SBOPKGTMP/sbopkg_output +TMPBUILDLOG=$SBOPKGTMP/sbopkg-tmp-buildlog +TMPSUMMARYLOG=$SBOPKGTMP/sbopkg-tmp-summarylog # Change $SLACKVER if set manually using cli -v if [[ $VERSION ]]; then @@ -3494,23 +3437,33 @@ else for PKGBUILD in $BUILD; do if [[ -r $QUEUEDIR/$PKGBUILD ]]; then # Add an entire queue - CLIQUEUEFILE=$PKGBUILD cp $QUEUEDIR/$PKGBUILD $CLIQUEUE else - # Add a single package - echo $PKGBUILD > $CLIQUEUE - fi - # Reading from $CLIQUEUE... - while read PICK; do - PICK_NAME=${PICK%% *} - if ! grep -qx $PICK_NAME $SBOPKGTMP/sbopkg-start-queue; then - echo $PICK_NAME >> $SBOPKGTMP/sbopkg-start-queue + if search_package $PKGBUILD; then + # Add a single package + echo $PKGBUILD >> $CLIQUEUE + else + crunch_fmt "Queuefile or package $PKGBUILD not found - \ + skipping." + echo fi - done < $CLIQUEUE + fi done + if [[ ! -e $CLIQUEUE ]]; then + echo "No valid queuefile or package name given. Exiting." + cleanup + exit 1 + fi + # Reading from $CLIQUEUE... + while read PICK; do + PICK_NAME=${PICK%% *} + if ! grep -qx $PICK_NAME $SBOPKGTMP/sbopkg-start-queue; then + echo $PICK_NAME >> $SBOPKGTMP/sbopkg-start-queue + fi + done < $CLIQUEUE rm -f $CLIQUEUE unset CLIQUEUE - process_queue $BUILDPKGS + process_queue $TYPE fi if [[ $CHK_UPDATES ]]; then