From 550d792ec32e0254ce8f9a92f56e1a68d97059c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20=C5=A0egan?= Date: Fri, 26 Oct 2012 12:09:38 +0200 Subject: Add sanitization to build scripts. --- build-scripts/helpers | 5 +++++ build-scripts/sanitize-manifest.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 build-scripts/sanitize-manifest.py (limited to 'build-scripts') diff --git a/build-scripts/helpers b/build-scripts/helpers index be84f2c..bedb9a4 100644 --- a/build-scripts/helpers +++ b/build-scripts/helpers @@ -23,11 +23,16 @@ setup-repo-vars () { repo-sync-from-mirror () { setup-repo-vars + repo init $REPO_QUIET -u "${MANIFEST_REPO}" -b "${MANIFEST_BRANCH}" -m "${MANIFEST_FILENAME}" $REPO_MIRROR # Save input manifest as build artifact for reference mkdir -p out cp .repo/manifest.xml out/source-manifest.xml + echo Replace Linaro git URLs with lightweight http git URLs. + ${BUILD_SCRIPT_ROOT}/sanitize-manifest.py .repo/manifest.xml > out/processed-manifest.xml + cp out/processed_manifest.xml .repo/manifest.xml + echo ---------------------------- time repo sync $REPO_QUIET -j$SYNC_JOBS # Restore source manifest temporarily to create pinned manifest diff --git a/build-scripts/sanitize-manifest.py b/build-scripts/sanitize-manifest.py new file mode 100755 index 0000000..799f8f2 --- /dev/null +++ b/build-scripts/sanitize-manifest.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +from xml.etree.cElementTree import ( + ElementTree, + tostring, +) +import sys + + +et = ElementTree() +doc = open(sys.argv[1]) +root = et.parse(doc) + +remotes_to_handle = set([]) +default_remote = None + +for remote in root.findall("remote"): + if default_remote is None: + default_remote = remote.get('name') + + if remote.get('fetch').startswith('git://git.linaro.org'): + remote.set('fetch', 'http://git.linaro.org/git-ro/') + remotes_to_handle.add(remote.get('name')) + elif remote.get('fetch').startswith('git://android.git.linaro.org'): + remote.set('fetch', 'http://android.git.linaro.org/git-ro/') + remotes_to_handle.add(remote.get('name')) + +for project in root.findall("project"): + if (project.get('remote') in remotes_to_handle or + project.get('remote') is None and default_remote in remotes_to_handle): + if not project.get('name').endswith('.git'): + project.set('name', project.get('name') + '.git') + + +print tostring(root, 'UTF-8').decode('utf-8') -- cgit v1.2.3