manjaro-tools/bin/buildiso.in

199 lines
5.2 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@
BINDIR='@bindir@'
LIBDIR='@libdir@'
PKGDATADIR='@pkgdatadir@'
SYSCONFDIR='@sysconfdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
[[ -r ${LIBDIR}/util.sh ]] && source ${LIBDIR}/util.sh
[[ -r ${LIBDIR}/util-iso.sh ]] && source ${LIBDIR}/util-iso.sh
show_profile(){
cd $1
load_profile "$1"
if ${verbose};then
msg2 "work_dir: ${work_dir}"
msg2 "iso_file: ${iso_file}"
msg2 "is_custom_pac_conf: ${is_custom_pac_conf}"
msg2 "initsys: ${initsys}"
msg2 "displaymanager: ${displaymanager}"
msg2 "default_desktop_executable: ${default_desktop_executable}"
msg2 "default_desktop_file: ${default_desktop_file}"
msg2 "kernel: ${kernel}"
msg2 "efi_boot_loader: ${efi_boot_loader}"
msg2 "efi_part_size: ${efi_part_size}"
${is_plymouth} && msg2 "plymouth_theme: ${plymouth_theme}"
msg2 "hostname: ${hostname}"
msg2 "username: ${username}"
msg2 "password: ${password}"
msg2 "addgroups: ${addgroups}"
if [[ ${initsys} == 'systemd' ]];then
msg2 "start_systemd: ${start_systemd[*]}"
msg2 "start_systemd_live: ${start_systemd_live[*]}"
else
msg2 "start_openrc: ${start_openrc[*]}"
msg2 "start_openrc_live: ${start_openrc_live[*]}"
fi
fi
cd ..
}
show_build_queue(){
if ${is_buildset};then
local list=$(cat ${sets_dir_iso}/${buildset_iso}.set)
for item in ${list[@]}; do
check_profile "$item" "break"
show_profile "$item"
done
else
check_profile "${buildset_iso}" 'die "Profile sanity check failed."'
show_profile "${buildset_iso}"
fi
}
display_settings(){
show_version
show_config
msg "PROFILE:"
msg2 "buildsets: $(load_sets ${sets_dir_iso})"
msg2 "buildset_iso: ${buildset_iso}"
msg2 "is_buildset: ${is_buildset}"
msg "OPTIONS:"
msg2 "arch: ${arch}"
msg2 "branch: ${branch}"
msg2 "chroots_iso: ${chroots_iso}"
msg "ARGS:"
msg2 "clean_first: ${clean_first}"
msg2 "clean_cache_xorg: ${clean_cache_xorg}"
msg2 "clean_cache_lng: ${clean_cache_lng}"
msg2 "images_only: ${images_only}"
msg2 "iso_only: ${iso_only}"
msg "PATHS:"
msg2 "sets_dir_iso: ${sets_dir_iso}"
msg2 "cache_dir_iso: ${cache_dir_iso}"
msg2 "cache_dir_xorg: ${cache_dir_xorg}"
msg2 "cache_dir_lng: ${cache_dir_lng}"
msg "DIST SETTINGS:"
msg2 "dist_name: ${dist_name}"
msg2 "dist_release: ${dist_release}"
msg2 "dist_codename: ${dist_codename}"
msg2 "dist_version: ${dist_version}"
msg "ISO SETTINGS:"
msg2 "iso_label: ${iso_label}"
msg2 "iso_name: ${iso_name}"
msg2 "iso_publisher: ${iso_publisher}"
msg2 "iso_app_id: ${iso_app_id}"
msg2 "iso_compression: ${iso_compression}"
msg2 "iso_checksum: ${iso_checksum}"
msg "BUILD QUEUE:"
show_build_queue
}
load_user_info
load_config "${USER_CONFIG}/manjaro-tools.conf"
load_config "${SYSCONFDIR}/manjaro-tools.conf"
clean_first=true
clean_cache_xorg=false
clean_cache_lng=false
pretend=false
images_only=false
iso_only=false
verbose=false
pacman_conf_arch='default'
cache_dir_iso="${cache_dir}/iso"
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 ' -c Disable clean work dir'
echo ' -x Clean xorg cache'
echo ' -l Clean lng cache'
echo ' -i Build images only'
echo ' -s Generate iso only'
echo ' Requires pre built images (-i)'
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:cxlisvqh'
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) keep_repo="$OPTARG" ;;
c) clean_first=false ;;
x) clean_cache_xorg=true ;;
l) clean_cache_lng=true ;;
i) images_only=true ;;
s) 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'
cache_dir_lng="${cache_dir}/lng/${arch}"
cache_dir_xorg="${cache_dir}/xorg/${arch}"
mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf"
check_root "$0" "${orig_argv[@]}"
eval_buildset "${buildset_iso}" "${sets_dir_iso}"
prepare_cachedirs
${pretend} && display_settings && exit 1
build_iso