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.
|
# List of the packages to use.
|
||||||
packages="${@:2}"
|
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
|
mkdir -p $cache_dir
|
||||||
for package in $packages; do
|
for package in $packages; do
|
||||||
cache_filepath=$cache_dir/$package.tar.gz
|
cache_filepath=$cache_dir/$package.tar.gz
|
||||||
|
@ -24,4 +30,4 @@ for package in $packages; do
|
||||||
xargs tar -czf $cache_filepath -C /
|
xargs tar -czf $cache_filepath -C /
|
||||||
done
|
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.
|
# Root directory to untar the cached packages to.
|
||||||
# Typically filesystem root '/' but can be changed for testing.
|
# Typically filesystem root '/' but can be changed for testing.
|
||||||
cache_restore_root=$2
|
cache_restore_root=$2
|
||||||
|
# List of the packages to use.
|
||||||
|
packages="${@:3}"
|
||||||
|
|
||||||
cache_filenames=$(ls -1 $cache_dir | sort)
|
cache_filenames=$(ls -1 $cache_dir | sort)
|
||||||
echo "* Found ${#cache_filenames[@]} files in cache..."
|
cache_filename_count=$(echo $cache_filenames | wc -w)
|
||||||
echo $cache_filenames
|
echo "* Found $cache_filename_count files in cache..."
|
||||||
|
|
||||||
for cache_filename in $cache_filenames; do
|
for cache_filename in $cache_filenames; do
|
||||||
cache_filepath=$cache_dir/$cache_filename
|
echo " - $cache_filename"
|
||||||
echo "* Restoring $cache_filepath from cache... "
|
|
||||||
sudo tar -xf $cache_filepath -C $cache_restore_root
|
|
||||||
done
|
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