nix-tools/bin/buildiso.in

214 lines
6.7 KiB
Text
Raw Normal View History

2014-12-04 19:19:54 +01:00
#!/bin/bash
2014-12-04 19:20:28 +01:00
#
# 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.
2014-12-04 19:19:54 +01:00
version=@version@
2014-12-04 19:19:54 +01:00
LIBDIR='@libdir@'
DATADIR='@datadir@'
SYSCONFDIR='@sysconfdir@'
2014-12-14 03:48:46 +01:00
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
2015-06-09 00:01:31 +02:00
import ${LIBDIR}/util.sh
2014-12-04 19:19:54 +01:00
show_profile(){
2016-09-15 23:58:18 +02:00
prepare_profile "$1"
2017-02-16 10:24:38 +01:00
msg2 "iso_file: %s" "${iso_file}"
msg2 "iso_label: %s" "${iso_label}"
2018-04-14 00:07:43 +02:00
if ${verbose}; then
2016-09-15 23:58:18 +02:00
msg2 "autologin: %s" "${autologin}"
msg2 "nonfree_mhwd: %s" "${nonfree_mhwd}"
[[ ${target_arch} == 'x86_64' ]] && msg2 "multilib: %s" "${multilib}"
msg2 "extra: %s" "${extra}"
msg2 "office_installer: %s" "${office_installer}"
msg2 "permalink: %s" "${permalink}"
2016-09-15 23:58:18 +02:00
msg2 "netinstall: %s" "${netinstall}"
msg2 "chrootcfg: %s" "${chrootcfg}"
2016-09-15 23:58:18 +02:00
${netinstall} && msg2 "netgroups: %s" "$(get_yaml)"
msg2 "geoip: %s" "${geoip}"
2019-12-15 00:34:37 +01:00
msg2 "oem_used: %s" "${oem_used}"
2016-09-15 23:58:18 +02:00
msg2 "efi_boot_loader: %s" "${efi_boot_loader}"
2019-12-15 00:34:37 +01:00
msg2 "custom_boot_args: %s" "${custom_boot_args}"
2016-09-15 23:58:18 +02:00
msg2 "hostname: %s" "${hostname}"
msg2 "username: %s" "${username}"
msg2 "password: %s" "${password}"
2020-10-31 09:52:14 +01:00
msg2 "user_shell: %s" "${user_shell}"
2016-09-15 23:58:18 +02:00
msg2 "login_shell: %s" "${login_shell}"
msg2 "addgroups: %s" "${addgroups}"
[[ -n ${smb_workgroup} ]] && msg2 "smb_workgroup: %s" "${smb_workgroup}"
2018-04-14 01:09:07 +02:00
msg2 "enable_systemd: %s" "${enable_systemd[*]}"
msg2 "enable_systemd_live: %s" "${enable_systemd_live[*]}"
[[ -n ${disable_systemd[*]} ]] && msg2 "disable_systemd: %s" "${disable_systemd[*]}"
2019-06-12 21:52:16 +02:00
msg2 "strict_snaps: %s" "${strict_snaps}"
msg2 "classic_snaps: %s" "${classic_snaps}"
2019-06-13 00:49:26 +02:00
msg2 "snap_channel: %s" "${snap_channel}"
2016-09-15 23:58:18 +02:00
fi
reset_profile
}
2014-12-04 20:05:33 +01:00
display_settings(){
2016-09-15 23:58:18 +02:00
show_version
show_config
msg "PROFILE:"
msg2 "gitlab branch: %s" "${branch}"
2016-09-15 23:58:18 +02:00
msg2 "build_lists: %s" "$(show_build_lists ${list_dir_iso})"
msg2 "build_list_iso: %s" "${build_list_iso}"
msg2 "is_build_list: %s" "${is_build_list}"
msg "OPTIONS:"
msg2 "arch: %s" "${target_arch}"
msg2 "branch: %s" "${target_branch}"
msg2 "kernel: %s" "${kernel}"
2017-02-15 01:18:20 +01:00
[[ -n ${gpgkey} ]] && msg2 "gpgkey: %s" "${gpgkey}"
2016-09-15 23:58:18 +02:00
msg "ARGS:"
msg2 "clean_first: %s" "${clean_first}"
msg2 "images_only: %s" "${images_only}"
msg2 "iso_only: %s" "${iso_only}"
2016-10-13 15:24:31 +02:00
msg2 "persist: %s" "${persist}"
msg2 "extra: %s" "${full_iso}"
msg2 "permalink: %s" "${permalink}"
msg2 "office_installer: %s" "${office_installer}"
2016-09-15 23:58:18 +02:00
msg "DIST SETTINGS:"
msg2 "dist_name: %s" "${dist_name}"
msg2 "dist_release: %s" "${dist_release}"
msg2 "dist_codename: %s" "${dist_codename}"
2017-02-16 10:24:38 +01:00
msg "ISO INFO:"
msg2 "iso_compression: %s" "${iso_compression}"
2016-09-15 23:58:18 +02:00
msg "BUILD QUEUE:"
run show_profile "${build_list_iso}"
2015-01-15 02:49:21 +01:00
}
2015-01-13 13:41:28 +01:00
load_user_info
2014-12-14 03:48:46 +01:00
2016-06-14 17:54:44 +02:00
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}"
2015-12-01 12:24:23 +01:00
clean_first=true
2014-12-18 02:03:40 +01:00
pretend=false
images_only=false
2014-12-14 17:22:47 +01:00
iso_only=false
verbose=false
2016-10-13 15:24:31 +02:00
persist=false
initialize=false
permalink=false
2014-12-07 06:36:46 +01:00
usage() {
2016-09-15 23:58:18 +02:00
echo "Usage: ${0##*/} [options]"
echo " -a <arch> Arch [default: ${target_arch}]"
echo " -b <branch> Branch [default: ${target_branch}]"
echo ' -c Disable clean work dir'
echo ' -d <comp> Compression used for build ISO: gzip, lzma, lz4, lzo, xz, zstd'
echo " [default: ${iso_compression}]"
echo ' -f Build full ISO (extra=true)'
echo ' -g <key> The gpg key for sfs signing'
echo " [default: ${gpgkey}]"
echo " -i Initialize iso-profiles repo [default: ${branch}]"
echo ' -k <name> Kernel to use'
echo " [default: ${kernel}]"
echo ' -l Create permalink'
echo ' -m Set SquashFS image mode to persistence'
echo " -p <profile> Buildset or profile [default: ${build_list_iso}]"
echo ' -o Enable office installer module'
echo ' -q Query settings and pretend build'
2016-09-15 23:58:18 +02:00
echo ' -r <dir> Chroots directory'
echo " [default: ${chroots_iso}]"
echo ' -t <dir> Target directory'
echo " [default: ${cache_dir_iso}]"
echo ' -v Verbose output to log file, show profile detail (-q)'
2016-09-15 23:58:18 +02:00
echo ' -x Build images only'
echo ' -z Generate iso only'
echo ' Requires pre built images (-x)'
echo ' -h This help'
echo ''
echo ''
exit $1
2014-12-07 06:36:46 +01:00
}
orig_argv=("$@")
2020-03-01 12:29:59 +01:00
opts='p:a:b:r:t:k:g:d:cfzxmvqhilo'
2014-12-07 06:36:46 +01:00
while getopts "${opts}" arg; do
2016-09-15 23:58:18 +02:00
case "${arg}" in
i) initialize=true ;;
2016-09-15 23:58:18 +02:00
a) target_arch="$OPTARG" ;;
b) target_branch="$OPTARG" ;;
c) clean_first=false ;;
f) full_iso=true ;;
d) iso_compression="$OPTARG" ;;
2018-04-14 01:09:07 +02:00
g) gpgkey="$OPTARG" ;;
k) kernel="$OPTARG" ;;
2016-10-13 15:24:31 +02:00
m) persist=true ;;
2018-04-14 01:09:07 +02:00
p) build_list_iso="$OPTARG" ;;
2016-09-15 23:58:18 +02:00
q) pretend=true ;;
2018-04-14 01:09:07 +02:00
r) chroots_iso="$OPTARG" ;;
t) cache_dir_iso="$OPTARG" ;;
v) verbose=true ;;
x) images_only=true ;;
z) iso_only=true ;;
l) permalink=true ;;
2020-03-01 12:29:59 +01:00
o) office_installer=true ;;
2018-04-14 01:42:35 +02:00
h|?) usage 0 ;;
2016-09-15 23:58:18 +02:00
*) echo "invalid argument '${arg}'"; usage 1 ;;
esac
2014-12-07 06:36:46 +01:00
done
shift $(($OPTIND - 1))
if ${initialize}; then
msg "Initialize iso profiles ${branch}"
init_profiles
msg2 "Done: iso profiles are stored in /usr/share/manjaro-tools/iso-profiles"
exit 1
fi
2015-02-18 04:28:11 +01:00
timer_start=$(get_timer)
2015-02-17 19:45:35 +01:00
2015-01-15 02:49:21 +01:00
check_root "$0" "${orig_argv[@]}"
2014-12-05 02:22:14 +01:00
prepare_dir "${log_dir}"
2017-10-23 23:31:50 +02:00
user_own "${log_dir}"
prepare_dir "${tmp_dir}"
2016-06-09 18:03:38 +02:00
eval_build_list "${list_dir_iso}" "${build_list_iso}"
import ${LIBDIR}/util-iso.sh
import ${LIBDIR}/util-iso-mount.sh
check_requirements
for sig in TERM HUP QUIT; do
2016-09-15 23:58:18 +02:00
trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig"
done
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
${pretend} && display_settings && exit 1
2016-06-09 18:03:38 +02:00
run build "${build_list_iso}"