check for special opkg keywords: update, ... etc

This commit is contained in:
Gerhard Hoffmann 2022-06-04 18:15:19 +02:00
parent e3ae2e8d36
commit fab081d212

View File

@ -82,12 +82,14 @@ update() {
fi fi
done done
# TODO: backup implementieren
# Backup before any updates in case some previous test was wrong # Backup before any updates in case some previous test was wrong
if ! backup_previous_version; then if ! backup_previous_version; then
log_error "$func:${LINENO}: backup failed" log_error "$func:${LINENO}: backup failed"
revert_customer_repository ; exit 1 revert_customer_repository ; exit 1
fi fi
# TODO: implementieren, opkg pakete ausschliessen
files=$(changed_file_names) files=$(changed_file_names)
if ! check_md5_for_changed_customer_files $files ; then if ! check_md5_for_changed_customer_files $files ; then
log_error "$func:${LINENO}: new customer files wrong" log_error "$func:${LINENO}: new customer files wrong"
@ -97,31 +99,40 @@ update() {
if grep -qE ".*opkg_commands.*?" <<< $files; then if grep -qE ".*opkg_commands.*?" <<< $files; then
# read opkg_cmds: each line respresents an opkg-command # read opkg_cmds: each line respresents an opkg-command
readarray opkg_commands < <(cat $opkg_cmds_file) readarray opkg_commands < <(cat $opkg_cmds_file)
for opkg_command in "${opkg_commands[@]}"; do for opkg_c in "${opkg_commands[@]}"; do
if grep -qE "^\s*[#]+.*?$" <<< $opkg_command; then if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then
continue # found comment line continue # found comment line
fi fi
# FIXME: sollte nicht gebraucht werden
opkg_command=${opkg_command//[$'\r\n\t']/ }
local package=$(printf '%s' "$opkg_command" | awk '{ print $NF }')
local opkg_output=() # package manipulation commands without package:
if ! exec_opkg_info "$package" opkg_output; then local cwp="update|upgrade|clean"
log_error "$func:${LINENO}: opkg --noaction $opkg_command failed" # informational commands without package:
revert_customer_repository ; exit 1 cwp="${cwp}|list|list-installed|list-upgradable"
fi
if ! check_md5_for_opkg_packages opkg_output; then if grep -qE "^.*\s+($cwp)\s+.*$" <<< $opkg_c; then
log_error "$func:${LINENO}: wrong md5sum for some opkg packages" local p=$(printf '%s' "$opkg_c" | awk '{ print $NF }')
revert_customer_repository ; exit 1 local opkg_output=()
if ! exec_opkg_info "$p" opkg_output; then
log_error "$func:${LINENO}: opkg info $opkg_c failed"
revert_customer_repository ; exit 1
fi
if ! check_md5_for_opkg_packages opkg_output; then
log_error "$func:${LINENO}: "\
"wrong md5sum for opkg packages"
revert_customer_repository ; exit 1
fi
fi fi
# perform a dry-run and check if everything might work as expected. # perform a dry-run and check if everything might work as expected.
if ! exec_opkg_no_action $opkg_c; then
log_error "$func:${LINENO}: "\
"opkg --noaction $opkg_c failed"
fi
# Actually execute the opkg command # Actually execute the opkg command
if ! exec_opkg $opkg_command; then if ! exec_opkg $opkg_c; then
log_error "$func:${LINENO}: exec_opkg $opkg_command failed" log_error "$func:${LINENO}: exec_opkg $opkg_c failed"
fallback_to_previous_version fallback_to_previous_version
revert_customer_repository ; exit 1 revert_customer_repository ; exit 1
fi fi