123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- #!/bin/bash
- set -e -u
- # misc constants
- readonly ALL_ARCHES='i686 x86_64'
- readonly EFI_IMG_KBYTES=80000
- readonly LOG_COLOR='\033[01;34m'
- readonly ERR_COLOR='\033[00;31m'
- readonly END_COLOR='\033[00m'
- # edition-specific data
- declare -ar VALID_INITS=('openrc' 'systemd')
- declare -ar VALID_WMDES=('cli' 'lxde' 'mate' 'mini')
- # environment
- data_dir=/usr/share/parabolaiso/data
- releng_dir=$(readlink -f ${0%/*})
- initcpio_dir=${releng_dir}/../../parabolaiso/initcpio
- packages_dir=${releng_dir}/packages
- [ "$(which mkparabolaiso 2> /dev/null)" ] || export PATH=$PATH:"${releng_dir}/../../parabolaiso"
- # CLI option defaults
- iso_arch='x86_64'
- iso_init='systemd'
- iso_wmde='cli'
- enable_tts_brltty='false'
- enable_offline_install='false'
- iso_version=$(date +%Y.%m.%d)
- iso_label="PARA_$(date +%Y%m)"
- iso_dirname='parabola'
- pacman_conf_in=${releng_dir}/pacman.conf
- work_dir=./work
- out_dir=./out
- verbose=''
- # computed vars, pending CLI options
- edition_init='' # deferred
- edition_wmde='' # deferred
- iso_edition='' # deferred
- archs='' # deferred
- launch_msg='' # deferred
- iso_title='' # deferred
- release_id='' # deferred
- iso_filename='' # deferred
- arch='' # deferred
- pacman_conf='' # deferred
- _usage ()
- {
- echo "usage ${0} [options]"
- echo
- echo " General options:"
- echo " -A <iso_arch> Target architecture - one of: [ 'dual' , 'i686' , 'x86_64' ]"
- echo " Default: ${iso_arch}"
- echo " -I <iso_init> Init system - one of: [ 'openrc' , 'systemd' ]"
- echo " Default: ${iso_init}"
- echo " -W <iso_wmde> Graphical environment - one of: [ 'cli' , 'lxde' , 'mini' ]"
- echo " Default: ${iso_wmde}"
- echo " -S Enable speech and braille."
- echo " Default: '${enable_tts_brltty}'"
- echo " -O Enable offline install."
- echo " Default: '' (net-install only)"
- echo " -V <iso_version> Release version string"
- echo " Default: ${iso_version}"
- echo " -L <iso_label> Set the iso volume label"
- echo " Default: ${iso_label}"
- echo " -D <iso_dirname> Set the name of the directory inside the ISO"
- echo " Default: ${iso_dirname}"
- echo " -C Specify the pacman.conf file used for chroot install."
- echo " Default: '${pacman_conf_in}'"
- echo " -w <work_dir> Set the working directory"
- echo " Default: ${work_dir}"
- echo " -o <out_dir> Set the output directory"
- echo " Default: ${out_dir}"
- echo " -v Enable verbose output"
- echo " -h This help message"
- exit ${1}
- }
- LOG_STEP() { printf "${LOG_COLOR}%s${END_COLOR}\n" "$(echo -e $*)" ; }
- LOG_ERROR() { printf "${ERR_COLOR}%s${END_COLOR}\n" "$(echo -e $*)" ; }
- # Helper function to run make_*() only one time per architecture.
- run_once() {
- local buid_stamp="build.${1}_${arch}"
- if [[ ! -e ${work_dir}/${buid_stamp} ]]; then
- LOG_STEP "runnning build step: '${buid_stamp}'"
- $1
- touch ${work_dir}/${buid_stamp}
- fi
- }
- # Setup custom pacman.conf to cache packages on the target filesystem.
- make_pacman_conf() {
- local stash_dir=${work_dir}/isorepo-${arch}
- local isorepo_dir=${work_dir}/${arch}/root-image/isorepo/
- # restore package cache from previous build
- if [[ -d ${stash_dir} ]]; then
- echo "restoring package cache from ${stash_dir}"
- mkdir -p ${isorepo_dir}
- mv ${stash_dir}/* ${isorepo_dir} || true
- fi
- cp ${pacman_conf_in} ${pacman_conf}
- # enable [isorepo]
- sed -i -E 's|^#?\s*CacheDir.+|CacheDir = '${isorepo_dir}'|g' ${pacman_conf}
- # enable [nonsystemd] for openrc ISOs
- if [[ "${iso_init}" == 'openrc' ]]
- then sed -i 'N ; s|^#\[nonsystemd\].*#Include|\[nonsystemd\]\nInclude|' ${pacman_conf}
- fi
- }
- # Base installation, plus needed packages (root-image)
- make_basefs() {
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} init
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "memtest86+ mkinitcpio-nfs-utils nbd" install
- }
- # Additional packages (root-image)
- make_packages() {
- local _base_packages_msg="standard packages as declared in the following files:"
- local _extra_packages_msg="non-graphical packages as declared in the following files:"
- # standard package lists
- local _install_base_lists=$( ls ${packages_dir}/packages-{all,${iso_init}}.{all,${arch}} 2> /dev/null || true)
- local _cache_base_lists=$( ls ${packages_dir}/cache-{all,${iso_init}}.{all,${arch}} 2> /dev/null || true)
- # extra package lists
- local _install_extra_lists=$(ls ${packages_dir}/packages-gui.{all,${arch}} 2> /dev/null || true)
- local _cache_extra_lists=$( ls ${packages_dir}/cache-gui.{all,${arch}} 2> /dev/null || true)
- # init-specific extra package lists
- local _install_init_lists=$( ls ${packages_dir}/packages-${iso_init}-gui.{all,${arch}} 2> /dev/null || true)
- local _cache_init_lists=$( ls ${packages_dir}/cache-${iso_init}-gui.{all,${arch}} 2> /dev/null || true)
- # wmde-specific extra package lists
- local _install_wmde_lists=$( ls ${packages_dir}/packages-${iso_wmde}.{all,${arch}} 2> /dev/null || true)
- local _cache_wmde_lists=$( ls ${packages_dir}/cache-${iso_wmde}.{all,${arch}} 2> /dev/null || true)
- _install_base_lists=${_install_base_lists// /}
- _cache_base_lists=${_cache_base_lists// /}
- _install_extra_lists=${_install_extra_lists// /}
- _cache_extra_lists=${_cache_extra_lists// /}
- _install_init_lists=${_install_init_lists// /}
- _cache_init_lists=${_cache_init_lists// /}
- _install_wmde_lists=${_install_wmde_lists// /}
- _cache_wmde_lists=${_cache_wmde_lists// /}
- # collect standard packages
- local _install_base_packages=$( [ "${_install_base_lists}" ] && grep -hv ^# ${_install_base_lists})
- local _cache_base_packages=$( [ "${_cache_base_lists}" ] && grep -hv ^# ${_cache_base_lists})
- # collect extra packages
- local _install_basegui_packages=$([ "${_install_extra_lists}" ] && grep -hv ^# ${_install_extra_lists})
- local _cache_basegui_packages=$( [ "${_cache_extra_lists}" ] && grep -hv ^# ${_cache_extra_lists})
- # collect init-specific extra packages
- local _install_init_packages=$( [ "${_install_init_lists}" ] && grep -hv ^# ${_install_init_lists})
- local _cache_init_packages=$( [ "${_cache_init_lists}" ] && grep -hv ^# ${_cache_init_lists})
- # collect wmde-specific extra packages
- local _install_wmde_packages=$( [ "${_install_wmde_lists}" ] && grep -hv ^# ${_install_wmde_lists})
- local _cache_wmde_packages=$( [ "${_cache_wmde_lists}" ] && grep -hv ^# ${_cache_wmde_lists})
- if [[ "${iso_wmde}" != 'cli' && "${iso_wmde}" != 'mini' ]]; then
- _install_wmde_lists="${_install_extra_lists} ${_install_init_lists} ${_install_wmde_lists}"
- _cache_wmde_lists="${_cache_extra_lists} ${_cache_init_lists} ${_cache_wmde_lists}"
- _install_wmde_packages="${_install_basegui_packages} ${_install_init_packages} ${_install_wmde_packages}"
- _cache_wmde_packages="${_cache_basegui_packages} ${_cache_init_packages} ${_cache_wmde_packages}"
- fi
- _install_wmde_lists=${_install_wmde_lists// /}
- _cache_wmde_lists=${_cache_wmde_lists// /}
- _install_base_packages=${_install_base_packages// /}
- _cache_base_packages=${_cache_base_packages// /}
- _install_wmde_packages=${_install_wmde_packages// /}
- _cache_wmde_packages=${_cache_wmde_packages// /}
- # display results
- local _install_packages="${_install_base_packages} ${_install_wmde_packages}"
- local _cache_packages="${_cache_base_packages} ${_cache_wmde_packages}"
- _install_packages=${_install_packages// /}
- _cache_packages=${_cache_packages// /}
- [ "${_install_base_packages}" ] && echo "Installing ${_base_packages_msg}" && echo "${_install_base_lists}" | sed "s/.*\//\t/"
- [ "${_cache_base_packages}" ] && echo "Caching ${_base_packages_msg}" && echo "${_cache_base_lists}" | sed "s/.*\//\t/"
- [ "${_install_wmde_packages}" ] && echo "Installing ${_extra_packages_msg}" && echo "${_install_wmde_lists}" | sed "s/.*\//\t/"
- [ "${_cache_wmde_packages}" ] && echo "Caching ${_extra_packages_msg}" && echo "${_cache_wmde_lists}" | sed "s/.*\//\t/"
- # install packages
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${_install_packages}" install
- # create live environment local repo or stash package cache
- if [[ "$enable_offline_install" == 'true' ]]; then
- if [[ -n "${_cache_packages}" ]]; then
- # download any cache packages and prune obsolete packages
- echo 'downloading "cache-only" packages'
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${_cache_packages}" cache
- fi
- # create 'isorepo' for offline install
- echo "creating 'isorepo' for offline install"
- pushd ${work_dir}/${arch}/root-image/isorepo > /dev/null
- setarch ${arch} repo-add --new isorepo.db.tar.gz ./*
- popd > /dev/null
- else
- # stash package cache for next build
- echo "stashing package cache to ${work_dir}/isorepo-${arch}"
- mkdir -p ${work_dir}/isorepo-${arch}/
- mv ${work_dir}/${arch}/root-image/isorepo/* ${work_dir}/isorepo-${arch}/
- rmdir ${work_dir}/${arch}/root-image/isorepo
- fi
- }
- # Copy mkinitcpio parabolaiso hooks and build initramfs (root-image)
- make_setup_mkinitcpio() {
- local _hook
- for _hook in parabolaiso parabolaiso_shutdown parabolaiso_pxe_common parabolaiso_pxe_nbd parabolaiso_pxe_http parabolaiso_pxe_nfs parabolaiso_loop_mnt; do
- cp ${initcpio_dir}/hooks/${_hook} ${work_dir}/${arch}/root-image/usr/lib/initcpio/hooks
- cp ${initcpio_dir}/install/${_hook} ${work_dir}/${arch}/root-image/usr/lib/initcpio/install
- done
- cp ${initcpio_dir}/install/parabolaiso_kms ${work_dir}/${arch}/root-image/usr/lib/initcpio/install
- cp ${initcpio_dir}/hooks/parabolaiso_shutdown ${work_dir}/${arch}/root-image/usr/lib/initcpio
- cp ${releng_dir}/mkinitcpio.conf ${work_dir}/${arch}/root-image/etc/mkinitcpio-parabolaiso.conf
- [[ "${arch}" != 'i686' ]] && sed -i 's|pcmcia||' ${work_dir}/${arch}/root-image/etc/mkinitcpio-parabolaiso.conf
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -r 'mkinitcpio -c /etc/mkinitcpio-parabolaiso.conf -k /boot/vmlinuz-linux-libre -g /boot/parabolaiso.img' run
- }
- # Customize installation (root-image)
- make_customize_root_image() {
- cp -af ${releng_dir}/root-image ${work_dir}/${arch}
- echo "Customizing root image"
- ISO_TITLE="${iso_title}" \
- ISO_INIT="${iso_init}" \
- ISO_WMDE="${iso_wmde}" \
- ISO_ARCH="${iso_arch}" \
- ENABLE_OFFLINE_INSTALL="${enable_offline_install}" \
- ENABLE_TTS_BRLTTY="${enable_tts_brltty}" \
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} \
- -C ${pacman_conf} \
- -D ${iso_dirname} \
- -r /root/customize_root_image.sh \
- run
- rm ${work_dir}/${arch}/root-image/root/customize_root_image*
- }
- # Prepare kernel/initramfs ${iso_dirname}/boot/
- make_boot() {
- mkdir -p ${work_dir}/iso/${iso_dirname}/boot/${arch}
- cp ${work_dir}/${arch}/root-image/boot/parabolaiso.img ${work_dir}/iso/${iso_dirname}/boot/${arch}/parabolaiso.img
- cp ${work_dir}/${arch}/root-image/boot/vmlinuz-linux-libre ${work_dir}/iso/${iso_dirname}/boot/${arch}/vmlinuz
- }
- # Add other aditional/extra files to ${iso_dirname}/boot/
- make_boot_extra() {
- cp ${work_dir}/${arch}/root-image/boot/memtest86+/memtest.bin ${work_dir}/iso/${iso_dirname}/boot/memtest
- cp ${work_dir}/${arch}/root-image/usr/share/licenses/common/GPL2/license.txt ${work_dir}/iso/${iso_dirname}/boot/memtest.COPYING
- }
- # Prepare /${iso_dirname}/boot/syslinux
- make_syslinux() {
- mkdir -p ${work_dir}/iso/${iso_dirname}/boot/syslinux
- for _cfg in ${releng_dir}/syslinux/*.cfg; do
- sed "s|%PARABOLAISO_LABEL%|${iso_label}|g;
- s|%INSTALL_DIR%|${iso_dirname}|g" ${_cfg} > ${work_dir}/iso/${iso_dirname}/boot/syslinux/${_cfg##*/}
- done
- cp ${releng_dir}/syslinux/syslinux-splash-${iso_init}.png ${work_dir}/iso/${iso_dirname}/boot/syslinux/splash.png
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/*.c32 ${work_dir}/iso/${iso_dirname}/boot/syslinux
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/lpxelinux.0 ${work_dir}/iso/${iso_dirname}/boot/syslinux
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/memdisk ${work_dir}/iso/${iso_dirname}/boot/syslinux
- mkdir -p ${work_dir}/iso/${iso_dirname}/boot/syslinux/hdt
- gzip -c -9 ${work_dir}/${arch}/root-image/usr/share/hwdata/pci.ids > ${work_dir}/iso/${iso_dirname}/boot/syslinux/hdt/pciids.gz
- gzip -c -9 ${work_dir}/${arch}/root-image/usr/lib/modules/*-gnu-*/modules.alias > ${work_dir}/iso/${iso_dirname}/boot/syslinux/hdt/modalias.gz
- # inject edition title into boot menu
- sed -i "s|_EDITION_TITLE_|${iso_title}|" ${work_dir}/iso/${iso_dirname}/boot/syslinux/parabolaiso_head.cfg
- # prune orphan boot entries for single-architecture ISO
- if [[ "${archs}" == 'i686' ]]; then
- rm ${work_dir}/iso/${iso_dirname}/boot/syslinux/parabolaiso_*64*.cfg
- elif [[ "${archs}" == 'x86_64' ]]; then
- rm ${work_dir}/iso/${iso_dirname}/boot/syslinux/parabolaiso_*32*.cfg
- fi
- }
- # Prepare /isolinux
- make_isolinux() {
- mkdir -p ${work_dir}/iso/isolinux
- sed "s|%INSTALL_DIR%|${iso_dirname}|g" ${releng_dir}/isolinux/isolinux.cfg > ${work_dir}/iso/isolinux/isolinux.cfg
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/isolinux.bin ${work_dir}/iso/isolinux/
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/isohdpfx.bin ${work_dir}/iso/isolinux/
- cp ${work_dir}/${arch}/root-image/usr/lib/syslinux/bios/ldlinux.c32 ${work_dir}/iso/isolinux/
- }
- # Prepare /EFI
- make_efi() {
- mkdir -p ${work_dir}/iso/EFI/boot
- if [[ "${iso_init}" == 'systemd' ]]; then
- cp ${work_dir}/x86_64/root-image/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${work_dir}/iso/EFI/boot/bootx64.efi
- fi
- mkdir -p ${work_dir}/iso/loader/entries
- cp ${releng_dir}/efiboot/loader/loader.conf ${work_dir}/iso/loader/
- cp ${releng_dir}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/iso/loader/entries/
- cp ${releng_dir}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/iso/loader/entries/
- sed "s|%PARABOLAISO_LABEL%|${iso_label}|g;
- s|%INSTALL_DIR%|${iso_dirname}|g" \
- ${releng_dir}/efiboot/loader/entries/parabolaiso-x86_64-usb.conf > ${work_dir}/iso/loader/entries/parabolaiso-x86_64.conf
- # EFI Shell 2.0 for UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=UEFI_Shell )
- cp ${data_dir}/Shell.efi ${work_dir}/iso/EFI/shellx64_v2.efi
- # EFI Shell 1.0 for non UEFI 2.3+ ( http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Efi-shell )
- cp ${data_dir}/Shell_Full.efi ${work_dir}/iso/EFI/shellx64_v1.efi
- }
- # Prepare efiboot.img::/EFI for "El Torito" EFI boot mode
- make_efiboot() {
- # Cleanup in case of previous aborted run
- while mount | grep ${work_dir}/efiboot > /dev/null; do umount ${work_dir}/efiboot; sleep 1; done;
- rm ${work_dir}/iso/EFI/parabolaiso/efiboot.img 2> /dev/null || true
- # create EFI image
- mkdir -p ${work_dir}/iso/EFI/parabolaiso
- truncate -s ${EFI_IMG_KBYTES}K ${work_dir}/iso/EFI/parabolaiso/efiboot.img
- mkfs.vfat -n PARABOLAEFI ${work_dir}/iso/EFI/parabolaiso/efiboot.img
- mkdir -p ${work_dir}/efiboot
- mkdir -p ${work_dir}/efiboot-staging
- modprobe loop
- mount ${work_dir}/iso/EFI/parabolaiso/efiboot.img ${work_dir}/efiboot
- mkdir -p ${work_dir}/efiboot-staging/EFI/parabolaiso
- cp ${work_dir}/iso/${iso_dirname}/boot/x86_64/vmlinuz ${work_dir}/efiboot-staging/EFI/parabolaiso/vmlinuz.efi
- cp ${work_dir}/iso/${iso_dirname}/boot/x86_64/parabolaiso.img ${work_dir}/efiboot-staging/EFI/parabolaiso/parabolaiso.img
- mkdir -p ${work_dir}/efiboot-staging/EFI/boot
- if [[ "${iso_init}" == 'systemd' ]]; then
- cp ${work_dir}/x86_64/root-image/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${work_dir}/efiboot-staging/EFI/boot/bootx64.efi
- fi
- mkdir -p ${work_dir}/efiboot-staging/loader/entries
- cp ${releng_dir}/efiboot/loader/loader.conf ${work_dir}/efiboot-staging/loader/
- cp ${releng_dir}/efiboot/loader/entries/uefi-shell-v2-x86_64.conf ${work_dir}/efiboot-staging/loader/entries/
- cp ${releng_dir}/efiboot/loader/entries/uefi-shell-v1-x86_64.conf ${work_dir}/efiboot-staging/loader/entries/
- sed "s|%PARABOLAISO_LABEL%|${iso_label}|g;
- s|%INSTALL_DIR%|${iso_dirname}|g" \
- ${releng_dir}/efiboot/loader/entries/parabolaiso-x86_64-cd.conf > ${work_dir}/efiboot-staging/loader/entries/parabolaiso-x86_64.conf
- cp ${work_dir}/iso/EFI/shellx64_v2.efi ${work_dir}/efiboot-staging/EFI/
- cp ${work_dir}/iso/EFI/shellx64_v1.efi ${work_dir}/efiboot-staging/EFI/
- local efi_kbytes=$(($(du -ks ${work_dir}/efiboot-staging | cut -f 1) + 32))
- if [[ ${efi_kbytes} -lt $(( ${EFI_IMG_KBYTES} )) ]]; then
- echo "Populating EFI image (${efi_kbytes}KB)"
- cp -rT ${work_dir}/efiboot-staging ${work_dir}/efiboot
- rm -rf ${work_dir}/efiboot-staging
- umount ${work_dir}/efiboot
- else
- echo "Error: Not enough space on EFI image (${EFI_IMG_KBYTES}KB - need ${efi_kbytes}KB)"
- umount ${work_dir}/efiboot
- exit 1
- fi
- }
- # Copy aitab
- make_aitab() {
- mkdir -p ${work_dir}/iso/${iso_dirname}
- cp ${releng_dir}/aitab ${work_dir}/iso/${iso_dirname}/aitab
- }
- # Build all filesystem images specified in aitab (.fs.sfs .sfs)
- make_prepare() {
- cp -a -l -f ${work_dir}/${arch}/root-image ${work_dir}/
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/ -D ${iso_dirname} -C ${pacman_conf} pkglist
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/ -D ${iso_dirname} -C ${pacman_conf} prepare
- rm -rf ${work_dir}/root-image
- # rm -rf ${work_dir}/${arch}/root-image (if low space, this helps)
- }
- # Build ISO
- make_iso() {
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/ -D ${iso_dirname} checksum
- setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/ -D ${iso_dirname} -L ${iso_label} -o ${out_dir}/ iso ${iso_filename}
- }
- ## prepare state ##
- # collect CLI options
- while getopts 'A:I:W:SOV:L:D:C:w:o:vh' arg; do
- case "${arg}" in
- A) iso_arch="${OPTARG}" ;;
- I) iso_init="${OPTARG}" ;;
- W) iso_wmde="${OPTARG}" ;;
- S) enable_tts_brltty='true' ;;
- O) enable_offline_install='true' ;;
- V) iso_version="${OPTARG}" ;;
- L) iso_label="${OPTARG}" ;;
- D) iso_dirname="${OPTARG}" ;;
- C) pacman_conf_in="${OPTARG}" ;;
- w) work_dir="${OPTARG}" ;;
- o) out_dir="${OPTARG}" ;;
- v) verbose="-v" ;;
- h) _usage 0 ;;
- *)
- echo "Invalid argument '${arg}'"
- _usage 1
- ;;
- esac
- done
- # compute build configuration
- edition_init=$( case "${iso_init}" in 'openrc') echo 'OpenRC' ;; 'systemd') echo 'SystemD' ;; esac )
- edition_wmde=${iso_wmde^^}
- iso_edition=${edition_init}/${edition_wmde}
- case "${iso_arch}" in
- 'i686'|'x86_64')
- archs=${iso_arch}
- launch_msg="Building single-architecture ${iso_edition} ISO for ${archs}"
- ;;
- *)
- archs=${ALL_ARCHES}
- iso_arch='dual'
- launch_msg="Building multi-architecture ${iso_edition} ISO for ${archs}"
- ;;
- esac
- if [[ "$enable_offline_install" == 'true' ]]; then
- iso_type='complete'
- launch_msg="${launch_msg} (offline install enabled)"
- else
- iso_type='netinstall'
- launch_msg="${launch_msg} (net install only)"
- fi
- iso_title="Parabola GNU/Linux-libre Live - ${iso_edition} Edition ${iso_version}"
- release_id=${iso_arch}-${iso_init}-${iso_wmde}-${iso_version}
- iso_filename=parabola-${release_id}-${iso_type}.iso
- [[ "${archs}" == 'i686' ]] && arch='i686' || arch='x86_64'
- pacman_conf=${work_dir}/pacman.conf
- out_dir=${out_dir}/${release_id}
- ## sanity checks ##
- # sanitize mkparabolaiso args
- iso_init=${iso_init// /}
- iso_wmde=${iso_wmde// /}
- iso_arch=${iso_arch// /}
- iso_version=${iso_version// /}
- iso_label=${iso_label// /}
- iso_dirname=${iso_dirname// /}
- enable_offline_install=${enable_offline_install// /}
- enable_tts_brltty=${enable_tts_brltty// /}
- pacman_conf_in=${pacman_conf_in// /}
- work_dir=${work_dir// /}
- out_dir=${out_dir// /}
- iso_filename=${iso_filename// /}
- pacman_conf=${pacman_conf// /}
- # validate build environment
- if [[ "$(uname -m)" != 'x86_64' ]] || ! grep 'ID_LIKE="*arch' /usr/lib/os-release > /dev/null; then
- LOG_ERROR "This script needs to be run on an x86_64 ArchLinux derrivative."
- exit 1
- elif [[ ${EUID} -ne 0 ]]; then
- LOG_ERROR "This script needs to be run with root privileges."
- exit 1
- elif ! pacman --version | grep libalpm > /dev/null; then
- LOG_ERROR "This script needs the 'pacman' package manager to be installed."
- exit 1
- elif [[ "${archs}" =~ 'x86_64' ]] && ! pacman -Qi parabolaiso-data > /dev/null; then
- LOG_ERROR "x86_64 ISOs require the 'parabolaiso-data' package to be installed."
- exit 1
- elif ! echo "${VALID_INITS[@]}" | tr " " "\n" | grep -E "^${iso_init}$" > /dev/null || \
- ! echo "${VALID_WMDES[@]}" | tr " " "\n" | grep -E "^${iso_wmde}$" > /dev/null ; then
- LOG_ERROR "Invalid init/wm combination: '${iso_edition}'."
- exit 1
- fi
- # detect previously completed build
- prefix=${work_dir}/build.make_
- is_done=1
- single_pass_build_steps='boot_extra syslinux isolinux aitab iso'
- for build_step in $single_pass_build_steps
- do [ -f "${prefix}${build_step}_${arch}" ] || is_done=0
- done
- multi_pass_build_steps='pacman_conf basefs packages setup_mkinitcpio customize_root_image boot prepare'
- for build_step in $multi_pass_build_steps
- do for arch in ${archs}
- do [ -f "${prefix}${build_step}_${arch}" ] || is_done=0
- done
- done
- if ! (($is_done)); then LOG_STEP "${launch_msg}"; else LOG_STEP "Nothing to do"; exit; fi;
- ## build ISO ##
- # prepare environment
- chown -R 0:0 "${releng_dir}/root-image/"
- mkdir -p "$(realpath ${work_dir})" # allow symlink
- # prepare target filesystems
- for arch in ${archs}; do
- run_once make_pacman_conf
- run_once make_basefs
- run_once make_packages
- run_once make_setup_mkinitcpio
- run_once make_customize_root_image
- done
- # prepare kernels and initrds
- for arch in ${archs}; do
- run_once make_boot
- done
- # prepare ISO
- run_once make_boot_extra
- run_once make_syslinux
- run_once make_isolinux
- # prepare EFI
- if [[ "$(echo ${archs} | grep x86_64)" ]]; then
- run_once make_efi
- run_once make_efiboot
- fi
- # prepare SFSs
- run_once make_aitab
- for arch in ${archs}; do
- run_once make_prepare
- done
- # build ISO
- run_once make_iso
- LOG_STEP "done - ISO: '${iso_filename}' created successfully"
|