From: Michael Tremer Date: Mon, 10 May 2021 21:42:24 +0000 (+0000) Subject: Add scaffolding of a script that masters an ISO image X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d26c6d2a7e9fc0882e7f72e96cd83e09bc80a475;p=people%2Fms%2Fbricklayer.git Add scaffolding of a script that masters an ISO image Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 3e52766..50ff0d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -41,7 +41,8 @@ po/POTFILES.in: Makefile sed -e "s@$(abs_srcdir)/@@g" | LC_ALL=C sort > $@ dist_bin_SCRIPTS = \ - src/bricklayer + src/bricklayer \ + src/bricklayer-master dist_pkgpython_PYTHON = \ src/python/__init__.py \ diff --git a/src/bricklayer-master b/src/bricklayer-master new file mode 100644 index 0000000..4d1158f --- /dev/null +++ b/src/bricklayer-master @@ -0,0 +1,115 @@ +#!/bin/bash +############################################################################### +# # +# Bricklayer - An Installer for IPFire # +# Copyright (C) 2021 IPFire Development Team # +# # +# This program is free software; you can redistribute it and/or # +# modify it under the terms of the GNU General Public License # +# as published by the Free Software Foundation; either version 2 # +# of the License, or (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +mkimage() { + local filename="${1}" + local r=0 + + # Create a temporary working directory + local tempdir="$(mktemp -d)" + + # Create argument list for xorriso + local args=( + # Emulate running as mkisofs + -as mkisofs + + # Be less verbose + -quiet + + # The name of the volume + -volid "${name}" + + -iso-level 3 + -eltorito-alt-boot + -no-emul-boot + + # Where to write the output to? + -output "${filename}" + + # What files to package? + "${tempdir}" + ) + + # Append EFI arguments + if [ "${efi}" = "true" ]; then + args+=( + -e "EFI/efiboot.img" + ) + fi + + if ! xorriso "${args[@]}"; then + r=1 + fi + + # Cleanup + rm -rf "${tempdir}" + + return "${r}" +} + +main() { + local arch="$(uname -m)" + local efi="true" + local filename + + while [ $# -gt 0 ]; do + case "${1}" in + --arch=*) + arch="${1#*=}" + ;; + + --disable-efi) + efi="false" + ;; + + *.iso) + if [ -n "${filename}" ]; then + echo "Filename has already been set" >&2 + return 2 + fi + + filename="${1}" + ;; + + *) + echo "Unhandled argument: ${1}" >&2 + return 2 + ;; + esac + shift + done + + # Was filename set? + if [ -z "${filename}" ]; then + echo "You have not specified a target filename" >&2 + return 2 + fi + + # Make image and delete it if something went wrong + if ! mkimage "${filename}"; then + unlink "${filename}" + return 1 + fi + + return 0 +} + +main "$@" || exit $?