From 1decb12863a97bfbd6cacbac26342b4bdfafb61b Mon Sep 17 00:00:00 2001 From: awalsh128 Date: Thu, 21 Oct 2021 22:27:23 -0700 Subject: [PATCH] Filter packages correctly. --- restore_pkgs.sh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/restore_pkgs.sh b/restore_pkgs.sh index f687441..0aca493 100755 --- a/restore_pkgs.sh +++ b/restore_pkgs.sh @@ -10,26 +10,24 @@ cache_dir=$1 # Typically filesystem root '/' but can be changed for testing. cache_restore_root=$2 -# List of the packages to use. -packages="${@:3}" - -cache_filenames=$(ls -1 $cache_dir | sort) -echo "Found $(echo $cache_filenames | wc -w) files in the cache." -for cache_filename in $cache_filenames; do - echo "- $(basename $cache_filename)" +cache_filepaths=$(ls -1 $cache_dir | sort) +echo "Found $(echo $cache_filepaths | wc -w) files in the cache." +for cache_filepath in $cache_filepaths; do + echo "- $(basename $cache_filepath)" done # Only search for archived results. Manifest and cache key also live here. -cache_pkg_filenames=$(ls -1 $cache_dir/*.tar.gz | sort) -echo "Found $(echo $cache_pkg_filenames | wc -w) packages in the cache." -for cache_pkg_filename in $cache_pkg_filenames; do - echo "- $(basename $cache_pkg_filename)" +cache_pkg_filepaths=$(ls -1 $cache_dir/*.tar.gz | sort) +cache_pkg_filecount=$(echo $cache_pkg_filepaths | wc -w) +echo "Found $cache_pkg_filecount packages in the cache." +for cache_pkg_filepath in $cache_pkg_filepaths; do + echo "- $(basename $cache_pkg_filepath)" done -echo "Restoring $cache_filename_count packages from cache..." -for cache_pkg_filename in $cache_pkg_filenames; do - cache_pkg_filepath=$cache_dir/$package.tar.gz - echo "- $package ($(basename $cache_pkg_filepath))" +echo "Restoring $cache_pkg_filecount packages from cache..." +for cache_pkg_filepath in $cache_pkg_filepaths; do + package=$(basename $cache_pkg_filepath | awk -F. '{print $1}') + echo "- $package" sudo tar -xf $cache_pkg_filepath -C $cache_restore_root > /dev/null done echo "done."