summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJernej Jakob <jernej.jakob@gmail.com>2020-02-29 02:55:50 +0100
committerJernej Jakob <jernej.jakob@gmail.com>2020-02-29 02:55:50 +0100
commit0d983fb9be0e63e9af1ddca8ab714a62e360c87d (patch)
tree94146675d920036915f392336a328e49f5828fd7 /scripts
parent7b316a128576a3da862ff28c8616da9804bc6f39 (diff)
downloadvyos-build-0d983fb9be0e63e9af1ddca8ab714a62e360c87d.tar.gz
vyos-build-0d983fb9be0e63e9af1ddca8ab714a62e360c87d.zip
T2085: build-packages: fix clone_package function
- add package config option "shallow", defaulting to True - make it actually clone the commit id specified in the package - revert to deep clone if commit id is set - fix bug with --keep that caused the script to crash
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-packages20
1 files changed, 16 insertions, 4 deletions
diff --git a/scripts/build-packages b/scripts/build-packages
index 94c299f5..ce371175 100755
--- a/scripts/build-packages
+++ b/scripts/build-packages
@@ -11,7 +11,7 @@ current_working_directory = os.getcwd()
repo_root = subprocess.check_output('git rev-parse --show-toplevel', shell=True, universal_newlines=True).rstrip('\n')
repo_sha = subprocess.check_output('git rev-parse --short=12 HEAD', shell=True, universal_newlines=True).rstrip('\n')
-def add_package(name, url=None, commit='HEAD', branch='current', tag=None, custombuild_cmd=None):
+def add_package(name, url=None, commit='HEAD', branch='current', tag=None, shallow=True, custombuild_cmd=None):
"""
Build up source package with URL and build commands executed during the later
called build_package step.
@@ -32,6 +32,7 @@ def add_package(name, url=None, commit='HEAD', branch='current', tag=None, custo
'commit': commit,
'tag': tag,
'branch': branch,
+ 'shallow': shallow,
'path': repo_root + '/packages/' + name,
'custombuild_cmd': custombuild_cmd
}
@@ -98,7 +99,7 @@ def clone_package(pkg, log):
First cleanup any possible leftovers from previous builds
"""
- if args.keep:
+ if args.keep and os.path.isdir(pkg['path']):
log.debug("Keep possibly modified package '{}'".format(pkg['path']))
return False
elif args.clean:
@@ -114,14 +115,25 @@ def clone_package(pkg, log):
bashCommand = 'git clean -d -x --force && git reset --hard ' + pkg['commit']
return call(bashCommand, log)
- # resolve given tag to commit id to use shallow clone
+ if pkg['commit'] and pkg['shallow']:
+ log.debug("Package '{}' has both commit and shallow set, unsetting shallow to do a full clone.".format(pkg['name']))
+ pkg['shallow']=False
+
bashCommand = 'git clone ' + pkg['url']
+
+ if pkg['shallow']:
+ bashCommand += ' --depth 1'
+
if pkg['tag']:
bashCommand += ' --branch ' + pkg['tag']
elif pkg['branch']:
- bashCommand += ' --depth 1 --branch ' + pkg['branch']
+ bashCommand += ' --branch ' + pkg['branch']
bashCommand += ' ' + pkg['path']
+
+ if pkg['commit']:
+ bashCommand += ' && cd ' + pkg['path'] + ' && git reset --hard ' + pkg['commit']
+
return call(bashCommand, log)