From db57b92f0886e860312c5444304d4403104f2412 Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Tue, 20 Jan 2009 22:13:13 +0000 Subject: [PATCH] add initial implementation of new delete_build_queue instead of clear_build_queue; this function allows user to remove individual items from queue or delete the whole queue; there are probably other/better ways to do this but this is a first crack at it. --- src/usr/bin/sbopkg | 72 +++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index 2ff3acd..d413e64 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -1172,9 +1172,9 @@ load_user_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 + 10 50 2>$TMP/sbopkg-user-queue if [ $? = 0 ]; then - USERQUEUE="$(cat $TMP/sbopkg_user_queue)" + USERQUEUE="$(cat $TMP/sbopkg-user-queue)" if [ ! "$USERQUEUE" = "" ]; then if $(echo $USERQUEUE | grep -q \/); then USERQUEUE=$USERQUEUE @@ -1205,9 +1205,9 @@ save_user_queue () { 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 + 2>$TMP/sbopkg-user-queue if [ $? = 0 ]; then - USERQUEUE="$(cat $TMP/sbopkg_user_queue)" + USERQUEUE="$(cat $TMP/sbopkg-user-queue)" if [ ! "$USERQUEUE" = "" ]; then if $(echo $USERQUEUE | grep -q \/); then USERQUEUE=$USERQUEUE @@ -1234,18 +1234,49 @@ save_user_queue () { fi } -clear_build_queue () { - # This function clears the build queue. +delete_build_queue () { + # This function deletes items in the build queue. if empty_queue; then return; fi TMPQUEUE=$TMP/sbopkg-tmp-queue - 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 + REMOVEQUEUE=$TMP/sbopkg-remove-queue + WORKINGQUEUE=$TMP/sbopkg-working-queue + cat $TMPQUEUE | sed -e 's/[ON$|OFF$]//g' > $REMOVEQUEUE + while :; do + dialog --title "Delete Build Queue" --ok-label "Delete" \ + --extra-button --extra-label "Delete All" --help-button \ + --help-label "Done" --cancel-label "Cancel" \ + --menu "$(crunch "The following packages are currently in \ + the build queue. You can remove individual items from the build \ + queue by highlighting them and pressing . Press when \ + you are finished and the individual deletions will be \ + committed. Otherwise, press at any time to abort your \ + changes.")" 25 60 8 \ + --file $REMOVEQUEUE 2>$TMP/sbopkg-ans-queue + CHOICE=$? # 0 = Delete, 1 = Cancel, 2=Done, 3 = Delete All + REMOVED=$(cat $TMP/sbopkg-ans-queue) + if [ $CHOICE = 0 ]; then + echo $REMOVED >> $WORKINGQUEUE + sed -i "s/^$REMOVED .*$//" $REMOVEQUEUE + continue + elif [ $CHOICE = 1 ]; then + rm -f $REMOVEQUEUE + return 0 + elif [ $CHOICE = 2 ]; then + for REMOVE in $(cat $WORKINGQUEUE); do + sed -i "s/^$REMOVE .*$//" $TMPQUEUE + #cat $TMPQUEUE | grep -q "^$PICK " >> $WORKINGQUEUE + done + dialog --title "Done" --msgbox \ + "The items have been removed from the build queue." 8 30 + #rm -f $REMOVEQUEUE + return 0 + elif [ $CHOICE = 3 ]; then + rm -f $REMOVEQUEUE $TMPQUEUE + dialog --title "Done" --msgbox \ + "The build queue has been cleared." 8 30 + return 0 + fi + done } add_item_to_queue () { @@ -1310,7 +1341,7 @@ view_queue () { echo $PICK | sed -e 's/ON/OFF/' >> $WORKINGQUEUE fi done - cp $WORKINGQUEUE $TMPQUEUE + mv $WORKINGQUEUE $TMPQUEUE if [ "$BUILDPKGS" = 1 ]; then mv $TMP/sbopkg-ans-queue $TMP/sbopkg-start-queue fi @@ -1322,11 +1353,12 @@ view_queue () { tac $TMPQUEUE >$TMP/sbopkg-reversed-queue mv $TMP/sbopkg-reversed-queue $TMPQUEUE continue - else # Cancel or ESC + else # Cancel or ESC rm -f $TMP/sbopkg-ans-queue break - fi + fi done + rm -f $WORKINGQUEUE continue } @@ -2265,7 +2297,7 @@ queue_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" \ + "Delete" "Delete items from the build queue" \ "Process" "Process the build queue" \ "Load" "Load a saved build queue" \ "Save" "Save a build queue" \ @@ -2283,8 +2315,8 @@ queue_menu () { view_queue fi - if [ "$Q" = "Clear" ]; then - clear_build_queue + if [ "$Q" = "Delete" ]; then + delete_build_queue fi if [ "$Q" = "Process" ]; then