From affa6e70a9da9b4538f85141e604e2189a175e0a Mon Sep 17 00:00:00 2001 From: bill-auger Date: Mon, 16 Oct 2017 23:40:09 -0400 Subject: enable offline install --- configs/profile/build.sh | 39 +++++++++++++++------- configs/profile/root-image/etc/motd | 2 ++ configs/profile/root-image/etc/pacman-offline.conf | 10 ++++++ .../root-image/root/customize_root_image.sh | 20 ++++++++++- 4 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 configs/profile/root-image/etc/pacman-offline.conf (limited to 'configs/profile') diff --git a/configs/profile/build.sh b/configs/profile/build.sh index 959c9eb..fe2bdfb 100755 --- a/configs/profile/build.sh +++ b/configs/profile/build.sh @@ -12,6 +12,7 @@ iso_arch='dual' iso_version=$(date +%Y.%m.%d) iso_label="PARA_$(date +%Y%m)" iso_dirname='parabola' +enable_offline_install='false' work_dir=./work out_dir=./out target='' @@ -40,6 +41,8 @@ _usage () echo " Default: ${iso_label}" echo " -D Set the name of the directory inside the ISO" echo " Default: ${iso_dirname}" + echo " -O Enable offline install." + echo " Default: '${enable_offline_install}'" echo " -w Set the working directory" echo " Default: ${work_dir}" echo " -o Set the output directory" @@ -60,9 +63,7 @@ run_once() { # Setup custom pacman.conf with current cache directories. make_pacman_conf() { - local _cache_dirs - _cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g')) - sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${_cache_dirs[@]})|g" ${releng_dir}/pacman.conf > ${pacman_conf} + sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${work_dir}/${arch}/root-image/isorepo/|g" ${releng_dir}/pacman.conf > ${pacman_conf} } # Base installation, plus needed packages (root-image) @@ -74,6 +75,13 @@ make_basefs() { # Additional packages (root-image) make_packages() { setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "$(grep -h -v ^# ${releng_dir}/packages.{both,${arch}})" install + + # create live environment local repo + if [[ "$enable_offline_install" == 'true' ]]; then + local iso_repo_dir=${work_dir}/${arch}/root-image/isorepo + + setarch ${arch} repo-add ${iso_repo_dir}/isorepo.db.tar.gz ${iso_repo_dir}/* + fi } # Copy mkinitcpio parabolaiso hooks and build initramfs (root-image) @@ -91,13 +99,17 @@ make_setup_mkinitcpio() { # Customize installation (root-image) make_customize_root_image() { + [[ "$enable_offline_install" == 'true' ]] && offline='-O' || offline='' + cp -af ${releng_dir}/root-image ${work_dir}/${arch} echo "Customizing root image" iso_title="${iso_title}" \ + enable_offline_install="${enable_offline_install}" \ setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} \ -C ${pacman_conf} \ -D ${iso_dirname} \ + ${offline} \ -r ${chroot_customization_script} run rm ${work_dir}/${arch}/root-image${chroot_customization_script} } @@ -225,9 +237,11 @@ make_aitab() { # Build all filesystem images specified in aitab (.fs.sfs .sfs) make_prepare() { + [[ "$enable_offline_install" == 'true' ]] && offline='-O' || offline='' + cp -a -l -f ${work_dir}/${arch}/root-image ${work_dir} setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} pkglist - setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} prepare + setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} ${offline} prepare rm -rf ${work_dir}/root-image # rm -rf ${work_dir}/${arch}/root-image (if low space, this helps) @@ -245,13 +259,13 @@ make_iso() { ## prepare state ## # set CLI options - -while getopts 'T:V:L:D:w:o:vh' arg; do +while getopts 'T:V:L:D:Ow:o:vh' arg; do case "${arg}" in T) target="${OPTARG}" ;; V) iso_version="${OPTARG}" ;; L) iso_label="${OPTARG}" ;; D) iso_dirname="${OPTARG}" ;; + O) enable_offline_install='true' ;; w) work_dir="${OPTARG}" ;; o) out_dir="${OPTARG}" ;; v) verbose="-v" ;; @@ -268,17 +282,18 @@ case "${target}" in 'i686'|'x86_64') archs=${target} iso_arch=${target} - launch_msg="Building single-architecture ${iso_edition} ISO for ${target}" + launch_msg="Building single-architecture ${iso_edition} ISO for ${archs}" ;; *) - launch_msg="Building dual-architecture ${iso_edition} ISO for i686 and x86_64" + launch_msg="Building multi-architecture ${iso_edition} ISO for ${archs}" ;; esac -if [ "$enable_offline_install" == 'true' ]; then +if [[ "$enable_offline_install" == 'true' ]]; then iso_arch="${iso_arch}-complete" - launch_msg="${launch_msg} with offline install enabled" + launch_msg="${launch_msg} (net-install or offline install)" else iso_arch="${iso_arch}-netinstall" + launch_msg="${launch_msg} (net-install only)" fi [ "${archs}" == 'i686' ] && arch='i686' || arch='x86_64' iso_filename="parabola-${iso_edition}-${iso_arch}-${iso_version}.iso" @@ -327,13 +342,13 @@ if ! (($is_done)); then echo ${launch_msg}; else echo "Nothing to do"; exit; fi; ## build ISO ## +# prepare environment chown -R 0:0 "${releng_dir}/root-image/" mkdir -p ${work_dir} -run_once make_pacman_conf - # prepare target filesystems for arch in ${archs}; do + run_once make_pacman_conf run_once make_basefs run_once make_packages run_once make_setup_mkinitcpio diff --git a/configs/profile/root-image/etc/motd b/configs/profile/root-image/etc/motd index a2bf698..49febe9 100644 --- a/configs/profile/root-image/etc/motd +++ b/configs/profile/root-image/etc/motd @@ -3,6 +3,8 @@ _EDITION_TITLE_ + _NETWORK_MSG_ + To install Parabola, the system must be connected to the internet. For help establishing an internet connection, enter this command:  lynx network.html  diff --git a/configs/profile/root-image/etc/pacman-offline.conf b/configs/profile/root-image/etc/pacman-offline.conf new file mode 100644 index 0000000..e6efcf1 --- /dev/null +++ b/configs/profile/root-image/etc/pacman-offline.conf @@ -0,0 +1,10 @@ +[options] +HoldPkg = pacman glibc +Architecture = auto +CheckSpace +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional + +[isorepo] +SigLevel = Optional TrustAll +Server = file:///isorepo/ diff --git a/configs/profile/root-image/root/customize_root_image.sh b/configs/profile/root-image/root/customize_root_image.sh index de5481b..7505d8b 100755 --- a/configs/profile/root-image/root/customize_root_image.sh +++ b/configs/profile/root-image/root/customize_root_image.sh @@ -1,5 +1,16 @@ #!/bin/bash +readonly ISO_REPO_DEFINITION="[isorepo]\nSigLevel = Optional TrustAll\nServer = file:///isorepo/" +readonly NETINSTALL_MSG="To install Parabola, the system must be connected to the internet." +readonly COMPLETE_MSG="This ISO is capable of installing a complete Parabola system\n\ +>>>>without a connection to the internet. If you would like to fetch\n\ +>>>>the latest packages from the internet, run the following command\n\ +>>>>before beginning the install:\n\ + # cp /etc/pacman-online.conf /etc/pacman.conf" +[ "${enable_offline_install}" == 'false' ] && readonly NETWORK_MSG=${NETINSTALL_MSG} || \ + readonly NETWORK_MSG=${COMPLETE_MSG} + + set -e -u sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen @@ -17,7 +28,14 @@ chmod 750 /etc/sudoers.d chmod 440 /etc/sudoers.d/g_wheel sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist +if [ "${enable_offline_install}" == 'true' ] +then echo -e "${ISO_REPO_DEFINITION}" >> /etc/pacman.conf + mv /etc/pacman.conf /etc/pacman-online.conf + cp /etc/pacman-offline.conf /etc/pacman.conf +else rm /etc/pacman-offline.conf +fi systemctl enable multi-user.target pacman-init.service choose-mirror.service -sed -i "s|_EDITION_TITLE_|${iso_title}|" /etc/motd +sed -i "s|_EDITION_TITLE_|${iso_title}|" /etc/motd +sed -i "s|_NETWORK_MSG_|${NETWORK_MSG}| ; s|^>>>>\(.*\)| \1|g" /etc/motd -- cgit v1.2.2