diff options
Diffstat (limited to 'src/fripost-partman-udeb')
-rw-r--r-- | src/fripost-partman-udeb/base.sh | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/fripost-partman-udeb/base.sh b/src/fripost-partman-udeb/base.sh index b6af4d1..163134f 100644 --- a/src/fripost-partman-udeb/base.sh +++ b/src/fripost-partman-udeb/base.sh @@ -65,7 +65,7 @@ seed_urandom() { if [ -f "$seed" ]; then log "/dev/urandom has already been seeded since start-up" - return + return 0 fi [ -r $poolfile ] && bytes=$(cat $poolfile) @@ -226,6 +226,7 @@ fripost_mkpart() { | grep -m1 "^[0-9]:${start}s:" \ | sed 's/:.*//' ) + wait_for_device "${device}${part}" while [ $# -gt 3 ]; do flag="$4" log "Partition flag for ${device}${part} ($name): $flag" @@ -237,7 +238,6 @@ fripost_mkpart() { shift done - wait_for_device "${device}${part}" echo ${device}${part} } @@ -418,18 +418,26 @@ copy_authorized_keys() { ############################################################################## -# Add a progress bar to mkfs(8). +# Add a progress bar to mkfs(8). Exit gracefully if $device is empty # # Usage: fripost_mkfs <type> <device> [<options>] fripost_mkfs() { local type="$1" device="$2" fifo pid line stage step total= + [ "$device" ] || return 0 shift; shift log "Formatting $device as $type; options $@" + wait_for_device "$device" + + if ! [ "$type" = ext2 -o "$type" = ext3 -o "$type" = ext4 ]; then + # XXX: The parsing has been tested with mkfs.ext{2,3,4} only. + /sbin/mkfs."$type" "$@" "$device" + return 0 + fi + db_subst fripost/mkfs_progress_title DEVICE "$device" db_subst fripost/mkfs_progress_title TYPE "$type" - wait_for_device "$device" fifo=$(mktemp -u) /bin/mknod "$fifo" p || exit 1 @@ -437,7 +445,6 @@ fripost_mkfs() { /sbin/mkfs."$type" "$@" "$device" | tr '\b' '\n' > "$fifo" & pid=$! while read -u 7 line; do - # XXX: The parsing has been tested with mkfs.ext{2,3,4} only. case "$line" in *:*/*) [ "$total" ] && db_progress STOP @@ -472,7 +479,7 @@ fripost_mkfs() { ############################################################################## -# Set up the fstab +# Set up the fstab. Exit gracefully if $device is empty # # Usage: fripost_fstab <device> <mountpoint> <type> [<options>] # @@ -481,6 +488,7 @@ fripost_mkfs() { fripost_fstab() { local device="$1" mp="$2" type="$3" options="${4:-defaults}" pass + [ "$device" ] || return 0 if [ "$mp" = / ]; then log "Got root device, $device" @@ -562,14 +570,14 @@ fripost_mount_partitions() { if [ "$type" = swap ]; then /sbin/swapon "$dev" elif [ / = $(expr substr "$mp" 1 1) ]; then - mkdir "/target$mp" + mkdir -p "/target$mp" /bin/mount -t "$type" -o "$options" "$dev" "/target$mp" fi done # Post-installation scripts may use the install CD as a local mirror # for APT packages. - cdrom=$( sed -rn 's#^(\S+) /cdrom\s.*#\1#p' /proc/mounts | head -1 ) + cdrom=$( sed -rn '\#^(\S+) /cdrom\s.*# {s//\1/p; q}' /proc/mounts ) [ "$cdrom" ] || fatal "Error: Is /cdrom a mountpoint?" fripost_fstab_addentry "$cdrom" /media/cdrom0 udf,iso9660 user,noauto 0 0 mkdir -p /target/media/cdrom0 @@ -602,7 +610,7 @@ fripost_rmpart () { local device="$1" part="$2" n=$( /sbin/parted -sm "$device" p \ | sed -nr "/^[0-9].*:$part:[^:]*;$/ s/:.*//p" ) - [ "$n" ] || return + [ "$n" ] || return 0 log "Removing partition $n ($part) from $device" /sbin/parted -sm "$device" rm "$n" } |