From fab081d2122ec993aebe612a27f97984a0e80c24 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sat, 4 Jun 2022 18:15:19 +0200 Subject: [PATCH] check for special opkg keywords: update, ... etc --- update_psa | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/update_psa b/update_psa index a6d0880..ea4d52c 100755 --- a/update_psa +++ b/update_psa @@ -82,12 +82,14 @@ update() { fi done + # TODO: backup implementieren # Backup before any updates in case some previous test was wrong if ! backup_previous_version; then log_error "$func:${LINENO}: backup failed" revert_customer_repository ; exit 1 fi + # TODO: implementieren, opkg pakete ausschliessen files=$(changed_file_names) if ! check_md5_for_changed_customer_files $files ; then log_error "$func:${LINENO}: new customer files wrong" @@ -97,31 +99,40 @@ update() { if grep -qE ".*opkg_commands.*?" <<< $files; then # read opkg_cmds: each line respresents an opkg-command readarray opkg_commands < <(cat $opkg_cmds_file) - for opkg_command in "${opkg_commands[@]}"; do - if grep -qE "^\s*[#]+.*?$" <<< $opkg_command; then + for opkg_c in "${opkg_commands[@]}"; do + if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then continue # found comment line 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=() - if ! exec_opkg_info "$package" opkg_output; then - log_error "$func:${LINENO}: opkg --noaction $opkg_command failed" - revert_customer_repository ; exit 1 - fi + # package manipulation commands without package: + local cwp="update|upgrade|clean" + # informational commands without package: + cwp="${cwp}|list|list-installed|list-upgradable" - if ! check_md5_for_opkg_packages opkg_output; then - log_error "$func:${LINENO}: wrong md5sum for some opkg packages" - revert_customer_repository ; exit 1 + if grep -qE "^.*\s+($cwp)\s+.*$" <<< $opkg_c; then + local p=$(printf '%s' "$opkg_c" | awk '{ print $NF }') + 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 # 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 - if ! exec_opkg $opkg_command; then - log_error "$func:${LINENO}: exec_opkg $opkg_command failed" + if ! exec_opkg $opkg_c; then + log_error "$func:${LINENO}: exec_opkg $opkg_c failed" fallback_to_previous_version revert_customer_repository ; exit 1 fi