239 lines
6.3 KiB
Bash
Executable file
239 lines
6.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@
|
|
|
|
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
|
|
|
|
display_settings(){
|
|
msg "manjaro-tools"
|
|
msg2 "version: ${version}"
|
|
|
|
if [[ -f ${USER_CONFIG}/manjaro-tools.conf ]]; then
|
|
msg2 "user_config: ${USER_CONFIG}/manjaro-tools.conf"
|
|
else
|
|
msg2 "manjaro_tools_conf: ${manjaro_tools_conf}"
|
|
fi
|
|
|
|
msg "PROFILE:"
|
|
msg2 "iso_profile: ${iso_profile}"
|
|
msg2 "initsys: ${initsys}"
|
|
msg2 "displaymanager: ${displaymanager}"
|
|
|
|
msg "OPTIONS:"
|
|
msg2 "arch: ${arch}"
|
|
msg2 "branch: ${branch}"
|
|
msg2 "chroots_iso: ${chroots_iso}"
|
|
|
|
msg "ARGS:"
|
|
msg2 "clean_first: ${clean_first}"
|
|
msg2 "clean_cache_pkgs: ${clean_cache_pkgs}"
|
|
msg2 "clean_cache_lng: ${clean_cache_lng}"
|
|
msg2 "custom_pac_conf: ${custom_pac_conf}"
|
|
msg2 "images_only: ${images_only}"
|
|
msg2 "iso_only: ${iso_only}"
|
|
msg2 "auto_svc_conf: ${auto_svc_conf}"
|
|
msg2 "high_compression: ${high_compression}"
|
|
|
|
msg "PATHS:"
|
|
msg2 "work_dir: ${work_dir}"
|
|
msg2 "iso_dir: ${iso_dir}"
|
|
msg2 "cache_pkgs: ${cache_pkgs}"
|
|
msg2 "cache_lng: ${cache_lng}"
|
|
|
|
# msg2 "pacman_conf: ${pacman_conf}"
|
|
# msg2 "pacman_mirrors: ${mirrors_conf}"
|
|
|
|
msg "IMAGES SETTINGS:"
|
|
msg2 "manjaro_kernel: ${manjaro_kernel}"
|
|
msg2 "manjaro_version: ${manjaro_version}"
|
|
|
|
msg2 "plymouth_theme: ${plymouth_theme}"
|
|
|
|
if ${auto_svc_conf};then
|
|
if [ ${initsys} == "systemd" ];then
|
|
msg2 "start_systemd: ${start_systemd[*]}"
|
|
else
|
|
msg2 "start_openrc: ${start_openrc[*]}"
|
|
fi
|
|
fi
|
|
|
|
msg "ISO SETTINGS:"
|
|
msg2 "iso_label: ${iso_label}"
|
|
msg2 "iso_version: ${iso_version}"
|
|
msg2 "manjaroiso: ${manjaroiso}"
|
|
msg2 "code_name: ${code_name}"
|
|
msg2 "img_name: ${img_name}"
|
|
msg2 "install_dir: ${install_dir}"
|
|
msg2 "iso_file: ${iso_file}"
|
|
msg2 "compression: ${compression}"
|
|
|
|
msg "LIVECD:"
|
|
msg2 "username: ${username}"
|
|
msg2 "password: ${password}"
|
|
msg2 "addgroups: ${addgroups}"
|
|
msg2 "hostname: ${hostname}"
|
|
|
|
if ${auto_svc_conf};then
|
|
if [ ${initsys} == "systemd" ];then
|
|
msg2 "start_systemd_live: ${start_systemd_live[*]}"
|
|
else
|
|
msg2 "start_openrc_live: ${start_openrc_live[*]}"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
iso_owner=${SUDO_USER:-$USER}
|
|
|
|
if [[ -n $SUDO_USER ]]; then
|
|
eval "USER_HOME=~$SUDO_USER"
|
|
else
|
|
USER_HOME=$HOME
|
|
fi
|
|
|
|
USER_CONFIG="$USER_HOME/.config"
|
|
|
|
load_config "${USER_CONFIG}/manjaro-tools.conf"
|
|
load_config "${SYSCONFDIR}/manjaro-tools.conf"
|
|
|
|
load_desktop_definition
|
|
|
|
clean_first=true
|
|
auto_svc_conf=true
|
|
high_compression=true
|
|
clean_cache_pkgs=true
|
|
clean_cache_lng=true
|
|
|
|
pretend=false
|
|
verbose=false
|
|
images_only=false
|
|
iso_only=false
|
|
custom_pac_conf=false
|
|
|
|
pacman_conf_arch='default'
|
|
|
|
usage() {
|
|
echo "Usage: ${0##*/} [options]"
|
|
echo ' -a <arch> Set arch'
|
|
echo " [default: ${arch}]"
|
|
echo ' -b <branch> Set branch'
|
|
echo " [default: ${branch}]"
|
|
echo ' -r <dir> Chroots directory'
|
|
echo " [default: ${chroots_iso}]"
|
|
echo ' -t <dir> Target iso directory'
|
|
echo " [default: ${iso_dir}]"
|
|
echo ' -v Verbose iso compression'
|
|
echo ' -q Query settings and pretend build'
|
|
echo ' -c Disable clean work dir and target dir iso'
|
|
echo ' -z Disable high compression'
|
|
echo ' -A Disable auto configure services'
|
|
echo ' -B Build images only'
|
|
echo ' -G Generate iso only'
|
|
echo ' Requires pre built images'
|
|
echo ' -P Disable clean pkgs cache'
|
|
echo ' -L Disable clean lng cache'
|
|
echo " -C Use custom pacman.conf in iso profile"
|
|
echo ' -h This help'
|
|
echo ''
|
|
echo ''
|
|
exit 1
|
|
}
|
|
|
|
orig_argv=("$@")
|
|
|
|
opts='a:b:r:t:cvzqABGPLCh'
|
|
|
|
while getopts "${opts}" arg; do
|
|
case "${arg}" in
|
|
a) arch="$OPTARG" ;;
|
|
b) branch="$OPTARG" ;;
|
|
r) chroots_iso="$OPTARG" ;;
|
|
t) iso_dir="$OPTARG" ;;
|
|
v) verbose=true; mkiso_args+=(-v) ;;
|
|
B) images_only=true ;;
|
|
G) iso_only=true ;;
|
|
q) pretend=true ;;
|
|
C) custom_pac_conf=true ;;
|
|
P) clean_cache_pkgs=false ;;
|
|
L) clean_cache_lng=false ;;
|
|
c) clean_first=false ;;
|
|
z) high_compression=false ;;
|
|
A) auto_svc_conf=false ;;
|
|
h) usage ;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
if [[ "$arch" == 'x86_64' ]]; then
|
|
pacman_conf_arch='multilib'
|
|
fi
|
|
|
|
if ${custom_pac_conf};then
|
|
pacman_conf="${PWD}/pacman-${pacman_conf_arch}.conf"
|
|
else
|
|
pacman_conf="${PKGDATADIR}/pacman-${pacman_conf_arch}.conf"
|
|
fi
|
|
mirrors_conf="${PKGDATADIR}/pacman-mirrors-${branch}.conf"
|
|
|
|
create_args+=(-v -a ${arch} -D ${install_dir} -C ${pacman_conf} -M ${mirrors_conf})
|
|
|
|
mkiso_args+=(-a ${arch} -D ${install_dir} -L ${iso_label} -c ${compression})
|
|
|
|
iso_file="${iso_dir}/${img_name}-${desktop}-${iso_version}-${arch}.iso"
|
|
|
|
iso_profile=${PWD##*/}
|
|
|
|
work_dir=${chroots_iso}/${iso_profile}/${arch}
|
|
|
|
cache_lng="${cache_dir}/lng"
|
|
|
|
cache_pkgs="${cache_dir}/pkgs"
|
|
|
|
displaymanager=$(cat ${PWD}/displaymanager)
|
|
initsys=$(cat ${PWD}/initsys)
|
|
|
|
${high_compression} && mkiso_args+=(-x)
|
|
${clean_first} && mkiso_args+=(-f)
|
|
|
|
check_root "$0" "${orig_argv[@]}"
|
|
|
|
${pretend} && display_settings && exit 1
|
|
|
|
if ${iso_only}; then
|
|
[[ ! -d ${work_dir} ]] && die "You need to create images first eg. buildiso -B"
|
|
compress_images
|
|
exit 1
|
|
fi
|
|
|
|
${clean_first} && clean_up
|
|
|
|
${clean_cache_pkgs} && clean_cache "${cache_pkgs}"
|
|
${clean_cache_lng} && clean_cache "${cache_lng}"
|
|
|
|
prepare_buildiso
|
|
|
|
if ${images_only}; then
|
|
make_images
|
|
warning "Continue with eg. buildiso -Gv ..."
|
|
exit 1
|
|
else
|
|
make_images
|
|
fi
|
|
|
|
compress_images
|