Compare commits

..

2 Commits

Author SHA1 Message Date
cfce4ae53c remove opkg-part 2022-06-07 22:33:05 +02:00
7a77d03c7e Add some vars 2022-06-07 22:32:46 +02:00
2 changed files with 75 additions and 53 deletions

View File

@ -22,6 +22,9 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
readonly UPDATEPSABEGIN=./.updatepsa/begin readonly UPDATEPSABEGIN=./.updatepsa/begin
readonly UPDATEPSAEND=./.updatepsa/end readonly UPDATEPSAEND=./.updatepsa/end
readonly OPKG_CMDS_TMP=/tmp/opkg_commands
readonly GIT_PULL_TMP=/tmp/git_pull
readonly PROGRAM=`basename $0` readonly PROGRAM=`basename $0`
readonly WORKSPACE_DIR=workspace readonly WORKSPACE_DIR=workspace
@ -97,13 +100,15 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
compute_hash () { compute_hash () {
if cd_customer_repository; then if cd_customer_repository; then
local hash="" local hash=""
if [[ -z $1 ]]; then if [[ -z "$1" ]]; then
hash=$(git log -n 1 --pretty=format:%H) hash=$(git log -n 1 --pretty=format:%H)
else else
hash=$(git log -n 1 --pretty=format:%H -- $1) hash=$(git hash-object "$1")
fi fi
echo ${hash:0:10} # return the first 10 hex characters cd_home ; echo ${hash:0:10} # return the first 10 hex characters
return 0
fi fi
return 1
} }
compute_version () { compute_version () {

View File

@ -35,6 +35,9 @@ update_psa() {
exit $? exit $?
fi fi
rm -f "$OPKG_CMDS_TMP"
rm -f "$GIT_PULL_TMP"
update_psa_activated # message to ISMAS update_psa_activated # message to ISMAS
local try_update_count=0 local try_update_count=0
@ -73,63 +76,77 @@ update_psa() {
# no backup necessary as saved in git-repo # no backup necessary as saved in git-repo
local changed_files=$(changed_file_names) # local changed_files=$(changed_file_names)
if [[ ! -z $GIT_PULL_TMP ]]; then
# TODO
if ! check_hardware_compatibility "$files_to_copy" ; then if ! check_hardware_compatibility "$files_to_copy" ; then
local __r=$? local __r=$?
log_error "$func:${LINENO}: json/ini-files not fit for PSA" log_error "$func:${LINENO}: json/ini-files not fit for PSA"
revert_customer_repository revert_customer_repository
exit $__r exit $__r
fi fi
# check if the opkg-command-file has been changed during 'git pull'
if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
# read opkg_cmds: each line respresents an opkg-command
readarray opkg_commands < <(cat $OPKG_CMDS_PSA_FILE)
for opkg_c in "${opkg_commands[@]}"; do
if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then
continue # found comment line
fi fi
# package manipulation commands without package: if [[ ! -z "$OPKG_CMDS_TMP" ]]; then
local cwp="update|upgrade|clean" local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')"
# informational commands without package: log_info "$func:${LINENO}: executed opkg commands"
cwp="${cwp}|list|list-installed|list-upgradable" update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "$commands"
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_noaction $opkg_c; then
log_error "$func:${LINENO}: "\
"opkg --noaction $opkg_c failed"
fi
# Actually execute the opkg command
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
done
else else
log_info "$func:${LINENO}: no opkg commands to execute" log_info "$func:${LINENO}: no opkg commands to execute"
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \ update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
$RC_SUCCESS "no opkg commands to execute" $RC_SUCCESS "no opkg commands to execute"
fi fi
# check if the opkg-command-file has been changed during 'git pull'
#if grep -qE ".*opkg_commands.*?" <<< $changed_files; then
# # read opkg_cmds: each line respresents an opkg-command
# readarray opkg_commands < <(cat $OPKG_CMDS_PSA_FILE)
# for opkg_c in "${opkg_commands[@]}"; do
# if grep -qE "^\s*[#]+.*$" <<< $opkg_c; then
# continue # found comment line
# fi
# # package manipulation commands without package:
# local cwp="update|upgrade|clean"
# # informational commands without package:
# cwp="${cwp}|list|list-installed|list-upgradable"
# 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_noaction $opkg_c; then
# log_error "$func:${LINENO}: "\
# "opkg --noaction $opkg_c failed"
# fi
# # Actually execute the opkg command
# 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
# done
#else
# log_info "$func:${LINENO}: no opkg commands to execute"
# update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
# $RC_SUCCESS "no opkg commands to execute"
#fi
# Cleanup. # Cleanup.
#if ! cleanup_previous_version; then #if ! cleanup_previous_version; then
# log_error "$func:${LINENO}: cleanup_previous_version failed" # log_error "$func:${LINENO}: cleanup_previous_version failed"