]> git.ipfire.org Git - people/ms/bricklayer.git/commitdiff
Add scaffolding of a script that masters an ISO image
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 21:42:24 +0000 (21:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 10 May 2021 21:42:24 +0000 (21:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/bricklayer-master [new file with mode: 0644]

index 3e52766f063c5d16915d0eedf1a2fd0479f94634..50ff0d1dbb24a49f5c6c1b9491bb587b2e84d665 100644 (file)
@@ -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 (file)
index 0000000..4d1158f
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+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 $?