Add better diagnostics.
This commit is contained in:
parent
e558e74c19
commit
08d1b85370
2 changed files with 22 additions and 10 deletions
|
@ -8,6 +8,12 @@ cache_dir=$1
|
|||
# List of the packages to use.
|
||||
packages="${@:2}"
|
||||
|
||||
package_count=$(echo $packages | wc -w)
|
||||
echo "* Clean installing $package_count packages..."
|
||||
for package in $packages; do
|
||||
echo " - $package"
|
||||
done
|
||||
|
||||
mkdir -p $cache_dir
|
||||
for package in $packages; do
|
||||
cache_filepath=$cache_dir/$package.tar.gz
|
||||
|
@ -24,4 +30,4 @@ for package in $packages; do
|
|||
xargs tar -czf $cache_filepath -C /
|
||||
done
|
||||
|
||||
echo "Action complete. ${#packages[@]} package(s) installed and cached."
|
||||
echo "Action complete. $(echo $packages | wc -w) package(s) installed and cached."
|
||||
|
|
|
@ -8,17 +8,23 @@ cache_dir=$1
|
|||
# Root directory to untar the cached packages to.
|
||||
# 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 ${#cache_filenames[@]} files in cache..."
|
||||
echo $cache_filenames
|
||||
|
||||
cache_filename_count=$(echo $cache_filenames | wc -w)
|
||||
echo "* Found $cache_filename_count files in cache..."
|
||||
for cache_filename in $cache_filenames; do
|
||||
cache_filepath=$cache_dir/$cache_filename
|
||||
echo "* Restoring $cache_filepath from cache... "
|
||||
sudo tar -xf $cache_filepath -C $cache_restore_root
|
||||
echo " - $cache_filename"
|
||||
done
|
||||
# Update all packages.
|
||||
sudo apt-get --yes --only-upgrade install
|
||||
|
||||
echo "Action complete. $(echo $cache_filenames | wc -l) package(s) restored."
|
||||
for package in $packages; do
|
||||
cache_filepath=$cache_dir/$package.tar.gz
|
||||
echo "* Restoring package $package ($cache_filepath) from cache... "
|
||||
sudo tar -xf $cache_filepath -C $cache_restore_root
|
||||
# Upgrade the install from last state.
|
||||
# TODO(awalsh128) Add versioning to cache key creation.
|
||||
sudo apt-get --yes --only-upgrade install $package
|
||||
done
|
||||
|
||||
echo "Action complete. $cache_filename_count package(s) restored."
|
||||
|
|
Loading…
Reference in a new issue