From 8d373e005b776d56a327385d1569883758d5af21 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sun, 7 Sep 2008 15:39:29 +0100 Subject: Refactor partition size calculation, ensuring a uniform increase for ext partitions. --- functions/losetup.sh | 17 +++++++++++++++++ helpers/lh_binary_rootfs | 3 ++- helpers/lh_binary_usb-hdd | 2 +- helpers/lh_source_usb-hdd | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/functions/losetup.sh b/functions/losetup.sh index 233e637..3c470f9 100755 --- a/functions/losetup.sh +++ b/functions/losetup.sh @@ -35,3 +35,20 @@ Losetup () ${LH_ROOT_COMMAND} ${LH_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}" fi } + +Calculate_partition_size () +{ + ORIGINAL_SIZE="${1}" + FILESYSTEM="${2}" + + case "${FILESYSTEM}" in + ext2|ext3) + PERCENT="5" + ;; + *) + PERCENT="2" + ;; + esac + + echo $(expr ${ORIGINAL_SIZE} + ${ORIGINAL_SIZE} \* ${PERCENT} / 100) +} diff --git a/helpers/lh_binary_rootfs b/helpers/lh_binary_rootfs index 718f79f..85cccb9 100755 --- a/helpers/lh_binary_rootfs +++ b/helpers/lh_binary_rootfs @@ -137,7 +137,8 @@ case "${LH_CHROOT_FILESYSTEM}" in fi DU_DIM="$(du -ks chroot/chroot | cut -f1)" - REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 20)" # Just 5% more to be sure, need something more sophistcated here... + REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LH_CHROOT_FILESYSTEM})" + if [ "${LH_DISTRIBUTION}" = "etch" ] then RESERVED_PERCENTAGE="--reserved-blocks" diff --git a/helpers/lh_binary_usb-hdd b/helpers/lh_binary_usb-hdd index 0b4663d..77be539 100755 --- a/helpers/lh_binary_usb-hdd +++ b/helpers/lh_binary_usb-hdd @@ -91,7 +91,7 @@ fi # Everything which comes here needs to be cleaned up, DU_DIM="$(du -ms binary | cut -f1)" -REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 50 + 1)" # Just 2% more to be sure, need something more sophistcated here... +REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LH_BINARY_FILESYSTEM})" dd if=/dev/zero of=chroot/binary.img bs=1024k count=0 seek=${REAL_DIM} FREELO="$(${LH_LOSETUP} -f)" if [ ! -b chroot/${FREELO} ] diff --git a/helpers/lh_source_usb-hdd b/helpers/lh_source_usb-hdd index 1283667..73949e3 100755 --- a/helpers/lh_source_usb-hdd +++ b/helpers/lh_source_usb-hdd @@ -67,7 +67,7 @@ fi # Everything which comes here needs to be cleaned up, DU_DIM="$(du -ms source | cut -f1)" -REAL_DIM="$(expr ${DU_DIM} + ${DU_DIM} / 50 + 1)" # Just 2% more to be sure, need something more sophistcated here... +REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LH_BINARY_FILESYSTEM})" dd if=/dev/zero of=source.img bs=1024k count=0 seek=${REAL_DIM} FREELO="$(${LH_LOSETUP} -f)" if [ ! -b chroot/${FREELO} ] -- cgit v1.0