nix-tools/bin/buildiso.in

190 lines
5.3 KiB
Bash
Executable file

#!/bin/bash
#
# 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; version 2 of the License.
#
# 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.
version=@version@
LIBDIR='@libdir@'
DATADIR='@datadir@'
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
import ${LIBDIR}/util.sh
show_profile(){
eval_edition "$1"
load_profile "${run_dir}/${edition}/$1"
if ${verbose};then
msg2 "work_dir: %s" "${work_dir}"
msg2 "iso_dir: %s" "${iso_dir}"
msg2 "iso_file: %s" "${iso_file}"
msg2 "displaymanager: %s" "${displaymanager}"
msg2 "autologin: %s" "${autologin}"
msg2 "nonfree_xorg: %s" "${nonfree_xorg}"
msg2 "pxe_boot: %s" "${pxe_boot}"
msg2 "plymouth_boot: %s" "${plymouth_boot}"
${plymouth_boot} && msg2 "plymouth_theme: %s" "${plymouth_theme}"
[[ ${arch} == 'x86_64' ]] && msg2 "multilib: %s" "${multilib}"
msg2 "efi_boot_loader: %s" "${efi_boot_loader}"
msg2 "efi_part_size: %s" "${efi_part_size}"
msg2 "hostname: %s" "${hostname}"
msg2 "username: %s" "${username}"
msg2 "password: %s" "${password}"
msg2 "addgroups: %s" "${addgroups}"
if [[ ${initsys} == 'systemd' ]];then
msg2 "start_systemd: %s" "${start_systemd[*]}"
msg2 "start_systemd_live: %s" "${start_systemd_live[*]}"
msg2 "disable_systemd: %s" "${disable_systemd[*]}"
else
msg2 "start_openrc: %s" "${start_openrc[*]}"
msg2 "start_openrc_live: %s" "${start_openrc_live[*]}"
msg2 "disable_openrc: %s" "${disable_openrc[*]}"
fi
msg2 "is_custom_pac_conf: %s" "${is_custom_pac_conf}"
fi
unset_profile
}
display_settings(){
show_version
show_config
msg "PROFILE:"
msg2 "sets_dir_iso: %s" "${sets_dir_iso}"
msg2 "buildsets: %s" "$(list_sets ${sets_dir_iso})"
msg2 "buildset_iso: %s" "${buildset_iso}"
msg2 "is_buildset: %s" "${is_buildset}"
msg2 "run_dir: %s" "${run_dir}"
msg "OPTIONS:"
msg2 "arch: %s" "${arch}"
msg2 "branch: %s" "${branch}"
msg2 "chroots_iso: %s" "${chroots_iso}"
msg2 "initsys: %s" "${initsys}"
msg2 "kernel: %s" "${kernel}"
msg "ARGS:"
msg2 "clean_first: %s" "${clean_first}"
msg2 "images_only: %s" "${images_only}"
msg2 "iso_only: %s" "${iso_only}"
msg2 "sign: %s" "${sign}"
msg "DIST SETTINGS:"
msg2 "dist_name: %s" "${dist_name}"
msg2 "dist_release: %s" "${dist_release}"
msg2 "dist_codename: %s" "${dist_codename}"
msg "ISO SETTINGS:"
msg2 "iso_label: %s" "${iso_label}"
msg2 "iso_name: %s" "${iso_name}"
msg2 "iso_publisher: %s" "${iso_publisher}"
msg2 "iso_app_id: %s" "${iso_app_id}"
msg2 "iso_compression: %s" "${iso_compression}"
msg2 "iso_checksum: %s" "${iso_checksum}"
msg2 "use_overlayfs: %s" "${use_overlayfs}"
msg2 "iso_fs: %s" "${iso_fs}"
msg "BUILD QUEUE:"
run show_profile "${buildset_iso}"
}
load_user_info
load_config "${USERCONFDIR}/manjaro-tools.conf"
load_config "${SYSCONFDIR}/manjaro-tools.conf"
# to force old way to have buildiso run in iso-profiles dir
# run_dir=$(pwd)
load_run_dir "${profile_repo}"
clean_first=true
pretend=false
images_only=false
iso_only=false
verbose=false
sign=false
pacman_conf_arch='default'
usage() {
echo "Usage: ${0##*/} [options]"
echo " -p <profile> Buildset or profile [default: ${buildset_iso}]"
echo " -a <arch> Arch [default: ${arch}]"
echo " -b <branch> Branch [default: ${branch}]"
echo ' -r <dir> Chroots directory'
echo " [default: ${chroots_iso}]"
echo ' -t <dir> Target directory'
echo " [default: ${cache_dir_iso}]"
echo ' -k <name> Kernel to use'
echo " [default: ${kernel}]"
echo ' -i <name> Init system to use'
echo " [default: ${initsys}]"
echo ' -s Sign the iso'
echo ' -c Disable clean work dir'
echo ' -x Build images only'
echo ' -z Generate iso only'
echo ' Requires pre built images (-x)'
echo ' -v Verbose output, show profies detail (-q)'
echo ' -q Query settings and pretend build'
echo ' -h This help'
echo ''
echo ''
exit $1
}
orig_argv=("$@")
opts='p:a:b:r:t:k:i:czxsvqh'
while getopts "${opts}" arg; do
case "${arg}" in
p) buildset_iso="$OPTARG" ;;
a) arch="$OPTARG" ;;
b) branch="$OPTARG" ;;
r) chroots_iso="$OPTARG" ;;
t) cache_dir_iso="$OPTARG" ;;
k) kernel="$OPTARG" ;;
i) initsys="$OPTARG" ;;
s) sign=true ;;
c) clean_first=false ;;
x) images_only=true ;;
z) iso_only=true ;;
v) verbose=true ;;
q) pretend=true ;;
h|?) usage 0 ;;
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
shift $(($OPTIND - 1))
timer_start=$(get_timer)
[[ "${arch}" == 'x86_64' ]] && pacman_conf_arch='multilib'
mirrors_conf="${DATADIR}/pacman-mirrors-${branch}.conf"
check_root "$0" "${orig_argv[@]}"
eval_buildset "${sets_dir_iso}" "${buildset_iso}"
import ${LIBDIR}/util-iso.sh
check_requirements
${pretend} && display_settings && exit 1
run make_profile "${buildset_iso}"