Use APT syntax for name version delimitation and not a colon.
This commit is contained in:
parent
cdad971850
commit
f5bcdd76d3
3 changed files with 14 additions and 27 deletions
|
@ -33,8 +33,8 @@ manifest_main=""
|
||||||
log "Package list:"
|
log "Package list:"
|
||||||
for package in ${packages}; do
|
for package in ${packages}; do
|
||||||
read package_name package_ver < <(get_package_name_ver "${package}")
|
read package_name package_ver < <(get_package_name_ver "${package}")
|
||||||
manifest_main="${manifest_main}${package_name}:${package_ver},"
|
manifest_main="${manifest_main}${package_name}=${package_ver},"
|
||||||
log "- ${package_name}:${package_ver}"
|
log "- ${package_name} (${package_ver})"
|
||||||
done
|
done
|
||||||
write_manifest "main" "${manifest_main}" "${cache_dir}/manifest_main.log"
|
write_manifest "main" "${manifest_main}" "${cache_dir}/manifest_main.log"
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ log_empty_line
|
||||||
|
|
||||||
log "Installing apt-fast for optimized installs..."
|
log "Installing apt-fast for optimized installs..."
|
||||||
# Install apt-fast for optimized installs.
|
# Install apt-fast for optimized installs.
|
||||||
/bin/bash -c "$(curl -sL https://git.io/vokNn)"
|
# /bin/bash -c "$(curl -sL https://git.io/vokNn)"
|
||||||
log "done"
|
log "done"
|
||||||
|
|
||||||
log_empty_line
|
log_empty_line
|
||||||
|
@ -66,9 +66,8 @@ manifest_all=""
|
||||||
install_log_filepath="${cache_dir}/install.log"
|
install_log_filepath="${cache_dir}/install.log"
|
||||||
|
|
||||||
log "Clean installing ${package_count} packages..."
|
log "Clean installing ${package_count} packages..."
|
||||||
apt_syntax_packages="$(convert_action_to_apt_syntax_packages "${packages}")"
|
|
||||||
# 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-fast --yes install ${apt_syntax_packages} > "${install_log_filepath}"
|
sudo DEBIAN_FRONTEND=noninteractive apt-fast --yes install ${packages} > "${install_log_filepath}"
|
||||||
log "done"
|
log "done"
|
||||||
log "Installation log written to ${install_log_filepath}"
|
log "Installation log written to ${install_log_filepath}"
|
||||||
|
|
||||||
|
@ -77,7 +76,8 @@ log_empty_line
|
||||||
installed_packages=$(get_installed_packages "${install_log_filepath}")
|
installed_packages=$(get_installed_packages "${install_log_filepath}")
|
||||||
log "Installed package list:"
|
log "Installed package list:"
|
||||||
for installed_package in ${installed_packages}; do
|
for installed_package in ${installed_packages}; do
|
||||||
log "- ${installed_package}"
|
# Reformat for human friendly reading.
|
||||||
|
log "- $(echo ${installed_package} | awk -F\= '{print $1" ("$2")"}')"
|
||||||
done
|
done
|
||||||
|
|
||||||
log_empty_line
|
log_empty_line
|
||||||
|
@ -104,7 +104,7 @@ for installed_package in ${installed_packages}; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Comma delimited name:ver pairs in the all packages manifest.
|
# Comma delimited name:ver pairs in the all packages manifest.
|
||||||
manifest_all="${manifest_all}${package_name}:${package_ver},"
|
manifest_all="${manifest_all}${package_name}=${package_ver},"
|
||||||
done
|
done
|
||||||
log "done (total cache size $(du -h ${cache_dir} | tail -1 | awk '{print $1}'))"
|
log "done (total cache size $(du -h ${cache_dir} | tail -1 | awk '{print $1}'))"
|
||||||
|
|
||||||
|
|
22
lib.sh
22
lib.sh
|
@ -1,17 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Convert the APT syntax package (= delimited) to action syntax package
|
|
||||||
# (: delimited).
|
|
||||||
# Arguments:
|
|
||||||
# APT syntax package, with or without version.
|
|
||||||
# Returns:
|
|
||||||
# Action syntax package, with or without version.
|
|
||||||
###############################################################################
|
|
||||||
function convert_action_to_apt_syntax_packages() {
|
|
||||||
echo ${1} | sed 's/:/=/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Execute the Debian install script.
|
# Execute the Debian install script.
|
||||||
# Arguments:
|
# Arguments:
|
||||||
|
@ -23,7 +11,7 @@ function convert_action_to_apt_syntax_packages() {
|
||||||
# Filepath of the install script, otherwise an empty string.
|
# Filepath of the install script, otherwise an empty string.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
function execute_install_script {
|
function execute_install_script {
|
||||||
local package_name=$(basename ${2} | awk -F\: '{print $1}')
|
local package_name=$(basename ${2} | awk -F\= '{print $1}')
|
||||||
local install_script_filepath=$(\
|
local install_script_filepath=$(\
|
||||||
get_install_script_filepath "${1}" "${package_name}" "${3}")
|
get_install_script_filepath "${1}" "${package_name}" "${3}")
|
||||||
if test ! -z "${install_script_filepath}"; then
|
if test ! -z "${install_script_filepath}"; then
|
||||||
|
@ -67,7 +55,7 @@ function get_installed_packages {
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
# ${regex} should be unquoted since it isn't a literal.
|
# ${regex} should be unquoted since it isn't a literal.
|
||||||
if [[ "${line}" =~ ${regex} ]]; then
|
if [[ "${line}" =~ ${regex} ]]; then
|
||||||
dep_packages="${dep_packages}${BASH_REMATCH[1]}:${BASH_REMATCH[4]} "
|
dep_packages="${dep_packages}${BASH_REMATCH[1]}=${BASH_REMATCH[4]} "
|
||||||
else
|
else
|
||||||
log_err "Unable to parse package name and version from \"${line}\""
|
log_err "Unable to parse package name and version from \"${line}\""
|
||||||
exit 2
|
exit 2
|
||||||
|
@ -89,13 +77,13 @@ function get_installed_packages {
|
||||||
###############################################################################
|
###############################################################################
|
||||||
function get_package_name_ver {
|
function get_package_name_ver {
|
||||||
local ORIG_IFS="${IFS}"
|
local ORIG_IFS="${IFS}"
|
||||||
IFS=\: read name ver <<< "${1}"
|
IFS=\= read name ver <<< "${1}"
|
||||||
|
IFS="${ORIG_IFS}"
|
||||||
# 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-cache show ${name})" | awk '{print $2}')"
|
ver="$(grep "Version:" <<< "$(apt-cache show ${name})" | awk '{print $2}')"
|
||||||
fi
|
fi
|
||||||
echo "${name}" "${ver}"
|
echo "${name}" "${ver}"
|
||||||
IFS="${ORIG_IFS}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -56,8 +56,7 @@ log_empty_line
|
||||||
versioned_packages=""
|
versioned_packages=""
|
||||||
log "Verifying packages..."
|
log "Verifying packages..."
|
||||||
for package in ${packages}; do
|
for package in ${packages}; do
|
||||||
apt_syntax_package=$(convert_action_to_apt_syntax_packages ${package})
|
if test ! "$(apt-cache show ${package})"; then
|
||||||
if test ! "$(apt-cache show ${apt_syntax_package})"; then
|
|
||||||
echo "aborted"
|
echo "aborted"
|
||||||
log "Package '${package}' not found." >&2
|
log "Package '${package}' not found." >&2
|
||||||
exit 5
|
exit 5
|
||||||
|
@ -80,7 +79,7 @@ log "- Normalized package list is '${normalized_versioned_packages}'."
|
||||||
|
|
||||||
# Forces an update in cases where an accidental breaking change was introduced
|
# Forces an update in cases where an accidental breaking change was introduced
|
||||||
# and a global cache reset is required.
|
# and a global cache reset is required.
|
||||||
force_update_inc="0"
|
force_update_inc="1"
|
||||||
|
|
||||||
value="${normalized_versioned_packages} @ ${version} ${force_update_inc}"
|
value="${normalized_versioned_packages} @ ${version} ${force_update_inc}"
|
||||||
log "- Value to hash is '${value}'."
|
log "- Value to hash is '${value}'."
|
||||||
|
|
Loading…
Reference in a new issue