From ca95c0de727282753c5083f080d858ab3de3ab08 Mon Sep 17 00:00:00 2001 From: awalsh128 Date: Thu, 21 Oct 2021 12:41:47 -0700 Subject: [PATCH] Add better messaging. --- install_and_cache_pkgs.sh | 20 ++++++++++++++------ restore_pkgs.sh | 18 ++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/install_and_cache_pkgs.sh b/install_and_cache_pkgs.sh index 6e52a44..d5a7979 100755 --- a/install_and_cache_pkgs.sh +++ b/install_and_cache_pkgs.sh @@ -9,27 +9,35 @@ cache_dir=$1 packages="${@:2}" package_count=$(echo $packages | wc -w) -echo "* Clean installing $package_count packages..." +echo "::debug::Clean installing $package_count packages..." for package in $packages; do - echo " - $package" + echo "::debug::- $package" done +echo "::endgroup::" mkdir -p $cache_dir -echo "* Updating APT package list and get the latest information..." + +echo "::group::Update APT Package List" sudo apt-get update +echo "::endgroup::" + for package in $packages; do cache_filepath=$cache_dir/$package.tar.gz - echo "* Clean installing $package... " + echo "::group::Clean 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. dpkg -L $package | while IFS= read -r f; do if test -f $f; then echo $f; fi; done | xargs tar -czf $cache_filepath -C / + echo "::endgroup::" 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::" diff --git a/restore_pkgs.sh b/restore_pkgs.sh index 9f151e6..39df2b1 100755 --- a/restore_pkgs.sh +++ b/restore_pkgs.sh @@ -13,18 +13,24 @@ packages="${@:3}" cache_filenames=$(ls -1 $cache_dir | sort) 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 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 # Upgrade the install from last state. # TODO(awalsh128) Add versioning to cache key creation. sudo apt-get --yes --only-upgrade install $package 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::" \ No newline at end of file