From c3a55684115322f4f99359c3dcf8c79ba2ee872a Mon Sep 17 00:00:00 2001 From: bill-auger Date: Sun, 27 May 2018 03:22:33 -0400 Subject: bugfix cache stash --- configs/profile/build.sh | 24 ++++++++++++++++++++---- parabolaiso/mkparabolaiso | 43 +++++++++++++++++++------------------------ 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/configs/profile/build.sh b/configs/profile/build.sh index 326af1e..4752c64 100755 --- a/configs/profile/build.sh +++ b/configs/profile/build.sh @@ -78,7 +78,17 @@ run_once() { # 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} + local stash_dir=${work_dir}/isorepo-${arch} + local isorepo_dir=${work_dir}/${arch}/root-image/isorepo/ + + # restore package cache from previous build + if [[ -d ${stash_dir} ]]; then + echo "restoring package cache from ${stash_dir}" + mkdir -p ${isorepo_dir} + mv ${stash_dir}/* ${isorepo_dir} || true + fi + + sed --regexp-extended 's|^#?\s*CacheDir.+|CacheDir = '${isorepo_dir}'|g' ${releng_dir}/pacman.conf > ${pacman_conf} } # Base installation, plus needed packages (root-image) @@ -151,17 +161,23 @@ make_packages() { # create live environment local repo or stash package cache if [[ "$enable_offline_install" == 'true' ]]; then - if [[ -n ${_cache_packages} ]]; then + if [[ -n "${_cache_packages}" ]]; then # download any cache packages and prune obsolete packages + echo 'downloading "cach-only" packages' setarch ${arch} mkparabolaiso ${verbose} -w ${work_dir}/${arch} -C ${pacman_conf} -D ${iso_dirname} -p "${_cache_packages}" ${offline_switch} cache fi + # create 'isorepo' for offline install + echo "creating 'isorepo' for offline install" pushd ${work_dir}/${arch}/root-image/isorepo > /dev/null setarch ${arch} repo-add --new isorepo.db.tar.gz ./* - popd > /dev/null + popd > /dev/null else # stash package cache for next build - mv ${work_dir}/${arch}/root-image/isorepo ${work_dir}/../isorepo-${arch} || true + echo "stashing package cache to ${work_dir}/isorepo-${arch}" + mkdir -p ${work_dir}/isorepo-${arch}/ + mv ${work_dir}/${arch}/root-image/isorepo/* ${work_dir}/isorepo-${arch}/ + rmdir ${work_dir}/${arch}/root-image/isorepo fi } diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso index 1843594..deec844 100755 --- a/parabolaiso/mkparabolaiso +++ b/parabolaiso/mkparabolaiso @@ -255,7 +255,7 @@ _pacman () _msg_info "Packages installed successfully!" } -# Cache uninstalled packages in offline /isorepo and prune obsolete packages. +# Cache uninstalled packages in offline /isorepo and prune unused packages. _pacman_cache () { _msg_info "Caching packages to '${work_dir}/root-image/'..." @@ -264,27 +264,27 @@ _pacman_cache () 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 + if [[ "${_package_files}" ]]; then + # 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 + # remove any remaining obsolete or rogue 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 + # 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 [[ "${_package_files}" ]]; then + # download any missing packages if [[ "${quiet}" = "y" ]]; then pacman -Sw --root "${work_dir}/root-image" --config "${pacman_conf}" --noconfirm $* &> /dev/null else @@ -596,11 +596,6 @@ command_cache () { #trim spaces pkg_list="$(echo ${pkg_list})" - if [[ -z ${pkg_list} ]]; then - _msg_error "Packages must be specified" 0 - _usage 1 - fi - _show_config cache _pacman_cache "${pkg_list}" } -- cgit v1.2.2