summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-12-09 16:44:41 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-12-09 16:44:41 +0100
commit38613598a5a79ee1b266918878ca7864d2f2dd05 (patch)
tree03f857391aaacb1d2a399320faabecde451829dd /src
parentcd129c122cf0161afb96b60b5bc5c06c781ca5d6 (diff)
fix for variable not defined + refactored a bit
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh29
-rw-r--r--src/core/libs/lib-ui-interactive.sh39
2 files changed, 32 insertions, 36 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 7bc2730..26ab866 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -3,11 +3,11 @@
# FORMAT DEFINITIONS:
-# MAIN FORMAT FOR $BLOCK_DATA (format used to interface with this library): one line per blockdevice, multiple fs'es in 1 'fs-string'
-# $BLOCK_DATA entry.
+# MAIN FORMAT FOR $TMP_BLOCKDEVICES (format used to interface with this library): one line per blockdevice, multiple fs'es in 1 'fs-string'
+# $TMP_BLOCKDEVICES entry.
# <blockdevice> type label/no_label <FS-string>/no_fs
# FS-string:
-# type;recreate(yes/no);mountpoint;mount?(target,runtime,no);opts;label;params[|FS-string|...] where opts have _'s instead of whitespace
+# type;recreate(yes/no);mountpoint;mount?(target,runtime,no);opts;label;params[|FS-string|...] where opts/params have _'s instead of whitespace if needed
# NOTE: the 'mount?' for now just matters for the location (if 'target', the target path gets prepended and mounted in the runtime system)
@@ -26,6 +26,9 @@ TMP_DEV_MAP=/home/arch/aif/runtime/dev.map
TMP_FSTAB=/home/arch/aif/runtime/.fstab
TMP_PARTITIONS=/home/arch/aif/runtime/.partitions
TMP_FILESYSTEMS=/home/arch/aif/runtime/.filesystems # Only used internally by this library. Do not even think about using this as interface to this library. it won't work
+TMP_BLOCKDEVICES=/home/arch/aif/runtime/.blockdata
+
+
# procedural code from quickinst functionized and fixed.
# there were functions like this in the setup script too, with some subtle differences. see below
@@ -356,21 +359,21 @@ generate_filesystem_list ()
echo "$part $part_type $part_label $fs_type $fs_create $fs_mountpoint $fs_mount $fs_opts $fs_label $fs_params" >> $TMP_FILESYSTEMS
done
fi
- done < $BLOCK_DATA
+ done < $TMP_BLOCKDEVICES
}
-# process all entries in $BLOCK_DATA, create all blockdevices and filesystems and mount them correctly, destroying what's necessary first.
+# process all entries in $TMP_BLOCKDEVICES, create all blockdevices and filesystems and mount them correctly, destroying what's necessary first.
process_filesystems ()
{
- debug "process_filesystems Called. checking all entries in $BLOCK_DATA"
+ debug "process_filesystems Called. checking all entries in $TMP_BLOCKDEVICES"
rm -f $TMP_FSTAB
generate_filesystem_list
# phase 1: destruct all mounts in the vfs that are about to be reconstructed. (and also swapoff where appropriate)
# re-order list so that we umount in the correct order. eg first umount /a/b/c, then /a/b. we sort alphabetically, which has the side-effect of sorting by stringlength, hence by vfs dependencies.
- # TODO: this is not entirely correct: what if something is mounted in a previous run that is now not anymore in $BLOCK_DATA ? that needs to be cleaned up too.
+ # TODO: this is not entirely correct: what if something is mounted in a previous run that is now not anymore in $TMP_BLOCKDEVICES ? that needs to be cleaned up too.
sort -t \ -k 2 $TMP_FILESYSTEMS | tac | while read part part_type part_label fs_type fs_create fs_mountpoint fs_mount fs_opts fs_label fs_params
do
@@ -391,17 +394,17 @@ process_filesystems ()
# devs_avail=0
# for part in `findpartitions`
# do
-# if entry=`grep ^$part $BLOCK_DATA`
+# if entry=`grep ^$part $TMP_BLOCKDEVICES`
# then
-# process_filesystem "$entry" && sed -i "/^$part/d" $BLOCK_DATA && debug "$part processed and removed from $BLOCK_DATA"
+# process_filesystem "$entry" && sed -i "/^$part/d" $TMP_BLOCKDEVICES && debug "$part processed and removed from $TMP_BLOCKDEVICES"
# devs_avail=1
# fi
# done
# done
-# entries=`wc -l $BLOCK_DATA`
+# entries=`wc -l $TMP_BLOCKDEVICES`
# if [ $entries -gt 0 ]
# then
-# die_error "Could not process all entries because not all available blockdevices became available. Unprocessed:`awk '{print \$1}' $BLOCK_DATA`"
+# die_error "Could not process all entries because not all available blockdevices became available. Unprocessed:`awk '{print \$1}' $TMP_BLOCKDEVICES`"
# else
# debug "All entries processed..."
# fi
@@ -412,13 +415,13 @@ process_filesystems ()
# targets for destruction: /dev/mapper devices and lvm PV's who contain no fs, or a non-lvm/dm_crypt fs. TODO: improve regexes
# after destructing. the parent must be updated to reflect the vanished child.
- # NOTE: an alternative approach could be to just go over all /dev/mapper devices or normal devices that are lvm PV's (by using finddisks etc instead of $BLOCK_DATA, or even better by using finddisks and only doing it if they are in $BLOCK_DATA ) and attempt to destruct.
+ # NOTE: an alternative approach could be to just go over all /dev/mapper devices or normal devices that are lvm PV's (by using finddisks etc instead of $TMP_BLOCKDEVICES, or even better by using finddisks and only doing it if they are in $TMP_BLOCKDEVICES ) and attempt to destruct.
# do that a few times and the ones that blocked because something else on it will probable have become freed and possible to destruct
# TODO: do this as long as devices in this list remains and exist physically
# TODO: abort when there still are physical devices listed, but we tried to destruct them already, give error
- egrep '\+|mapper' $BLOCK_DATA | egrep -v ' lvm-pv;| lvm-vg;| lvm-lv;| dm_crypt;' | while read part part_type part_label fs
+ egrep '\+|mapper' $TMP_BLOCKDEVICES | egrep -v ' lvm-pv;| lvm-vg;| lvm-lv;| dm_crypt;' | while read part part_type part_label fs
do
real_part=${part/+/}
if [ -b "$real_part" ]
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 4f32338..c64c52a 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -152,10 +152,10 @@ interactive_autoprepare()
echo "$DISC $BOOT_PART_SIZE:ext2:+ $SWAP_PART_SIZE:swap $ROOT_PART_SIZE:$FSTYPE *:$FSTYPE" > $TMP_PARTITIONS
- echo "${DISC}1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params" >$BLOCK_DATA
- echo "${DISC}2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params" >$BLOCK_DATA
- echo "${DISC}3 raw no_label $FSTYPE;yes;/;target;no_opts;no_label;no_params" >$BLOCK_DATA
- echo "${DISC}4 raw no_label $FSTYPE;yes;/home;target;no_opts;no_label;no_params" >$BLOCK_DATA
+ echo "${DISC}1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params" >$TMP_BLOCKDEVICES
+ echo "${DISC}2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params" >$TMP_BLOCKDEVICES
+ echo "${DISC}3 raw no_label $FSTYPE;yes;/;target;no_opts;no_label;no_params" >$TMP_BLOCKDEVICES
+ echo "${DISC}4 raw no_label $FSTYPE;yes;/home;target;no_opts;no_label;no_params" >$TMP_BLOCKDEVICES
process_disks || die_error "Something went wrong while partitioning"
@@ -311,7 +311,7 @@ interactive_filesystem ()
do
list="$list $pv ON"
done
- for pv in `grep '+ lvm-pv' $BLOCK_DATA | awk '{print $1}' | sed 's/\+$//'` # find PV's to be added: their blockdevice ends on + and has lvm-pv as type #TODO: i'm not sure we check which pv's are taken already
+ for pv in `grep '+ lvm-pv' $TMP_BLOCKDEVICES | awk '{print $1}' | sed 's/\+$//'` # find PV's to be added: their blockdevice ends on + and has lvm-pv as type #TODO: i'm not sure we check which pv's are taken already
do
grep -q "$pv ON" <<< "$list" || list="$list $pv OFF"
done
@@ -357,16 +357,16 @@ interactive_filesystem ()
# add new theoretical blockdevice, if relevant
if [ "$fs_type" = lvm-vg ]
then
- echo "/dev/mapper/$fs_label $fs_type $fs_label no_fs" >> $BLOCK_DATA
+ echo "/dev/mapper/$fs_label $fs_type $fs_label no_fs" >> $TMP_BLOCKDEVICES
elif [ "$fs_type" = lvm-pv ]
then
- echo "$part+ $fs_type no_label no_fs" >> $BLOCK_DATA
+ echo "$part+ $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
elif [ "$fs_type" = lvm-lv ]
then
- echo "/dev/mapper/$part_label-$fs_label $fs_type no_label no_fs" >> $BLOCK_DATA
+ echo "/dev/mapper/$part_label-$fs_label $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
elif [ "$fs_type" = dm_crypt ]
then
- echo "/dev/mapper/$fs_label $fs_type no_label no_fs" >> $BLOCK_DATA
+ echo "/dev/mapper/$fs_label $fs_type no_label no_fs" >> $TMP_BLOCKDEVICES
fi
# TODO: cascading remove theoretical blockdevice(s), if relevant ( eg if we just changed from vg->ext3, dm_crypt -> fat, or if we changed the label of something, etc)
@@ -374,7 +374,7 @@ interactive_filesystem ()
then
[ "$fs" = lvm-vg -o "$fs" = dm_cryp ] && target="/dev/mapper/$label"
[ "$fs" = lvm-lv ] && target="/dev/mapper/$vg-$label" #TODO: $vg not set
- sed -i "#$target#d" $BLOCK_DATA #TODO: check affected items, delete those, etc etc.
+ sed -i "#$target#d" $TMP_BLOCKDEVICES #TODO: check affected items, delete those, etc etc.
fi
}
@@ -382,14 +382,7 @@ interactive_filesystems() {
notify "Available Disks:\n\n$(_getavaildisks)\n"
- BLOCK_DATA=/home/arch/aif/runtime/.blockdata
-
- # $BLOCK_DATA entry. easily parsable.:
- # <blockdevice> type label/no_label <FS-string>/no_fs
- # FS-string:
- # type;recreate;mountpoint;mount?(target,runtime,no);opts;label;params[|FS-string|...] where opts/params have _'s instead of whitespace if needed
-
- findpartitions 0 'no_fs' ' raw no_label' > $BLOCK_DATA
+ findpartitions 0 'no_fs' ' raw no_label' > $TMP_BLOCKDEVICES
ALLOK=0
while [ "$ALLOK" = 0 ]
@@ -406,7 +399,7 @@ interactive_filesystems() {
infostring="type:$type,label:$label,fs:$fs"
[ -b "$part" ] && get_blockdevice_size ${part/+/} && infostring="size:${BLOCKDEVICE_SIZE}MB,$infostring" # add size in MB for existing blockdevices (eg not for mapper devices that are not yet created yet)
menu_list="$menu_list $part $infostring" #don't add extra spaces, dialog doesn't like that.
- done < $BLOCK_DATA
+ done < $TMP_BLOCKDEVICES
ask_option no "Manage filesystems, block devices and virtual devices. Note that you don't *need* to specify opts, labels or extra params if you're not using lvm, dm_crypt, etc." $menu_list DONE _
[ $? -gt 0 ] && USERHAPPY=1 && break
@@ -416,9 +409,9 @@ interactive_filesystems() {
declare part_escaped=${part//\//\\/} # escape all slashes otherwise awk complains
declare part_escaped=${part_escaped/+/\\+} # escape the + sign too
- part_type=$( awk "/^$part_escaped/ {print \$2}" $BLOCK_DATA)
- part_label=$(awk "/^$part_escaped/ {print \$3}" $BLOCK_DATA)
- fs=$( awk "/^$part_escaped/ {print \$4}" $BLOCK_DATA)
+ part_type=$( awk "/^$part_escaped/ {print \$2}" $TMP_BLOCKDEVICES)
+ part_label=$(awk "/^$part_escaped/ {print \$3}" $TMP_BLOCKDEVICES)
+ fs=$( awk "/^$part_escaped/ {print \$4}" $TMP_BLOCKDEVICES)
[ "$part_label" == no_label ] && part_label=
[ "$fs" == no_fs ] && fs=
@@ -472,7 +465,7 @@ interactive_filesystems() {
# update the menu # NOTE that part_type remains raw for basic filesystems!
[ -z "$part_label" ] && part_label=no_label
[ -z "$fs" ] && fs=no_fs
- sed -i "s#^$part $part_type $part_label.*#$part $part_type $part_label $fs#" $BLOCK_DATA # '#' is a forbidden character !
+ sed -i "s#^$part $part_type $part_label.*#$part $part_type $part_label $fs#" $TMP_BLOCKDEVICES # '#' is a forbidden character !
done