mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2024-12-22 18:55:30 +00:00
Merge pull request #19 from awalsh128/staging
Sync state of staging to dev with experimental diffs intact.
This commit is contained in:
commit
c25bf34f45
|
@ -25,9 +25,6 @@ outputs:
|
||||||
# This compound expression is needed because lhs can be empty.
|
# This compound expression is needed because lhs can be empty.
|
||||||
# Need to output true and false instead of true and nothing.
|
# Need to output true and false instead of true and nothing.
|
||||||
value: ${{ steps.load-cache.outputs.cache-hit || false }}
|
value: ${{ steps.load-cache.outputs.cache-hit || false }}
|
||||||
cache-key:
|
|
||||||
description: 'The key where the cache is stored with packages, their versions, and the cache version (i.e. package=version package=version @ 1).'
|
|
||||||
value: ${{ steps.pre-cache.outputs.cache-key }}
|
|
||||||
package-version-list:
|
package-version-list:
|
||||||
description: 'The packages and versions that are installed as a comma delimited list with colon delimit on the package version (i.e. <package>:<version,<package>:<version>).'
|
description: 'The packages and versions that are installed as a comma delimited list with colon delimit on the package version (i.e. <package>:<version,<package>:<version>).'
|
||||||
value: ${{ steps.post-cache.outputs.package-version-list }}
|
value: ${{ steps.post-cache.outputs.package-version-list }}
|
||||||
|
@ -42,7 +39,6 @@ runs:
|
||||||
"${{ inputs.version }}" \
|
"${{ inputs.version }}" \
|
||||||
${{ inputs.packages }}
|
${{ inputs.packages }}
|
||||||
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
|
||||||
echo "::set-output name=cache-key::$(cat ~/cache-apt-pkgs/cache_key.md5)"
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- id: load-cache
|
- id: load-cache
|
||||||
|
|
|
@ -8,7 +8,7 @@ script_dir="$(dirname -- "$(realpath -- "${0}")")"
|
||||||
source "${script_dir}/lib.sh"
|
source "${script_dir}/lib.sh"
|
||||||
|
|
||||||
# Directory that holds the cached packages.
|
# Directory that holds the cached packages.
|
||||||
cache_dir="${1}"
|
cache_dir=$1
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
input_packages="${@:2}"
|
input_packages="${@:2}"
|
||||||
|
@ -27,7 +27,7 @@ echo -n "Updating APT package list..."
|
||||||
sudo apt-get update > /dev/null
|
sudo apt-get update > /dev/null
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
manifest=
|
manifest=""
|
||||||
echo "Clean installing and caching ${package_count} packages..."
|
echo "Clean installing and caching ${package_count} packages..."
|
||||||
for package in "${packages}"; do
|
for package in "${packages}"; do
|
||||||
get_package_name_ver "${package}" # -> package_name, package_ver
|
get_package_name_ver "${package}" # -> package_name, package_ver
|
||||||
|
|
|
@ -4,23 +4,23 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Directory that holds the cached packages.
|
# Directory that holds the cached packages.
|
||||||
cache_dir="${1}"
|
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
|
||||||
|
|
||||||
# Indicates that the cache was found.
|
# Indicates that the cache was found.
|
||||||
cache_hit="${3}"
|
cache_hit=$3
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
packages="${@:4}"
|
packages="${@:4}"
|
||||||
|
|
||||||
script_dir="$(dirname -- "$(realpath -- "${0}")")"
|
script_dir=$(dirname $0)
|
||||||
|
|
||||||
if [ "${cache_hit}" == true ]; then
|
if [ "$cache_hit" == true ]; then
|
||||||
"${script_dir}/restore_pkgs.sh" ~/cache-apt-pkgs "${cache_restore_root}"
|
$script_dir/restore_pkgs.sh ~/cache-apt-pkgs $cache_restore_root
|
||||||
else
|
else
|
||||||
"${script_dir}/install_and_cache_pkgs.sh" ~/cache-apt-pkgs "${packages}"
|
$script_dir/install_and_cache_pkgs.sh ~/cache-apt-pkgs $packages
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
@ -5,10 +5,10 @@ script_dir="$(dirname -- "$(realpath -- "${0}")")"
|
||||||
source "${script_dir}/lib.sh"
|
source "${script_dir}/lib.sh"
|
||||||
|
|
||||||
# Directory that holds the cached packages.
|
# Directory that holds the cached packages.
|
||||||
cache_dir="${1}"
|
cache_dir=$1
|
||||||
|
|
||||||
# Version of the cache to create or load.
|
# Version of the cache to create or load.
|
||||||
cache_version="${2}"
|
version=$2
|
||||||
|
|
||||||
# List of the packages to use.
|
# List of the packages to use.
|
||||||
input_packages="${@:3}"
|
input_packages="${@:3}"
|
||||||
|
@ -17,15 +17,15 @@ input_packages="${@:3}"
|
||||||
packages="$(normalize_package_list "${input_packages}")"
|
packages="$(normalize_package_list "${input_packages}")"
|
||||||
|
|
||||||
# Create cache directory so artifacts can be saved.
|
# Create cache directory so artifacts can be saved.
|
||||||
mkdir -p "${cache_dir}"
|
mkdir -p $cache_dir
|
||||||
|
|
||||||
echo -n "Validating action arguments (version='${cache_version}', packages='${packages}')...";
|
|
||||||
|
|
||||||
|
echo -n "Validating action arguments (version='$version', packages='$packages')...";
|
||||||
if grep -q " " <<< "${cache_version}"; then
|
if grep -q " " <<< "${cache_version}"; then
|
||||||
echo "aborted."
|
echo "aborted."
|
||||||
echo "Version value '${cache_version}' cannot contain spaces." >&2
|
echo "Version value '$version' cannot contain spaces." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Is length of string zero?
|
# Is length of string zero?
|
||||||
if test -z "${packages}"; then
|
if test -z "${packages}"; then
|
||||||
echo "aborted."
|
echo "aborted."
|
||||||
|
@ -34,16 +34,12 @@ if test -z "${packages}"; then
|
||||||
fi
|
fi
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
echo -n "Updating APT package list..."
|
|
||||||
sudo apt-get update > /dev/null
|
|
||||||
echo "done."
|
|
||||||
|
|
||||||
versioned_packages=""
|
versioned_packages=""
|
||||||
echo -n "Verifying packages..."
|
echo -n "Verifying packages..."
|
||||||
for package in ${packages}; do
|
for package in ${packages}; do
|
||||||
if test ! "$(apt show "${package}")"; then
|
if test ! "$(apt show "${package}")"; then
|
||||||
echo "aborted."
|
echo "aborted."
|
||||||
echo "Package '${package}' not found." >&2
|
echo "Package '$package' not found." >&2
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
get_package_name_ver "${package}" # -> package_name, package_ver
|
get_package_name_ver "${package}" # -> package_name, package_ver
|
||||||
|
@ -68,6 +64,6 @@ echo "- Value hashed as '${key}'."
|
||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
key_filepath="${cache_dir}/cache_key.md5"
|
key_filepath="$cache_dir/cache_key.md5"
|
||||||
echo "${key}" > "${key_filepath}"
|
echo $key > $key_filepath
|
||||||
echo "Hash value written to ${key_filepath}"
|
echo "Hash value written to $key_filepath"
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Directory that holds the cached packages.
|
# Directory that holds the cached packages.
|
||||||
cache_dir="${1}"
|
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
|
||||||
|
|
||||||
cache_filepaths="$(ls -1 "${cache_dir}" | sort)"
|
cache_filepaths=$(ls -1 $cache_dir | sort)
|
||||||
echo "Found $(echo "${cache_filepaths}" | wc -w) files in the cache."
|
echo "Found $(echo $cache_filepaths | wc -w) files in the cache."
|
||||||
for cache_filepath in ${cache_filepaths}; do
|
for cache_filepath in $cache_filepaths; do
|
||||||
echo "- $(basename "${cache_filepath}")"
|
echo "- $(basename $cache_filepath)"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Reading from manifest..."
|
echo "Reading from manifest..."
|
||||||
|
@ -23,12 +23,12 @@ done
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
# Only search for archived results. Manifest and cache key also live here.
|
# Only search for archived results. Manifest and cache key also live here.
|
||||||
cache_pkg_filepaths=$(ls -1 ${cache_dir}/*.tar.gz | sort)
|
cache_pkg_filepaths=$(ls -1 $cache_dir/*.tar.gz | sort)
|
||||||
cache_pkg_filecount=$(echo "${cache_pkg_filepaths}" | wc -w)
|
cache_pkg_filecount=$(echo $cache_pkg_filepaths | wc -w)
|
||||||
echo "Restoring ${cache_pkg_filecount} packages from cache..."
|
echo "Restoring $cache_pkg_filecount packages from cache..."
|
||||||
for cache_pkg_filepath in ${cache_pkg_filepaths}; do
|
for cache_pkg_filepath in $cache_pkg_filepaths; do
|
||||||
echo -n "- $(basename "${cache_pkg_filepath}") restoring..."
|
echo -n "- $(basename $cache_pkg_filepath) restoring..."
|
||||||
sudo tar -xf ${cache_pkg_filepath} -C ${cache_restore_root} > /dev/null
|
sudo tar -xf $cache_pkg_filepath -C $cache_restore_root > /dev/null
|
||||||
echo "done."
|
echo "done."
|
||||||
done
|
done
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
Loading…
Reference in a new issue