summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/licensecheck.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/scripts/licensecheck.py b/scripts/licensecheck.py
index 59125ea1..08d0e1b4 100755
--- a/scripts/licensecheck.py
+++ b/scripts/licensecheck.py
@@ -84,6 +84,8 @@ def check_repo_if_needed(name, repo, ref, repos_dir, licenses_dir):
if repo_name.endswith(".git"):
repo_name = repo_name[:-4]
+ repo_url = scriptslib.parse_repo_alias(repo)
+
# Check if ref is sha1 to speedup
if len(ref) == 40 and all(c in string.hexdigits for c in ref):
license_file = license_file_name(repo_name, ref, licenses_dir)
@@ -98,13 +100,31 @@ def check_repo_if_needed(name, repo, ref, repos_dir, licenses_dir):
subprocess.check_call([
"git", "remote", "update", "origin", "--prune"],
stderr=devnull, stdout=devnull, cwd=clone_path)
+ # Update submodules
+ subprocess.check_call(
+ ["git", "submodule", "update", "--recursive"],
+ stderr=devnull, stdout=devnull, cwd=clone_path)
subprocess.check_call(["git", "checkout", ref], stderr=devnull,
stdout=devnull, cwd=clone_path)
else:
sys.stderr.write("Getting repo '%s' ...\n" % repo_name)
with open(os.devnull, 'w') as devnull:
- subprocess.check_call(["morph", "get-repo", name, clone_path],
- stdout=devnull, stderr=devnull)
+ try:
+ # Attempt to use morph to obtain a repository, from morph's
+ # existing local git cache if possible
+ subprocess.check_call(
+ ["morph", "get-repo", name, clone_path],
+ stdout=devnull, stderr=devnull)
+
+ except (OSError, subprocess.CalledProcessError):
+ # Fall back to git clone, when morph hasn't been found on the
+ # system, or otherwise fails to get a repo. This is required
+ # where morph isn't available, e.g. when using YBD to build.
+ # YBD currently doesn't offer a similar 'get-repo' feature.
+ sys.stderr.write("Falling back to git clone.\n")
+ subprocess.check_call(
+ ["git", "clone", "--recursive", repo_url, clone_path],
+ stdout=devnull, stderr=devnull) # also clone submodules
sha = subprocess.check_output(
["git", "rev-parse", "HEAD"], cwd=clone_path).strip()
@@ -145,6 +165,9 @@ def main():
args = parser.parse_args()
+ if not os.path.exists(args.repos_dir):
+ os.makedirs(args.repos_dir)
+
system = scriptslib.load_yaml_file(args.system)
license_files = []
for stratum in system['strata']: