Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (f4503b5d881b6bee8ef1611e54125fd21044852b)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (f4503b5d881b6bee8ef1611e54125fd21044852b)
  • Date: Sat, 3 Jan 2009 05:22:53 -0600

GIT changes to test cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

iso/usr/share/doc/smgl.install/steps/select-spells | 19 --
iso/usr/share/smgl.install/smgl-chroot | 4
iso/usr/share/smgl.install/smgl-enchant | 10 +
iso/usr/share/smgl.install/smgl-spellcaster | 180
++++++++++++---------
4 files changed, 127 insertions(+), 86 deletions(-)

New commits:
commit f4503b5d881b6bee8ef1611e54125fd21044852b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: update info message

Updated the info message displayed at startup to match the current
implementation.

commit e7064a0ef1a7e9663e5ef8caefcf8045c57ca2cf
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: reimplement

Reimplemented the major functions (parsing and processing the input).
The script is now much more correct/accurate, and allows for more
features at the same time.

commit 773a2440f9aae204c6071f14675c521e8a0493e6
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: better uniqing

sort can handle uniq'ing itself, and since we are running sort anyway,
we should kill 2 birds with 1 stone. Also, sort can safely output to the
same file it reads from, whereas the I/O redirection here before would
cause there to be an empty file. Additionally, test to make sure the
file exists before trying to operate on it.

commit 6a41270e8914a037c91b2b8f05d1c517e72388d1
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: don't cast anything

This script should only build the list of the spells the user wants to
have. It shouldn't operate on any of them. smgl-enchant is for that.

commit b52a2b60d3be41b16baddb375d6c018aaab3d98a
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: less > more

Use less instead of more, because more was causing runtime bugs due to
its own faults.

commit cded4720f74e66f77a6a94221a8e270c74fe78a2
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: test file exists

Check to see if /tmp/spells exists before trying to read it on startup.

commit ea749fd2579975c964c5eff0e44724c7a7674868
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-spellcaster: use cache file

Create and make use of a cache file that stores the results of scanning
/var/cache/sorcery to speed up the script. Unfortunately the big speed
hit at script startup is with reading /tmp/spells to load saved
settings.

commit 5d3edc0f648cf6bf9b2078941fe6034126d77adb
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

steps/select-spells: smgl-spells, /tmp/spells

Changed opt-spells to spells, and changed the info to match smgl-spells.

commit 0578a29de9e6d9c3235fd4c2e089c1cd7f40f5ad
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-chroot: fix quoting, rc handling

Fixed the quoting with setting the target dir, and removed the forced
exit $? usage.

commit 4eeb6340ff3c1a96840511559775cb9aec149727
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

smgl.install/smgl-enchant: install system.tar.bz2

By default, install system.tar.bz2, as it's kind of required in order to
be able to source the proper sorcery routines. Added an option to
operate on caches only, with the assumption that system.tar.bz2 would
already be installed.

diff --git a/iso/usr/share/doc/smgl.install/steps/select-spells
b/iso/usr/share/doc/smgl.install/steps/select-spells
index b4486ed..5c52163 100644
--- a/iso/usr/share/doc/smgl.install/steps/select-spells
+++ b/iso/usr/share/doc/smgl.install/steps/select-spells
@@ -1,22 +1,19 @@
select-spells step
You may now select the spells you would like that are provided on the ISO.
There are currently two ways that you can accomplish this. Both methods make
-use of /tmp/opt-spells. Note that it is crucial to install some spells (such
as
-a bootloader) or your system may not function, so some of these have been
-included as defaults in /tmp/opt-spells.
+use of /tmp/spells. Note that it is crucial to install some spells (such as a
+bootloader) or your system may not function, so some of these have been
+included as defaults in /tmp/spells.

-The menu will present a list of the spells available on the ISO, as well as
-mark which ones are selected for install. The menu is accessed as follows.
-
-menu:
- alchemy
+text menu:
+ smgl-spells

manual:
- $EDITOR /tmp/opt-spells
+ $EDITOR /tmp/spells

You can of course use any editor you like, in case you haven't set $EDITOR.

-You can re-edit /tmp/opt-spells any time during the install session and it
will
-remember your changes each time. Likewise, you may re-run alchemy.
+You can re-edit /tmp/spells any time during the install session and it will
+remember your changes each time. Likewise, you may re-run smgl-spells.

When you are finished selecting your spells, type next.
diff --git a/iso/usr/share/smgl.install/smgl-chroot
b/iso/usr/share/smgl.install/smgl-chroot
index 6744361..8639e79 100755
--- a/iso/usr/share/smgl.install/smgl-chroot
+++ b/iso/usr/share/smgl.install/smgl-chroot
@@ -2,7 +2,7 @@

# Check if called with optional argument,
# If yes then R00T=$1, else ROOT=/mnt/root
-ROOT=${"$1":-/mnt/root}
+ROOT="${1:-/mnt/root}"

