summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-05-03 15:06:16 -0500
committerChristian Breunig <christian@breunig.cc>2024-05-05 20:34:43 +0200
commit255bf960995ec072ba7b72fe2d926cfd986adc2f (patch)
treef39933179d860be1c4ebe2f9736c782b62022ae7 /scripts
parent3e3f2181ab5334b590c7a97d9c4b984842d712ed (diff)
downloadvyos-build-255bf960995ec072ba7b72fe2d926cfd986adc2f.tar.gz
vyos-build-255bf960995ec072ba7b72fe2d926cfd986adc2f.zip
build: T3664: fix regression and bug in clone vyos-1x repo
(cherry picked from commit 02c340d9d76ee89f47d7d6d245c5dea955a5f683)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/image-build/build-vyos-image14
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/image-build/build-vyos-image b/scripts/image-build/build-vyos-image
index 5b315484..c2d39c82 100755
--- a/scripts/image-build/build-vyos-image
+++ b/scripts/image-build/build-vyos-image
@@ -66,7 +66,17 @@ try:
branch_name = build_defaults['vyos_branch']
url_vyos_1x = 'https://github.com/vyos/vyos-1x'
path_vyos_1x = os.path.join(defaults.BUILD_DIR, 'vyos-1x')
- repo_vyos_1x = git.Repo.clone_from(url_vyos_1x, path_vyos_1x, no_checkout=True)
+ try:
+ repo_vyos_1x = git.Repo.clone_from(url_vyos_1x, path_vyos_1x, no_checkout=True)
+ except git.GitCommandError:
+ if os.path.exists(path_vyos_1x):
+ try:
+ repo_vyos_1x = git.Repo(path_vyos_1x)
+ except git.GitError:
+ print(f'E: Corrupted vyos-1x git repo: {path_vyos_1x}; remove')
+ sys.exit(1)
+ else:
+ raise
# alternatively, pass commit hash or tag as arg:
repo_vyos_1x.git.checkout(branch_name)
except Exception as e:
@@ -368,7 +378,7 @@ if __name__ == "__main__":
# Initialize Git object from our repository
try:
- repo = git.Repo('.')
+ repo = git.Repo('.', search_parent_directories=True)
# Retrieve the Git commit ID of the repository, 14 charaters will be sufficient
build_git = repo.head.object.hexsha[:14]
# If somone played around with the source tree and the build is "dirty", mark it