[library-web] add requests for git updates to stable releases



commit 46142002e799acb161e56b18b21363f8ae9fd671
Author: Frédéric Péters <fpeters 0d be>
Date:   Tue Jan 28 11:59:29 2014 +0000

    add requests for git updates to stable releases

 src/lgo.py |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 3 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index e66c20a..f450f26 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -268,6 +268,9 @@ class Lgo(App):
                     # not shipped with latest GNOME are made available.
                     moduleset.seek(0)
                     self.process_latest_moduleset(moduleset)
+                if int(r.split('.')[1]) % 2 == 0:
+                    moduleset.seek(0)
+                    self.process_stable_moduleset(moduleset, r)
 
     def download(self, url, use_cache=True):
         if url.startswith('gnome+git://'):
@@ -280,7 +283,7 @@ class Lgo(App):
                 logging.debug('ignoring git for %s (version != branch)' % module_name)
                 return
 
-            fake_version_number = version_value
+            fake_version_number = version_value + '.999'
 
             base_git_dir = os.path.join(self.config.download_cache_dir, 'git')
             if not os.path.exists(base_git_dir):
@@ -296,8 +299,11 @@ class Lgo(App):
             logging.debug('switching to branch %s' % branch_name)
             subprocess.Popen(['git', 'checkout', '-b', branch_name, 'origin/%s' % branch_name],
                     cwd=module_git_clone_dir).wait()
-            if subprocess.call(['git', 'show-ref', '--verify', '--quiet',
-                    'refs/heads/%s' % branch_name]) != 0:
+
+            subp = subprocess.Popen(['git', 'show-ref', '--verify', '--quiet',
+                'refs/heads/%s' % branch_name], cwd=module_git_clone_dir)
+            subp.wait()
+            if subp.returncode != 0:
                 logging.debug('branch do not exist, skipping')
                 return
             filename = '%s-%s.tar.gz' % (module_name, fake_version_number)
@@ -499,6 +505,54 @@ class Lgo(App):
             extra_tarball = 'gnome://%s?min=%s' % (module.attrib['id'], min_version)
             self.config.extra_tarballs.append(extra_tarball)
 
+    def process_stable_moduleset(self, moduleset, release):
+        '''Register all modules from latest stable modulesets as modules that
+           could be updated from git'''
+
+        git_branch = 'gnome-%s-%s' % tuple(release.split('.')[:2])
+
+        tree = ET.parse(moduleset)
+        for tarball in tree.findall('tarball'):
+            if self.config.modules is not None and not tarball.attrib['id'] in self.config.modules:
+                continue
+
+            url = tarball.find('source').attrib['href']
+            if not (url.startswith('http://download.gnome.org/') or
+                    url.startswith('http://ftp.gnome.org/')):
+                continue
+            min_version = tarball.attrib.get('version')
+            if not min_version:
+                continue
+            logging.info('registering module %s for git stable update' % tarball.attrib['id'])
+            extra_tarball = 'gnome+git://%s?branch=%s&version=%s' % (
+                    module.attrib['id'], git_branch, min_version)
+            self.config.extra_tarballs.append(extra_tarball)
+
+        # XXX: this needs to be refactored, and moduleset processing code to be
+        # shared with process_moduleset (bis repetita)
+        for module in tree.findall('autotools'):
+            if self.config.modules is not None and not module.attrib['id'] in self.config.modules:
+                continue
+            branch = module.find('branch')
+            if branch is None:
+                continue
+
+            repository = self.repositories.get(branch.attrib.get('repo'))
+            if repository is None:
+                continue
+            url = repository + branch.attrib.get('module')
+            if not (url.startswith('http://download.gnome.org/') or
+                    url.startswith('http://ftp.gnome.org/')):
+                continue
+
+            min_version = branch.attrib.get('version')
+            if not min_version:
+                continue
+            logging.info('registering module %s for git stable update' % module.attrib['id'])
+            extra_tarball = 'gnome+git://%s?branch=%s&version=%s' % (
+                    module.attrib['id'], git_branch, min_version)
+            self.config.extra_tarballs.append(extra_tarball)
+
     def extract_modules(self, filename, nightly = False):
         logging.debug('looking for doc modules in %s' % filename)
         doc_modules = []


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]