Add better messaging.

This commit is contained in:
awalsh128 2021-10-21 12:41:47 -07:00
parent 9512f95182
commit ca95c0de72
2 changed files with 26 additions and 12 deletions

View file

@ -9,27 +9,35 @@ cache_dir=$1
packages="${@:2}" packages="${@:2}"
package_count=$(echo $packages | wc -w) package_count=$(echo $packages | wc -w)
echo "* Clean installing $package_count packages..." echo "::debug::Clean installing $package_count packages..."
for package in $packages; do for package in $packages; do
echo " - $package" echo "::debug::- $package"
done done
echo "::endgroup::"
mkdir -p $cache_dir mkdir -p $cache_dir
echo "* Updating APT package list and get the latest information..."
echo "::group::Update APT Package List"
sudo apt-get update sudo apt-get update
echo "::endgroup::"
for package in $packages; do for package in $packages; do
cache_filepath=$cache_dir/$package.tar.gz cache_filepath=$cache_dir/$package.tar.gz
echo "* Clean installing $package... " echo "::group::Clean install $package"
sudo apt-get --yes install $package sudo apt-get --yes install $package
echo "::endgroup::"
echo "* Caching $package to $cache_filepath..." echo "::group::Caching $package to $cache_filepath"
# Pipe all package files (no folders) to Tar. # Pipe all package files (no folders) to Tar.
dpkg -L $package | dpkg -L $package |
while IFS= read -r f; do while IFS= read -r f; do
if test -f $f; then echo $f; fi; if test -f $f; then echo $f; fi;
done | done |
xargs tar -czf $cache_filepath -C / xargs tar -czf $cache_filepath -C /
echo "::endgroup::"
done done
echo "Action complete. $(echo $packages | wc -w) package(s) installed and cached." echo "::group::Finished"
echo "::debug::$(echo $packages | wc -w) package(s) installed and cached."
echo "::endgroup::"

View file

@ -13,18 +13,24 @@ packages="${@:3}"
cache_filenames=$(ls -1 $cache_dir | sort) cache_filenames=$(ls -1 $cache_dir | sort)
cache_filename_count=$(echo $cache_filenames | wc -w) cache_filename_count=$(echo $cache_filenames | wc -w)
echo "* Found $cache_filename_count files in cache..."
for cache_filename in $cache_filenames; do
echo " - $cache_filename"
done
echo "::group::Found $cache_filename_count files in cache."
for cache_filename in $cache_filenames; do
echo "::debug::$cache_filename"
done
echo "::endgroup::"
echo "::group::Package Restore"
for package in $packages; do for package in $packages; do
cache_filepath=$cache_dir/$package.tar.gz cache_filepath=$cache_dir/$package.tar.gz
echo "* Restoring package $package ($cache_filepath) from cache... " echo "::debug::Restoring package $package ($cache_filepath) from cache... "
sudo tar -xf $cache_filepath -C $cache_restore_root sudo tar -xf $cache_filepath -C $cache_restore_root
# Upgrade the install from last state. # Upgrade the install from last state.
# TODO(awalsh128) Add versioning to cache key creation. # TODO(awalsh128) Add versioning to cache key creation.
sudo apt-get --yes --only-upgrade install $package sudo apt-get --yes --only-upgrade install $package
done done
echo "::endgroup::"
echo "Action complete. $cache_filename_count package(s) restored." echo "::group::Finished"
echo "::debug::Action complete. $cache_filename_count package(s) restored."
echo "::endgroup::"