functions: add to build with extra space

Extra space in partitions can be defined in '/custom/*/partitions' by
adding symbols 'EXTRA_<BOOT|ROOT>_SIZE' with size in MBytes

	EXTRA_BOOT_SIZE=128
	EXTRA_ROOT_SIZE=256

Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: I08f0daae5abc12857986d29bb58a18afb40c1ee7
This commit is contained in:
Dongjin Kim
2024-01-08 17:43:32 +09:00
parent a2586aad39
commit 330f86648b
2 changed files with 27 additions and 13 deletions

View File

@@ -4,6 +4,7 @@
. ${1} . ${1}
do_fdisk_commands() { do_fdisk_commands() {
[ ! -z ${TOTAL_SECTORS} ] || return
TOTAL=0 TOTAL=0
for (( p = 0 ; p < ${#PART[@]} ; p++ )); do for (( p = 0 ; p < ${#PART[@]} ; p++ )); do

View File

@@ -297,15 +297,35 @@ do_create_partition() {
local boot_blk=$((${2} * 1024 * 1024 / 512 - 1)) local boot_blk=$((${2} * 1024 * 1024 / 512 - 1))
local root_blk=$(($(du -s --block-size=512 ${rootfs_mnt} | cut -f1) * 12 / 10)) local root_blk=$(($(du -s --block-size=512 ${rootfs_mnt} | cut -f1) * 12 / 10))
local boot_pstart=$(get_reserved_sectors) local boot_pstart=$(get_reserved_sectors)
local fdiskcmd=""
[ "x${boot_pstart}" = "x" ] && boot_pstart=2048 [ "x${boot_pstart}" = "x" ] && boot_pstart=2048
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/partitions ]; then
echo ${TOPDIR}/custom/${CUSTOMOS}/partitions
. ${TOPDIR}/custom/${CUSTOMOS}/partitions
if [ ! -z ${TOTAL_SECTORS} ]; then
fdiskcmd=$(${TOPDIR}/fdiskcmd.sh ${TOPDIR}/custom/${CUSTOMOS}/partitions)
fi
fi
if [ ! -z ${EXTRA_BOOT_SIZE} ]; then
blks=$((${EXTRA_BOOT_SIZE} * 1024 * 1024 / 512 - 1))
boot_blk=$((${boot_blk} + ${blks}))
fi
if [ ! -z ${EXTRA_ROOT_SIZE} ]; then
blks=$((${EXTRA_ROOT_SIZE} * 1024 * 1024 / 512 - 1))
root_blk=$((${root_blk} + ${blks}))
fi
local boot_size=$((${boot_pstart} + ${boot_blk})) local boot_size=$((${boot_pstart} + ${boot_blk}))
local blocks=$((${boot_pstart} + ${boot_blk} + ${root_blk})) local blocks=$((${boot_pstart} + ${boot_blk} + ${root_blk}))
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/partitions ]; then blocks=${TOTAL_SECTORS:-${blocks}}
. ${TOPDIR}/custom/${CUSTOMOS}/partitions
blocks=${TOTAL_SECTORS} if [ "x${fdiskcmd}" = "x" ]; then
fdiskcmd="n\np\n\n${boot_pstart}\n${boot_size}\nn\np\n\n$((${boot_size} + 1))\n\nw\n"
fi fi
if [ ! -b ${disk} ]; then if [ ! -b ${disk} ]; then
@@ -325,16 +345,9 @@ do_create_partition() {
[ "${BASH_VERSION}" = "" ] || BACKSLASH_ESCAPE="-e" [ "${BASH_VERSION}" = "" ] || BACKSLASH_ESCAPE="-e"
echo "I: creating a partition table to '${disk}'" echo "I: creating a partition table to '${disk}'"
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/partitions ]; then echo fdiskcmd=${fdiskcmd}
echo ${BACKSLASH_ESCAPE} \ echo ${BACKSLASH_ESCAPE} ${fdiskcmd} | fdisk ${disk} \
$(${TOPDIR}/fdiskcmd.sh ${TOPDIR}/custom/${CUSTOMOS}/partitions) \ || panic "failed to create partition table" >/dev/null
| fdisk ${disk} >/dev/null
fi
echo ${BACKSLASH_ESCAPE} \
"n\np\n\n${boot_pstart}\n${boot_size}\n" \
"n\np\n\n$((${boot_size} + 1))\n\n" \
"w\n" | fdisk ${disk} >/dev/null
partprobe partprobe
if [ ! -b ${disk} ]; then if [ ! -b ${disk} ]; then