From 3574453066c772fa17288dbb6417718fe61df981 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 9 Jun 2022 18:41:33 +0200 Subject: [PATCH] 'git pull' calls the hook post-merge when new data arrive. If this is the case, write a file /tmp/git-pull which contains the names of changed files. Do not search for any special output of git. --- update_psa_impl | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/update_psa_impl b/update_psa_impl index bc212e7..f0047ad 100755 --- a/update_psa_impl +++ b/update_psa_impl @@ -35,42 +35,20 @@ update_psa() { exit $? fi - rm -f "$OPKG_CMDS_TMP" - rm -f "$GIT_PULL_TMP" - update_psa_activated # message to ISMAS - local try_update_count=0 local func="${FUNCNAME[0]}" log_debug "$func:${LINENO}: fetch/merge updates..." # Fetch new updates (using git) - while : - do - local repository_is_already_up_to_date="" - if ! fetch_customer_updates repository_is_already_up_to_date; then - if [ "$repository_is_already_up_to_date" = "yes" ]; then - log_error "$func:${LINENO}: $customer_id is up-to-date"\ - "-> no files to update -> no psa update" - update_psa_false_alarm \ - "update request, but no change in $CUSTOMER_REPOSITORY_PATH" - exit $? - fi - try_updates_count=$((try_updates_count+1)) - if [[ "$try_updates_count" -eq 5 ]]; then - log_error "$func:${LINENO}: fetch/merging failed" - update_psa_pull_error # message to ISMAS - exit $? - fi - update_psa_pull_error # message to ISMAS - sleep 10s - else - # Fetched updates successfully - try_updates_count=0 - break - fi - done + if ! fetch_customer_updates; then + log_error "$func:${LINENO}: fetch no data for $customer_id"\ + "-> no files to update -> no psa update" + update_psa_false_alarm \ + "update request, but no change in $CUSTOMER_REPOSITORY_PATH" + # TODO + fi update_psa_pull_customer_repository # message to ISMAS @@ -78,7 +56,7 @@ update_psa() { # local changed_files=$(changed_file_names) - if [[ ! -z $GIT_PULL_TMP ]]; then + if [[ -f "$GIT_PULL_TMP" ]]; then # TODO if ! check_hardware_compatibility "$files_to_copy" ; then local __r=$? @@ -88,7 +66,7 @@ update_psa() { fi fi - if [[ ! -z "$OPKG_CMDS_TMP" ]]; then + if [[ -f "$OPKG_CMDS_TMP" ]]; then local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')" log_info "$func:${LINENO}: executed opkg commands" update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \ @@ -158,6 +136,7 @@ update_psa() { update_psa_cleanup $UPDATE_ISMAS_PROGRESS \ $RC_SUCCESS "cleanup after psa update" + # TODO exit 0 }