# Note: don't use --rbind: It creates several mounts, and we wouldn't be able
# to figure out easily what to umount.
@@ -14,13 +14,11 @@ mount --bind /proc "$ROOT"/proc &&
export PS1="[inside chroot, type exit to return to installer]\n\u
\w\$ " &&

chroot "$ROOT" "$@"
-rc=$?

# clean up the chroot mounts
umount "$ROOT"/proc
umount "$ROOT"/dev/pts
umount "$ROOT"/dev

-exit $rc

# vim:sw=2:ts=2:softtabstop=2:expandtab:ai
diff --git a/iso/usr/share/smgl.install/smgl-enchant
b/iso/usr/share/smgl.install/smgl-enchant
index 5450100..9a3d535 100755
--- a/iso/usr/share/smgl.install/smgl-enchant
+++ b/iso/usr/share/smgl.install/smgl-enchant
@@ -12,6 +12,8 @@ command-line, you must give the full cache filename, and
caches with
an extension of .tar.bz2 are expected.

Options:
+ -c If specified, system.tar.bz2 will not be installed (cache only).
+
-d Path to target directory. Defaults to /mnt/root.

-h Shows this help information
@@ -49,9 +51,10 @@ function generate_state() {
done
}

-while getopts ":d:h" Option
+while getopts ":cd:h" Option
do
case $Option in
+ c ) NOSYS="yes" ;;
d ) TARGET="$OPTARG" ;;
h ) usage ;;
* ) echo "Unrecognized option." >&2 && usage ;;
@@ -64,6 +67,11 @@ CACHE_LIST="${CACHE_LIST:-/tmp/spells}"
TABLETS="${TABLETS:-/tmp/tablets}"
TARGET="${TARGET:-/mnt/root}"

+if [[ ! $NOSYS == "yes" ]]
+then
+ tar xjvf /system.tar.bz2 -C "$TARGET"
+fi
+
. "$TARGET"/etc/sorcery/config ||
die "Couldn't source $TARGET/etc/sorcery/config"

diff --git a/iso/usr/share/smgl.install/smgl-spellcaster
b/iso/usr/share/smgl.install/smgl-spellcaster
index 6c8c726..c11017a 100755
--- a/iso/usr/share/smgl.install/smgl-spellcaster
+++ b/iso/usr/share/smgl.install/smgl-spellcaster
@@ -14,44 +14,30 @@ Generates a listing of cache files available to install.
USAGE
}

