summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
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)