aboutsummaryrefslogtreecommitdiff
path: root/build-scripts
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2014-03-07 11:42:51 +0800
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2014-03-07 11:42:51 +0800
commit68f3c0400f0793585426a4f4aecb3f652e5c1c60 (patch)
tree20320250e12deac6c06b0255140e5e2f106e3820 /build-scripts
parentf5f48c38b6c74a93829fe8e224eacc20ed3f51d7 (diff)
rewrite-manifest.py: Handle manifests with relative fetch URLs.
This requires passing manifest repository URL to the rewriting script. This should fix lp:1287618. Change-Id: Icf54e2e96185301f66e77b7fea2ed1ff313a1ef7
Diffstat (limited to 'build-scripts')
-rw-r--r--build-scripts/helpers4
-rwxr-xr-xbuild-scripts/rewrite-manifest.py39
2 files changed, 36 insertions, 7 deletions
diff --git a/build-scripts/helpers b/build-scripts/helpers
index 2c67f98..5a2ad9d 100644
--- a/build-scripts/helpers
+++ b/build-scripts/helpers
@@ -42,7 +42,7 @@ repo-sync-from-mirror () {
cp .repo/manifest.xml out/source-manifest.xml
echo Replace Linaro git URLs with lightweight http git URLs.
- ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml > processed-manifest.xml
+ ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml -o processed-manifest.xml -u "${MANIFEST_REPO}"
cp processed-manifest.xml .repo/manifest.xml
echo ----------------------------
@@ -75,7 +75,7 @@ repo-sync-from-seed () {
cp .repo/manifest.xml out/source-manifest.xml
echo Replace Linaro git URLs with lightweight http git URLs.
- ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml > processed-manifest.xml
+ ${BUILD_SCRIPT_ROOT}/rewrite-manifest.py .repo/manifest.xml -o processed-manifest.xml -u "${MANIFEST_REPO}"
cp processed-manifest.xml .repo/manifest.xml
export TIMEFORMAT="TIME: Repo sync (using seed as reference): %lR"
diff --git a/build-scripts/rewrite-manifest.py b/build-scripts/rewrite-manifest.py
index 4bdf15a..352e207 100755
--- a/build-scripts/rewrite-manifest.py
+++ b/build-scripts/rewrite-manifest.py
@@ -1,10 +1,14 @@
#!/usr/bin/env python
+from __future__ import print_function
+import argparse
+import os
+import sys
from xml.etree.cElementTree import (
ElementTree,
tostring,
)
-import sys
+
rewrite_urls = {
# 'git://git.linaro.org': 'http://git.linaro.org/git-ro',
@@ -17,7 +21,12 @@ rewrite_urls = {
'git://android.git.linaro.org/': 'http://android.git.linaro.org/git/',
}
-def rewrite_git_urls(root):
+def fatal(msg):
+ sys.stderr.write("Error: " + msg + "\n")
+ sys.exit(1)
+
+
+def rewrite_git_urls(root, options):
"""Rewrites all android.git.linaro.org and git.linaro.org URLs.
Makes them use /git-ro and appends '.git' to repo names if they
@@ -31,6 +40,20 @@ def rewrite_git_urls(root):
default_remote = remote.get('name')
remote_url = remote.get('fetch')
+ if "://" not in remote_url:
+ if not options.manifest_repo:
+ fatal("Remote %s uses relative fetch path '%s', "
+ "but repo url (-u) is not known" % (remote.get('name'),
+ remote.get('fetch')))
+ base_url = os.path.dirname(options.manifest_repo)
+ remote_url = os.path.join(base_url, remote_url)
+ proto, rest = remote_url.split("://")
+ rest = os.path.normpath(rest)
+ remote_url = proto + "://" + rest
+ print("Remote %s uses relative fetch path '%s', "
+ "normalized to '%s'" % (remote.get('name'),
+ remote.get('fetch'), remote_url))
+
if remote_url in rewrite_urls:
remote.set('fetch', rewrite_urls[remote_url])
remotes_to_handle.add(remote.get('name'))
@@ -46,18 +69,24 @@ def rewrite_git_urls(root):
project.set('name', project.get('name') + '.git')
if __name__ == '__main__':
- import argparse
parser = argparse.ArgumentParser(
description=(
'Switch Linaro git URLs to scalable git URLs in repo manifest '
'files and print the result manifest on stdout.'))
parser.add_argument('manifest', type=str,
help='manifest file to process')
+ parser.add_argument('-o', type=str, metavar='FILE', dest='outfile',
+ required=True,
+ help='output manifest file')
+ parser.add_argument('-u', type=str, metavar='URL', dest='manifest_repo',
+ help='Manifest repository URL (required if manifest uses relative paths)')
args = parser.parse_args()
# Parse the manifest file.
et = ElementTree()
doc = open(args.manifest)
root = et.parse(doc)
- rewrite_git_urls(root)
- print tostring(root, 'UTF-8').decode('utf-8')
+ rewrite_git_urls(root, args)
+ f = open(args.outfile, "w")
+ f.write(tostring(root, 'UTF-8'))
+ f.close()