Compare commits
20 Commits
cfce4ae53c
...
szeged_pre
Author | SHA1 | Date | |
---|---|---|---|
c229f7072c | |||
7a35039dad | |||
42fb74a041 | |||
d69f767002 | |||
7c2d78e6db | |||
9dd7eb7a3c | |||
87be571e43 | |||
2045dcedf5 | |||
9d6bb99963 | |||
8b5cda7f73 | |||
52271bef21 | |||
f080f34bb3 | |||
6f8ba186dd | |||
0541206033 | |||
b3eed36db8 | |||
966a779065 | |||
da3c9abbf5 | |||
3574453066 | |||
27445f354a | |||
83aa2dbd5c |
@@ -82,33 +82,37 @@ if [ "${general_utils_sourced:-1}" = "1" ]; then # include only once
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert_s () {
|
assert_s () {
|
||||||
if [ -z ${!1} ]; then
|
# if [ -z ${!1} ]; then
|
||||||
log_fatal "$1 not set"
|
# log_fatal "$1 not set"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_d () {
|
assert_d () {
|
||||||
if [ ! -d ${!1} ]; then
|
# if [ ! -d ${!1} ]; then
|
||||||
log_fatal "$1 does not exist"
|
# log_fatal "$1 does not exist"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
# log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_f () {
|
assert_f () {
|
||||||
if [ ! -f ${!1} ]; then
|
# if [ ! -f ${!1} ]; then
|
||||||
log_fatal "$1 does not exist"
|
# log_fatal "$1 does not exist"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=${!1}"
|
#log_debug "$1=${!1}"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_a () {
|
assert_a () {
|
||||||
local readonly __m="${1}[@]"
|
local readonly __m="${1}[@]"
|
||||||
local readonly __n=(${!__m})
|
local readonly __n=(${!__m})
|
||||||
local __len=${#__n[@]}
|
local __len=${#__n[@]}
|
||||||
if [ $__len -eq 0 ]; then
|
# if [ $__len -eq 0 ]; then
|
||||||
log_fatal "$1 not set"
|
# log_fatal "$1 not set"
|
||||||
fi
|
# fi
|
||||||
log_debug "$1=$__n"
|
# log_debug "$1=$__n"
|
||||||
|
:
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
159
git_helpers
159
git_helpers
@@ -71,9 +71,7 @@ revert_to_commit_before_pull () {
|
|||||||
clone_customer_repository () {
|
clone_customer_repository () {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
if [ "$PWD" = "$WORKING_DIRECTORY" ]; then
|
if [ "$PWD" = "$WORKING_DIRECTORY" ]; then
|
||||||
if ! [[ -d "./$WORKSPACE_DIR" ]]; then
|
mkdir -p "./$WORKSPACE_DIR"
|
||||||
{ mkdir -p ./$WORKSPACE_DIR; }
|
|
||||||
fi
|
|
||||||
# check if the directory is empty. If so, clone the
|
# check if the directory is empty. If so, clone the
|
||||||
# customer repository
|
# customer repository
|
||||||
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
||||||
@@ -83,14 +81,43 @@ clone_customer_repository () {
|
|||||||
$(exec_git_command git clone "$1")
|
$(exec_git_command git clone "$1")
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
log_debug "$func:${LINENO} cloning ${1} done"
|
log_debug "$func:${LINENO} cloning ${1} done"
|
||||||
local res=$(exec_git_command git --git-dir="${CUSTOMER_ID_BASE_DIR}/.git" --work-tree="/" init)
|
GIT_CLONE_EXECUTED=1
|
||||||
if ! [[ -z $res ]]; then
|
rm -f $GIT_PULL_TMP
|
||||||
|
rm -f $OPKG_CMDS_TMP
|
||||||
|
# after cloning, cd into repository, and re-initialize,
|
||||||
|
# setting the work-tree as "/". This has the effect that
|
||||||
|
# a "git pull" will automatically fetched files in the
|
||||||
|
# corresponding sytem-folders.
|
||||||
|
if cd ${CUSTOMER_ID_BASE_DIR}; then
|
||||||
|
# local res=$(exec_git_command git --git-dir=.git --work-tree=/ init)
|
||||||
|
exec_git_command git checkout "$LOCAL_BRANCH"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} checked out local branch $LOCAL_BRANCH"
|
||||||
|
exec_git_command git config core.worktree "/"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} configured worktree"
|
||||||
|
exec_git_command git fetch --all
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} fetch repository"
|
||||||
|
exec_git_command git reset --hard "$LOCAL_BRANCH"
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
log_debug "$func:${LINENO} reset --hard $LOCAL_BRANCH"
|
||||||
|
# re-initialized. copy post-merge (a hook called
|
||||||
|
# when 'git pull' is executed and changed data
|
||||||
|
# are received).
|
||||||
|
if cp ".githooks/post-merge" ".git/hooks"; then
|
||||||
|
log_debug "$func:${LINENO} copied post-merge to .git/hooks"
|
||||||
CLONE_CUSTOMER_REPOSITORY=true
|
CLONE_CUSTOMER_REPOSITORY=true
|
||||||
log_debug "$func:${LINENO} re-init of ${1} done"
|
log_debug "$func:${LINENO} re-init of ${1} done"
|
||||||
cd -; return 0
|
cd_home; return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd -
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
cd_home; return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# the directory is not empty, so we assume the
|
# the directory is not empty, so we assume the
|
||||||
@@ -148,109 +175,27 @@ pull_customer_repository () {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local commit_before_pull=$(latest_commit)
|
#local commit_before_pull=$(latest_commit)
|
||||||
if [ -z $commit_before_pull ]; then
|
#if [ -z $commit_before_pull ]; then
|
||||||
log_warn "$func:${LINENO}: commit_before_pull empty"
|
# log_warn "$func:${LINENO}: commit_before_pull empty"
|
||||||
cd_home ; return 1
|
# cd_home ; return 1
|
||||||
fi
|
#fi
|
||||||
log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
#log_debug "$func:${LINENO}: commit_before_pull=$commit_before_pull"
|
||||||
|
|
||||||
|
rm -f "$OPKG_CMDS_TMP"
|
||||||
|
rm -f "$GIT_PULL_TMP"
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: executing 'git pull'..."
|
log_debug "$func:${LINENO}: executing 'git pull'..."
|
||||||
|
exec_git_command 'git pull'
|
||||||
|
|
||||||
local git_result=$(exec_git_command 'git pull')
|
# GIT_PULL_TMP created by hook post-merge. it contains the names of the
|
||||||
|
# changed files.
|
||||||
if [ -z "$git_result" ]; then
|
if [[ -f $GIT_PULL_TMP ]]; then
|
||||||
log_warn "$func:${LINENO}: git result empty" ; cd_home;
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# see https://www.gnu.org/
|
|
||||||
# software/bash/manual/html_node/Shell-Parameter-Expansion.html
|
|
||||||
# [...]
|
|
||||||
#
|
|
||||||
# ${parameter//pattern/string}
|
|
||||||
#
|
|
||||||
# If there are two slashes separating parameter and pattern (...),
|
|
||||||
# all matches of pattern are replaced with string.
|
|
||||||
#
|
|
||||||
# If the expansion of string is null, matches of pattern are deleted.
|
|
||||||
# [...]
|
|
||||||
git_result=${git_result//[$'\r\n\t']/ }
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO} git-pull-result=${git_result}"
|
|
||||||
|
|
||||||
if grep -qE "^.*?Already\s+\up\s+\to\s+date.*$" <<< "$git_result"; then
|
|
||||||
log_warn "$func:${LINENO}: repository $PWD already up to date."
|
|
||||||
read $1 <<< 'yes'
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local commit_after_pull=$(latest_commit)
|
|
||||||
if [ -z $commit_after_pull ]; then
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: commit_after_pull=$commit_after_pull"
|
|
||||||
|
|
||||||
# Note: # 'git pull' is a 'git fetch' followed by a 'git merge'.
|
|
||||||
# Here's the fetch portion:
|
|
||||||
#
|
|
||||||
# remote: Counting objects: 11, done.
|
|
||||||
# remote: Compressing objects: 100% (5/5), done.
|
|
||||||
# remote: Total 7 (delta 2), reused 0 (delta 0)
|
|
||||||
#
|
|
||||||
# At this point, you've told the remote what you want.
|
|
||||||
# It finds all the objects it needs to give you,
|
|
||||||
# compresses them for faster transfer over the network,
|
|
||||||
# and then reports what it's sending you.
|
|
||||||
#
|
|
||||||
# Unpacking objects: 100% (7/7), done.
|
|
||||||
#
|
|
||||||
# You receive the pack (set of compressed objects) and unpack it.
|
|
||||||
#
|
|
||||||
# From ssh://my.remote.host.com/~/git/myproject
|
|
||||||
# * branch master -> FETCH_HEAD
|
|
||||||
|
|
||||||
# You've fetched the branch 'master' from the given remote;
|
|
||||||
# the ref FETCH_HEAD now points to it.
|
|
||||||
# Now we move on to the merge - precisely, git will merge
|
|
||||||
# FETCH_HEAD (the remote's master branch) into your current branch
|
|
||||||
# (presumably master).
|
|
||||||
#
|
|
||||||
#######################################################################
|
|
||||||
# here starts "message"
|
|
||||||
#
|
|
||||||
# Updating 9d447d2..f74fb21
|
|
||||||
# Fast forward
|
|
||||||
#
|
|
||||||
# It turns out that you haven't diverged from the remote's master branch,
|
|
||||||
# so the merge is a fast-forward (a trivial merge where it simply moves
|
|
||||||
# you forward in the history).
|
|
||||||
#
|
|
||||||
# Git notes the original position of your master branch (9d447d2)
|
|
||||||
# and the new position (f74fb21) it's been fast-forwarded to.
|
|
||||||
# If you had diverged from the remote's master branch,
|
|
||||||
# you'd see the output of a recursive merge here - Merge made
|
|
||||||
# by recursive, possibly along with some Auto-merged <file>
|
|
||||||
# and (oh no!) merge conflicts!
|
|
||||||
#
|
|
||||||
# szeged/1/1/etc/psa_config/device.conf | 13 +++++++------
|
|
||||||
# szeged/update.conf | 2 +-
|
|
||||||
# 2 files changed, 8 insertions(+), 7 deletions(-)
|
|
||||||
#
|
|
||||||
# Finally, it shows you the diffstat between the original and post-merge
|
|
||||||
# position of your master branch;
|
|
||||||
# this is basically what you'd get from
|
|
||||||
#
|
|
||||||
# git diff --stat master@{1} master.
|
|
||||||
#
|
|
||||||
|
|
||||||
update_commit="${commit_before_pull}..${commit_after_pull}"
|
|
||||||
if ! grep -qE ".*Updating\s+${update_commit}.*?" <<< $git_result; then
|
|
||||||
log_crit "$func:${LINENO}: no $update_commit in [ $git_result ]"
|
|
||||||
cd_home ; return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd_home; return 0
|
cd_home; return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_warn "$func:${LINENO}: no data fetched form repository"
|
||||||
|
cd_home; return 1
|
||||||
}
|
}
|
||||||
# pull_customer_repository customer_281
|
# pull_customer_repository customer_281
|
||||||
|
|
||||||
|
16
log_helpers
16
log_helpers
@@ -1,6 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
|
RED='\e[0;31m'
|
||||||
|
GREEN='\e[0;32m'
|
||||||
|
NC='\e[0m' # No Color
|
||||||
|
|
||||||
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
||||||
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
readonly log_helpers_sourced=${BASH_SOURCE[0]}
|
||||||
|
|
||||||
@@ -47,32 +51,32 @@ if [ "${log_helpers_sourced:-1}" = "1" ]; then # include only once
|
|||||||
|
|
||||||
log_info() {
|
log_info() {
|
||||||
if [ $log_level -le $INFO ]; then
|
if [ $log_level -le $INFO ]; then
|
||||||
log "INFO $*"
|
log "${GREEN}INFO $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_warn() {
|
log_warn() {
|
||||||
if [ $log_level -le $WARN ]; then
|
if [ $log_level -le $WARN ]; then
|
||||||
log "WARN $*"
|
log "${RED}WARN $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_crit() {
|
log_crit() {
|
||||||
if [ $log_level -le $CRIT ]; then
|
if [ $log_level -le $CRIT ]; then
|
||||||
log "CRIT $*"
|
log "${RED}CRIT $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_error() {
|
log_error() {
|
||||||
if [ $log_level -le $ERROR ]; then
|
if [ $log_level -le $ERROR ]; then
|
||||||
log "ERROR $*"
|
log "${RED}ERROR $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
log_fatal() {
|
log_fatal() {
|
||||||
if [ $log_level -le $FATAL ]; then
|
if [ $log_level -le $FATAL ]; then
|
||||||
log "FATAL $*"
|
log "${RED}FATAL $*"
|
||||||
log "exiting ..."
|
log "${RED}exiting ..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
36
read_config
36
read_config
@@ -28,6 +28,8 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly PROGRAM=`basename $0`
|
readonly PROGRAM=`basename $0`
|
||||||
readonly WORKSPACE_DIR=workspace
|
readonly WORKSPACE_DIR=workspace
|
||||||
|
|
||||||
|
GIT_CLONE_EXECUTED=0
|
||||||
|
|
||||||
EXITCODE=$RC_SUCCESS
|
EXITCODE=$RC_SUCCESS
|
||||||
CLONE_CUSTOMER_REPOSITORY=false
|
CLONE_CUSTOMER_REPOSITORY=false
|
||||||
|
|
||||||
@@ -35,17 +37,13 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
read_config() {
|
read_config() {
|
||||||
local func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
WORKING_DIRECTORY=${WORKING_DIRECTORY:-$UPDATEPSAHOME}
|
WORKING_DIRECTORY=${PWD}
|
||||||
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
CONFIGFILENAME=${CONFIGFILENAME:-'update_psa.conf'}
|
||||||
|
|
||||||
if ! [ -f "$CONFIGFILENAME" ]; then
|
if ! [ -f "$CONFIGFILENAME" ]; then
|
||||||
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
log_fatal "$func:${LINENO}: $CONFIGFILENAME not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -d "$WORKING_DIRECTORY" ]; then
|
|
||||||
log_fatal "$func:${LINENO}: $WORKING_DIRECTORY not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
log_debug "$func:${LINENO}: CONFIGFILENAME=$CONFIGFILENAME"
|
||||||
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
log_debug "$func:${LINENO}: WORKING_DIRECTORY=$WORKING_DIRECTORY"
|
||||||
|
|
||||||
@@ -92,6 +90,16 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
readonly ZONE_GROUPS=(${__zone_groups[@]})
|
||||||
assert_a ZONE_GROUPS
|
assert_a ZONE_GROUPS
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
||||||
|
# TODO
|
||||||
|
# Zone aus /etc/zone_nr auslesen
|
||||||
|
#
|
||||||
|
readonly ZONE_GROUP=1
|
||||||
|
readonly ZONE=1
|
||||||
|
|
||||||
|
readonly LOCAL_BRANCH="$(cat "$cf" | jq -r .local_branches[$ZONE])"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -151,13 +159,7 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
# readonly CUST_BASE_DIRS=(${__customer_base_dirs[@]})
|
||||||
# assert_a CUST_BASE_DIRS
|
# assert_a CUST_BASE_DIRS
|
||||||
|
|
||||||
# TODO
|
|
||||||
# TODO: falls mehrere gruppen/zonen auftauchen hier anpassen
|
|
||||||
# TODO
|
|
||||||
# Zone aus /etc/zone_nr auslesen
|
|
||||||
#
|
|
||||||
readonly ZONE_GROUP=1
|
|
||||||
readonly ZONE=1
|
|
||||||
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
readonly CUST_BASE_DIR="$CUSTOMER_ID_BASE_DIR"
|
||||||
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
#readonly CUST_BASE_DIR="${CUST_BASE_DIRS[$ZONE]}"
|
||||||
#assert_d CUST_BASE_DIR
|
#assert_d CUST_BASE_DIR
|
||||||
@@ -377,11 +379,11 @@ if [ ${read_config_sourced:-1} = "1" ]; then # include only once
|
|||||||
${DC_PSA_DC_FILE##*${CUSTOMER_ID}/} \
|
${DC_PSA_DC_FILE##*${CUSTOMER_ID}/} \
|
||||||
${OPKG_CMDS_PSA_FILE##*${CUSTOMER_ID}/})
|
${OPKG_CMDS_PSA_FILE##*${CUSTOMER_ID}/})
|
||||||
|
|
||||||
log_debug "known json/ini/hex_files ->"
|
# log_debug "known json/ini/hex_files ->"
|
||||||
for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
# for (( i=0; i < ${#KNOWN_FILES[@]}; ++i )); do
|
||||||
tab=$'\t'
|
# tab=$'\t'
|
||||||
log_debug "$tab$tab ${KNOWN_FILES[$i]}"
|
# log_debug "$tab$tab ${KNOWN_FILES[$i]}"
|
||||||
done
|
# done
|
||||||
log_debug "sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
log_debug "sanity of ${CUSTOMER_REPOSITORY_PATH} OK"
|
||||||
|
|
||||||
# compute version string for current (i.e. previous) version
|
# compute version string for current (i.e. previous) version
|
||||||
|
14
update_psa
14
update_psa
@@ -14,10 +14,10 @@
|
|||||||
# ./update_psa --file $PWD/update_psa.conf --wdir $PWD
|
# ./update_psa --file $PWD/update_psa.conf --wdir $PWD
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
if [ $# -eq 0 ]; then
|
# if [ $# -eq 0 ]; then
|
||||||
# no parameters given -> nothing to do
|
# no parameters given -> nothing to do
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
if [ -z $IFS ]; then
|
if [ -z $IFS ]; then
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
@@ -59,11 +59,12 @@ while test $# -gt 0; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if cd "$WORKING_DIRECTORY"; then
|
||||||
source ./update_psa_impl
|
source ./update_psa_impl
|
||||||
|
|
||||||
if read_config
|
if read_config
|
||||||
then
|
then
|
||||||
if clone_customer_repository $CUSTOMER_REPOSITORY_PATH
|
if clone_customer_repository ${CUSTOMER_REPOSITORY_PATH}
|
||||||
then
|
then
|
||||||
check_sanity_of_repository
|
check_sanity_of_repository
|
||||||
|
|
||||||
@@ -74,9 +75,12 @@ then
|
|||||||
# updates_available && break
|
# updates_available && break
|
||||||
#done
|
#done
|
||||||
|
|
||||||
|
# update_psa "testing"
|
||||||
update_psa
|
update_psa
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
exit $EXIT_CODE
|
exit -1
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@@ -6,11 +6,15 @@
|
|||||||
"customer_location" : "szeged",
|
"customer_location" : "szeged",
|
||||||
|
|
||||||
"" : "unique customer identifier",
|
"" : "unique customer identifier",
|
||||||
"customer_id" : "customer_szeged_281",
|
"customer_id" : "customer_281",
|
||||||
|
|
||||||
"" : "zone file for PSA",
|
"" : "zone file for PSA",
|
||||||
"zone" : "/etc/zone_nr",
|
"zone" : "/etc/zone_nr",
|
||||||
|
|
||||||
|
"" : "local branches",
|
||||||
|
"local_branches" : ["master",
|
||||||
|
"zg1/zone1", "zg1/zone2", "zg1/zone3"],
|
||||||
|
|
||||||
"" : "customer number of PSA",
|
"" : "customer number of PSA",
|
||||||
"customer_id_" : "/etc/cust_nr",
|
"customer_id_" : "/etc/cust_nr",
|
||||||
|
|
||||||
@@ -25,5 +29,5 @@
|
|||||||
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
"zg" : [ 1, { "z" : [ 3, 1, 2, 3] } ],
|
||||||
|
|
||||||
"" : "url of customer repository",
|
"" : "url of customer repository",
|
||||||
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_szeged_281"
|
"cust_repository_path" : "https://git.mimbach49.de/GerhardHoffmann/customer_281.git"
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ exec_opkg_command () {
|
|||||||
# Fetch/merge updates from predefined repository using git.
|
# Fetch/merge updates from predefined repository using git.
|
||||||
#
|
#
|
||||||
fetch_customer_updates() {
|
fetch_customer_updates() {
|
||||||
if ! pull_customer_repository $1; then
|
if ! pull_customer_repository; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
@@ -28,49 +28,32 @@ collect_current_configuration () {
|
|||||||
#done
|
#done
|
||||||
}
|
}
|
||||||
|
|
||||||
update_psa() {
|
update_psa() { # calling with a parameter is used for testing
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
if ! updates_available; then # check for false alarm
|
if ! updates_available; then # check for false alarm
|
||||||
update_psa_false_alarm "update requested, but no WAIT state detected"
|
update_psa_false_alarm "update requested, but no WAIT state detected"
|
||||||
exit $?
|
exit $EXITCODE
|
||||||
|
fi
|
||||||
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 func="${FUNCNAME[0]}"
|
local func="${FUNCNAME[0]}"
|
||||||
|
|
||||||
log_debug "$func:${LINENO}: fetch/merge updates..."
|
log_debug "$func:${LINENO}: fetch/merge updates..."
|
||||||
|
|
||||||
# Fetch new updates (using git)
|
# Fetch new updates (using git). but only when repository has already been
|
||||||
while :
|
# cloned.
|
||||||
do
|
if [ $GIT_CLONE_EXECUTED -eq 0 ]; then
|
||||||
local repository_is_already_up_to_date=""
|
if ! fetch_customer_updates; then
|
||||||
if ! fetch_customer_updates repository_is_already_up_to_date; then
|
log_error "$func:${LINENO}: fetch no data for $customer_id"\
|
||||||
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"
|
"-> no files to update -> no psa update"
|
||||||
update_psa_false_alarm \
|
update_psa_false_alarm \
|
||||||
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
|
"update request, but no change in $CUSTOMER_REPOSITORY_PATH"
|
||||||
exit $?
|
# TODO
|
||||||
fi
|
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
|
fi
|
||||||
update_psa_pull_error # message to ISMAS
|
|
||||||
sleep 10s
|
|
||||||
else
|
|
||||||
# Fetched updates successfully
|
|
||||||
try_updates_count=0
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
update_psa_pull_customer_repository # message to ISMAS
|
update_psa_pull_customer_repository # message to ISMAS
|
||||||
|
|
||||||
@@ -78,7 +61,7 @@ update_psa() {
|
|||||||
|
|
||||||
# local changed_files=$(changed_file_names)
|
# local changed_files=$(changed_file_names)
|
||||||
|
|
||||||
if [[ ! -z $GIT_PULL_TMP ]]; then
|
if [[ -f "$GIT_PULL_TMP" ]]; then
|
||||||
# TODO
|
# TODO
|
||||||
if ! check_hardware_compatibility "$files_to_copy" ; then
|
if ! check_hardware_compatibility "$files_to_copy" ; then
|
||||||
local __r=$?
|
local __r=$?
|
||||||
@@ -88,7 +71,7 @@ update_psa() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$OPKG_CMDS_TMP" ]]; then
|
if [[ -f "$OPKG_CMDS_TMP" ]]; then
|
||||||
local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')"
|
local commands="$(cat ${OPKG_CMDS_TMP} | tr '\n' '; ')"
|
||||||
log_info "$func:${LINENO}: executed opkg commands"
|
log_info "$func:${LINENO}: executed opkg commands"
|
||||||
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
update_psa_install_opkg_packages $UPDATE_ISMAS_PROGRESS \
|
||||||
@@ -158,6 +141,7 @@ update_psa() {
|
|||||||
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
update_psa_cleanup $UPDATE_ISMAS_PROGRESS \
|
||||||
$RC_SUCCESS "cleanup after psa update"
|
$RC_SUCCESS "cleanup after psa update"
|
||||||
|
|
||||||
|
# TODO
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user