From 9c187f6fe319a1bf341fabead730f35fe96ec510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=2E=20Y=2E=20Cemal=20=C3=96zt=C3=BCrk?= Date: Fri, 28 Jul 2023 15:26:07 +0300 Subject: [PATCH] switch to m4 for partable (#9) --- cuteloader-sfd.awk | 7 ------- util/partable.m4 | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) delete mode 100755 cuteloader-sfd.awk create mode 100644 util/partable.m4 diff --git a/cuteloader-sfd.awk b/cuteloader-sfd.awk deleted file mode 100755 index 70fa22a..0000000 --- a/cuteloader-sfd.awk +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/awk -f - -BEGIN { - printf("label: dos\nunit: sectors\n\n") - printf("%s1 : start=2048, size=1469440, type=0C # FAT32\n", device_name) - printf("%s2 : start=1471488, size=1469440, type=83 # Linux\n", device_name) -} diff --git a/util/partable.m4 b/util/partable.m4 new file mode 100644 index 0000000..46480ac --- /dev/null +++ b/util/partable.m4 @@ -0,0 +1,33 @@ +# partable.m4 - Partitioning table for Cuteloader + +# the device name which Cuteloader will be installed +define(`device_name', `/dev/sdb')dnl + +# the record label for the disk +define(`reclabel_type', `mbr')dnl + +# the stage1 bootloader partition +define(`STAGE1_START', `2048')dnl +define(`STAGE1_SIZE', `1469440')dnl +define(`STAGE1_TYPE', `0C')dnl + +# the stage2 bootloader (and ramdisk images) partition +define(`STAGE2_START', `1471488')dnl +define(`STAGE2_SIZE', `1469440')dnl +define(`STAGE2_TYPE', `83')dnl + +# Run fdisk to get the device size and capture the output +define(`FDISK_OUTPUT', `esyscmd(`fdisk -l `device_name)')dnl + +# Extract the line containing the device size information using grep +define(`SIZE_LINE', `regexp(FDISK_OUTPUT, `^Disk `device_name)': ')dnl + +# Extract the total device size in sectors using awk +define(`DEVICE_SIZE', `regexp(SIZE_LINE, ` ([0-9]+) sectors', ` \1')')dnl + +# Calculate the start and size of the third partition +define(`PART3_START', `STAGE2_START + STAGE2_SIZE')dnl +define(`PART3_SIZE', `DEVICE_SIZE - PART3_START')dnl + +# the third partition (freely available space) +define(`PART3_TYPE', `83')dnl