mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2026-05-09 19:43:21 +00:00
Preserve apt package install order on restore.
* The manifest_all.log file is now kept in the order apt installed the packages. * restore_pkgs.sh now restores packages in the order they are in the manifest_all.log file instead of the order of the tarballs in the filesystem. Resolves: #196
This commit is contained in:
parent
acb598e5dd
commit
ffda9493fe
2
lib.sh
2
lib.sh
|
|
@ -172,7 +172,7 @@ function write_manifest {
|
||||||
else
|
else
|
||||||
log "Writing ${1} packages manifest to ${3}..."
|
log "Writing ${1} packages manifest to ${3}..."
|
||||||
# 0:-1 to remove trailing comma, delimit by newline and sort.
|
# 0:-1 to remove trailing comma, delimit by newline and sort.
|
||||||
echo "${2:0:-1}" | tr ',' '\n' | sort > ${3}
|
echo "${2:0:-1}" | tr ',' '\n' > ${3}
|
||||||
log "done"
|
log "done"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,15 @@ log "done"
|
||||||
log_empty_line
|
log_empty_line
|
||||||
|
|
||||||
# Only search for archived results. Manifest and cache key also live here.
|
# Only search for archived results. Manifest and cache key also live here.
|
||||||
cached_filepaths=$(ls -1 "${cache_dir}"/*.tar 2>/dev/null | sort)
|
manifest_all="${cache_dir}/manifest_all.log"
|
||||||
cached_filecount=$(echo ${cached_filepaths} | wc -w)
|
mapfile -t packages <"${manifest_all}"
|
||||||
|
|
||||||
|
cached_filecount="${#packages[@]}"
|
||||||
log "Restoring ${cached_filecount} packages from cache..."
|
log "Restoring ${cached_filecount} packages from cache..."
|
||||||
for cached_filepath in ${cached_filepaths}; do
|
|
||||||
|
|
||||||
log "- $(basename "${cached_filepath}") restoring..."
|
for package in "${packages[@]}"; do
|
||||||
|
cached_filepath="${cache_dir}/${package}.tar"
|
||||||
|
log "- ${package} restoring..."
|
||||||
sudo tar -xf "${cached_filepath}" -C "${cache_restore_root}" > /dev/null
|
sudo tar -xf "${cached_filepath}" -C "${cache_restore_root}" > /dev/null
|
||||||
log " done"
|
log " done"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue