Merge branch 'master' into install

This commit is contained in:
Nico Schottelius 2011-10-04 16:36:38 +02:00
commit b91a597e44
5 changed files with 55 additions and 26 deletions

View file

@ -36,20 +36,18 @@ EXAMPLES
--------
--------------------------------------------------------------------------------
# 128MB linux, bootable
# 128MB, linux, bootable
__partition_msdos /dev/sda1 --type 83 --size 128M --bootable true
# 512MB swap
# 512MB, swap
__partition_msdos /dev/sda2 --type 82 --size 512M
# extended
# 100GB, extended
__partition_msdos /dev/sda3 --type extended --size 100G
# 10GB, linux
__partition_msdos /dev/sda5 --type 83 --size 10G
# 50% of free space, linux
# 50% of the free space of the extended partition, linux
__partition_msdos /dev/sda6 --type 83 --size 50%
# rest of disk, linux
# rest of the extended partition, linux
__partition_msdos /dev/sda7 --type 83 --size +
# same thing as
__partition_msdos /dev/sda7 --type 83
--------------------------------------------------------------------------------

View file

@ -7,11 +7,13 @@ debug() {
}
fdisk_command() {
local device=$1
local cmd=$2
local device="$1"
local cmd="$2"
debug fdisk_command "running fdisk command '${cmd}' on device ${device}"
echo -en "${cmd}\nw\n" | fdisk -c -u "$device"
printf "${cmd}\nw\n" | fdisk -c -u "$device"
# give disk some time
sleep 1
return $?
}
@ -24,11 +26,11 @@ create_disklabel() {
}
create_partition() {
local device=$1
local minor=$2
local size=$3
local type=$4
local primary_count=$5
local device="$1"
local minor="$2"
local size="$3"
local type="$4"
local primary_count="$5"
if [ "$type" = "extended" -o "$type" = "5" ]; then
# Extended partition

View file

@ -23,7 +23,8 @@ die() {
exit 1
}
debug() {
echo "[__partition_msdos_apply] $@" >&2
#echo "[__partition_msdos_apply] $@" >&2
:
}
# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB.
@ -57,32 +58,43 @@ cat "$__type/files/lib.sh"
partitions="$__object/explorer/partitions"
objects=$(find "$__global/object/__partition_msdos" -path "*.cdist")
current_device=""
available_device_size=
available_extended_size=
available_size=
primary_count=0
for object in $objects; do
device="$(cat "$object/parameter/device")"
if [ "$current_device" != "$device" ]; then
echo "create_disklabel $device"
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'"
current_device="$device"
device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g')
available_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
# make sure we don't go past the end of the drive
available_size=$((available_size - 2))
available_device_size=$((available_device_size - 2))
available_extended_size=0
primary_count=0
debug "----- $device"
debug "current_device=$current_device"
debug "available_size=$available_size"
debug "available_device_size=$available_device_size"
fi
type="$(cat "$object/parameter/type")"
partition="$(cat "$object/parameter/partition")"
minor="$(cat "$object/parameter/minor")"
if [ "${minor}" -lt "5" ]; then
primary_count=$(( $primary_count + 1 ))
fi
bootable="$(cat "$object/parameter/bootable")"
size="$(cat "$object/parameter/size")"
if [ "${minor}" -lt "5" ]; then
# Primary partitions
primary_count=$(( $primary_count + 1 ))
available_size=$available_device_size
else
# Logical partitions
available_size=$available_extended_size
fi
if [ "$size" = "+" ]; then
# use rest of device
partition_size=""
@ -92,6 +104,18 @@ for object in $objects; do
available_size="$(( $available_size - $partition_size ))"
fi
if [ "${minor}" -lt "5" ]; then
# Primary partitions
available_device_size=$available_size
if [ "$type" = "extended" -o "$type" = "5" ]; then
# Extended partition
available_extended_size=$partition_size
fi
else
# Logical paritions
available_extended_size=$available_size
fi
[ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value"
debug "----- $partition"
debug "primary_count=$primary_count"
@ -104,7 +128,11 @@ for object in $objects; do
debug "size=$size"
debug "partition_size=$partition_size"
debug "available_size=$available_size"
debug "available_device_size=$available_device_size"
debug "available_extended_size=$available_extended_size"
debug "----------"
echo "create_partition $device $minor $partition_size $type $primary_count"
echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \
|| die 'Failed to create partition: $partition'"
done

View file

@ -55,7 +55,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
if [ "$new_value" != "$current_value" ]; then
set -- "$@" "--$property" \"$new_value\"
set -- "$@" "--$property" \'$new_value\'
fi
done
@ -67,7 +67,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
else
for property in $(ls .); do
new_value="$(cat "$property")"
set -- "$@" "--$property" \"$new_value\"
set -- "$@" "--$property" \'$new_value\'
done
echo useradd "$@" "$name"

View file

@ -1,5 +1,6 @@
2.0.3:
* Improved logging, added --verbose, by more quiet by default
* Bugfix __user: Correct quoting (Steven Armstrong)
2.0.2: 2011-09-27
* Add support for detection of OpenWall Linux (Matthias Teege)