Skip to content

Commit

Permalink
Replace command substitution by pipe operator to hopefully make the s…
Browse files Browse the repository at this point in the history
…cript fail if the source files do not exist
  • Loading branch information
torsknod2 authored Jan 12, 2025
1 parent e40d1ce commit 25a0e17
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions restore_pkgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,28 @@ test -d ${cache_restore_root} || mkdir ${cache_restore_root}
# Cache and execute post install scripts on restore.
execute_install_scripts="${3}"

cache_filepaths="$(ls -1 "${cache_dir}" | sort)"
log "Found $(echo ${cache_filepaths} | wc -w) files in the cache."
for cache_filepath in ${cache_filepaths}; do
ls -1 "${cache_dir}" | sort | while read cache_filepath; do
log "- "$(basename ${cache_filepath})""
done

log_empty_line

log "Reading from main requested packages manifest..."
for logline in $(cat "${cache_dir}/manifest_main.log" | tr ',' '\n' ); do
cat "${cache_dir}/manifest_main.log" | tr ',' '\n' | while read logline; do
log "- $(echo "${logline}" | tr ':' ' ')"
done
log "done"

log_empty_line

# Only search for archived results. Manifest and cache key also live here.
cached_filepaths=$(ls -1 "${cache_dir}"/*.tar | sort)
cached_filecount=$(echo ${cached_filepaths} | wc -w)

log "Restoring ${cached_filecount} packages from cache..."
for cached_filepath in ${cached_filepaths}; do
ls -1 "${cache_dir}"/*.tar | sort | while read cached_filepath; do

log "- $(basename "${cached_filepath}") restoring..."
sudo tar -xf "${cached_filepath}" -C "${cache_restore_root}" > /dev/null
log " done"

# Execute install scripts if available.
# Execute install scripts if available.
if test ${execute_install_scripts} == "true"; then
# May have to add more handling for extracting pre-install script before extracting all files.
# Keeping it simple for now.
Expand Down

0 comments on commit 25a0e17

Please sign in to comment.