nix-tools/bin/buildiso.in

247 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
2014-12-04 19:20:28 +01:00
version=@version@
2014-12-04 19:19:54 +01:00
2014-12-04 19:20:28 +01:00
[[ -r @libdir@/util-msg.sh ]] && source @libdir@/util-msg.sh
[[ -r @libdir@/util.sh ]] && source @libdir@/util.sh
2014-12-08 23:50:56 +01:00
[[ -r @libdir@/util-iso.sh ]] && source @libdir@/util-iso.sh
2014-12-07 06:53:12 +01:00
# [[ -r @libdir@/util-mount.sh ]] && source @libdir@/util-mount.sh
2014-12-04 19:19:54 +01:00
2014-12-04 20:05:33 +01:00
display_settings(){
msg "manjaro-tools"
msg2 "version: ${version}"
2014-12-10 02:16:23 +01:00
msg2 "manjaro_tools_conf: ${manjaro_tools_conf}"
if [[ -f $USER_HOME/.config/manjaro-tools.conf ]]; then
msg2 "user_config: $USER_HOME/.config/manjaro-tools.conf"
fi
2014-12-04 20:05:33 +01:00
msg "OPTIONS:"
msg2 "arch: ${arch}"
msg2 "branch: ${branch}"
msg2 "work_dir: ${work_dir}"
2014-12-04 22:54:23 +01:00
msg2 "target_dir: ${target_dir}"
msg2 "pacman_conf: ${pacman_conf}"
2014-12-04 22:54:23 +01:00
2014-12-04 20:05:33 +01:00
msg "ARGS:"
2014-12-07 06:36:46 +01:00
msg2 "xorg_overlays: ${xorg_overlays}"
msg2 "kde_lng_packages: ${kde_lng_packages}"
msg2 "high_compression: ${high_compression}"
msg "ISO SETTINGS:"
msg2 "iso_label: ${iso_label}"
msg2 "iso_version: ${iso_version}"
msg2 "manjaro_kernel: ${manjaro_kernel}"
msg2 "manjaro_kernel_ver: ${manjaro_kernel_ver}"
msg2 "manjaro_version: ${manjaro_version}"
msg2 "manjaroiso: ${manjaroiso}"
msg2 "code_name: ${code_name}"
msg2 "img_name: ${img_name}"
msg2 "install_dir: ${install_dir}"
msg2 "plymouth_theme: ${plymouth_theme}"
msg2 "compression: ${compression}"
2014-12-07 06:36:46 +01:00
2014-12-11 04:03:12 +01:00
msg "LIVECD:"
2014-12-11 04:04:51 +01:00
msg2 "username: ${username}"
2014-12-11 04:03:12 +01:00
msg2 "password: ${password}"
msg2 "encrypted password: $(gen_pw)"
msg2 "addgroups: ${addgroups}"
msg2 "hostname: ${hostname}"
msg2 "pacman_mirrors: ${mirrors_conf}"
2014-12-12 21:29:37 +01:00
if ${auto_svc_conf};then
msg2 "startservices_systemd: ${startservices_systemd[*]}"
msg2 "startservices_openrc: ${startservices_openrc[*]}"
msg2 "startservices_livecd: ${startservices_livecd[*]}"
fi
2014-12-07 06:36:46 +01:00
msg "ISOFILE:"
msg2 "iso_file: ${iso_file}"
2014-12-04 20:05:33 +01:00
}
copy_util_sh(){
local util=$1
2014-12-09 03:06:48 +01:00
msg2 "Copying @libdir@/util.sh to $1/util-config.sh ..."
cp @libdir@/util.sh $1/util-config.sh
}
2014-12-09 00:40:46 +01:00
# Prepare overlay-image
make_overlay() {
if [[ ! -e ${work_dir}/build.${FUNCNAME} ]]; then
msg "Prepare overlay-image"
2014-12-09 14:40:06 +01:00
2014-12-09 00:40:46 +01:00
mkdir -p ${work_dir}/overlay/etc/pacman.d
copy_overlay_livecd "${work_dir}/overlay"
2014-12-09 00:40:46 +01:00
copy_livecd '/usr/share/manjaro-tools'
copy_livecd_init "${work_dir}/overlay"
2014-12-09 00:40:46 +01:00
#wget -O ${work_dir}/overlay/etc/pacman.d/mirrorlist http://git.manjaro.org/packages-sources/basis/blobs/raw/master/pacman-mirrorlist/mirrorlist
2014-12-12 21:29:37 +01:00
${auto_svc_conf} && configure_services_livecd "${work_dir}/overlay"
2014-12-12 02:32:58 +01:00
2014-12-09 00:40:46 +01:00
# copy over manjaro-tools.conf
2014-12-09 02:05:15 +01:00
copy_manjaro_tools_conf "${work_dir}/overlay/opt/livecd"
2014-12-09 00:40:46 +01:00
2014-12-09 14:40:06 +01:00
# copy over the config loader lib to load manjaro-tools.conf vars
copy_util_sh "${work_dir}/overlay/opt/livecd"
2014-12-09 00:40:46 +01:00
cp ${work_dir}/root-image/etc/pacman.d/mirrorlist ${work_dir}/overlay/etc/pacman.d/mirrorlist
sed -i "s/#Server/Server/g" ${work_dir}/overlay/etc/pacman.d/mirrorlist
sed -i "s/^.*TITLE=.*/ TITLE=\"Manjaro Linux Installation Framework (v${iso_version})\"/g" ${work_dir}/overlay/opt/livecd/setup
#chmod -R 755 ${work_dir}/overlay/home
: > ${work_dir}/build.${FUNCNAME}
msg "Done"
fi
}
iso_owner=${SUDO_USER:-$USER}
if [[ -n $SUDO_USER ]]; then
eval "USER_HOME=~$SUDO_USER"
else
USER_HOME=$HOME
fi
2014-12-08 22:58:38 +01:00
load_config "$USER_HOME/.config/manjaro-tools.conf"
load_config '@sysconfdir@/manjaro-tools.conf'
load_desktop_definitions
clean_first=false
2014-12-07 06:36:46 +01:00
pretend=false
2014-12-08 01:35:22 +01:00
high_compression=false
2014-12-07 06:36:46 +01:00
verbose=false
overwrite=false
xorg_overlays=false
kde_lng_packages=false
2014-12-12 21:29:37 +01:00
auto_svc_conf=false
2014-12-07 06:36:46 +01:00
pacman_conf_arch='default'
2014-12-07 06:36:46 +01:00
usage() {
echo "Usage: ${0##*/} [options]"
echo " -a <arch> Set arch [default: ${arch}]"
echo " -b <branch> Set branch [default: ${branch}]"
echo " -r <dir> Work directory [default: ${work_dir}]"
echo " -t <dir> Target iso directory [default: ${target_dir}]"
2014-12-10 02:16:23 +01:00
echo " -i <file> Config file for pacman"
echo " [default: @pkgdatadir@/pacman-${pacman_conf_arch}.conf]"
2014-12-07 06:36:46 +01:00
echo ' -c Clean work dir'
echo ' -v Verbose'
echo ' -f Overwrite'
echo ' -z High compression'
echo ' -x Xorg overlays'
echo ' -k kde lng packages'
2014-12-12 21:29:37 +01:00
echo ' -A Let buildiso configure services(experimental)'
2014-12-07 06:36:46 +01:00
echo ' -q Query settings and pretend build'
echo ' -h This help'
echo ''
echo ''
exit 1
}
orig_argv=("$@")
2014-12-12 21:29:37 +01:00
opts='a:b:r:t:i:cvfzqxkAh'
2014-12-07 06:36:46 +01:00
while getopts "${opts}" arg; do
case "${arg}" in
a) arch="$OPTARG" ;;
b) branch="$OPTARG" ;;
r) work_dir="$OPTARG" ;;
t) target_dir="$OPTARG" ;;
c) clean_first=true ;;
v) verbose=true; iso_args+=(-v) ;;
2014-12-07 06:36:46 +01:00
f) overwrite=true; iso_args+=(-f) ;;
2014-12-08 01:35:22 +01:00
z) high_compression=true; iso_args+=(-x) ;;
2014-12-07 06:36:46 +01:00
x) xorg_overlays=true ;;
k) kde_lng_packages=true ;;
i) pacman_conf="$OPTARG" ;;
2014-12-12 21:29:37 +01:00
A) auto_svc_conf=true ;;
2014-12-07 06:36:46 +01:00
q) pretend=true ;;
h) usage ;;
esac
done
shift $(($OPTIND - 1))
work_dir=${work_dir}/${desktop}/${arch}
2014-12-09 23:23:54 +01:00
if [[ "$arch" == 'x86_64' ]]; then
pacman_conf_arch='multilib'
fi
2014-12-10 14:08:38 +01:00
load_pacman_conf "${pacman_conf}"
load_pacman_conf "@pkgdatadir@/pacman-${pacman_conf_arch}.conf"
mirrors_conf="@pkgdatadir@/pacman-mirrors-${branch}.conf"
2014-12-08 23:17:56 +01:00
create_args+=(-v -a ${arch} -D ${install_dir} -C ${pacman_conf} -M ${mirrors_conf})
2014-12-07 06:36:46 +01:00
iso_args+=(-a ${arch} -D ${install_dir} -L ${iso_label} -c ${compression})
2014-12-08 01:35:22 +01:00
iso_file="${target_dir}/${img_name}-${desktop}-${iso_version}-${arch}.iso"
2014-12-07 06:36:46 +01:00
2014-12-10 07:02:25 +01:00
iso_profile=${PWD##*/}
2014-12-07 06:36:46 +01:00
check_root "$0" "${orig_argv[@]}"
2014-12-11 00:33:56 +01:00
get_pkglist
2014-12-07 06:36:46 +01:00
if [ -e Packages-Xorg ] ; then
2014-12-11 00:33:56 +01:00
get_pkglist_xorg
2014-12-07 06:36:46 +01:00
fi
if [ -e Packages-Lng ] ; then
2014-12-11 00:33:56 +01:00
get_pkglist_lng
2014-12-07 06:36:46 +01:00
fi
if [ -e "${pkgsfile}" ] ; then
2014-12-11 00:33:56 +01:00
get_pkglist_de
2014-12-07 06:36:46 +01:00
fi
2014-12-04 20:05:33 +01:00
${pretend} && display_settings && exit 1
${clean_first} && clean_up
2014-12-05 02:22:14 +01:00
prepare_targetdir
2014-12-04 19:19:54 +01:00
# install basic
make_root_image
2014-12-07 06:36:46 +01:00
2014-12-04 19:19:54 +01:00
# install DE(s)
2014-12-07 06:36:46 +01:00
if [ -e "${pkgsfile}" ] ; then
make_de_image
fi
2014-12-04 19:19:54 +01:00
# install xorg-drivers
if [ -e Packages-Xorg ] ; then
make_pkgs_image
fi
# install translations
if [ -e Packages-Lng ] ; then
make_lng_image
fi
# install common
make_boot
if [ "${arch}" == "x86_64" ]; then
make_efi
make_efiboot
fi
make_isolinux
make_overlay
2014-12-11 05:03:23 +01:00
2014-12-04 19:19:54 +01:00
make_isomounts
make_iso