fix(shredos): refactor post-process scripts

Post-processing used a static (outdated?) GRUB image for USB image generation, but it is better to use the GRUB image produced as part of the building process, which ensures that the actual compiled GRUB version is used as bootloader in our images and not an outdated one.

Post-processing previously embedded the 64-bit EFI bootloader to 32-bit builds, as no architecture checks were in place. This was changed to check for architecture and embed the correct EFI bootloader for the respective target architecture instead.

The GRUB configuration was changed to use a menu, to allow the user to choose between standard and nomodeset parameters, while also allowing the user to edit the command line to append other kernel parameters they may need for their systems.

The vanity kernel image name was returned to bzImage to clearly mark the image for what it is, and to remain consistent with the ISO file generation where we have no direct control over the image now.

Signed-off-by: desertwitch <24509509+desertwitch@users.noreply.github.com>
This commit is contained in:
desertwitch
2025-11-18 07:32:51 +01:00
parent 56333565cb
commit af1654ee9f
7 changed files with 130 additions and 37 deletions

Binary file not shown.

View File

@@ -1,30 +0,0 @@
#!/bin/bash -e
version=`cat board/shredos/fsoverlay/etc/shredos/version.txt`
cp "board/shredos/grub.cfg" "${BINARIES_DIR}/grub.cfg" || exit 1
cp "board/shredos/bootx64.efi" "${BINARIES_DIR}/bootx64.efi" || exit 1
#cp "${HOST_DIR}/lib/grub/i386-pc/boot.img" "${BINARIES_DIR}/boot.img" || exit 1
cp "output/target/lib/grub/i386-pc/boot.img" "${BINARIES_DIR}/boot.img" || exit 1
# copy the ShredOS icon and Windows autorun.inf; if a USB stick is plugged into a Windows system
# it will be identified as 'ShredOS - Dangerous' as a warning to users unaware what ShredOS is.
cp "board/shredos/autorun.inf" "${BINARIES_DIR}/autorun.inf" || exit 1
cp "board/shredos/README.txt" "${BINARIES_DIR}/README.txt" || exit 1
cp "board/shredos/shredos.ico" "${BINARIES_DIR}/shredos.ico" || exit 1
# version.txt is used to help identify boot disc
cp "board/shredos/fsoverlay/etc/shredos/version.txt" "${BINARIES_DIR}/version.txt" || exit 1
rm -rf "${BUILD_DIR}/genimage.tmp" || exit 1
genimage --rootpath="${TARGET_DIR}" --inputpath="${BINARIES_DIR}" --outputpath="${BINARIES_DIR}" --config="board/shredos/genimage.cfg" --tmppath="${BUILD_DIR}/genimage.tmp" || exit 1
# renaming
SUFFIXIMG="${version}_$(date +%Y%m%d)"
FINAL_IMAGE_PATH="${BINARIES_DIR}/shredos-${SUFFIXIMG}.img"
mv "${BINARIES_DIR}/shredos.img" "${FINAL_IMAGE_PATH}" || exit 1
#mv "${BINARIES_DIR}/bzImage" "${FINAL_IMAGE_PATH}" || exit 1
echo "File ${FINAL_IMAGE_PATH} created successfully"
exit 0

View File

