sm-admin AT lists.ibiblio.org
Subject: Developer Only Discussion List
List archive
[SM-Admin] Sorcery needs a way to restart a rebuild after a crash
- From: Eric Schabell <eschabell AT sourcemage.org>
- To: SM-Admin <sm-admin AT lists.ibiblio.org>
- Subject: [SM-Admin] Sorcery needs a way to restart a rebuild after a crash
- Date: Sat, 24 Jan 2004 18:20:59 +0100
Howdy all,
I was looking at an old bug and have adapted the patch/files for our
current system:
http://bugs.sourcemage.org/show_bug.cgi?id=389
I will attach my files and would appreciate some feedback before adding
to the devel sorcery branch.
Patch is for /usr/sbin/sorcery and /etc/sorcery/config.
script is for runlevel S in /etc/init.d/runlevels/%S
Give it a try!
thanks,
erics
--- usr/sbin/sorcery 2003-12-22 15:06:25.000000000 +0100
+++ /usr/sbin/sorcery 2004-01-24 17:57:00.473559688 +0100
@@ -508,7 +508,7 @@
message "To do a non recursive rebuild"
message "all installed spells must be fixed first."
sleep 3
- $CAST --fix
+# $CAST --fix
for LINE in `cat $SPELL_STATUS`; do
SPELL=`echo "$LINE" | cut -d : -f1`
@@ -523,18 +523,72 @@
done
unset SPELL
+
+ # raise the sorcery rebuild flag to retry on reboot
+ touch $REBUILD_FLAG
+
$CAST --queue
-#Taken care of cast --queue now:
-# if query "Edit Rebuild/Install Queue?" n
-# then edit_file $INSTALL_QUEUE
-# fi
-# $CAST --compile `cat $INSTALL_QUEUE`
-# rm $INSTALL_QUEUE
+ rm -f $REBUILD_FLAG
+
+}
+
+
+#
+# void rebuild_retry()
+#
+# Setup REBUILD_RETRY param
+#
+# Allow SA to control "sorcery rebuild" upon reboot
+#
+rebuild_retry() {
+
+ while
+
+ Z_HELP="Skip sorcery rebuild resuming upon reboot (Skip)"
+ A_HELP="Always resume sorcery rebuild upon reboot (Always)"
+ Y_HELP="Prompt for resuming upon reboot (default to Yes)"
+ N_HELP="Prompt for resuming upon reboot (default to No)"
+
+ COMMAND=`eval $DIALOG '--title "Retry and continue sorcery rebuild
Setup" \
+ --ok-label "Select"
\
+ --cancel-label "Exit"
\
+ --default-item $COMMAND
\
+ --item-help
\
+ --menu
\
+ ""
\
+ 0 0 0
\
+ "A" "Always" "$A_HELP"
\
+ "Z" "Skip" "$Z_HELP"
\
+ "Y" "Prompt (default Y)" "$Y_HELP"
\
+ "N" "Prompt (default N)" "$P_HELP"'`
+
+ do
+
+ case $COMMAND in
+
+ A) REBUILD_RETRY="Always" ;;
+ Z) REBUILD_RETRY="Skip" ;;
+ Y) REBUILD_RETRY="Yes" ;;
+ N) REBUILD_RETRY="No" ;;
+
+ esac
+
+
+ TEMP=`grep -v "REBUILD_RETRY=" $LOCAL_CONFIG`
+ echo " $TEMP" > $LOCAL_CONFIG
+ echo " REBUILD_RETRY=$REBUILD_RETRY" >> $LOCAL_CONFIG
+
+ $DIALOG --msgbox \
+ "Rebuild on reboot settings ($REBUILD_RETRY) saved to
$LOCAL_CONFIG" 8 45
+
+ break
+ done
}
+
make_checklist() {
@@ -1336,7 +1390,8 @@
J_HELP="Enter the number of jobs 'make' should run at the same time"
C_HELP="Setup distributed compilation"
R_HELP="Enter the maximum rate for downloading"
- S_HELP="Sorcery development options (debugging)"
+ S_HELP="Sorcery development options (debugging)"
+ Z_HELP="Setup sorcery rebuild resume on reboot"
COMMAND=`eval $DIALOG ' --title "Option Menu" \
@@ -1356,7 +1411,8 @@
"C" "Distributed compilation" "$C_HELP" \
"M" "Software Mirrors" "$M_HELP" \
"O" "Optimize Architecture" "$O_HELP" \
- "S" "Sorcery Development"
"$S_HELP"'`
+ "S" "Sorcery Development" "$S_HELP" \
+ "Z" "Sorcery rebuild resume" "$Z_HELP"'`
do
@@ -1372,7 +1428,8 @@
C) sorcery_distcc ;;
M) mirror_menu ;;
O) optimize_architecture ;;
- S) sorcery_devel_settings ;;
+ S) sorcery_devel_settings ;;
+ Z) rebuild_retry ;;
esac
@@ -1505,6 +1562,107 @@
#---------------------------------------------------------------------
+#-item sorcery_running_rebuild_check
+##
+## Check for running sorcery rebuild copies, if found warns user.
+##
+## cli function
+#---------------------------------------------------------------------
+sorcery_running_rebuild_check() {
+
+ # if sorcery is started in non interactive mode, warns this way
+ if [ "$1" != "" ] && [ -e $REBUILD_FLAG ] && [ -e $INSTALL_QUEUE ]; then
+ message "${MESSAGE_COLOR}Warning: sorcery rebuild may be already running
in background..."
+ message -n "This sorcery process will start in 5 seconds (press CTRL+C
to interrupt)${DEFAULT_COLOR}"
+ wait_flag_up
+ wait_flag $$ &
+ sleep 5
+ wait_flag_down
+ message " "
+ fi
+
+ if [ -e $REBUILD_FLAG ] && [ "$1" == "" ]; then
+
+ if [ -e $INSTALL_QUEUE ]; then
+ while
+
+ HELP=""
+ E_HELP="Exit (this) sorcery"
+ S_HELP="Stop previous sorcery rebuild and continue"
+ L_HELP="Leave sorcery rebuild and continue (caution)"
+ TITLE="Warning: 'sorcery rebuild' is running or was interrupted..."
+
+ COMMAND=`$DIALOG --title "$TITLE" \
+ --item-help \
+ --ok-label "Select" \
+ --no-cancel \
+ --menu \
+ "$HELP" \
+ 0 0 0 \
+ "E" "Exit (this) sorcery" "$E_HELP" \
+ "S" "Stop previous sorcery" "$S_HELP" \
+ "L" "Leave previous sorcery" "$L_HELP"`
+ do
+
+ case $COMMAND in
+ E) exit 0 ;;
+ S) rm -f $INSTALL_QUEUE ; rm -f $REBUILD_FLAG ; break ;;
+ L) $DIALOG --msgbox \
+ "Run 'sorcery resume' to resume your previous rebuild..." 8 45
+ break ;;
+ esac
+
+ done
+
+ else
+
+ # if the flag is up and install queue is missing... there is something
wrong...
+ rm -f $REBUILD_FLAG
+ fi
+
+ fi
+
+}
+
+#---------------------------------------------------------------------
+#-item initialize()
+##
+## Initialize sorcery, perform some sanity checks
+##
+## cli function
+#---------------------------------------------------------------------
+initialize() {
+
+ # check for running sorcery rebuild
+ sorcery_running_rebuild_check $1
+
+}
+
+#---------------------------------------------------------------------
+#-item resume()
+##
+## Resume an interrupted sorcery rebuild
+##
+## cli function
+#---------------------------------------------------------------------
+resume() {
+
+ $CAST --fix
+
+ if [ ! -e $INSTALL_QUEUE ]; then
+ message "${PROBLEM_COLOR} $INSTALL_QUEUE not found... nothing to resume
${DEFAULT_COLOR}"
+ exit 1
+ fi
+
+ $CAST --compile `cat $INSTALL_QUEUE`
+ rm $INSTALL_QUEUE
+
+ rm -f $REBUILD_FLAG
+
+}
+
+
+#---------------------------------------------------------------------
#-item sorcery_hold_spells <spells>
##
## sets <spells>'s status to held
@@ -1532,9 +1690,13 @@
rm -f $UPDATE_SCRIPT
+
if [ -z $1 ]; then
main_menu
else
+ # initialize, make some sanity checks
+ initialize $1
+
case $1 in
update) update_sorcery ;;
system-update) update_pkgs autoupdate ;;
@@ -1542,9 +1704,10 @@
queue) update_queue ;;
review-queue) install_queue_history ;;
rebuild) rebuild ;;
- show-held) sorcery_show_held_spells ;;
- hold) shift; sorcery_hold_spells "$@" ;;
- unhold) shift; sorcery_unhold_spells "$@" ;;
+ resume) resume ;;
+ show-held) sorcery_show_held_spells ;;
+ hold) shift; sorcery_hold_spells "$@" ;;
+ unhold) shift; sorcery_unhold_spells "$@" ;;
-h|--help) help ;;
--- etc/sorcery/config 2004-01-22 19:14:56.000000000 +0100
+++ /etc/sorcery/config 2004-01-24 18:02:02.636623920 +0100
@@ -171,3 +171,6 @@
optimize
[ -r $GRIMOIRE_LIST ] && . $GRIMOIRE_LIST
+
+ REBUILD_FLAG=/var/state/sorcery/sorcery-rebuild.flag
+REBUILD_RESUME_SCRIPT=/tmp/sorcery-rebuild.resume
Attachment:
sorcery_rebuild.sh
Description: sorcery_rebuild.sh
Attachment:
pgpfDkjU1P_N1.pgp
Description: PGP signature
- [SM-Admin] Sorcery needs a way to restart a rebuild after a crash, Eric Schabell, 01/24/2004
Archive powered by MHonArc 2.6.24.