Copy from master to staging.
This commit is contained in:
parent
fa7091e9a8
commit
f7b89333d6
3 changed files with 19 additions and 10 deletions
|
@ -45,7 +45,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- id: load-cache
|
- id: load-cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/cache-apt-pkgs
|
path: ~/cache-apt-pkgs
|
||||||
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
|
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
|
||||||
|
|
|
@ -39,21 +39,22 @@ for package in ${normalized_packages}; do
|
||||||
# Comma delimited name:ver pairs in the main requested packages manifest.
|
# Comma delimited name:ver pairs in the main requested packages manifest.
|
||||||
manifest_main="${manifest_main}${package_name}:${package_ver},"
|
manifest_main="${manifest_main}${package_name}:${package_ver},"
|
||||||
|
|
||||||
all_packages="$(apt-get install --dry-run --yes "${package_name}" | grep "^Inst" | awk '{print $2}')"
|
read dep_packages < <(get_dep_packages "${package_name}")
|
||||||
dep_packages="$(echo ${all_packages} | grep -v "${package_name}" | tr '\n' ,)"
|
if test -z "${dep_packages}"; then
|
||||||
if "${dep_packages}" == ","; then
|
dep_packages_text="none";
|
||||||
dep_packages="none";
|
else
|
||||||
|
dep_packages_text="${dep_packages}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "- ${package_name}"
|
log "- ${package_name}"
|
||||||
log " * Version: ${package_ver}"
|
log " * Version: ${package_ver}"
|
||||||
log " * Dependencies: ${dep_packages}"
|
log " * Dependencies: ${dep_packages_text}"
|
||||||
log " * Installing..."
|
log " * Installing..."
|
||||||
# Zero interaction while installing or upgrading the system via apt.
|
# Zero interaction while installing or upgrading the system via apt.
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-get --yes install "${package}" > /dev/null
|
sudo DEBIAN_FRONTEND=noninteractive apt-get --yes install "${package_name}" > /dev/null
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
for cache_package in ${all_packages}; do
|
for cache_package in ${package_name}:${package_ver} ${dep_packages}; do
|
||||||
cache_filepath="${cache_dir}/${cache_package}.tar.gz"
|
cache_filepath="${cache_dir}/${cache_package}.tar.gz"
|
||||||
|
|
||||||
if test ! -f "${cache_filepath}"; then
|
if test ! -f "${cache_filepath}"; then
|
||||||
|
@ -65,7 +66,7 @@ for package in ${normalized_packages}; do
|
||||||
if test -f $f || test -L $f; then echo "${f:1}"; fi; #${f:1} removes the leading slash that Tar disallows
|
if test -f $f || test -L $f; then echo "${f:1}"; fi; #${f:1} removes the leading slash that Tar disallows
|
||||||
done |
|
done |
|
||||||
xargs tar -czf "${cache_filepath}" -C /
|
xargs tar -czf "${cache_filepath}" -C /
|
||||||
log "done (compressed size $(du -k "${cache_filepath}" | cut -f1))."
|
log "done (compressed size $(du -h "${cache_filepath}" | cut -f1))."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Comma delimited name:ver pairs in the all packages manifest.
|
# Comma delimited name:ver pairs in the all packages manifest.
|
||||||
|
|
10
lib.sh
10
lib.sh
|
@ -9,9 +9,17 @@ function normalize_package_list {
|
||||||
echo "${sorted}"
|
echo "${sorted}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Gets a package list of dependencies as common delimited pairs
|
||||||
|
# <name>:<version>,<name:version>...
|
||||||
|
function get_dep_packages {
|
||||||
|
echo $(apt-get install --dry-run --yes "${1}" | \
|
||||||
|
grep "^Inst" | sort | awk '{print $2 $3}' | \
|
||||||
|
tr '(' ':' | grep -v "${1}:")
|
||||||
|
}
|
||||||
|
|
||||||
# Split fully qualified package into name and version
|
# Split fully qualified package into name and version
|
||||||
function get_package_name_ver {
|
function get_package_name_ver {
|
||||||
IFS=\= read name ver <<< "${1}"
|
IFS=\: read name ver <<< "${1}"
|
||||||
# If version not found in the fully qualified package value.
|
# If version not found in the fully qualified package value.
|
||||||
if test -z "${ver}"; then
|
if test -z "${ver}"; then
|
||||||
ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')"
|
ver="$(grep "Version:" <<< "$(apt show ${name})" | awk '{print $2}')"
|
||||||
|
|
Loading…
Reference in a new issue