/usr/sbin/sorcery
1 #!/bin/bash
2 #---------------------------------------------------------------------
3 ##
4 ##=head1 SYNOPSIS
5 ##
6 ## Sorcery is a spell management utility
7 ##
8 ##=head1 DESCRIPTION
9 ##
10 ## ...
11 ##
12 ##=head1 COPYRIGHT
13 ##
14 ## Original version Copyright 2001 by Kyle Sallee
15 ## Additions/corrections Copyright 2002 by the Source Mage Team
16 ##
17 ##=head1 FUNCTIONS
18 ##
19 ##=over 4
20 ##
21 #---------------------------------------------------------------------
22
23 help">help">help() {
24
25 cat << EOF
26
27 Sorcery is the menu interface for changing system settings, and used
28 for updating the system.
29
30 Example: sorcery
31 Usage: sorcery [parameters]
32
33 Optional Parameters:
34
35 -h | --help | help">help">help Display this help">help">help screen
36
37 -s | system-update Perform a system update (updates sorcery, grimoire,
38 and spells).
39 [ scribe update, sorcery queue, cast --queue ]
40 -u | update Update the sorcery scripts only.
41 -g | upgrade Do not update grimoire, just any spells that need to
42 be upgraded. [ sorcery queue, cast --queue ]
43
44 -r | rebuild rebuild all spells
45
46 -q | queue Compare installed grimoire to installed spells,
47 generate queue of spells needing to be updated.
48 queue-security Same as queue, but only for spells that need
49 updating due to security fixes.
50
51 review-queue Review the install queue for each spell's history
52 since each was last installed.
53
54 add-queue <spell|s> Add spell(s) to install queue
55 remove-queue <spell|s> Remove spell(s) from install queue
56
57 hold <spell|s> Sets spells' status to held.
58 unhold <spell|s> Sets spells' status to installed.
59
60 exile <spell|s> Sets spells' status to exiled.
61 unexile <spell|s> Removes spells' exiled status (to not installed at all).
62
63
64 default add spell_1 spell_2 on/off If "spell_1" optionally depends
65 on "spell_2" the default answer
66 is on/off.
67
68 default add "" spell on/off If anything optionally depends on "spell" the
69 default answer is on/off.
70
71 default add spell "" on/off If "spell" optionally depends on anything
72 the default answer is on/off.
73
74 default add spell PROVIDER on/off "Spell" is the provider for
75 PROVIDER by default, in the
76 case of optional_depends, if
77 on/off is off, none is chosen
78 by default instead.
79
80 default remove [spell|""] [spell|PROVIDER|""] Remove entry from defaults
81 default search [spell|""] [spell|PROVIDER|""] [on|off] Search defaults
82
83 -v | --version Print the sorcery version
84
85 EOF
86
87 exit 1
88 #' <-- fix for syntax highlighting in nedit
89 }
90
91 mirror_list() {
92 local mirror_list
93 for mirror_list in $MIRRORS; do
94 [[ -f $mirror_list/$1 ]] || continue
95 sort $mirror_list/$1 | awk '{ print "\""$NF"\""; NF--; print $0; }'
96 break # only list duplicate mirror lists once
97 done
98 }
99
100
101 select_mirror() {
102
103 local MIRROR_LIST=`mirror_list $1`
104
105 eval $DIALOG ' --title "Select Mirror Please" \
106 --ok-label "Select" \
107 --menu \
108 "" \
109 0 0 0 \
110 '$MIRROR_LIST
111
112 }
113
114
115 mirror_menu() {
116 local mirror_list mirrors mirror_name mirror_help cmd
117
118 mirrors=$(find $MIRRORS -maxdepth 1 -mindepth 1 -type f -printf "%f\n" | sort -u)
119 cmd='--title "Mirror Menu" \
120 --ok-label "Select" \
121 --cancel-label "Exit" \
122 --item-help \
123 --menu "" 0 0 0'
124
125 while read mirror_name; do
126 mirror_help="Select mirror for downloading $mirror_name sources."
127 cmd="$cmd $mirror_name '' '$mirror_help'"
128 done <<< "$mirrors"
129 local HELP="Selecting a mirror site can speed your downloads."
130
131 while COMMAND=$(eval $DIALOG "$cmd"); do
132 MIRROR=${COMMAND}_URL
133
134 if MIRROR_URL=`select_mirror $COMMAND`; then
135
136 if [ "$MIRROR_URL" == "Custom" ]; then
137 MIRROR_URL=`eval $DIALOG ' --inputbox "Please enter the URL." 0 0'`
138 fi &&
139
140 remove_config $LOCAL_CONFIG "$MIRROR" &&
141 modify_config $LOCAL_URL_CONFIG "$MIRROR" "$MIRROR_URL" &&
142
143 eval $DIALOG '--msgbox \
144 "$MIRROR=$MIRROR_URL saved in $LOCAL_URL_CONFIG" 0 0'
145
146 fi
147
148 done
149
150 }
151
152
153 show_spells() { (
154
155 local SECTION=`codex_find_section_by_name $1`
156 local SPELLS=`codex_get_spells_in_section $SECTION`
157
158 for SPELL in $SPELLS; do
159
160 smgl_basename $SPELL SPELLNAME
161 if ! spell_installed $SPELLNAME &&
162 ! spell_held $SPELLNAME &&
163 ! spell_exiled $SPELLNAME
164 then
165
166 codex_set_current_spell $SPELL
167 echo -en '"'${SPELL:="Unknown"}'"'
168 echo -en '\t"'${VERSION:="-"}'"'
169 echo -e '\t"'${SHORT:="Description Unavailable"}'"'
170
171 fi
172
173 done
174
175 ) }
176
177
178 show_sections() {
179
180 LIST=`codex_get_all_section_names | sort -u`
181
182 for LINE in $LIST; do
183 echo $LINE
184 echo "section"
185 done
186
187 }
188
189
190 select_section() {
191
192 eval $DIALOG '--title "Section Selection Menu" \
193 --default-item "$SECTION" \
194 --ok-label "Select" \
195 --cancel-label "Exit" \
196 --menu \
197 "" \
198 0 0 0 \
199 `show_sections`'
200
201 }
202
203
204 add_pkgs() { (
205
206 while
207
208 SECTION=`select_section`
209
210 do
211
212 while
213
214 SPELLS=`show_spells $SECTION` &&
215 ! [ -z "$SPELLS" ] &&
216 SPELL=`eval $DIALOG ' --title "Select spell to install please" \
217 --item-help \
218 --menu \
219 "$SECTION" \
220 0 0 0 \
221 '$SPELLS`
222
223 do
224
225 codex_set_current_spell_by_name $SPELL
226 SPELL_DESCRIPTION=`codex_get_spell_description $SPELL_DIRECTORY`
227
228 if eval $DIALOG '--title "Install $SPELL" \
229 --yesno "$SPELL_DESCRIPTION" \
230 0 0'
231 then
232
233 push_install_queue $SPELL
234 eval $DIALOG '--msgbox "$SPELL added to the install queue." 0 0'
235
236 else
237
238 eval '$DIALOG --msgbox "$SPELL will not be installed." 0 0'
239
240 fi
241 done
242 done
243
244 ) }
245
246
247 file_list() {
248
249 LIST=`ls $1`
250 for LINE in $LIST; do
251 echo $LINE
252 echo `file -b $1/$LINE | cut -d ' ' -f1`
253 done
254
255 }
256
257
258 file_menu() {
259
260 FILE_LIST=`file_list $1`
261 echo $1/`eval $DIALOG ' --title "Please select a file." \
262 --menu "" 0 0 0 \
263 $FILE_LIST'`
264
265 }
266
267
268 show_installed_spells() {
269 local spell date status version
270
271 while read spell date status version; do
272 if [[ $status == "installed" ]] ||
273 [[ $status == "held" ]]; then
274
275 if codex_set_current_spell_by_name $spell; then
276 SHORT=${SHORT:-"Description unavailable"}
277 echo -en '"'${spell:="Unknown"}'"'
278 echo -en '\t"'${version:="-"}'"'
279 echo -e '\t"'${SHORT//\"/\'}'"'
280 fi
281
282 fi
283 done < <(tr : " " < $SPELL_STATUS) | sort
284 codex_clear_current_spell
285 }
286
287
288 remove_pkgs() {
289
290 while
291
292 if [ -z "$INSTALLED_SPELLS" ]; then
293 echo "Discovering installed spells..."
294 INSTALLED_SPELLS=`show_installed_spells`
295 fi
296
297 SPELL=`eval $DIALOG ' --title "Select spell to remove please." \
298 --item-help \
299 --ok-label "Select" \
300 --cancel-label "Exit" \
301 --menu "" 0 0 0 \
302 '$INSTALLED_SPELLS`
303
304 do
305
306 local DESCRIPTION="Description unavailable"
307
308 codex_set_current_spell_by_name $SPELL
309 DESCRIPTION=`codex_get_spell_description $SPELL_DIRECTORY`
310
311 if eval $DIALOG '--title "Remove $SPELL?" \
312 --yesno "$DESCRIPTION" \
313 0 0'
314 then
315 push_remove_queue $SPELL &&
316 eval $DIALOG '--msgbox "$SPELL added to the remove queue." 0 0' ||
317 eval $DIALOG '--msgbox "$SPELL is not really installed?" 0 0'
318 fi
319
320 done
321
322 }
323
324
325 update_pkgs() {
326
327 if ps -C cast > /dev/null; then
328 echo "Unable to update sorcery concurrently while casting."
329 sleep 5
330 return 1
331 fi
332
333 message "${CHECK_COLOR}Updating ... please wait ... ${DEFAULT_COLOR}"
334
335 local UPDATE_SCRIPT=$TMP_DIR/sorcery.update
336 rm -rf $UPDATE_SCRIPT
337 cat << EOF > $UPDATE_SCRIPT
338 #!/bin/bash
339 ############################################################
340 # Copyright 2001 by Kyle Sallee #
341 ############################################################
342 # This helper script $UPDATE_SCRIPT is #
343 # created and executed when sorcery updates #
344 ############################################################
345
346 . /etc/sorcery/config
347
348 if [[ \$1 == "autoupdate" ]]; then
349 message "${MESSAGE_COLOR}"
350 message "Interrupting while upgrading the sorcery scripts may"
351 message "cause the sorcery scripts to be lost. If the sorcery"
352 message "scripts are lost, they can be restored by"
353 message "running the following script:"
354 message "${FILE_COLOR}"
355 message " bash ${RESTORE_SCRIPT}"
356 message "${MESSAGE_COLOR}"
357 message "If for some reason this does not work, see the"
358 message "Source Mage website at http://www.sourcemage.org/"
359 message "${DEFAULT_COLOR}"
360 message "${MESSAGE_COLOR}Updating grimoire...${DEFAULT_COLOR}"
361 scribe update
362 message "${MESSAGE_COLOR}Ensuring sorcery-$SORCERY_BRANCH is at it's latest version...${DEFAULT_COLOR}"
363 update_sorcery_scripts $SORCERY_BRANCH
364 fi
365
366 clean_logs
367 update_install_queue # generate $INSTALL_QUEUE file
368 list_install_queue
369
370 message "${MESSAGE_COLOR}Casting updated spells...${DEFAULT_COLOR}"
371 cast --queue
372
373 fix_installed_spells # check integrity of installed spells
374
375 EOF
376
377 make_restore_script
378
379 chmod 100 $RESTORE_SCRIPT
380 chmod 100 $UPDATE_SCRIPT
381 exec bash $UPDATE_SCRIPT $1
382 # run it via bash to bypass /tmp mounted with noexec option
383
384
385 }
386
387 function make_restore_script() {
388 # note the lines:
389 #SORCERY_SPOOL=${SOURCE_CACHE}
390 #SORCERY_BRANCH=${SORCERY_BRANCH}
391 # actually have their values filed in at script generation time
392 # everything else must be back-quoted to work properly
393
394 rm -f $RESTORE_SCRIPT
395 cat << EOF > $RESTORE_SCRIPT
396 #!/bin/bash
397 ############################################################
398 # This helper script /tmp/sorcery.restore can #
399 # be run to restore the sorcery scripts if they #
400 # are lost during a sorcery update. #
401 ############################################################
402
403 echo "Restoring the sorcery scripts, please wait ..."
404 SORCERY_SPOOL=${SOURCE_CACHE}
405 SORCERY_BRANCH=${SORCERY_BRANCH}
406
407 if [[ \$1 ]]; then
408 SORCERY_BRANCH=\$1
409 fi
410
411 if cd /usr/src &&
412 bunzip2 -c \$SORCERY_SPOOL/sorcery-\$SORCERY_BRANCH.tar.bz2 | tar xf - &&
413 cd sorcery &&
414 ./install; then
415 cd ..
416 rm -rf /usr/src/sorcery
417 echo "Sorcery was successfully restored."
418 else
419 echo "Unable to restore sorcery. Try running this file with"
420 echo "the name of the branch you had previously installed as"
421 echo "the command-line parameter: (e.g. stable, or devel)."
422 echo
423 echo "For more help">help">help, see the Source Mage website "
424 echo "(http://www.sourcemage.org/)."
425 fi
426
427 EOF
428 }
429
430
431 update_sorcery () {
432
433 make_restore_script
434
435 message "${MESSAGE_COLOR}"
436 message "Interrupting while upgrading the sorcery scripts may"
437 message "cause the sorcery scripts to be lost. If the sorcery,"
438 message "scripts are lost, Source Mage can be restored by"
439 message "running the following script:"
440 message "${FILE_COLOR}"
441 message " bash ${RESTORE_SCRIPT}"
442 message "${MESSAGE_COLOR}"
443 message "If for some reason this does not work, see the"
444 message "Source Mage website at http://www.sourcemage.org/"
445 message "${DEFAULT_COLOR}"
446
447 update_sorcery_scripts $SORCERY_BRANCH
448
449 }
450
451
452 update_queue () {
453 update_install_queue
454 list_install_queue
455 }
456
457 update_security_queue () {
458 update_security_install_queue
459 list_install_queue
460 }
461
462 rebuild() {
463 local reconfigure=$1
464
465 lock_file $INSTALL_QUEUE
466 rm -rf $INSTALL_QUEUE
467 get_all_spells_with_status installed >> $INSTALL_QUEUE
468 unlock_file $INSTALL_QUEUE
469 cast -c -b --queue $reconfigure
470
471 }
472
473
474 make_checklist() {
475
476
477 local SECTION=`codex_find_section_by_name $1`
478 local SPELLS=`codex_get_spells_in_section $SECTION`
479
480 for SPELL in $SPELLS; do
481
482 if codex_set_current_spell $SPELL; then
483
484 STATUS="OFF"
485
486 if spell_ok $SPELL
487 then STATUS="on"
488 else STATUS="off"
489 fi
490
491 echo -en '"'${SPELL:="Unknown"}'"'
492 echo -en '\t"'${VERSION:="-"}'"'
493 echo -en '\t"'$STATUS'"'
494 echo -e '\t"'${SHORT:="Description Unavailable"}'"'
495
496 fi
497
498 done
499
500 }
501
502
503 process_section() {
504
505 local SECTION=`codex_find_section_by_name $1`
506 local KEEP_LIST=$2
507 local SPELLS=`ls $GRIMOIRE/$SECTION`
508
509 for SPELL in $SPELLS; do
510
511 smgl_basename "$SPELL" LINE
512 if echo -e "$KEEP_LIST" |
513 grep -q "^$LINE\$"
514 then push_install_queue $LINE
515 else push_remove_queue $LINE
516 fi
517
518 done
519
520 }
521
522
523 select_pkgs() {
524
525 local SELECT_TITLE="Spell Toggle Selection Menu"
526 local SELECT_HELP="[X]=install [ ]=remove"
527
528 while SECTION=`select_section`; do
529
530 CHECKLIST=`make_checklist $SECTION`
531
532 if OUTLIST=`eval $DIALOG ' --title "$SELECT_TITLE" \
533 --ok-label "Commit" \
534 --item-help \
535 --separate-output \
536 --checklist \
537 "$SELECT_HELP $SECTION" \
538 0 0 0 \
539 '$CHECKLIST`
540
541 then process_section "$SECTION" "$OUTLIST"
542 fi
543 done
544
545 }
546
547
548 make_hold_checklist() {
549
550 array=()
551
552 for LINE in `sort $SPELL_STATUS`; do
553
554 explode "$LINE" ":" "array"
555
556 SPELL="${array[0]}"
557 STATUS="${array[2]}"
558 VERSION="${array[3]}"
559
560 if [ "$STATUS" == "installed" ] ||
561 [ "$STATUS" == "held" ]; then
562
563 [ "$STATUS" == "held" ] &&
564 HELD="on" ||
565 HELD="off"
566
567 if codex_set_current_spell_by_name $SPELL; then
568
569 echo -en "\"${SPELL:="Unknown"}\""
570 echo -en "\t\"${VERSION:="-"}\""
571 echo -en "\t\"$HELD\""
572 echo -e "\t\"${SHORT:="Description Unavailable"}\""
573
574 fi
575 fi
576 done
577
578 }
579
580
581 hold_pkgs() {
582
583 local array=()
584 local tSPELL_STATUS
585
586 local CHECKLIST=`make_hold_checklist`
587
588 local HOLD_TITLE="Select spells to hold or unhold"
589 local HOLD_HELP="[X]=held [ ]=installed"
590
591 if OUTLIST=`eval $DIALOG ' --title "$HOLD_TITLE" \
592 --item-help \
593 --ok-label "Commit" \
594 --separate-output \
595 --checklist \
596 "$HOLD_HELP" \
597 0 0 0 \
598 '$CHECKLIST`
599 then
600 set_unheld $(get_all_spells_with_status "held")
601 set_held $OUTLIST
602 fi
603
604 }
605
606
607 spell_menu() {
608
609 local U_HELP="Current software hinders crackers' attempts to infiltrate your box"
610 local S_HELP="Install and remove multiple spells from a section using a single selection"
611 local A_HELP="Simple safe, verbose way of selecting spells for installation"
612 local R_HELP="Simple safe, verbose way of selecting spells for removal"
613 local B_HELP="Rebuild all installed spells"
614 local H_HELP="Held spells will not be upgraded until unheld or broken"
615 local E_HELP="Done managing spells"
616 local TITLE="Spell Menu"
617 local OK="Select"
618 local CANCEL="Exit"
619
620 while
621
622
623 COMMAND=`eval $DIALOG ' --title "$TITLE" \
624 --item-help \
625 --ok-label "$OK" \
626 --cancel-label "$CANCEL" \
627 --menu "" 0 0 0 \
628 "A" "Add" "$A_HELP" \
629 "B" "Rebuild" "$B_HELP" \
630 "H" "Hold" "$H_HELP" \
631 "R" "Remove" "$R_HELP" \
632 "S" "Select" "$S_HELP" \
633 "U" "Update" "$U_HELP"'`
634 do
635
636 case $COMMAND in
637 U) ( sorcery system-update; ) ;;
638 S) select_pkgs ;;
639 A) add_pkgs ;;
640 R) remove_pkgs ;;
641 B) rebuild ;;
642 H) hold_pkgs ;;
643 E) break ;;
644 esac
645
646 done
647
648 }
649
650
651 grep_install_logs() {
652
653 local WHAT
654 if WHAT=`eval $DIALOG ' --inputbox \
655 "Please enter full path and name of file" \
656 0 0'`
657 then
658 cd $INSTALL_LOGS
659 grep "$WHAT\$" * | $PAGER
660 fi
661
662 }
663
664
665 optimize_architecture() {
666 architecture_menu ARCHITECTURE "Build system selection"
667 if [[ $CROSS_INSTALL == on ]]; then
668 architecture_menu TARGET "Target system selection"
669 fi
670 optimization_menu
671 custom_optimization_menu
672 . $LOCAL_CONFIG
673 optimize
674 }
675
676 architecture_menu() {
677
678 debug "sorcery" "architecture_menu()"
679 local SPECFILE
680 local LIST CPUNAME specname
681 local specname CPUNAME
682 hash_reset archspec_hash
683 # this loop finds archspecs, it uses a hash table to ensure that theres
684 # only one entry per archspec (there could be several archspecs with the
685 # same name), it reverses the output from tac so that the first archspecs
686 # found are the last added to the hash table and thus are prefered over
687 # ones found later
688 for SPECFILE in $(find $ARCH_SPECS -type f -not -name '*~' | tac); do
689 if test -x "$SPECFILE" && grep -q "CPUNAME" $SPECFILE; then
690 smgl_basename "$SPECFILE" specname
691 hash_put archspec_hash $specname $SPECFILE
692 fi
693 done
694
695 # now that there archspecs have been found, build the dialog list
696 for specname in $(hash_get_table_fields archspec_hash|sort); do
697 CPUNAME=""
698 hash_get_ref archspec_hash $specname SPECFILE &&
699 debug "sorcery" "architecture_menu() - $specname found at $SPECFILE"
700 CPUNAME=$( . $SPECFILE && echo $CPUNAME ) &&
701 LIST="$LIST $specname \"$CPUNAME\" \"$CPUNAME\""
702 done
703 hash_reset archspec_hash
704 debug "sorcery" "architecture_menu() - Dialog options are $LIST"
705
706 local ARCH_TITLE="$2"
707 local ARCH_HELP="Please select a microprocessor category"
708
709 # CURRENT_ARCH is the currently selected architecture
710
711 # NEW_ARCH is the new architecture selected (can be an empty string if
712 # the user press cancel).
713
714 # do not use ARCHITECTURE or TARGET variable since they are already
715 # used by sorcery configuration
716
717 local CURRENT_ARCH="${!1}"
718 local NEW_ARCH
719
720 if NEW_ARCH=`eval $DIALOG ' --title "$ARCH_TITLE" \
721 --item-help \
722 --default-item "${CURRENT_ARCH}" \
723 --menu \
724 "$ARCH_HELP" \
725 0 0 0 \
726 '$LIST `; then
727
728 # remove spurious ""
729 NEW_ARCH=`echo "${NEW_ARCH}" | sed -e 's/^"//' -e 's/"$//'`
730
731 debug "sorcery" "architecture_menu() - NEW_ARCH='$NEW_ARCH'"
732
733 modify_local_config "$1" "${NEW_ARCH}"
734 fi
735
736
737 }
738
739 optimization_menu(){
740
741 local OPTIMIZATIONS=${OPTIMIZATIONS}
742 # this is here so PRELINK, RISKY, etc. are set
743 # and appear in the menu
744 optimize
745 local OPT_TITLE="Optimization Menu"
746 local OPT_HELP="Please select optimizations"
747
748 local PRELINK_HELP="Speed up loading applications by pre-linking libraries (CFLAGS=-DPIC -fPIC)"
749 local RISKY_HELP="Optimize by violating ANSI/IEEE (unsafe) (CFLAGS=-ffast-math -funroll-loops)"
750 local SPEEDY_HELP="Optimize generated code, conflicts with 'tiny' (CFLAGS=$FAST)"
751 local STRIP_HELP="Remove all symbol table and relocation (debugging) information (LDFLAGS=-s)"
752 local TINY_HELP="Optimize to smaller generated code, conflicts with 'speedy' (CFLAGS=$SMALL)"
753
754 if OPTIMIZATIONS=`eval $DIALOG ' --title "$OPT_TITLE" \
755 --no-cancel \
756 --item-help \
757 --separate-output \
758 --checklist \
759 "$OPT_HELP" \
760 0 0 0 \
761 "prelink" " +speed" "$PRELINK" "$PRELINK_HELP" \
762 "risky" " +speed" "$RISKY" "$RISKY_HELP" \
763 "speedy" " +size ++speed" "$SPEEDY" "$SPEEDY_HELP" \
764 "strip" " --size" "$STRIP" "$STRIP_HELP" \
765 "tiny" " -size +speed" "$TINY" "$TINY_HELP"'`
766 then
767
768 OPTIMIZATIONS=`echo ${OPTIMIZATIONS} | tr '\n' ' '`
769 debug "sorcery" "optimization_menu() - OPTIMIZATIONS='${OPTIMIZATIONS}'"
770
771 modify_local_config "OPTIMIZATIONS" "$OPTIMIZATIONS"
772
773 fi
774 }
775
776 custom_optimization_menu() {
777 local RESULTS KEY rc
778
779 while true ; do
780 # input box returns things of the form "RENAMED CFLAGS -O3 -march=foo ..."
781 # the ( ) interprits as an array, then using the magic power of set we
782 # get to use shift and $@ to get things done
783 RESULTS=(`eval $DIALOG ' --extra-label Adjust --inputmenu \
784 "Custom Optimizations Menu" \
785 17 50 9 \
786 CFLAGS "$CUSTOM_CFLAGS" \
787 CXXFLAGS "$CUSTOM_CXXFLAGS" \
788 LDFLAGS "$CUSTOM_LDFLAGS" \
789 CPPFLAGS "$CUSTOM_CPPFLAGS"'`)
790 rc=$?
791 [[ $rc == 0 ]] || [[ $rc == 1 ]] && break
792 set ${RESULTS[*]}
793 KEY=$2
794 shift 2
795 case "$KEY" in
796 CFLAGS) CUSTOM_CFLAGS="$@" ;;
797 CXXFLAGS) CUSTOM_CXXFLAGS="$@" ;;
798 CPPFLAGS) CUSTOM_CPPFLAGS="$@" ;;
799 LDFLAGS) CUSTOM_LDFLAGS="$@" ;;
800 esac
801 done
802
803 # only commit values if user selected "OK"
804 if [ $rc == 0 ] ; then
805 modify_local_config CUSTOM_CFLAGS "$CUSTOM_CFLAGS"
806 modify_local_config CUSTOM_CXXFLAGS "$CUSTOM_CXXFLAGS"
807 modify_local_config CUSTOM_LDFLAGS "$CUSTOM_LDFLAGS"
808 modify_local_config CUSTOM_CPPFLAGS "$CUSTOM_CPPFLAGS"
809 fi
810 }
811
812 integrity_fix_menu() {
813
814 local INT_TITLE="Integrity Checking Selection Menu"
815 local INT_HELP="Please select the tests which cleanse --fix should execute."
816 local FIND_HELP="Discover missing binary executables, libraries, and header files"
817 local LDD_HELP="Discover broken binary executables, and libraries"
818 local SYM_HELP="Discover misowned symbolic links to files"
819 local MD5SUM_HELP="Discover modified binary executables, and libraries"
820
821 if INT_FIX_CHECKS=`eval $DIALOG ' --title "$INT_TITLE" \
822 --no-cancel \
823 --item-help \
824 --separate-output \
825 --checklist \
826 "$INT_HELP" \
827 0 0 0 \
828 "FIND_CHECK" "" "$FIND_CHECK" "$FIND_HELP" \
829 "MD5SUM_CHECK" "" "$MD5SUM_CHECK" "$MD5SUM_HELP" \
830 "LDD_CHECK" "" "$LDD_CHECK" "$LDD_HELP" \
831 "SYM_CHECK" "" "$SYM_CHECK" "$SYM_HELP"'`
832 then
833
834 FIND_CHECK=off
835 MD5SUM_CHECK=off
836 LDD_CHECK=off
837 SYM_CHECK=off
838
839 for CHECK in $INT_FIX_CHECKS; do
840 case $CHECK in
841 FIND_CHECK) FIND_CHECK=on ;;
842 MD5SUM_CHECK) MD5SUM_CHECK=on ;;
843 LDD_CHECK) LDD_CHECK=on ;;
844 SYM_CHECK) SYM_CHECK=on ;;
845 esac
846 done
847
848 modify_local_config "FIND_CHECK" "$FIND_CHECK"
849 modify_local_config "MD5SUM_CHECK" "$MD5SUM_CHECK"
850 modify_local_config "LDD_CHECK" "$LDD_CHECK"
851 modify_local_config "SYM_CHECK" "$SYM_CHECK"
852
853 fi
854
855 }
856
857
858 integrity_download_menu() {
859
860 local INT_DL_TITLE="Archive Integrity Checking Level Menu"
861 local INT_DL_HELP="On bad archive integrity checks:
862 c = continue, a = abort, n = ask default abort no,
863 y = ask default abort yes, - = doesn't get checked, continues.
864 K MD5SUM_DL . good bad IGNORE missing
865 - ----------- ---- --- ------ -------
866 P all_abort . . c . a . . a . . . a .
867 A on|*. . . . . c . a . . y . . . a .
868 B ask_abort . . c . y . . y . . . y .
869 U ask_risky . . c . y . . n . . . y .
870 G ask_ignore. . c . n . . n . . . n .
871 I off . . . . . - . - . . - . . . - .
872 "
873 local ABORT_ALL_HELP="Abort use of the file. Do not prompt. Period. PARANOID"
874 local ABORT_HELP="Abort use of the file. Do not prompt unless the MD5 is set to IGNORE. SAFER"
875 local ABORT_ASK_HELP="Ask, but default to abort. SAFE"
876 local ABORT_IGN_HELP="Ask, but default to abort unless the MD5 is set to IGNORE. RISKY"
877 local IGNORE_ASK_HELP="Ask, but default to ignore. UNSAFE"
878 local IGNORE_HELP="Ignore (do not check) integrity of downloads. DANGEROUS!"
879
880 if INT_DL_CHECK=`eval $DIALOG ' --title "$INT_DL_TITLE" \
881 --no-cancel \
882 --ok-label "Commit" \
883 --item-help \
884 --menu \
885 "$INT_DL_HELP" \
886 0 0 0 \
887 "P" "Abort unpack paranoid" "$ABORT_ALL_HELP" \
888 "A" "Abort unpack but ask on ignore" "$ABORT_HELP" \
889 "B" "Ask (default abort)" "$ABORT_ASK_HELP" \
890 "U" "Ask (default abort save ignore)" "$ABORT_IGN_HELP" \
891 "G" "Ask (default ignore)" "$IGNORE_ASK_HELP" \
892 "I" "Ignore (do not check)" "$IGNORE_HELP"'`
893 then
894 case $INT_DL_CHECK in
895 P) modify_local_config "MD5SUM_DL" "abort_all" ;;
896 A) modify_local_config "MD5SUM_DL" "on" ;;
897 B) modify_local_config "MD5SUM_DL" "ask_abort" ;;
898 U) modify_local_config "MD5SUM_DL" "ask_risky" ;;
899 G) modify_local_config "MD5SUM_DL" "ask_ignore" ;;
900 I) modify_local_config "MD5SUM_DL" "off" ;;
901 esac
902 fi
903
904 }
905
906 function gpg_download_menu() {
907 local CHECK CHECKS
908 local INT_TITLE="GnuPG Signature Checking Selection Menu"
909 local INT_HELP="Enable/Disable GnuPG signature checking here"
910 local SRY_HELP="Toggle sorcery gpg signature checking on sorcery update"
911 local GRM_HELP="Toggle grimoire gpg signature checking on scribe update"
912
913 if CHECKS=`eval $DIALOG ' --title "$INT_TITLE" \
914 --no-cancel \
915 --item-help \
916 --separate-output \
917 --checklist \
918 "$INT_HELP" \
919 0 0 0 \
920 "GPG_VERIFY_SORCERY" "" "$GPG_VERIFY_SORCERY" "$SRY_HELP" \
921 "GPG_VERIFY_GRIMOIRE" "" "$GPG_VERIFY_GRIMOIRE" "$GRM_HELP"'`
922 then
923 GPG_VERIFY_SORCERY=off
924 GPG_VERIFY_GRIMOIRE=off
925
926 for CHECK in $CHECKS; do
927 case $CHECK in
928 GPG_VERIFY_SORCERY) GPG_VERIFY_SORCERY=on ;;
929 GPG_VERIFY_GRIMOIRE) GPG_VERIFY_GRIMOIRE=on ;;
930 esac
931 done
932
933 modify_local_config "GPG_VERIFY_SORCERY" "$GPG_VERIFY_SORCERY"
934 modify_local_config "GPG_VERIFY_GRIMOIRE" "$GPG_VERIFY_GRIMOIRE"
935 fi
936 }
937
938 function vrf_select_hashes() {
939 local DIALOG_TITLE="Select the source hashes you would like to use"
940 local DIALOG_HELP="Select the source hashes you would like to consider valid hashes"
941 local DEFAULT_LIST=$(gpg_get_hashes)
942 local rc=0
943 local CHECKS=""
944 local check=""
945 local hash=""
946 local DIALOG_LIST=""
947 if [ -z "$DEFAULT_LIST" ] ; then
948 eval $DIALOG '--title "ERROR" \
949 --msgbox \
950 "ERROR: gpg isn't installed or isn't in your PATH. Please cast gnupg." 20 20' &&
951 return 1
952 else
953 # move old values (named with GPG) to new ones
954 # this can be removed after 11/26/05 (afk -- 10/26/05)
955 if [[ -n "$GPG_ALLOWED_HASHES" ]] ; then
956 VRF_ALLOWED_HASHES=$GPG_ALLOWED_HASHES
957 modify_config $LOCAL_CONFIG "VRF_ALLOWED_HASHES" "$VRF_ALLOWED_HASHES"
958 fi
959 if [[ -n "$GPG_ALLOW_NEW_HASHES" ]] ; then
960 VRF_ALLOW_NEW_HASHES=$GPG_ALLOW_NEW_HASHES
961 modify_config $LOCAL_CONFIG "VRF_ALLOW_NEW_HASHES" "$VRF_ALLOW_NEW_HASHES"
962 fi
963 remove_config $LOCAL_CONFIG "GPG_ALLOWED_HASHES"
964 remove_config $LOCAL_CONFIG "GPG_ALLOW_NEW_HASHES"
965
966 DIALOG_LIST=""
967 if [[ -z "$VRF_ALLOWED_HASHES" ]]
968 then
969 for hash in $DEFAULT_LIST
970 do
971 DIALOG_LIST="${DIALOG_LIST}${hash} '${hash} was selected' on "
972 done
973 else
974 for hash in $DEFAULT_LIST
975 do
976 if list_find "$VRF_ALLOWED_HASHES" "${hash}:on"
977 then
978 DIALOG_LIST="${DIALOG_LIST}${hash} '${hash} was selected' on "
979 else
980 DIALOG_LIST="${DIALOG_LIST}${hash} '${hash} was not selected' off "
981 fi
982 done
983 fi
984 if [[ "$VRF_ALLOW_NEW_HASHES" == "on" ]]
985 then
986 DIALOG_LIST="new 'Allow new hashes was selected' on ${DIALOG_LIST}"
987 else
988 DIALOG_LIST="new 'Allow new hashes was not selected' off ${DIALOG_LIST}"
989 fi
990 CHECKS=$(eval $DIALOG ' --title "$DIALOG_TITLE" \
991 --checklist "$DIALOG_HELP" \
992 0 0 0 ' \
993 ${DIALOG_LIST})
994 rc="$?"
995 if [[ "$rc" == "0" ]]
996 then
997 VRF_ALLOWED_HASHES=""
998 CHECKS=${CHECKS//\"/}
999 if list_find "${CHECKS}" new
1000 then
1001 VRF_ALLOW_NEW_HASHES=on
1002 else
1003 VRF_ALLOW_NEW_HASHES=off
1004 fi
1005 for hash in ${DEFAULT_LIST}
1006 do
1007 if list_find "${CHECKS}" $hash
1008 then
1009 VRF_ALLOWED_HASHES="${VRF_ALLOWED_HASHES}${hash}:on "
1010 else
1011 VRF_ALLOWED_HASHES="${VRF_ALLOWED_HASHES}${hash}:off "
1012 fi
1013 done
1014 modify_local_config VRF_ALLOWED_HASHES "${VRF_ALLOWED_HASHES}"
1015 modify_local_config VRF_ALLOW_NEW_HASHES "${VRF_ALLOW_NEW_HASHES}"
1016 fi
1017 fi
1018 return 0
1019 }
1020
1021 function vrf_select_level() {
1022 local DIALOG_TITLE="Source Verification Level Checking"
1023 local DIALOG_HELP="Select the minimum level for source verification"
1024 local DIALOG_LIST=""
1025 local CHECKS level
1026 local rc=0
1027
1028 # move old values (named with GPG) to new ones
1029 # this can be removed after 11/26/05 (afk -- 10/26/05)
1030 if [[ -n "$GPG_ALLOWED_LEVELS" ]] ; then
1031 VRF_ALLOWED_LEVELS=$GPG_ALLOWED_LEVELS
1032 modify_config $LOCAL_CONFIG "VRF_ALLOWED_LEVELS" "$VRF_ALLOWED_LEVELS"
1033 fi
1034 if [[ -n "$GPG_ALLOW_NEW_LEVELS" ]] ; then
1035 VRF_ALLOW_NEW_LEVELS=$GPG_ALLOW_NEW_LEVELS
1036 modify_config $LOCAL_CONFIG "VRF_ALLOW_NEW_LEVELS" "$VRF_ALLOW_NEW_LEVELS"
1037 fi
1038 remove_config $LOCAL_CONFIG "GPG_ALLOWED_LEVELS"
1039 remove_config $LOCAL_CONFIG "GPG_ALLOW_NEW_LEVELS"
1040
1041 DIALOG_LIST=""
1042 if [[ -z "$VRF_ALLOWED_LEVELS" ]]
1043 then
1044 for level in $VERIFY_SPELL_LEVELS
1045 do
1046 DIALOG_LIST="${DIALOG_LIST}${level} '${level} was selected' on "
1047 done
1048 else
1049 for level in $VERIFY_SPELL_LEVELS
1050 do
1051 if list_find "$VRF_ALLOWED_LEVELS" "${level}:on"
1052 then
1053 DIALOG_LIST="${DIALOG_LIST}${level} '${level} was selected' on "
1054 else
1055 DIALOG_LIST="${DIALOG_LIST}${level} '${level} was not selected' off "
1056 fi
1057 done
1058 fi
1059 if [[ "$VRF_ALLOW_NEW_LEVELS" == "on" ]]
1060 then
1061 DIALOG_LIST="new 'Allow new levels was selected' on ${DIALOG_LIST}"
1062 else
1063 DIALOG_LIST="new 'Allow new levels was not selected' off ${DIALOG_LIST}"
1064 fi
1065 CHECKS=$(eval $DIALOG ' --title "$DIALOG_TITLE" \
1066 --checklist "$DIALOG_HELP" \
1067 0 0 0 \
1068 '${DIALOG_LIST})
1069 rc="$?"
1070 if [[ "$rc" == "0" ]]
1071 then
1072 VRF_ALLOWED_LEVELS=""
1073 CHECKS=${CHECKS//\"/}
1074 if list_find "${CHECKS}" new
1075 then
1076 VRF_ALLOW_NEW_LEVELS=on
1077 else
1078 VRF_ALLOW_NEW_LEVELS=off
1079 fi
1080 for level in ${VERIFY_SPELL_LEVELS}
1081 do
1082 if list_find "${CHECKS}" $level
1083 then
1084 VRF_ALLOWED_LEVELS="${VRF_ALLOWED_LEVELS}${level}:on "
1085 else
1086 VRF_ALLOWED_LEVELS="${VRF_ALLOWED_LEVELS}${level}:off "
1087 fi
1088 done
1089 modify_local_config VRF_ALLOWED_LEVELS "${VRF_ALLOWED_LEVELS}"
1090 modify_local_config VRF_ALLOW_NEW_LEVELS "${VRF_ALLOW_NEW_LEVELS}"
1091 fi
1092 return 0
1093 }
1094
1095 integrity_menu() {
1096
1097 local INT_TITLE="Integrity Checking Selection Menu"
1098 local INT_HELP="Options involving integrity checking, including --fix and download options."
1099 local FIX_HELP="Set cleanse --fix checks"
1100 local DL_HELP="Discover corrupted or modified archives during cast"
1101 local GPG_HELP="Verify GnuPG signatures on sorcery/grimoire tarballs"
1102 local SGPG_HELP="Verify GnuPG signatures on spell source tarballs"
1103 local HGPG_HELP="Verify GnuPG signatures with selected hashs"
1104
1105 while INT_CHECKS=`eval $DIALOG ' --title "$INT_TITLE" \
1106 --cancel-label "Exit" \
1107 --ok-label "Select" \
1108 --item-help \
1109 --menu \
1110 "$INT_HELP" \
1111 0 0 0 \
1112 "F" "System integrity" "$FIX_HELP" \
1113 "D" "Download integrity" "$DL_HELP" \
1114 "G" "Sorcery GPG Signature Checking" "$GPG_HELP" \
1115 "S" "Spell Source Verification Level Checking" "$SGPG_HELP" \
1116 "M" "Spell Source Hash List" "$HGPG_HELP"'`
1117 do
1118 case $INT_CHECKS in
1119 F) integrity_fix_menu ;;
1120 D) integrity_download_menu ;;
1121 G) gpg_download_menu ;;
1122 S) vrf_select_level ;;
1123 M) vrf_select_hashes ;;
1124 esac
1125 done
1126
1127 }
1128
1129 set_email() {
1130
1131 if SORCERER=`eval $DIALOG ' --ok-label "Commit" \
1132 --inputbox \
1133 "Please enter the email address of the person or role account
1134 that should receive reports from this box." \
1135 0 0 "$SORCERER"'`
1136 then
1137
1138 modify_local_config "SORCERER" "$SORCERER"
1139
1140 fi
1141
1142 }
1143
1144 function service_defaults() {
1145 local INSTALL_INIT_HELP="Install init.d scripts by default?"
1146 local ENABLE_INIT_HELP="If an init.d script is being installed, also enable it by default?"
1147 local INSTALL_XINETD_HELP="Install xinetd scripts by default?"
1148 local ENABLE_XINETD_HELP="If an xinetd script is being installed, also enable it by default?"
1149 local INIT_VS_XINETD="If both xinetd or init.d scripts exist, prefer xinetd over init.d?"
1150
1151 local MENU_TITLE="Init.d/Xinetd Default Answer Selection Menu"
1152 local MENU_INFO="Choose your defaults\nPer spell answers are remembered on recasts"
1153 local RESULT RESULTS TMP i
1154 if RESULTS=`eval $DIALOG '--item-help \
1155 --backtitle backtitle \
1156 --separate-output \
1157 --title "$MENU_TITLE" \
1158 --checklist "$MENU_INFO" \
1159 0 0 0 \
1160 "INSTALL_INIT" "Install init.d scripts by default" \
1161 "$DEF_INSTALL_INIT" "$INSTALL_INIT_HELP" \
1162 "ENABLE_INIT" "Enable init.d scripts by default" \
1163 "$DEF_ENABLE_INIT" "$ENABLE_INIT_HELP" \
1164 "INSTALL_XINETD" "Install xinetd scripts by default" \
1165 "$DEF_INSTALL_XINETD" "$INSTALL_XINETD_HELP" \
1166 "ENABLE_XINETD" "Enable xinetd scripts by default" \
1167 "$DEF_ENABLE_XINETD" "$INSTALL_XINETD_HELP" \
1168 "INIT_VS_XINETD" "Prefer xinetd over init.d" \
1169 "$DEF_INIT_VS_XINETD" "$INIT_VS_XINETD"'`
1170 then
1171
1172 TEMP=(DEF_INSTALL_INIT DEF_ENABLE_INIT DEF_INSTALL_XINETD DEF_ENABLE_XINETD DEF_INIT_VS_XINETD)
1173 for i in ${TEMP[*]} ; do
1174 eval $i=off
1175 done
1176
1177 for RESULT in $RESULTS; do
1178
1179 case $RESULT in
1180 INSTALL_INIT) DEF_INSTALL_INIT=on ;;
1181 ENABLE_INIT) DEF_ENABLE_INIT=on ;;
1182 INSTALL_XINETD) DEF_INSTALL_XINETD=on ;;
1183 ENABLE_XINETD) DEF_ENABLE_XINETD=on ;;
1184 INIT_VS_XINETD) DEF_INIT_VS_XINETD=on ;;
1185 esac
1186
1187 done
1188 for i in ${TEMP[*]} ; do
1189 modify_local_config "$i" "${!i}"
1190 done
1191 fi
1192 }
1193
1194 function parallel_compilation_menu() {
1195 local RESULTS KEY rc
1196 local TITLE="Parallel/Distributed Compilation Options Menu"
1197 local HELP="Number of make jobs is\n((length of DISTCC_HOSTS)*JOBS_PER_HOST+EXTRA_JOBS)\nIf distcc is disabled by a spell, then the number of make jobs is EXTRA_JOBS, it is recommended that you dont set it to zero. If the number of jobs totals to zero make will run an unlimited number of jobs."
1198
1199 while true ; do
1200 # input box returns things of the form "RENAMED CFLAGS -O3 -march=foo ..."
1201 # the ( ) interprits as an array, then using the magic power of set we
1202 # get to use shift and $@ to get things done
1203 RESULTS=(`eval $DIALOG ' --extra-label Adjust --inputmenu \
1204 "$TITLE\n$HELP" \
1205 23 70 9 \
1206 DISTCC_HOSTS "$DISTCC_HOSTS" \
1207 JOBS_PER_HOST "$JOBS_PER_HOST" \
1208 EXTRA_JOBS "$MAKE_NJOBS" \
1209 CCACHE_DIR "$CCACHE_DIR"'`)
1210 rc=$?
1211
1212 [[ $rc == 0 ]] || [[ $rc == 1 ]] && break
1213 set ${RESULTS[*]}
1214 KEY=$2
1215 shift 2
1216 case "$KEY" in
1217 DISTCC_HOSTS) DISTCC_HOSTS="$@" ;;
1218 JOBS_PER_HOST) JOBS_PER_HOST="$@" ;;
1219 EXTRA_JOBS) MAKE_NJOBS="$@" ;;
1220 CCACHE_DIR) CCACHE_DIR="$@" ;;
1221 esac
1222 done
1223
1224 # only commit values if user selected "OK"
1225 if [ $rc == 0 ] ; then
1226 modify_config $LOCAL_COMPILE_CONFIG DISTCC_HOSTS "$DISTCC_HOSTS"
1227 modify_config $LOCAL_COMPILE_CONFIG JOBS_PER_HOST "$JOBS_PER_HOST"
1228 modify_config $LOCAL_COMPILE_CONFIG MAKE_NJOBS "$MAKE_NJOBS"
1229 modify_config $LOCAL_COMPILE_CONFIG CCACHE_DIR "$CCACHE_DIR"
1230 fi
1231 }
1232
1233 set_branch() {
1234
1235 local D_HELP="Nightly devel snapshots"
1236 local T_HELP="Current release candidate or stable release"
1237 local S_HELP="Current stable version"
1238 local C_HELP="Choose a custom version"
1239
1240 while
1241
1242
1243 COMMAND=`eval $DIALOG ' --title "Currently tracking : $SORCERY_BRANCH " \
1244 --item-help \
1245 --ok-label "Select" \
1246 --cancel-label "Exit" \
1247 --menu \
1248 "" \
1249 0 0 0 \
1250 "S" "Stable Branch" "$S_HELP" \
1251 "T" "Test Branch" "$T_HELP" \
1252 "D" "Devel Branch" "$D_HELP" \
1253 "C" "Custom Branch" "$C_HELP"'`
1254
1255 do
1256
1257 case $COMMAND in
1258
1259 S) modify_local_config "SORCERY_BRANCH" "stable" &&
1260 SORCERY_BRANCH="stable" ;;
1261 T) modify_local_config "SORCERY_BRANCH" "test" &&
1262 SORCERY_BRANCH="test" ;;
1263 D) modify_local_config "SORCERY_BRANCH" "devel" &&
1264 SORCERY_BRANCH="devel" ;;
1265 C) set_custom_branch ;;
1266
1267 esac
1268
1269 done
1270
1271 }
1272
1273 set_custom_branch() {
1274
1275 local C_HELP="Please choose the sorcery release/version you want to use, this can be anything you want from download.sourcemage.org/sorcery/sorcery-<version>.tar.bz2"
1276 while
1277
1278 COMMAND=`eval $DIALOG ' --title "Currently tracking : $SORCERY_BRANCH " \
1279 --item-help \
1280 --ok-label "Select" \
1281 --cancel-label "Exit" \
1282 --inputbox \
1283 "$C_HELP" \
1284 0 0 \
1285 "$SORCERY_BRANCH"'`
1286
1287 do
1288
1289 modify_local_config "SORCERY_BRANCH" "$COMMAND" &&
1290 SORCERY_BRANCH="$COMMAND"
1291
1292 done
1293
1294
1295 }
1296
1297
1298
1299 set_delay() {
1300
1301 if PROMPT_DELAY=`eval $DIALOG ' --ok-label "Commit" \
1302 --inputbox \
1303 "Please enter the time in seconds to wait for a response when prompted with a question." \
1304 0 0 "$PROMPT_DELAY"'`
1305 then
1306
1307 modify_local_config "PROMPT_DELAY" "$PROMPT_DELAY"
1308
1309 fi
1310
1311 }
1312
1313
1314 set_download_rate() {
1315
1316 local PROMPT="Please enter the maximum bytes per second for summoning"
1317
1318 if DOWNLOAD_RATE=`eval $DIALOG ' --ok-label "Commit" \
1319 --inputbox \
1320 "$PROMPT" \
1321 0 0 "$DOWNLOAD_RATE"'`
1322 then
1323
1324 modify_local_config "DOWNLOAD_RATE" "$DOWNLOAD_RATE"
1325
1326 fi
1327
1328 }
1329
1330 set_http_ftp_timeout() {
1331
1332 local PROMPT="Please enter maximum time (seconds) summon is to wait for each download server"
1333
1334 if URL_HTTP_FTP_TIMEOUT=`eval $DIALOG ' --ok-label "Commit" \
1335 --inputbox \
1336 "$PROMPT" \
1337 0 0 "$URL_HTTP_FTP_TIMEOUT"'`
1338 then
1339
1340 modify_local_config "URL_HTTP_FTP_TIMEOUT" "$URL_HTTP_FTP_TIMEOUT"
1341
1342 fi
1343
1344 }
1345
1346 queue_menu() {
1347
1348 local I_HELP="View the list of spells selected for installation"
1349 local i_HELP="Edit the list of spells selected for installation"
1350 local R_HELP="View the list of spells selected for removal"
1351 local r_HELP="Edit the list of spells selected for removal"
1352 local S_HELP="View the datafile of installed spells"
1353 local s_HELP="Edit the datafile of installed spell"
1354
1355 while
1356
1357 COMMAND=`eval $DIALOG ' --title "Queue Menu" \
1358 --ok-label "Select" \
1359 --cancel-label "Exit" \
1360 --default-item $COMMAND \
1361 --item-help \
1362 --menu \
1363 "" \
1364 0 0 0 \
1365 "I" "View install queue" "$I_HELP" \
1366 "i" "Edit install queue" "$i_HELP" \
1367 "R" "View removal queue" "$R_HELP" \
1368 "r" "Edit removal queue" "$r_HELP" \
1369 "S" "View spell status" "$S_HELP" \
1370 "s" "Edit spell status" "$s_HELP"'`
1371
1372 do
1373 lock_file $SPELL_STATUS
1374 lock_file $INSTALL_QUEUE
1375 lock_file $REMOVE_QUEUE
1376
1377 case $COMMAND in
1378 S) show_file $SPELL_STATUS ;;
1379 s) edit_file $SPELL_STATUS ;;
1380 I) show_file $INSTALL_QUEUE ;;
1381 i) edit_file $INSTALL_QUEUE ;;
1382 R) show_file $REMOVE_QUEUE ;;
1383 r) edit_file $REMOVE_QUEUE ;;
1384 esac
1385
1386 unlock_file $SPELL_STATUS
1387 unlock_file $INSTALL_QUEUE
1388 unlock_file $REMOVE_QUEUE
1389 done
1390
1391 }
1392
1393
1394 log_menu() {
1395
1396 local C_HELP="View compile logs of previously installed software"
1397 local G_HELP="Discover a file's origin"
1398 local I_HELP="View logs of files previously installed"
1399 local c_HELP="Remove a compile log"
1400 local i_HELP="Edit a log of files previously installed"
1401
1402 while
1403
1404 COMMAND=`eval $DIALOG ' --title "Log Menu" \
1405 --ok-label "Select" \
1406 --cancel-label "Exit" \
1407 --default-item $COMMAND \
1408 --item-help \
1409 --menu \
1410 "" \
1411 0 0 0 \
1412 "G" "Grep install logs" "$G_HELP" \
1413 "I" "View install log" "$I_HELP" \
1414 "i" "Edit install log" "$i_HELP" \
1415 "C" "View compile log" "$C_HELP" \
1416 "c" "Remove compile log" "$c_HELP"'`
1417
1418 do
1419
1420 case $COMMAND in
1421
1422 G) grep_install_logs ;;
1423 I) show_file `file_menu $INSTALL_LOGS` ;;
1424 i) edit_file `file_menu $INSTALL_LOGS` ;;
1425 C) show_file `file_menu $COMPILE_LOGS` ;;
1426 c) rm `file_menu $COMPILE_LOGS` ;;
1427
1428 esac
1429
1430 done
1431
1432 }
1433
1434 sorcery_devel_settings() {
1435
1436 local D_HELP="Set the debugging file for normal debugging."
1437 local S_HELP="Turn on Super Debug. You probably don't want to do this."
1438 local C_HELP="Change this to 0 to remove castfs debugging."
1439
1440 while
1441
1442 COMMAND=`eval $DIALOG '--title "Sorcery Development" \
1443 --ok-label "Select" \
1444 --cancel-label "Exit" \
1445 --default-item $COMMAND \
1446 --item-help \
1447 --menu \
1448 "" \
1449 0 0 0 \
1450 "D" "Debug file" "$D_HELP" \
1451 "S" "Super debugging toggle" "$S_HELP" \
1452 "C" "Castfs debuging level" "$C_HELP"'`
1453 do
1454
1455 case $COMMAND in
1456
1457 D) TEXT="Note: if you turn this on, don't forget to empty the log file occasionaly.\nWhat file do you want the debugging logged to?"
1458 FILE=`eval $DIALOG --ok-label "Commit" --inputbox \"$TEXT\" 0 0 \"$DEBUG\"` &&
1459 modify_local_config "DEBUG" "$FILE" ;;
1460 S) TEXT="Note: You don't want to do this probably. Don't forget to 2>/root/debug.out.\nDo you want super debugging on?"
1461 TOGGLE=`eval $DIALOG --yesno \"$TEXT\" 0 0` &&
1462 ( modify_local_config "SUPER_DEBUG" "on" ; modify_local_config "set" "-x" "command" ) ||
1463 ( modify_local_config "SUPER_DEBUG" "" ; modify_local_config "set" "+x" "command" ) ;;
1464 C) TEXT="Note: This is a numeric value that represents a mask to castfs, 0 means no debugging, 1 means file system debugging, 2 is lower level debugging, 3 means both. All other values are currently undefined."
1465 LEVEL=`eval $DIALOG --ok-label "Commit" --inputbox \"$TEXT\" 0 0 \"$CASTFS_DEBUG_LEVEL\"` &&
1466 modify_local_config "CASTFS_DEBUG_LEVEL" "$LEVEL" ;;
1467
1468 esac
1469
1470 done
1471
1472 }
1473
1474 function set_dl_handler() {
1475 local W_HELP="Use wget to download from urls using the http/ftp/https protocols"
1476 local A_HELP="Use aria2 to download from urls using the http/ftp/https protocols"
1477
1478 while
1479 COMMAND=$(eval $DIALOG '--title "Currently using: ${HTTP_DL_HANDLER:-wget}" \
1480 --item-help \
1481 --ok-label "Select" \
1482 --cancel-label "Exit" \
1483 --menu \
1484 "" \
1485 0 0 0 \
1486 "W" "wget (default)" "$W_HELP" \
1487 "A" "aria2" "$A_HELP"')
1488 do
1489 case $COMMAND in
1490 W) modify_local_config HTTP_DL_HANDLER wget &&
1491 HTTP_DL_HANDLER=wget ;;
1492 A)
1493 if ! spell_ok aria2; then
1494 local error_msg
1495 error_msg="aria2 is not installed on this system!\nIf you want"
1496 error_msg="$error_msg to use it, cast it first, then revisit"
1497 error_msg="$error_msg this menu.\n\nYour download handler choice"
1498 error_msg="$error_msg has not been saved!"
1499 eval "$DIALOG --msgbox \"\$error_msg\" 0 0"
1500 else
1501 modify_local_config HTTP_DL_HANDLER aria2 &&
1502 HTTP_DL_HANDLER=aria2
1503 fi ;;
1504 esac
1505 break
1506 done
1507 }
1508
1509 feature_menu() {
1510
1511 local B_HELP="Administrate groups of Unix/Linux boxes?"
1512 local C_HELP="Colorized messages on cast and dispel?"
1513 local D_HELP="Automatically gather miscellaneous documentation from spells"
1514 local E_HELP="Remove files when dispelling?"
1515 local F_HELP="Check for and repair broken programs after updating sorcery?"
1516 local G_HELP="Slower initial compilation, accelerated upgrade compilation?"
1517 local I_HELP="Create archives of installed software?"
1518 local L_HELP="Locally customize SPELL configuration?"
1519 local M_HELP="Email reports?"
1520 local P_HELP="Preserve modified files or backup them up and overwrite with defaults?"
1521 local R_HELP="Prompt to view reports?"
1522 local SCL_HELP="Store config.log in compile log?"
1523 local TMP_HELP="Attempt to compile entirely in RAM?"
1524 local T_HELP="Disallow dispelling of spells that would cause terrible malfunctions?"
1525 local U_HELP="Automatically remove old sources and install caches upon sorcery update?"
1526 local V_HELP="View compilation as it happens?"
1527 local NS_HELP="Use netselect to try fastest mirrors first if netselect is available?"
1528 local CS_HELP="Clean up source directories after failures?"
1529 local CI_HELP="Non-native installation / cross compilation"
1530 local ST_HELP="Set xterm title/screen window title on cast?"
1531 local UF_HELP="Ensure a sane environment before sorcery update"
1532 local SCR_HELP="Toggle usage of screen in cast"
1533 local PSC_HELP="Ask for custom cflags for each spell"
1534 local SHSQ_HELP="Show spell description option in queries for optional dependencies"
1535
1536 if TOGGLES=`eval $DIALOG ' --title "Feature Menu" \
1537 --no-cancel \
1538 --item-help \
1539 --separate-output \
1540 --checklist \
1541 "" \
1542 0 0 0 \
1543 "ARCHIVE" "Toggle" "$ARCHIVE" "$I_HELP" \
1544 "AUTOFIX" "Toggle" "$AUTOFIX" "$F_HELP" \
1545 "UPDATEFIX" "Toggle" "$UPDATEFIX" "$UF_HELP" \
1546 "AUTOPRUNE" "Toggle" "$AUTOPRUNE" "$U_HELP" \
1547 "CCACHE" "Toggle" "$CCACHE" "$G_HELP" \
1548 "COLOR" "Toggle" "$COLOR" "$C_HELP" \
1549 "CONFIG_LOC" "Toggle" "$CONFIG_LOC" "$L_HELP" \
1550 "GATHER_DOCS" "Toggle" "$GATHER_DOCS" "$D_HELP" \
1551 "MAIL_REPORTS" "Toggle" "$MAIL_REPORTS" "$M_HELP" \
1552 "PRESERVE" "Toggle" "$PRESERVE" "$P_HELP" \
1553 "SUSTAIN" "Toggle" "$SUSTAIN" "$T_HELP" \
1554 "TMPFS" "Toggle" "$TMPFS" "$TMP_HELP" \
1555 "VIEW_REPORTS" "Toggle" "$VIEW_REPORTS" "$R_HELP" \
1556 "VOYEUR" "Toggle" "$VOYEUR" "$V_HELP" \
1557 "REAP" "Toggle" "$REAP" "$E_HELP" \
1558 "STORE_CONF_LOG" "Toggle" "$STORE_CONF_LOG" "$SCL_HELP" \
1559 "NET_SELECT" "Toggle" "$NET_SELECT" "$NS_HELP" \
1560 "CLEAN_SOURCE" "Toggle" "$CLEAN_SOURCE" "$CS_HELP" \
1561 "CROSS_INSTALL" "Toggle" "$CROSS_INSTALL" "$CI_HELP" \
1562 "SET_TERM_TITLE" "Toggle" "$SET_TERM_TITLE" "$ST_HELP" \
1563 "SCREEN" "Toggle" "$SCREEN" "$SCR_HELP" \
1564 "PER_SPELL_CFLAGS" "Toggle" "$PER_SPELL_CFLAGS" "$PSC_HELP" \
1565 "SHOW_GAZE_SHORT_QUERY" "Toggle" "$SHOW_GAZE_SHORT_QUERY" "$SHSQ_HELP"'`
1566 then
1567 TEMP=(ARCHIVE AUTOFIX UPDATEFIX AUTOPRUNE CCACHE COLOR CONFIG_LOC GATHER_DOCS MAIL_REPORTS PRESERVE SUSTAIN TMPFS VIEW_REPORTS VOYEUR REAP STORE_CONF_LOG NET_SELECT CLEAN_SOURCE CROSS_INSTALL SET_TERM_TITLE SCREEN PER_SPELL_CFLAGS SHOW_GAZE_SHORT_QUERY)
1568 for i in ${TEMP[*]} ; do
1569 eval $i=off
1570 done
1571
1572 for TOGGLE in $TOGGLES; do
1573 eval $TOGGLE=on
1574 done
1575
1576 for i in ${TEMP[*]} ; do
1577 case $i in
1578 CCACHE) modify_config $LOCAL_COMPILE_CONFIG CCACHE $CCACHE ;;
1579 COLOR) modify_config $LOCAL_MEDIA_CONFIG "color" "$COLOR" "command" ;;
1580 *) modify_local_config "$i" "${!i}" ;;
1581 esac
1582 done
1583 fi
1584
1585 }
1586
1587 option_menu() {
1588
1589 local B_HELP="Specify the sorcery branch you would like to track"
1590 local H_HELP="Specify the color scheme for messages"
1591 local D_HELP="Enter the default delay time for prompts"
1592 local E_HELP="Enter the email address for this box's sorcerer"
1593 local F_HELP="Select many options on or off at once"
1594 local M_HELP="Select ftp and http mirrors for faster downloads"
1595 local O_HELP="Select architecture optimizations"
1596 local I_HELP="Select the test that cleanse --fix, and AUTOFIX execute"
1597 local J_HELP="User defined defaults for depends following"
1598 local C_HELP="Setup distributed compilation"
1599 local R_HELP="Enter the maximum rate for downloading"
1600 local T_HELP="Select compression program for logs and archives"
1601 local N_HELP="Enter the process priority (nice value) to use for sorcery"
1602 local U_HELP="Enter the permissions mask (umask value) to use for sorcery"
1603 local S_HELP="Sorcery development options (debugging)"
1604 local W_HELP="Enter maximum timeout (seconds) for summoning sources"
1605 local Y_HELP="Select the default http/https/ftp download handler"
1606 local X_HELP="Init.d/Xinetd Default Answer Selection Menu"
1607 local Z_HELP="Select sorcery sound scheme"
1608
1609 while
1610
1611 COMMAND=`eval $DIALOG ' --title "Option Menu" \
1612 --item-help \
1613 --ok-label "Select" \
1614 --cancel-label "Exit" \
1615 --menu \
1616 "" \
1617 0 0 0 \
1618 "B" "Sorcery Branch" "$B_HELP" \
1619 "H" "Color Scheme" "$H_HELP" \
1620 "D" "Prompt Delay" "$D_HELP" \
1621 "R" "Download Rate" "$R_HELP" \
1622 "N" "Nice Level" "$N_HELP" \
1623 "U" "Umask Value" "$U_HELP" \
1624 "E" "Email of Sorcerer" "$E_HELP" \
1625 "F" "Feature Menu" "$F_HELP" \
1626 "I" "Integrity Checking" "$I_HELP" \
1627 "C" "Parallel/Cached/Distributed Compiling" "$C_HELP" \
1628 "J" "Dependency Following" "$J_HELP" \
1629 "M" "Software Mirrors" "$M_HELP" \
1630 "O" "Optimize Architecture" "$O_HELP" \
1631 "T" "Compression Type" "$T_HELP" \
1632 "S" "Sorcery Development" "$S_HELP" \
1633 "W" "Summon Timeout Value" "$W_HELP" \
1634 "Y" "Default download tool" "$Y_HELP" \
1635 "X" "init.d xinetd.d defaults" "$X_HELP" \
1636 "Z" "Select Sound Scheme" "$Z_HELP"'`
1637
1638 do
1639
1640 case $COMMAND in
1641
1642 B) set_branch ;;
1643 H) color_schemes_menu ;;
1644 D) set_delay ;;
1645 R) set_download_rate ;;
1646 N) set_nice ;;
1647 U) set_umask ;;
1648 E) set_email ;;
1649 F) feature_menu ;;
1650 I) integrity_menu ;;
1651 J) dispel_depends_defaults_menu ;;
1652 C) parallel_compilation_menu ;;
1653 M) mirror_menu ;;
1654 O) optimize_architecture ;;
1655 S) sorcery_devel_settings ;;
1656 T) set_compression_type ;;
1657 W) set_http_ftp_timeout ;;
1658 Y) set_dl_handler ;;
1659 X) service_defaults ;;
1660 Z) sound_schemes_menu ;;
1661
1662 esac
1663
1664 done
1665
1666 }
1667
1668
1669 goodbye() {
1670
1671 echo "Have a sorcerous day."
1672 exit
1673
1674 }
1675
1676
1677 background_execute() {
1678
1679 eval "$DIALOG --msgbox \"Processing queues in the background.\" 0 0"
1680
1681 [[ -s $REMOVE_QUEUE ]] &&
1682 dispel `cat $REMOVE_QUEUE` 1>/dev/null 2>&1
1683 rm -f $REMOVE_QUEUE
1684
1685 if [[ -s $INSTALL_QUEUE ]]; then
1686 cast --deps `cat $INSTALL_QUEUE`
1687 ( cast `cat $INSTALL_QUEUE` 1>/dev/null 2>&1 &&
1688 rm $INSTALL_QUEUE
1689 ) &
1690 fi
1691
1692 goodbye
1693
1694 }
1695
1696
1697 foreground_execute() {
1698
1699 [[ -s $REMOVE_QUEUE ]] &&
1700 dispel `cat $REMOVE_QUEUE`
1701 rm -f $REMOVE_QUEUE
1702
1703 [[ -s $INSTALL_QUEUE ]] &&
1704 cast `cat $INSTALL_QUEUE`
1705 rm -f $INSTALL_QUEUE
1706
1707 goodbye
1708
1709 }
1710
1711
1712 main_menu() {
1713
1714 local S_HELP="Easy spell management."
1715 local O_HELP="Change sorcery options and features."
1716 local L_HELP="View and edit sorcery generated log files."
1717 local Q_HELP="View and edit sorcery queues."
1718 local F_HELP="Process queues while you watch and wait."
1719 local B_HELP="Process queues in the background."
1720 local E_HELP="Exit without processing queues."
1721 local I_HELP="Setting your install/state/track root locations"
1722 local C_HELP="Administrate groups of Unix/Linux boxes."
1723 local OK="Select"
1724 local CANCEL="Exit"
1725
1726 while
1727 COMMAND=`eval $DIALOG ' --title "Main Menu" \
1728 --item-help \
1729 --ok-label "$OK" \
1730 --cancel-label "$CANCEL" \
1731 --menu \
1732 "Sorcery Version $SORCERY_VERSION" \
1733 0 0 0 \
1734 "S" "Spell Menu" "$S_HELP" \
1735 "O" "Option Menu" "$O_HELP" \
1736 "L" "Log Menu" "$L_HELP" \
1737 "Q" "Queue Menu" "$Q_HELP" \
1738 "F" "Foreground Execute" "$F_HELP" \
1739 "B" "Background Execute" "$B_HELP" \
1740 "I" "Install Root Menu" "$I_HELP"'`
1741 do
1742
1743 case $COMMAND in
1744 S) spell_menu ;;
1745 O) option_menu ;;
1746 L) log_menu ;;
1747 Q) queue_menu ;;
1748 F) foreground_execute ;;
1749 B) background_execute ;;
1750 I) install_root_menu ;;
1751 esac
1752
1753 done
1754
1755 }
1756
1757
1758
1759 #---------------------------------------------------------------------
1760 #-item sorcery_hold_spells <spells>
1761 ##
1762 ## sets <spells>'s status to held
1763 ##
1764 ## cli function
1765 #---------------------------------------------------------------------
1766 sorcery_hold_spells () {
1767 set_held $@
1768 }
1769
1770
1771 #---------------------------------------------------------------------
1772 #-item sorcery_unhold_spells <spells>
1773 ##
1774 ## unholds <spells>'s status. (Sets it to installed)
1775 ##
1776 ## cli function
1777 #---------------------------------------------------------------------
1778 sorcery_unhold_spells () {
1779 set_unheld $@
1780 }
1781
1782
1783 #---------------------------------------------------------------------
1784 #-item sorcery_set_default <spells>
1785 ##
1786 ## Used for setting default_depends/providers
1787 ##
1788 ## cli function
1789 #---------------------------------------------------------------------
1790 sorcery_cli_defaults () {
1791 local cmd=$1
1792 shift
1793 case $cmd in
1794 add) sorcery_add_defaults "$@" ;;
1795 search) sorcery_search_defaults "$@" ;;
1796 remove) sorcery_remove_defaults "$@" ;;
1797 *) help">help">help ;;
1798 esac
1799 }
1800
1801 #---------------------------------------------------------------------
1802 #-item sorcery_add_default <spells>
1803 ##
1804 ## Used for setting default_depends/providers
1805 ##
1806 ## cli function
1807 #---------------------------------------------------------------------
1808 sorcery_add_defaults () {
1809 if [ $# -ne 3 ] ; then
1810 message "${PROBLEM_COLOR}Wrong number of arguments.${DEFAULT_COLOR}"
1811 help">help">help
1812 fi
1813
1814
1815 # check for this first as a slight optimization
1816 if [[ $3 != on ]] && [[ $3 != off ]] ; then
1817 message "${PROBLEM_COLOR}Please choose on or off.${DEFAULT_COLOR}"
1818 help">help">help
1819 fi
1820
1821 if [[ ! $1 ]] && [[ ! $2 ]] ; then
1822 message "${PROBLEM_COLOR}Can't set anything to be the default" \
1823 "for everything!${DEFAULT_COLOR}"
1824 fi
1825
1826 if [[ $1 ]] && ! codex_does_spell_exist $1; then
1827 #echo "$1 is not a spell" # already printed by codex_does_spell_exist
1828 help">help">help
1829 fi
1830
1831 if [[ ! $2 ]] || codex_does_spell_exist $2 &>/dev/null; then
1832 add_default_depends $DEFAULT_DEPENDS "$@"
1833 elif codex_does_service_exist $2 ; then
1834 add_default_provider $DEFAULT_PROVIDERS "$@"
1835 else
1836 message "${SPELL_COLOR}$2${PROBLEM_COLOR} is not a valid choice." \
1837 "Please choose a spell, provider, or \"\".${DEFAULT_COLOR}"
1838 help">help">help
1839 fi || echo "Unknown error occured, contact the sorcery team"
1840 }
1841
1842 #---------------------------------------------------------------------
1843 #-item sorcery_search_default <spells>
1844 ##
1845 ## Used for searching default_depends/providers
1846 ##
1847 ## cli function
1848 #---------------------------------------------------------------------
1849 sorcery_search_defaults () {
1850 # it wont hurt to look in both
1851 if [[ -z $1 ]]; then
1852 cat $DEFAULT_DEPENDS $DEFAULT_PROVIDERS 2>/dev/null
1853 else
1854 search_default_depends $DEFAULT_DEPENDS "$@"
1855 search_default_provider $DEFAULT_PROVIDERS "$@"
1856 fi
1857 }
1858
1859 #---------------------------------------------------------------------
1860 #-item sorcery_remove_default <spells>
1861 ##
1862 ## Used for removing default_depends/providers
1863 ##
1864 ## cli function
1865 #---------------------------------------------------------------------
1866 sorcery_remove_defaults () {
1867 remove_default_depends $DEFAULT_DEPENDS "$@"
1868 remove_default_provider $DEFAULT_PROVIDERS "$@"
1869 }
1870
1871 #---------------------------------------------------------------------
1872 #-item sorcery_queue_add <spells>
1873 ##
1874 ## Used for adding spells to install queue
1875 ##
1876 ## cli function
1877 #---------------------------------------------------------------------
1878 sorcery_queue_add() {
1879 lock_start_transaction "$INSTALL_QUEUE" tINSTALL_QUEUE
1880 for SPELL in "$@"; do
1881 grep -qE "^$SPELL\$" "$tINSTALL_QUEUE" || echo "$SPELL" >> "$tINSTALL_QUEUE"
1882 done
1883 lock_commit_transaction "$INSTALL_QUEUE"
1884 }
1885
1886 #---------------------------------------------------------------------
1887 #-item sorcery_queue_remove <spells>
1888 ##
1889 ## Used for removing spells from install queue
1890 ##
1891 ## cli function
1892 #---------------------------------------------------------------------
1893 sorcery_queue_remove() {
1894 lock_start_transaction "$INSTALL_QUEUE" tINSTALL_QUEUE
1895 for SPELL in "$@"; do
1896 if grep -qE "^$SPELL\$" "$tINSTALL_QUEUE"; then
1897 grep -vE "^$SPELL\$" "$tINSTALL_QUEUE" > "$TMP_DIR/tmp_queue"
1898 mv "$TMP_DIR/tmp_queue" "$tINSTALL_QUEUE"
1899 else
1900 message "${PROBLEM_COLOR}Spell ${SPELL_COLOR}$SPELL${PROBLEM_COLOR} not found in install queue!${DEFAULT_COLOR}"
1901 fi
1902 done
1903 lock_commit_transaction "$INSTALL_QUEUE"
1904 }
1905
1906 #---------------------------------------------------------------------
1907 ## Make sure the parameters are ok. Used for verification before the
1908 ## user is asked for the su password to avoid futile su-ing.
1909 #---------------------------------------------------------------------
1910 verify_parameters() {
1911 [[ -z $1 ]] && return 0
1912
1913 case $1 in
1914 -u|update|-s|system-update|-g|upgrade) true ;;
1915 -q|queue|queue-security) true ;;
1916 -r|rebuild|-rr|rebuild-reconfigure) true ;;
1917 add-queue|remove-queue|review-queue) true ;;
1918 hold|unhold|exile|unexile) true ;;
1919 default*) true ;;
1920 *) help">help">help ;;
1921 esac
1922 }
1923
1924
1925 main">main">main">main">main() {
1926
1927 rm -f $UPDATE_SCRIPT
1928
1929 if [ -z $1 ]; then
1930 main_menu
1931 else
1932 case $1 in
1933 -u|update) update_sorcery ;;
1934 -s|system-update) update_pkgs autoupdate ;;
1935 -g|upgrade) update_pkgs upgrade ;;
1936 -q|queue) update_queue ;;
1937 queue-security) update_security_queue ;;
1938 -r|rebuild) rebuild ;;
1939 -rr|rebuild-reconfigure) rebuild -r ;;
1940 review-queue) install_queue_history ;;
1941 add-queue) shift; sorcery_queue_add "$@" ;;
1942 remove-queue) shift; sorcery_queue_remove "$@" ;;
1943 hold) shift; sorcery_hold_spells "$@" ;;
1944 unhold) shift; sorcery_unhold_spells "$@" ;;
1945 exile) shift; set_exiled $@ ;;
1946 unexile) shift; set_unexiled $@ ;;
1947 default*) shift; sorcery_cli_defaults "$@" ;;
1948
1949 -h|--help|help">help">help) help">help">help ;;
1950 -v|--version|version) echo $SORCERY_VERSION ;;
1951 *) help">help">help ;;
1952 esac
1953 fi
1954
1955 }
1956
1957 . /etc/sorcery/config
1958 if [ "$UID" == 0 ]; then
1959 DIALOG='$DIALOGPROG --backtitle "Sorcery Spell Management Utility" --stdout'
1960
1961 SORCERY_VERSION=`cat /etc/sorcery/version`
1962 mk_tmp_dirs sorcery
1963 main">main">main">main">main "$@"
1964 rc=$?
1965 cleanup_tmp_dir $TMP_DIR
1966 exit $rc
1967 else
1968 if [[ $1 == -h ]] || [[ $1 == --help ]] || [[ $1 == help">help">help ]]; then
1969 help">help">help
1970 else
1971 if [[ $1 == -v ]] || [[ $1 == --version ]] || [[ $1 == version ]]; then
1972 cat /etc/sorcery/version
1973 else
1974 # validate the rest of the parameters before su-ing
1975 verify_parameters "$@"
1976
1977 echo "Enter the root password, please."
1978 PARAMS=$(consolidate_params "$@")
1979 exec su -c "sorcery $PARAMS" root
1980 fi
1981 fi
1982 fi
1983
1984
1985 #---------------------------------------------------------------------
1986 ##=back
1987 ##
1988 ##=head1 LICENSE
1989 ##
1990 ## This software is free software; you can redistribute it and/or modify
1991 ## it under the terms of the GNU General Public License as published by
1992 ## the Free Software Foundation; either version 2 of the License, or
1993 ## (at your option) any later version.
1994 ##
1995 ## This software is distributed in the hope that it will be useful,
1996 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
1997 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1998 ## GNU General Public License for more details.
1999 ##
2000 ## You should have received a copy of the GNU General Public License
2001 ## along with this software; if not, write to the Free Software
2002 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2003 ##
2004 #---------------------------------------------------------------------