@@ -1,14 +1,14 @@
image boot.vfat {
vfat {
extraargs = "-F 32 -n SHREDOS"
file boot/bzImage { image = 'bzImage' }
file boot/grub/grub.cfg { image = 'grub.cfg' }
file boot/shredos { image = 'bzImage' }
file boot/version.txt { image = 'version.txt' }
file EFI/BOOT/bootx64.efi { image = 'bootx64.efi' }
file EFI/BOOT/grub.cfg { image = 'grub.cfg' }
file shredos.ico { image = 'shredos.ico' }
file README.txt { image = 'README.txt' }
file autorun.inf { image = 'autorun.inf' }
file shredos.ico { image = 'shredos.ico' }
file README.txt { image = 'README.txt' }
file autorun.inf { image = 'autorun.inf' }
}
size = 310000000

View File

@@ -0,0 +1,40 @@
image boot.vfat {
vfat {
extraargs = "-F 32 -n SHREDOS"
file boot/bzImage { image = 'bzImage' }
file boot/grub/grub.cfg { image = 'grub.cfg' }
file boot/version.txt { image = 'version.txt' }
file EFI/BOOT/bootia32.efi { image = 'bootia32.efi' }
file EFI/BOOT/grub.cfg { image = 'grub.cfg' }
file shredos.ico { image = 'shredos.ico' }
file README.txt { image = 'README.txt' }
file autorun.inf { image = 'autorun.inf' }
}
size = 310000000
}
image shredos.img {
hdimage {
}
partition boot {
in-partition-table = "no"
image = "boot.img"
offset = 0
size = 512
holes = {"(440; 512)"}
}
partition grub {
in-partition-table = "no"
image = "grub.img"
offset = 512
}
partition vfat {
partition-type = 0xC
image = "boot.vfat"
offset = 646656
}
}

View File

@@ -1,6 +1,10 @@
set default="0"
set timeout="0"
set timeout="5"
menuentry "shredos" {
linux /boot/shredos console=tty3 loglevel=3
menuentry "ShredOS" {
linux /boot/bzImage console=tty3 loglevel=3
}
menuentry "ShredOS (nomodeset)" {
linux /boot/bzImage console=tty3 loglevel=3 nomodeset
}

50
board/shredos/make_img_file.sh Executable file
View File

@@ -0,0 +1,50 @@
#!/bin/bash -e
if grep -Eq "^BR2_ARCH_IS_64=y$" "${BR2_CONFIG}"; then
MKIMAGE_ARCH=x86_64
MKIMAGE_EFI=bootx64.efi
MKIMAGE_CFG=genimage.cfg
else
MKIMAGE_ARCH=i586
MKIMAGE_EFI=bootia32.efi
MKIMAGE_CFG=genimage_i586.cfg
fi
version=$(cat board/shredos/fsoverlay/etc/shredos/version.txt)
cp "board/shredos/grub.cfg" "${BINARIES_DIR}/grub.cfg" || exit 1
cp "output/target/lib/grub/i386-pc/boot.img" "${BINARIES_DIR}/boot.img" || exit 1
cp "${BINARIES_DIR}/efi-part/EFI/BOOT/${MKIMAGE_EFI}" "${BINARIES_DIR}/${MKIMAGE_EFI}" || exit 1
cp "board/shredos/autorun.inf" "${BINARIES_DIR}/autorun.inf" || exit 1
cp "board/shredos/README.txt" "${BINARIES_DIR}/README.txt" || exit 1
cp "board/shredos/shredos.ico" "${BINARIES_DIR}/shredos.ico" || exit 1
# version.txt is used to help identify the (boot) USB disk
cp "board/shredos/fsoverlay/etc/shredos/version.txt" "${BINARIES_DIR}/version.txt" || exit 1
rm -rf "${BUILD_DIR}/genimage.tmp" || exit 1
genimage --rootpath="${TARGET_DIR}" \
--inputpath="${BINARIES_DIR}" \
--outputpath="${BINARIES_DIR}" \
--config="board/shredos/${MKIMAGE_CFG}" \
--tmppath="${BUILD_DIR}/genimage.tmp" || exit 1
SUFFIXIMG="${version}_$(date +%Y%m%d)"
FINAL_IMAGE_PATH="${BINARIES_DIR}/shredos-${SUFFIXIMG}.img"
mv "${BINARIES_DIR}/shredos.img" "${FINAL_IMAGE_PATH}" || exit 1
GREEN="\033[0;32m"
RESET="\033[0m"
printf "%b" "$GREEN"
echo
echo "==============================================="
echo " USB image '${FINAL_IMAGE_PATH}'"
echo " (for '${MKIMAGE_ARCH}' architecture)"
echo " CREATED SUCCESSFULLY!"
echo "==============================================="
echo
printf "%b\n" "$RESET"
exit 0

29
board/shredos/make_iso_file.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash -e
if grep -Eq "^BR2_ARCH_IS_64=y$" "${BR2_CONFIG}"; then
MKIMAGE_ARCH=x86_64
else
MKIMAGE_ARCH=i386
fi
version=$(cat board/shredos/fsoverlay/etc/shredos/version.txt)
SUFFIXISO="${version}_$(date +%Y%m%d)"
FINAL_ISO_PATH="${BINARIES_DIR}/shredos-${SUFFIXISO}.iso"
mv "${BINARIES_DIR}/rootfs.iso9660" "${FINAL_ISO_PATH}" || exit 1
GREEN="\033[0;32m"
RESET="\033[0m"
printf "%b" "$GREEN"
echo
echo "==============================================="
echo " ISO image '${FINAL_ISO_PATH}'"
echo " (for '${MKIMAGE_ARCH}' architecture)"
echo " CREATED SUCCESSFULLY!"
echo "==============================================="
echo
printf "%b" "$RESET"
exit 0