index : releng | |
Archlinux32 release engineering | gitolite user |
summaryrefslogtreecommitdiff |
-rwxr-xr-x | build-iso | 124 |
diff --git a/build-iso b/build-iso new file mode 100755 index 0000000..7c6ac33 --- /dev/null +++ b/build-iso @@ -0,0 +1,124 @@ +#!/bin/bash + +# parameters and default values +CONFIG="releng" +ARCH="i686" +DATE=$(date +%Y.%m.%d) +ISO="archlinux32-${DATE}-${ARCH}.iso" +OUTPUT_DIR="${HOME}/archisos" + +# prerequisites: +# - https://gitlab.archlinux.org/archlinux/archiso +# - mkinitcpio-archiso32, archiso32 installed in /usr/local +# - pacman-mirrorlist32 for /etc/pacman.d/mirrorlist32 +# - arch-install-scripts awk dosfstools e2fsprogs findutils gzip +# libarchive libisoburn mtools openssl pacman sed squashfs-tools + +usage() { + >&2 echo "" + >&2 echo "build-iso: builds ISOs for Archlinux32" + >&2 echo "" + >&2 echo "possible options:" + >&2 echo " -h|--help: show this help and exit." + >&2 echo " --config mkarchiso configuration to use, default is '$CONFIG'." + >&2 echo " --arch architecture to build ISO for, default is '$ARCH'." + >&2 echo " --outputdir where to write the isos, default is '~/archisos." + >&2 echo " --iso name of the resulting ISO, default is '$ISO'." + >&2 echo " --no-cleanup do not clean up tmpdir after run, for debugging." + [ -z "$1" ] && exit 1 || exit "$1" +} + +# fail on first error +set -e + +# cleanup hook +tmp_dir="$(mktemp -d)" +cleanup() { + if [ "${no_cleanup}" = 0 ]; then + if mountpoint -q "${tmp_dir}"; then + sudo umount "${tmp_dir}" + fi + rm -rf --one-file-system "${tmp_dir}" + fi +} +trap cleanup EXIT + +eval set -- "$( + getopt -o h \ + --long help \ + --long config: \ + --long arch: \ + --long output-dir: \ + --long iso: \ + --long no-cleanup \ + -n "$(basename "$0")" -- "$@" || \ + echo usage +)" + +config="$CONFIG" +arch="$ARCH" +iso="$ISO" +no_cleanup=0 +output_dir="${OUTPUT_DIR}" + +while [ $# -gt 0 ]; do + case "$1" in + '--config') + shift + config="$1" + if [ ! -s "/usr/local/share/archiso/configs/${config}/profiledef.sh" ]; then + printf "'${config}' is not a valid mkarchiso profile in usr/local/share/archiso/configs" >&2 + usage + fi + ;; + '--arch') + shift + arch="$1" + ;; + '--iso') + shift + iso="$1" + ;; + '--output-dir') + shift + output_dir="$1" + ;; + '--no-cleanup') + no_cleanup=1 + ;; + '--help'|'-h') + usage 0 + ;; + '--') + shift + break + ;; + *) + >&2 printf 'Whoops, option "%s" is not yet implemented!\n' "$1" >&2 + exit 42 + ;; + esac + shift +done + +if [ $# -gt 0 ]; then + >&2 echo 'Too many arguments.' >&2 + exit 2 +fi + +echo "parameters for ISO are:" +echo "mkarchiso config: $config" +echo "architecture: $arch" +echo "destination ISO file: $iso" +sleep 5 + +echo "building $ISO..." +tmp_dir=$(mktemp -d) +trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT +arch="${arch}" setarch i686 mkarchiso -L "ARCH32_$DATE" -o "${output_dir}" -w "${tmp_dir}" -v "/usr/local/share/archiso/configs/${config}" + +if [ "${no_cleanup}" -eq 1 ]; then + echo "no-cleanup specified, find your temporary data in ${tmp_dir}.." +fi + +echo "done" |