summaryrefslogtreecommitdiff
path: root/parabolaiso
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2017-11-16 09:29:16 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2018-01-01 00:53:10 -0500
commit29d6684b62948101a46ba0baa10fd322242101f5 (patch)
treebac76fffbb5bfe33671a3bc9d94ae514376549f7 /parabolaiso
parentba318b2df7904523a9792fea37263103c5905353 (diff)
add cached packages list
Diffstat (limited to 'parabolaiso')
-rwxr-xr-xparabolaiso/mkparabolaiso67
1 files changed, 58 insertions, 9 deletions
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
}