diff options
| author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-02-29 02:55:50 +0100 | 
|---|---|---|
| committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-02-29 02:55:50 +0100 | 
| commit | 0d983fb9be0e63e9af1ddca8ab714a62e360c87d (patch) | |
| tree | 94146675d920036915f392336a328e49f5828fd7 /scripts/build-packages | |
| parent | 7b316a128576a3da862ff28c8616da9804bc6f39 (diff) | |
| download | vyos-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/build-packages')
| -rwxr-xr-x | scripts/build-packages | 20 | 
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) | 
