enforce '.sboq.' extension to queuefiles; also, if argument passed at cli is the name of a queuefile and a package, ask user which one he wants to use

This commit is contained in:
chess.griffin 2009-05-20 12:51:16 +00:00
parent c39e7e2b1b
commit 5da74910d6

View File

@ -1297,14 +1297,15 @@ queue_dir_lister() {
local QFS=$SBOPKGTMP/sbopkg_queue_files_selection
local QFM=$SBOPKGTMP/sbopkg_queue_files_menu
if [[ -z $(ls -A $QUEUEDIR 2> /dev/null) ]]; then
if [[ -z $(ls -A $QUEUEDIR/*.sboq 2> /dev/null) ]]; then
if [[ $DIAG ]]; then
dialog --title "ERROR" --msgbox "$(crunch "The queue directory \
$QUEUEDIR is empty.")" 8 30
continue
fi
fi
find $QUEUEDIR -type f -not -name '*~' -printf "\"%P\" \"\" off\n" | sort > $QFM
find $QUEUEDIR -type f -name '*.sboq' -printf "\"%P\" \"\" off\n" \
| sed -e 's/.sboq//' | sort > $QFM
# The --default item doesn't work on deletions and renames (because the
# variable expands to a no-longer existing file) but you can't give it an
# index argument, unfortunately
@ -1344,6 +1345,7 @@ load_user_queue() {
for ((i=0; i<${#USERQUEUE[*]}; i++)); do
FILE=$QUEUEDIR/${USERQUEUE[$i]//'"'/}
FILE="$FILE.sboq"
if [[ -r $FILE ]]; then
CLIQUEUEFILE=$FILE
# this inhibits add_item_to_queue's msgbox for each added app
@ -1375,6 +1377,7 @@ delete_user_queue() {
for ((i=0; i<${#USERQUEUE[*]}; i++)); do
FILE=$QUEUEDIR/${USERQUEUE[$i]//'"'/}
FILE="$FILE.sboq"
if ! rm -f $FILE 2> /dev/null; then
dialog --title "ERROR" --msgbox \
"You do not have permission to remove $FILE" 0 0
@ -1417,6 +1420,7 @@ rename_user_queue() {
COUNTER=${#USERQUEUE[*]}
for ((i=0; i<$COUNTER; i++)); do
FILE=$QUEUEDIR/${USERQUEUE[$i]//'"'/}
FILE="$FILE.sboq"
if [[ -w ${FILE%/*} ]]; then
# This loops so the user can be brought back to the inputbox on a
# failure (continue) or back to the dir lister on success (break)
@ -1433,7 +1437,7 @@ rename_user_queue() {
exists. Please choose another name.")" 0 0
continue
else
mv "$FILE" "$QUEUEDIR/$NEWNAME"
mv "$FILE" "$QUEUEDIR/$NEWNAME.sboq"
break
fi
else
@ -1474,7 +1478,7 @@ save_user_queue() {
to discard it")
# Find an unused automatic file name
i=0
while [[ -f $QUEUEDIR/sbopkg-autosave-$i ]]; do
while [[ -f $QUEUEDIR/sbopkg-autosave-$i.sboq ]]; do
(( i++ ))
done
DEFAULT=sbopkg-autosave-$i
@ -1500,7 +1504,7 @@ save_user_queue() {
if ! validate_queue_name $USERQUEUE; then
continue
fi
if [[ -e $USERQUEUE_NAME ]]; then
if [[ -e $USERQUEUE_NAME.sboq ]]; then
dialog --title "ERROR" --yesno "$(crunch "Another file \
with that name already exists. Press <Yes> to \
continue and overwrite the other file, or press <No> \
@ -1509,8 +1513,8 @@ save_user_queue() {
continue
fi
fi
if cp $TMPQUEUE $QUEUEDIR/$USERQUEUE_NAME; then
LAST_USER_QUEUE_ON_DISK=$QUEUEDIR/$USERQUEUE_NAME
if cp $TMPQUEUE $QUEUEDIR/$USERQUEUE_NAME.sboq; then
LAST_USER_QUEUE_ON_DISK=$QUEUEDIR/$USERQUEUE_NAME.sboq
else
dialog --title "ERROR" --msgbox "Problem saving build queue."\
8 30
@ -3581,17 +3585,39 @@ else
CLIQUEUE=$SBOPKGTMP/sbopkg_cli_queue
> $SBOPKGTMP/sbopkg-start-queue
for PKGBUILD in $BUILD; do
if [[ -r $QUEUEDIR/$PKGBUILD ]]; then
# Add an entire queue
cp $QUEUEDIR/$PKGBUILD $CLIQUEUE
if [[ -r $QUEUEDIR/$PKGBUILD.sboq ]] && search_package $PKGBUILD; then
crunch_fmt "Both a queuefile and a package were found with \
the name \"$PKGBUILD\". Which would you like to use?"
echo
echo "Please enter (Q)ueuefile, (P)ackage, or (A)bort:"
while :; do
read ANS
case $ANS in
q* | Q* ) cp $QUEUEDIR/$PKGBUILD.sboq $CLIQUEUE
break
;;
p* | P* ) echo $PKGBUILD >> $CLIQUEUE
break
;;
a* | A* ) cleanup
exit 1
;;
* ) echo "Unknown response." ;;
esac
done
else
if search_package $PKGBUILD; then
# Add a single package
echo $PKGBUILD >> $CLIQUEUE
if [[ -r $QUEUEDIR/$PKGBUILD.sboq ]]; then
# Add an entire queue
cp $QUEUEDIR/$PKGBUILD.sboq $CLIQUEUE
else
crunch_fmt "Queuefile or package $PKGBUILD not found - \
skipping."
echo
if search_package $PKGBUILD; then
# Add a single package
echo $PKGBUILD >> $CLIQUEUE
else
crunch_fmt "Queuefile or package $PKGBUILD not found - \
skipping."
echo
fi
fi
fi
done