← Back to team overview

ubuntu-phone team mailing list archive

[PATCH] Modifying roomservice.py so that it can breakfast for phablet.

 

These modifications allow the removal of the nexus family from the
main manifest for them to be installed with breakfast as is done
with cyanogenmod.

Additionally, if the device is not on phablet.ubuntu.com, it goes
and fetches the repositories from github/CyanogenMod for easier
bootstrapping.

Signed-off-by: Sergio Schvezov <sergio.schvezov@xxxxxxxxxxxxx>
---
 tools/roomservice.py | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/tools/roomservice.py b/tools/roomservice.py
index 48d562b..3680706 100755
--- a/tools/roomservice.py
+++ b/tools/roomservice.py
@@ -23,6 +23,12 @@ from xml.etree import ElementTree
 
 product = sys.argv[1];
 
+phablet = {'branch': 'phablet-10.1',
+           'fallback_branch': 'cm-10.1',
+           'remote': 'phablet',
+           'url_template': 'http://phablet.ubuntu.com/gitweb?p=CyanogenMod/%s.git;a=heads',
+           }
+
 if len(sys.argv) > 2:
     depsonly = sys.argv[2]
 else:
@@ -148,6 +154,10 @@ def add_to_manifest(repositories):
 
         if 'branch' in repository:
             project.set('revision',repository['branch'])
+            if repository['branch'] == phablet['branch']:
+                project.set('remote',phablet['remote'])
+        else:
+            project.set('revision',phablet['fallback_branch'])
 
         lm.append(project)
 
@@ -186,6 +196,29 @@ def fetch_dependencies(repo_path):
         print 'Syncing dependencies'
         os.system('repo sync %s' % ' '.join(syncable_repos))
 
+def phablet_has_branch(repository, revision):
+    print "Searching for repository on phablet.ubuntu.com"
+    phablet_url = phablet['url_template'] % repository
+    try:
+        request = urllib2.urlopen(phablet_url).read()
+        heads_html = filter(lambda x: '<a class="list name"' in x,
+                            request.split('\n'))
+        heads = [ re.sub('<[^>]*>', '', i) for i in heads_html ]
+        print "Found heads:"
+        for head in heads:
+            print head
+        if revision in heads:
+            return True
+        else:
+            return False
+    except urllib2.HTTPError as e:
+        if e.code == 404:
+            print "Repository not found on phablet.ubuntu.com"
+            print "This may likely be an unsupported build target"
+            return False
+        else:
+            raise e
+
 def has_branch(branches, revision):
     return revision in [branch['name'] for branch in branches]
 
@@ -216,7 +249,10 @@ else:
             repo_path = "device/%s/%s" % (manufacturer, device)
             adding = {'repository':repo_name,'target_path':repo_path}
             
-            if not has_branch(result, default_revision):
+            if phablet_has_branch(repository['name'], default_revision):
+                print 'Found on phablet'
+                adding['branch'] = default_revision
+            elif not has_branch(result, default_revision):
                 found = False
                 if os.getenv('ROOMSERVICE_BRANCHES'):
                     fallbacks = filter(bool, os.getenv('ROOMSERVICE_BRANCHES').split(' '))
@@ -226,6 +262,14 @@ else:
                             found = True
                             adding['branch'] = fallback
                             break
+
+                # Adding specifically for phablet
+                if has_branch(result, phablet['fallback_branch']):
+                    print "Using %s as a fallback for %s" % \
+                           (phablet['fallback_branch'], phablet['branch'])
+                    found = True
+                    adding['branch'] = phablet['fallback_branch']
+                    default_revision = phablet['fallback_branch']
                             
                 if not found:
                     print "Default revision %s not found in %s. Bailing." % (default_revision, repo_name)
-- 
1.8.1.2



Follow ups