add guard clauses if dpkg status is missing

This commit is contained in:
Jérémy Lecour 2024-03-29 10:31:34 +01:00 committed by Jérémy Lecour
parent c67c1ca7ad
commit 297cafe04b
Signed by: jlecour
SSH key fingerprint: SHA256:h+5LgHRKwN9lS0SsdVR5yZPeFlJE4Mt+8UtL4CcP8dY
2 changed files with 48 additions and 37 deletions

View file

@ -15,6 +15,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
### Changed
* rsync `/etc` with `--delete`
* add guard clauses if dpkg status is missing
### Fixed

View file

@ -187,11 +187,13 @@ task_dpkg_full() {
apt_config_bin=$(command -v apt-config)
if [ -n "${apt_config_bin}" ]; then
# will do something like `dir_state_status='/var/lib/dpkg/status'`
eval "$(${apt_config_bin} shell dir_state_status Dir::State::status)"
fi
dpkg_dir=$(dirname "${dir_state_status}")
if [ -d "${dpkg_dir}" ]; then
last_result=$(mkdir -p "${dump_dir}${dpkg_dir}" && chmod -R 755 "${dump_dir}${dpkg_dir}")
last_rc=$?
@ -230,6 +232,9 @@ task_dpkg_full() {
rc=10
fi
fi
else
debug "* ${dpkg_dir} not found"
fi
}
task_dpkg_status() {
@ -240,9 +245,11 @@ task_dpkg_status() {
apt_config_bin=$(command -v apt-config)
if [ -n "${apt_config_bin}" ]; then
# will do something like `dir_state_status='/var/lib/dpkg/status'`
eval "$(${apt_config_bin} shell dir_state_status Dir::State::status)"
fi
if [ -f "${dir_state_status}" ]; then
last_result=$(cp "${dir_state_status}" "${dump_dir}/dpkg-status.txt")
last_rc=$?
@ -253,6 +260,9 @@ task_dpkg_status() {
debug "${last_result}"
rc=10
fi
else
debug "* ${dir_state_status} not found"
fi
}
task_packages() {