#!/usr/bin/env bash # # Copyright 2025, Stormux, # # This 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 3, or (at your option) any later # version. # # This software 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 package; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # set -e help() { echo "Stormux x86_64 ISO Builder" echo echo "Usage: $0 [options]" echo echo "Options:" echo " -o Output directory (default: ./out)" echo " -w Work directory (default: ./work)" echo " -h Show this help" echo echo "This script builds a Stormux x86_64 ISO using archiso." echo "It must be run as root on an Arch Linux system." exit 0 } # Parse command line arguments output_dir="./out" work_dir="./work" while getopts "o:w:h" opt; do case "$opt" in o) output_dir="$OPTARG" ;; w) work_dir="$OPTARG" ;; h) help ;; *) help ;; esac done # Make sure this script is run as root if [ "$(whoami)" != "root" ]; then echo "Error: This script must be run as root." exit 1 fi # Check for required tools for tool in mkarchiso pacman; do if ! command -v "$tool" &> /dev/null; then echo "Error: $tool is not installed. Please install archiso package." exit 1 fi done # Get the directory where this script is located script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" pi4_files_dir="$script_dir/../pi4/files" echo "Building Stormux x86_64 ISO..." echo "Profile directory: $script_dir" echo "Output directory: $output_dir" echo "Work directory: $work_dir" echo # Clean up work directory from previous builds to ensure clean build environment if [ -d "$work_dir" ]; then echo "Cleaning up previous build artifacts..." rm -rf "$work_dir" fi # Note: Shared configuration files from pi4/files should already be in airootfs/ # The airootfs/ directory is maintained as part of the x86_64 profile # and should not be dynamically copied during build to avoid conflicts with packages echo "Using existing airootfs configuration files..." # Add Stormux repository key to build host's keyring echo "Setting up Stormux repository key on build host..." key_file="$script_dir/stormux_repo.pub" if [ ! -f "$key_file" ]; then echo "Error: Stormux repository key not found at $key_file" echo "Please ensure stormux_repo.pub exists in the x86_64 directory" exit 1 fi # Check if key is already in keyring if ! pacman-key --list-keys 52ADA49000F1FF0456F8AEEFB4CDE1CD56EF8E82 &>/dev/null; then echo "Adding Stormux repository key to build host keyring..." pacman-key --add "$key_file" pacman-key --lsign-key 52ADA49000F1FF0456F8AEEFB4CDE1CD56EF8E82 echo "Key added successfully" else echo "Stormux repository key already in keyring" fi # Build the ISO mkarchiso -v -w "$work_dir" -o "$output_dir" "$script_dir" echo echo "Build complete!" echo "ISO file is in: $output_dir"