From 1b1ae96965686b78e21dbd172425abc801b33303 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Fri, 25 Mar 2022 13:30:02 +0000 Subject: [PATCH 01/13] call clean script when repo sync fails --- src/build.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index 365de70..bc9ef8d 100755 --- a/src/build.sh +++ b/src/build.sh @@ -118,7 +118,15 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if ! repo sync -c --force-sync then - sync_successful=false + if [ -f /root/userscripts/clean.sh ]; then + echo ">> [$(date)] Running clean.sh" + /root/userscripts/clean.sh + if ! repo sync -c --force-sync + then + sync_successful=false + fi + fi + else repo forall -c 'git lfs pull' fi -- GitLab From 2c4a98b1d769dde756ae22509a455bd50ecf9700 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 09:02:28 +0000 Subject: [PATCH 02/13] send list of failing repos to clean script --- src/build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/build.sh b/src/build.sh index bc9ef8d..db2c667 100755 --- a/src/build.sh +++ b/src/build.sh @@ -115,12 +115,13 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] Syncing branch repository" builddate=$(date +%Y%m%d) - - if ! repo sync -c --force-sync + repo_status=`repo sync -c --force-sync` + if ! $repo_status then if [ -f /root/userscripts/clean.sh ]; then + list_line=`echo -e $repo_status | sed 's/.*Failing repos: //'` echo ">> [$(date)] Running clean.sh" - /root/userscripts/clean.sh + /root/userscripts/clean.sh $list_line if ! repo sync -c --force-sync then sync_successful=false -- GitLab From 15a66802a03a885ce58564b056ba40949f71b15c Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 09:19:03 +0000 Subject: [PATCH 03/13] redirect error to repo_status --- src/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index db2c667..5631266 100755 --- a/src/build.sh +++ b/src/build.sh @@ -115,7 +115,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] Syncing branch repository" builddate=$(date +%Y%m%d) - repo_status=`repo sync -c --force-sync` + repo_status=$(repo sync -c --force-sync 2>&1 > /dev/null) if ! $repo_status then if [ -f /root/userscripts/clean.sh ]; then -- GitLab From b48a46bec98ff251d86d77ad914d6d6ccaa1247d Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 10:10:13 +0000 Subject: [PATCH 04/13] echo repo_status --- src/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/build.sh b/src/build.sh index 5631266..1493bf4 100755 --- a/src/build.sh +++ b/src/build.sh @@ -119,6 +119,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if ! $repo_status then if [ -f /root/userscripts/clean.sh ]; then + echo $repo_status list_line=`echo -e $repo_status | sed 's/.*Failing repos: //'` echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line -- GitLab From 96deabe85c90e894824fe2c1cc70133f0d3f8e4f Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 10:33:37 +0000 Subject: [PATCH 05/13] send arguments only if Failing repos is defined --- src/build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/build.sh b/src/build.sh index 1493bf4..6192091 100755 --- a/src/build.sh +++ b/src/build.sh @@ -119,8 +119,10 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if ! $repo_status then if [ -f /root/userscripts/clean.sh ]; then - echo $repo_status - list_line=`echo -e $repo_status | sed 's/.*Failing repos: //'` + echo -e $repo_status + if [[ "$repo_status" == *"Failing repos:"* ]]; then + list_line=`echo -e $repo_status | sed 's/.*Failing repos: //'` + fi echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line if ! repo sync -c --force-sync -- GitLab From 2f4f304ad9003ef2b3a78780942c932bca94df6d Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 10:53:21 +0000 Subject: [PATCH 06/13] use exit code for status --- src/build.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/build.sh b/src/build.sh index 6192091..60f1af8 100755 --- a/src/build.sh +++ b/src/build.sh @@ -115,13 +115,14 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] Syncing branch repository" builddate=$(date +%Y%m%d) - repo_status=$(repo sync -c --force-sync 2>&1 > /dev/null) + repo_out=$(repo sync -c --force-sync 2>&1 > /dev/null) + repo_status=$? if ! $repo_status then if [ -f /root/userscripts/clean.sh ]; then - echo -e $repo_status - if [[ "$repo_status" == *"Failing repos:"* ]]; then - list_line=`echo -e $repo_status | sed 's/.*Failing repos: //'` + echo -e $repo_out + if [[ "$repo_out" == *"Failing repos:"* ]]; then + list_line=`echo -e $repo_out | sed 's/.*Failing repos: //'` fi echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line -- GitLab From 4594a1943a3d4717b81aa39b14ac9ff1c7aaf9aa Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 12:00:04 +0000 Subject: [PATCH 07/13] fixing "if" --- src/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/build.sh b/src/build.sh index 60f1af8..793d6ec 100755 --- a/src/build.sh +++ b/src/build.sh @@ -117,8 +117,8 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then builddate=$(date +%Y%m%d) repo_out=$(repo sync -c --force-sync 2>&1 > /dev/null) repo_status=$? - if ! $repo_status - then +if [[ "$repo_status" != "0" ]] +then if [ -f /root/userscripts/clean.sh ]; then echo -e $repo_out if [[ "$repo_out" == *"Failing repos:"* ]]; then -- GitLab From 503b99398c1b26eed669e8b350089f79ed0734d2 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Mon, 28 Mar 2022 12:31:59 +0000 Subject: [PATCH 08/13] always echo repo result --- src/build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/build.sh b/src/build.sh index 793d6ec..f9ab88b 100755 --- a/src/build.sh +++ b/src/build.sh @@ -117,8 +117,10 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then builddate=$(date +%Y%m%d) repo_out=$(repo sync -c --force-sync 2>&1 > /dev/null) repo_status=$? -if [[ "$repo_status" != "0" ]] -then + echo -e $repo_out + + if [[ "$repo_status" != "0" ]] + then if [ -f /root/userscripts/clean.sh ]; then echo -e $repo_out if [[ "$repo_out" == *"Failing repos:"* ]]; then -- GitLab From 9a1c83c8f952805222ce83f9fe0d22e2e391f35a Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 29 Mar 2022 08:44:31 +0000 Subject: [PATCH 09/13] execupte git lfs pull on success --- src/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index f9ab88b..29a5b0c 100755 --- a/src/build.sh +++ b/src/build.sh @@ -133,8 +133,9 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then sync_successful=false fi fi + fi - else + if [ "$sync_successful" = true ]; then repo forall -c 'git lfs pull' fi -- GitLab From 4f6adef8d31a4076f09df5425b7d28b8e105b400 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 29 Mar 2022 09:15:37 +0000 Subject: [PATCH 10/13] removing manually project that cannot be removed because of uncommitted changes --- src/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/build.sh b/src/build.sh index 29a5b0c..3170e55 100755 --- a/src/build.sh +++ b/src/build.sh @@ -126,6 +126,9 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if [[ "$repo_out" == *"Failing repos:"* ]]; then list_line=`echo -e $repo_out | sed 's/.*Failing repos: //'` fi + if [[ "$repo_out" == *"Cannot remove project"* ]]; then + list_line=`echo -e $failing | grep "Cannot remove project" | sed -e 's/.*error: \(.*\): Cannot.*/\1/'` + fi echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line if ! repo sync -c --force-sync -- GitLab From 9e682275ae5ed2ed82c3b4ae5f5668c7a51d73c4 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 29 Mar 2022 09:26:53 +0000 Subject: [PATCH 11/13] fixing code error --- src/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.sh b/src/build.sh index 3170e55..9ec0d96 100755 --- a/src/build.sh +++ b/src/build.sh @@ -127,7 +127,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then list_line=`echo -e $repo_out | sed 's/.*Failing repos: //'` fi if [[ "$repo_out" == *"Cannot remove project"* ]]; then - list_line=`echo -e $failing | grep "Cannot remove project" | sed -e 's/.*error: \(.*\): Cannot.*/\1/'` + list_line=`echo -e $repo_out | grep "Cannot remove project" | sed -e 's/.*error: \(.*\): Cannot.*/\1/'` fi echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line -- GitLab From a2cbee28ee56c6eee2aa8e2899290716d72aa2b6 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 29 Mar 2022 12:36:14 +0000 Subject: [PATCH 12/13] fix coding style + removing double echo --- src/build.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/build.sh b/src/build.sh index 9ec0d96..7a2a4a5 100755 --- a/src/build.sh +++ b/src/build.sh @@ -119,10 +119,8 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then repo_status=$? echo -e $repo_out - if [[ "$repo_status" != "0" ]] - then + if [ "$repo_status" != "0" ]; then if [ -f /root/userscripts/clean.sh ]; then - echo -e $repo_out if [[ "$repo_out" == *"Failing repos:"* ]]; then list_line=`echo -e $repo_out | sed 's/.*Failing repos: //'` fi @@ -131,8 +129,7 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then fi echo ">> [$(date)] Running clean.sh" /root/userscripts/clean.sh $list_line - if ! repo sync -c --force-sync - then + if ! repo sync -c --force-sync ; then sync_successful=false fi fi -- GitLab From bdf2601dbf57e3e8c0f8881202faaabb29b88d77 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 29 Mar 2022 14:22:36 +0000 Subject: [PATCH 13/13] sync_successful=false if clean script doesn't exist and sync has failed once --- src/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/build.sh b/src/build.sh index 7a2a4a5..7b2d730 100755 --- a/src/build.sh +++ b/src/build.sh @@ -132,6 +132,8 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then if ! repo sync -c --force-sync ; then sync_successful=false fi + else + sync_successful=false fi fi -- GitLab