--- /dev/null
+#!/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 $?