From 29d6684b62948101a46ba0baa10fd322242101f5 Mon Sep 17 00:00:00 2001 From: bill-auger Date: Thu, 16 Nov 2017 09:29:16 -0500 Subject: add cached packages list --- configs/profile/build.sh | 34 +++++++----- configs/profile/packages/packages-cache-lxde.both | 9 +++ parabolaiso/mkparabolaiso | 67 ++++++++++++++++++++--- 3 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 configs/profile/packages/packages-cache-lxde.both diff --git a/configs/profile/build.sh b/configs/profile/build.sh index 830a760..8748efa 100755 --- a/configs/profile/build.sh +++ b/configs/profile/build.sh @@ -3,11 +3,10 @@ set -e -u # edition-specific strings -iso_edition="SystemD/CLI" # default init/wm pair iso_title="Parabola GNU/Linux-libre Live" # $iso_edition and $iso_version appended -base_group='base' # default base package group # CLI option defaults +iso_edition="SystemD/CLI" archs='i686 x86_64' iso_arch='dual' iso_version=$(date +%Y.%m.%d) @@ -67,7 +66,7 @@ run_once() { fi } -# Setup custom pacman.conf with current cache directories. +# Setup custom pacman.conf to cache packages on the target filesystem. make_pacman_conf() { sed -r "s|^#?\\s*CacheDir.+|CacheDir = ${work_dir}/${arch}/root-image/isorepo/|g" ${releng_dir}/pacman.conf > ${pacman_conf} } @@ -80,14 +79,21 @@ make_basefs() { # Additional packages (root-image) make_packages() { - packages=$(grep -h -v ^# ${packages_dir}/packages-{${iso_init},${iso_gui},${iso_wm}}.{both,${arch}} 2> /dev/null || true) - setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${packages}" install + local _install_packages=$(grep -h -v ^# ${packages_dir}/packages-{${iso_init},${iso_gui},${iso_wm}}.{both,${arch}} 2> /dev/null || true) + local _cache_packages=$(grep -h -v ^# ${packages_dir}/packages-cache-{${iso_init},${iso_gui},${iso_wm}}.{both,${arch}} 2> /dev/null || true) + + setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${_install_packages}" 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}/* + if [[ -n ${_cache_packages} ]]; then + setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${_cache_packages}" -O install + fi + pushd ${work_dir}/${arch}/root-image/isorepo > /dev/null + setarch ${arch} repo-add --new isorepo.db.tar.gz ./* + popd > /dev/null + else + mv ${work_dir}/${arch}/root-image/isorepo ${work_dir}/../isorepo-${arch} fi } @@ -111,6 +117,7 @@ make_customize_root_image() { cp -af ${releng_dir}/root-image ${work_dir}/${arch} echo "Customizing root image" + arch="${arch}" \ iso_title="${iso_title}" \ iso_init="${iso_init}" \ iso_wm="${iso_wm}" \ @@ -193,7 +200,7 @@ make_efi() { # Prepare efiboot.img::/EFI for "El Torito" EFI boot mode make_efiboot() { - # cleanup from previous runs + # Cleanup in case of previous aborted run while mount | grep ${work_dir}/efiboot; do umount ${work_dir}/efiboot; sleep 1; done; rm ${work_dir}/iso/EFI/parabolaiso/efiboot.img 2> /dev/null || true @@ -250,7 +257,7 @@ make_prepare() { 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} ${offline} prepare + setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir} -D ${iso_dirname} -C ${pacman_conf} ${offline} prepare rm -rf ${work_dir}/root-image # rm -rf ${work_dir}/${arch}/root-image (if low space, this helps) @@ -304,13 +311,14 @@ else iso_arch="${iso_arch}-netinstall" launch_msg="${launch_msg} (net-install only)" fi -iso_title="${iso_title}${iso_edition} Edition ${iso_version}" +iso_title="${iso_title} ${iso_edition} Edition ${iso_version}" iso_filename="parabola-${iso_edition}-${iso_arch}-${iso_version}.iso" iso_filename=$(echo ${iso_filename} | tr '[:upper:]/' '[:lower:]-') iso_init=$(echo ${iso_edition} | cut -d '/' -f 1 | tr '[:upper:]' '[:lower:]') iso_wm=$( echo ${iso_edition} | cut -d '/' -f 2 | tr '[:upper:]' '[:lower:]') -[[ "${iso_wm}" == 'cli' ]] && iso_gui='' || iso_gui='gui' -[[ "${archs}" == 'i686' ]] && arch='i686' || arch='x86_64' +[[ "${iso_init}" == 'openrc' ]] && base_group='base-openrc' || base_group='base' +[[ "${iso_wm}" == 'cli' ]] && iso_gui='' || iso_gui='gui' +[[ "${archs}" == 'i686' ]] && arch='i686' || arch='x86_64' ## sanity checks ## diff --git a/configs/profile/packages/packages-cache-lxde.both b/configs/profile/packages/packages-cache-lxde.both new file mode 100644 index 0000000..3ee77a3 --- /dev/null +++ b/configs/profile/packages/packages-cache-lxde.both @@ -0,0 +1,9 @@ +# this file specifies the packages that are to be downloaded +# and cached in the /isorepo for offline install +# in all live environments regardless of the init system and graphical environment + + +lightdm-gtk-greeter-settings +mate +mate-extra +volumeicon diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso index ad82c81..a7eb760 100755 --- a/parabolaiso/mkparabolaiso +++ b/parabolaiso/mkparabolaiso @@ -51,6 +51,15 @@ _show_space_usage () { } _chroot_mount () { + # Cleanup in case of previous aborted run + declare -a mountpoints=() + for target in dev/pts dev/shm dev proc run sys tmp; do + local mountpoint=$(findmnt --noheadings --output="TARGET" "${work_dir}/root-image/${target}" || true) + + if [[ "${mountpoint}" != "" ]]; then mountpoints=( ${mountpoints[@]} "${mountpoint}" ); fi; + done + for mountpoint in ${mountpoints[@]}; do umount "${mountpoint}"; done; + mount -t devtmpfs dev "${work_dir}/root-image/dev" mount -t devpts devpts "${work_dir}/root-image/dev/pts" mount -t tmpfs devshm "${work_dir}/root-image/dev/shm" @@ -80,10 +89,6 @@ _chroot_init() { _pacman ${base_group} _pacman "syslinux" fi - # Restore live local repo cache - if [[ -d "${work_dir}/isorepo-${arch}" ]]; then - mv "${work_dir}/isorepo-${arch}" "${work_dir}/root-image/" - fi } _chroot_run() { @@ -203,6 +208,7 @@ _show_config () { ;; install) _msg_info " Pacman config file: ${pacman_conf}" + _msg_info " Offline install: ${enable_offline_install}" _msg_info " Packages: ${pkg_list}" ;; run) @@ -210,6 +216,7 @@ _show_config () { _msg_info " Offline install: ${enable_offline_install}" ;; prepare) + _msg_info " Pacman config file: ${pacman_conf}" _msg_info " Offline install: ${enable_offline_install}" ;; checksum) @@ -244,12 +251,52 @@ _pacman () _msg_info "Packages installed successfully!" } +# Cache uninstalled packages in offline /isorepo +_pacman_cache () +{ + _msg_info "Caching packages to '${work_dir}/root-image/'..." + + _chroot_mount + + local _package_files=$(pacman -S --root "${work_dir}/root-image" --config "${pacman_conf}" --print $* | sed "s|.*\/\(.*\)|\1|") + + # stash any existing interesting uninstalled packages + pushd "${work_dir}/root-image/isorepo/" > /dev/null + mkdir -p ../isorepo-uninstalled &> /dev/null + mv ${_package_files} ../isorepo-uninstalled/ &> /dev/null || true + popd > /dev/null + + # remove any remaining obsolete packages + if [[ "${quiet}" = "y" ]]; then + pacman -Sc --root "${work_dir}/root-image" --config "${pacman_conf}" --noconfirm &> /dev/null + else + pacman -Sc --root "${work_dir}/root-image" --config "${pacman_conf}" --noconfirm + fi + + # restore interesting uninstalled packages + pushd "${work_dir}/root-image/isorepo/" > /dev/null + mv ../isorepo-uninstalled/* . &> /dev/null || true + rmdir ../isorepo-uninstalled &> /dev/null + popd > /dev/null + + # download any missing packages + if [[ "${quiet}" = "y" ]]; then + pacman -Sw --root "${work_dir}/root-image" --config "${pacman_conf}" --noconfirm $* &> /dev/null + else + pacman -Sw --root "${work_dir}/root-image" --config "${pacman_conf}" --noconfirm $* + fi + + _chroot_umount + + _msg_info "Packages cached successfully!" +} + # Cleanup root-image _cleanup () { _msg_info "Cleaning up what we can on root-image..." # Delete initcpio image(s) - if [[ -d "${work_dir}/root-image/boot" ]]; then + if [[ -d "${work_dir}/root-image/boot" ]]; then find "${work_dir}/root-image/boot" -type f -name '*.img' -delete fi # Delete kernel(s) @@ -269,8 +316,6 @@ _cleanup () { if [[ -d "${work_dir}/root-image/var/cache/pacman/pkg" ]]; then find "${work_dir}/root-image/var/cache/pacman/pkg" -type f -delete fi - # Stash live local repo cache - mv "${work_dir}/root-image/isorepo" "${work_dir}/isorepo-${arch}" 2> /dev/null || true fi # Delete all log files, keeps empty dirs. if [[ -d "${work_dir}/root-image/var/log" ]]; then @@ -345,7 +390,7 @@ _mkfs () { fi fi - # cleanup from previous runs + # Cleanup in case of previous aborted run while mount | grep "${_fs_img}"; do umount "${_fs_img}"; sleep 1; done; rm -f "${_fs_img}" @@ -524,7 +569,11 @@ command_install () { if [[ -f "${work_dir}/install.${_pkg_list_hash}" ]]; then _msg_info "These packages are already installed, skipping." else - _pacman "${pkg_list}" + if [[ "${enable_offline_install}" == 'true' ]]; then + _pacman_cache "${pkg_list}" + else + _pacman "${pkg_list}" + fi : > "${work_dir}/install.${_pkg_list_hash}" fi } -- cgit v1.2.2