install same post-merge-hook as in branch zg1/zone1

This commit is contained in:
Gerhard Hoffmann 2023-06-27 14:36:36 +02:00
parent 28f597898e
commit 9519a6555e

View File

@ -11,11 +11,9 @@ if [ -z $IFS ]; then
IFS=$'\n' IFS=$'\n'
fi fi
GIT_PULL_TMP=/tmp/git_changed_files_for_last_pull GIT_UPDATE_LOG=/opt/app/tools/atbupdate/update_log.csv
OPKG_CMDS_TMP=/tmp/opkg_commands
rm -f $GIT_PULL_TMP #TODO: use in UpdateController
rm -f $OPKG_CMDS_TMP
get_blob () { # get the blob of the file(name) passed as $1 get_blob () { # get the blob of the file(name) passed as $1
# note: this can be used for any file in the filesystem # note: this can be used for any file in the filesystem
@ -29,26 +27,30 @@ get_commit_for_blob () {
grep -q $1 && echo -n {} && head -n 1") grep -q $1 && echo -n {} && head -n 1")
} }
for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do write_log_file () {
if grep -E -q "(DC.*json|dc.*hex|dc.*bin|tariff.*json)" <<< $fn; then local now=$(date +"%Y-%m-%dT%T")
# called in repository: $fn is e.g. etc/psa_tariff/tariff01.json for fn in $(git diff-tree -r HEAD@{1} HEAD --name-only); do
# add '/' prefix if grep -qE "DC2C.*json" <<< $fn; then
fn=$(echo $fn | awk '{ printf "/"$0 }') # called in repository: $fn is e.g. etc/psa_tariff/tariff01.json
if [[ -f "$fn" ]]; then # add '/' prefix
blob=$(get_blob "$fn") echo "DOWNLOAD, $(echo $fn | awk '{ printf "/"$0 }'), $now, N/A" >> "$GIT_UPDATE_LOG"
commit=$(get_commit_for_blob $blob "$fn") elif grep -qE "dc2c.bin" <<< $fn; then
fsize=$(ls -l "$fn" | awk '{ print $5 }') # download the file referenced by the link dc2c.bin
echo "$fn $fsize $blob $commit" >> $GIT_PULL_TMP echo "DOWNLOAD, "/etc/dc/dc2c.bin", $now, N/A" >> "$GIT_UPDATE_LOG"
elif grep -qE ".*opkg_commands" <<< $fn; then
readarray opkg_commands < <(cat $fn)
for opkg_c in "${opkg_commands[@]}"; do
# check for lines longer than 'opkg '
if [ "${#opkg_c}" -gt 4 ]; then
# comment: spaces, at least one '#'
grep -qE '^[[:space:]]*#+.*$' <<< "$opkg_c" && continue
echo -n "EXECUTE, $opkg_c, $now, N/A" | tr -d '\n\r' >> $GIT_UPDATE_LOG 2>&1
echo "" >> $GIT_UPDATE_LOG 2>&1
fi
done
fi fi
fi done
if grep -E -q ".*opkg_commands" <<< $fn; then }
readarray opkg_commands < <(cat $fn)
for opkg_c in "${opkg_commands[@]}"; do write_log_file
test -z $opkg_c && continue;
test ! -z $(grep -E "^\s*[#]+.*$" <<< $opkg_c) && continue
echo -n "$opkg_c" | tr -d '\n\r' >> $OPKG_CMDS_TMP 2>&1
echo "" >> $OPKG_CMDS_TMP 2>&1
done
source "$fn"
fi
done