summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-11-21 22:06:44 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-11-21 22:06:44 +0100
commit07a3d23197d60b357f3b42e0cc2e490d07702982 (patch)
tree6b92b60c76770091f6f971126d16db8500296e50
parent6b367253b892737547049e8b7791095e957c4490 (diff)
porting of interactive_filesystems WIP
-rw-r--r--TODO4
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh115
-rw-r--r--src/core/libs/lib-ui-interactive.sh51
-rw-r--r--src/core/procedures/interactive2
4 files changed, 81 insertions, 91 deletions
diff --git a/TODO b/TODO
index 9c19e78..6b625dd 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,9 @@
See also the FIXME's and TODO's in the code.
+* finish interactive_filesystems port to refactored code
+* do the remaining bits in lib-blockdevices-filesystems
+* test
+
ALPHA PHASE: get some people to test and suggest ideas, while fixing bugs and refactoring
General:
* setup bugtracker/roadmap thingie
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 81816e2..7624b2c 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -275,10 +275,10 @@ target_configure_fstab()
}
-# partitions a disk , creates filesystems and mounts them
+# partitions a disk. heavily altered
# $1 device to partition
-# $2 a string of the form: <mountpoint>:<partsize>:<fstype>[:+] (the + is bootable flag)
-partition_deprecated ()
+# $2 a string of the form: <partsize>:<fstype>[:+] (the + is bootable flag)
+partition()
{
debug "Partition called like: partition '$1' '$2'"
[ -z "$1" ] && die_error "partition() requires a device file and a partition string"
@@ -287,56 +287,38 @@ partition_deprecated ()
DEVICE=$1
STRING=$2
- # validate DEVICE
- if [ ! -b "$DEVICE" ]; then
- notify "Device '$DEVICE' is not valid"
- return 1
- fi
+ # validate DEVICE
+ if [ ! -b "$DEVICE" ]; then
+ notify "Device '$DEVICE' is not valid"
+ return 1
+ fi
- # validate DEST
- if [ ! -d "$var_TARGET_DIR" ]; then
- notify "Destination directory '$var_TARGET_DIR' is not valid"
- return 1
- fi
+ target_umountall
- # / required
- if [ $(grep -c '/:' <<< $STRING) -ne 1 ]; then
- notify "Need exactly one root partition"
- return 1
- fi
+ # setup input var for sfdisk
+ for fsspec in $STRING; do
+ fssize=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
+ fssize_spec=",$fssize"
+ [ "$fssize" = "*" ] && fssize_spec=';'
- rm -f $TMP_FSTAB
+ fstype=$(echo $fsspec | tr -d ' ' | cut -f2 -d:)
+ fstype_spec=","
+ [ "$fstype" = "swap" ] && fstype_spec=",S"
- target_umountall
- # setup input var for sfdisk #TODO: even though $STRING Contains a '/home' part it doesn't go through in the loops.. is this only in vbox?
- for fsspec in $STRING; do
- fssize=$(echo $fsspec | tr -d ' ' | cut -f2 -d:)
- if [ "$fssize" = "*" ]; then
- fssize_spec=';'
- else
- fssize_spec=",$fssize"
- fi
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if [ "$fstype" = "swap" ]; then
- fstype_spec=",S"
- else
- fstype_spec=","
- fi
- bootflag=$(echo $fsspec | tr -d ' ' | cut -f4 -d:)
- if [ "$bootflag" = "+" ]; then
- bootflag_spec=",*"
- else
- bootflag_spec=""
- fi
- sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"
- done
- sfdisk_input=$(printf "$sfdisk_input")
+ bootflag=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
+ bootflag_spec=""
+ [ "$bootflag" = "+" ] && bootflag_spec=",*"
- # invoke sfdisk
- debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input"
- printk off
- infofy "Partitioning $DEVICE"
- sfdisk $DEVICE -uM >$LOG 2>&1 <<EOF
+ sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"
+ done
+
+ sfdisk_input=$(printf "$sfdisk_input")
+
+ # invoke sfdisk
+ debug "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input"
+ printk off
+ infofy "Partitioning $DEVICE"
+ sfdisk $DEVICE -uM >$LOG 2>&1 <<EOF
$sfdisk_input
EOF
if [ $? -gt 0 ]; then
@@ -346,28 +328,6 @@ EOF
fi
printk on
- # need to mount root first, then do it again for the others
- part=1
- for fsspec in $STRING; do
- mountpoint=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if echo $mountpoint | tr -d ' ' | grep '^/$' 2>&1 > /dev/null; then
- _mkfs yes ${DEVICE}${part} "$fstype" "$var_TARGET_DIR" "$mountpoint" || return 1
- fi
- part=$(($part + 1))
- done
-
- # make other filesystems
- part=1
- for fsspec in $STRING; do
- mountpoint=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
- fstype=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
- if [ $(echo $mountpoint | tr -d ' ' | grep -c '^/$') -eq 0 ]; then
- _mkfs yes ${DEVICE}${part} "$fstype" "$var_TARGET_DIR" "$mountpoint" || return 1
- fi
- part=$(($part + 1))
- done
-
return 0
}
@@ -414,13 +374,23 @@ fix_filesystems_deprecated ()
# file layout:
#TMP_PARTITIONS
-# disk something-sfdisk-compliant
+# disk partition-scheme
# go over each disk in $TMP_PARTITIONS and partition it
-process_partitions ()
+process_disks ()
+{
+ while read disk scheme
+ do
+ process_disk $disk "$scheme"
+ done < $TMP_PARTITIONS
+}
+
+
+process_disk ()
{
+ partition $1 $2
}
@@ -431,6 +401,7 @@ process_filesystems ()
#TODO: we must make sure we have created all PV's, then reate a vg and the lv's.
#TODO: 'deconstruct' the mounted filesystems, pv's, lv's,vg's,dm_crypt's.. in the right order before doing this (opposite order of construct) and swapoff.
debug "process_filesystems Called. checking all entries in $TMP_FILESYSTEMS"
+ rm -f $TMP_FSTAB
devs_avail=1
while [ $devs_avail = 1 ]
do
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index e13a952..77b0033 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -178,8 +178,7 @@ interactive_autoprepare()
SET_DEFAULTFS=1
done
- _dia_DIALOG --defaultno --yesno "$DISC will be COMPLETELY ERASED! Are you absolutely sure?" 0 0 \
- || return 1
+ _dia_DIALOG --defaultno --yesno "$DISC will be COMPLETELY ERASED! Are you absolutely sure?" 0 0 || return 1
# we assume a /dev/hdX format (or /dev/sdX)
@@ -220,28 +219,44 @@ interactive_partition() {
[ "$DISC" = "DONE" ] && break
# Partition disc
notify "Now you'll be put into the cfdisk program where you can partition your hard drive. You should make a swap partition and as many data partitions as you will need.\
- NOTE: cfdisk may tell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to step 2."
+ NOTE: cfdisk may tell you to reboot after creating partitions. If you need to reboot, just re-enter this install program, skip this step and go on to the mountpoints selection step."
cfdisk $DISC
done
return 0
}
-interactive_mountpoints() {
- while [ "$PARTFINISH" != "DONE" ]; do
- : >$TMP_FSTAB
- : >/home/arch/aif/runtime/.parts #TODO: use a variable instead of a file, we don't need to use a file for this
+interactive_filesystems() {
- # Determine which filesystems are available
- FSOPTS="ext2 ext2 ext3 ext3"
- [ "$(which mkreiserfs 2>/dev/null)" ] && FSOPTS="$FSOPTS reiserfs Reiser3"
- [ "$(which mkfs.xfs 2>/dev/null)" ] && FSOPTS="$FSOPTS xfs XFS"
- [ "$(which mkfs.jfs 2>/dev/null)" ] && FSOPTS="$FSOPTS jfs JFS"
- [ "$(which mkfs.vfat 2>/dev/null)" ] && FSOPTS="$FSOPTS vfat VFAT"
+ # Determine which filesystems are available
+ FSOPTS="ext2 ext2 ext3 ext3"
+ which mkreiserfs 2>/dev/null && FSOPTS="$FSOPTS reiserfs Reiser3"
+ which mkfs.xfs 2>/dev/null && FSOPTS="$FSOPTS xfs XFS"
+ which mkfs.jfs 2>/dev/null && FSOPTS="$FSOPTS jfs JFS"
+ which mkfs.vfat 2>/dev/null && FSOPTS="$FSOPTS vfat VFAT"
+ which pvcreate 2>/dev/null && FSOPTS="$FSOPTS lvm-pv LVM Physical Volume"
+ which lvcreate 2>/dev/null && FSOPTS="$FSOPTS lvm-lv LVM Logical Volume"
+ which cryptsetup 2>/dev/null && FSOPTS="$FSOPTS dm_crypt DM_crypt Volume"
+
+ notify "Available Disks:\n\n$(_getavaildisks)\n"
+
+ # Let the user make filesystems and mountpoints
+ USERHAPPY=0
+ while [ "$USERHAPPY" = 0 ]
+ do
+ PARTS=$(findpartitions _)
+ ask_option no "Add/edit partitions" $PARTS $UPCOMINGPARTS
+ ANSWER_OPTION
+
+ #TODO: let user choose FS, mountpoint etc, and even create lvm pv's, dm_crypt stuff etc, create $UPCOMINGPARTS as needed
+ # also show the disks along with the fs, mountpoint that has been choosen (maybe) already
+ done
+
+ # If the user has forgotten one or more fundamental ones, ask him now
+ ALLOK=true
+ # TODO: check all conditions that would make ALLOK untrue again
+ while [ "$ALLOK" != "true" ]; do
- # Select mountpoints
- notify "Available Disks:\n\n$(_getavaildisks)\n"
- PARTS=$(findpartitions _)
_dia_DIALOG --menu "Select the partition to use as swap" 21 50 13 NONE - $PARTS 2>$ANSWER || return 1
PART=$(cat $ANSWER)
PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")"
@@ -283,7 +298,7 @@ interactive_mountpoints() {
done
DOMKFS="no"
ask_yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" && DOMKFS="yes"
- echo "$PART:$FSTYPE:$MP:$DOMKFS" >>/home/arch/aif/runtime/.parts
+ echo "$PART:$FSTYPE:$MP:$DOMKFS" >>file
_dia_DIALOG --menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
PART=$(cat $ANSWER)
done
@@ -292,7 +307,7 @@ interactive_mountpoints() {
target_umountall
- fix_filesystems /home/arch/aif/runtime/.parts && notify "Partitions were successfully mounted." && return 0
+ fix_filesystems && notify "Partitions were successfully mounted." && return 0
show_warning "Failure while doing filesystems" "Something went wrong. Check your logs"
return 1
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 1fb3378..d912091 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -165,7 +165,7 @@ worker_prepare_disks()
if [ "$DISK_CONFIG_TYPE" = "auto" ]; then
notify "You have already prepared your filesystems with Auto-prepare" #TODO: allow user to do this anyway. he can change his mind.
else
- interactive_mountpoints && ret=0 && NEXTITEM=4 && DISK_CONFIG_TYPE=manual
+ interactive_filesystems && ret=0 && NEXTITEM=4 && DISK_CONFIG_TYPE=manual
fi
;;
*)