-function prompt() {
- local input=
-
- echo ""
- printf "\tPlease enter a number (0 when finished): "
- while [[ -z $input ]]
- do
- read input
- if [[ -n $input ]]
- then
- # fancy way to make sure that we have the correct input
- # if the user passes 1-12, that will be evaluated mathematically fist,
- # yielding -11, which fals outside the range of allowable input
- # this may be changed later, but currently we only support entering one
- # value at a time
- if [[ $(echo $((input)) ) -lt 0 || $(echo $((input)) ) -gt $NUM_CACHES
]]
- then
- echo "Error: You must enter a number corresponding to one"
- echo "of the choices in the list."
- input=
- fi
- fi
- done
- return $input
-}
-
function make_list {
# get a list of all the caches available and get the spell names from them,
# sorted and uniq'ed
- CACHES=( $(find $PREFIX/ -maxdepth 1 -type f -name "$EXTENSION" | sed
's#.*/##' | sed 's/-[0-9].*//' | sort | uniq) )
+ if [[ ! -e /tmp/caches ]]
+ then
+ find $PREFIX/ -maxdepth 1 -type f -name "$EXTENSION" |
+ sed 's#.*/##' |
+ sed 's#-[0-9].*$##' |
+ sort |
+ uniq > /tmp/caches
+ fi
+ CACHES=( $(</tmp/caches) )
NUM_CACHES=${#CACHES[*]}

# for each cache available, check to see if it was already selected before
# and mark it as selected if found
- for ((i=0; i < $NUM_CACHES; i++))
- do
- grep -s -q "^${CACHES[i]}$" /tmp/spells && SELECTED[i]="*"
- done
+ if [[ -e /tmp/spells ]]
+ then
+ for ((i=0; i < $NUM_CACHES; i++))
+ do
+ grep -s -q "^${CACHES[i]}$" /tmp/spells &&
+ SELECTED[i]="*"
+ done
+ fi
}

function print_list {
@@ -59,77 +45,129 @@ function print_list {
for ((i=0; i < $NUM_CACHES; i++))
do
printf "[%2d] %s %s\n" "$(($i + 1))" "${SELECTED[i]:- }" "${CACHES[i]}"
- done | column | more
+ done | column | less -F -J
}

-function main {
- local choice=-1
+function toggle_choice {
+ local choice="$1"
+ if [[ $choice -gt 0 ]]
+ then
+ choice=$((choice-1))
+ # if the choice was not previously selected, select it, otherwise
+ # deselect it (toggle)
+ if [[ SELECTED[choice] == '*' ]]
+ then
+ SELECTED[choice]=
+ else
+ SELECTED[choice]="*"
+ fi
+ fi
+}
+
+function prompt() {
+ local choice=
+ local input=
+
+ echo ""
+ echo -n "Please make a selection (a for all, n for none, 0 when finished):
"
+ read input
+ if $(echo "$input" | grep -q '\*')
+ then
+ echo "$input" >&2
+ input=$(echo "$input" | sed 's/\*//g')
+ echo "New:" >&2
+ echo "$input" >&2
+ fi
+ for choice in $input
+ do
+ # if the user entered 0, we're done here
+ [[ $choice == "0" ]] && break 2

+ # if 'a', we want everything
+ if [[ $choice == "a" ]]
+ then
+ for ((i=0; i < $NUM_CACHES; i++))
+ do
+ SELECTED[$i]="*"
+ done
+ continue
+ fi
+
+ # if 'n', we want none
+ if [[ $choice == "n" ]]
+ then
+ echo "none" >&2
+ for ((i=0; i < $NUM_CACHES; i++))
+ do
+ SELECTED[i]=
+ done
+ continue
+ fi
+
+ # ignore anything that doesn't consist of numbers or '-'
+ if $(echo $choice | grep -q -v '^\([0-9]\+-\?[0-9]*\)\|[*]$')
+ then
+ echo "Error: You must enter only numbers or ranges like 4-8, or "all""
>&2
+ continue
+ fi
+
+ # if the user passed something like 5-12, process the sequence
+ if $(echo $choice | grep -q '-')
+ then
+ for num in $(seq $(echo $choice | cut -d- -f1-2 --output-delimiter='
'))
+ do
+ toggle_choice $num
+ done
+ else
+ toggle_choice $choice
+ fi
+ done
+}
+
+function main {
# generate the list of spells to choose from by scanning the contents of
# /var/caches/sorcery on the ISO
- echo "Generating cache list, please be patient..."
+ echo "Populating internal cache list, please be patient..."
make_list

# present the menu and prompt for user input, until the user enters 0 to
# finish
- while [[ $choice -ne 0 ]]
+ while true
do
print_list
prompt
- choice="$?"
- [[ $choice -gt 0 ]] && SELECTED[$((choice-1))]="*"
done

# for each selected spell, output it to the spell listing file
for (( i=0; i < $NUM_CACHES; i++ ))
do
- if [[ ${SELECTED[i]} = '*' ]]
+ if [[ ${SELECTED[i]} = "*" ]]
then
echo ${CACHES[i]} >> /tmp/spells
fi
done

# make sure we don't have duplicates
- sort /tmp/spells | uniq > /tmp/spells
-
- # copy the selected list so that it's available inside the chroot
- cp -f /tmp/spells "$TARGET"/spells
-
- # mount bind to get to the caches from inside the chroot
- # this is cheaper than copying, plus the user doesn't have a bunch of
- # "useless" cache files on their system since presumably they will be
- # changing both compile options (like arch) and spell version when they
- # update their grimoires
- mount --bind /var/cache/sorcery "$TARGET"/var/cache/sorcery
-
- # cast inside the chroot using the selected list and ISO caches
- chroot "$TARGET" /usr/sbin/cast $(< /spells)
-
- # clean up
- umount "$TARGET"/var/cache/sorcery
- rm "$TARGET"/spells
+ [[ -e /tmp/spells ]] && sort -u -o /tmp/spells /tmp/spells
}

function message() {
echo ""
- cat <<-Message
+ cat <<-"Message"
Spell selection menu.
- You may select any number of the following spells to install. Some of
them may
- be necessary, depending on how you have set up your installation. For
example,
- if you formatted your disk with xfs, then you will need xfsprogs. Also,
you
- will need at least one bootloader installed (e.g. lilo, grub, etc.).
-
- When you are satisfied with your selections, enter 0 (zero) and the list
of
- spells to cast will be compiled. Sorcery will then ask you if the list of
- spells is correct and if you would like to cast them, as it normally
does when
- casting.
-
+ You may select any number of the following spells to install. Some of
them
+ may be necessary, depending on how you have set up your installation. For
+ example, if you formatted your disk with xfs, then you will need
xfsprogs.
+ Also, you will need at least one bootloader installed (e.g. lilo, grub,
+ etc.).
+
+ The output is piped through less, so if there are too many caches to
+ fit on one screen you will be able to scroll. When you are satisfied with
+ your selections, enter 0 (zero) and the list of spells to cast will be
+ installed.
Message
}

-[[ $# -lt 1 ]] && TARGET="/mnt/root"
-TARGET=$1
-
message

main



  • [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (f4503b5d881b6bee8ef1611e54125fd21044852b), Justin Boffemmyer, 01/03/2009

Archive powered by MHonArc 2.6.24.

Top of Page