[jhbuild] Add the ability to override tarball names



commit ef5f40c5978365c9fec773d723d2827bca39a25f
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Oct 10 15:51:37 2017 +0100

    Add the ability to override tarball names
    
    Modules hosted on GitHub have autogenerated tarball names coming from
    the release tag. This means a lot of them have unhelpful names like
    'v1.0.1.tar.gz', or '296.zip'.
    
    If two different modules have the same tag, we end up with a collision
    when trying to check that the tarball downloaded have the same checksum.
    
    We can add a simple XML attribute that allows us to rename the tarball
    if that's the case; we can also throw in variables support for the name
    of the module and the version, which will hopefully help us to avoid
    collisions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788779

 doc/C/index.docbook               |    4 ++++
 jhbuild/versioncontrol/tarball.py |   15 +++++++++++----
 modulesets/moduleset.dtd          |    3 ++-
 modulesets/moduleset.rnc          |    3 ++-
 4 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/doc/C/index.docbook b/doc/C/index.docbook
index 159883b..201fca6 100644
--- a/doc/C/index.docbook
+++ b/doc/C/index.docbook
@@ -2818,6 +2818,10 @@ Optional packages: (JHBuild will build the missing packages)
           If these attributes are present, they are used to check that the
           source package was downloaded correctly.</para>
 
+        <para>The <sgmltag class="attribute">rename-tarball</sgmltag> can be
+          used to rename the tarball file when downloading, in case the original
+          name conflicts with another module.</para>
+
         <para>Any number of <sgmltag class="element">patch</sgmltag> elements
           may be nested inside the <sgmltag class="element">branch</sgmltag>
           element. These patches are applied, in order, to the source tree after
diff --git a/jhbuild/versioncontrol/tarball.py b/jhbuild/versioncontrol/tarball.py
index 58c1a7e..b3815f1 100644
--- a/jhbuild/versioncontrol/tarball.py
+++ b/jhbuild/versioncontrol/tarball.py
@@ -56,11 +56,11 @@ class TarballRepository(Repository):
 
     branch_xml_attrs = ['version', 'module', 'checkoutdir',
                         'size', 'md5sum', 'source-subdir',
-                        'hash']
+                        'hash', 'rename-tarball']
 
     def branch(self, name, version, module=None, checkoutdir=None,
                size=None, md5sum=None, hash=None, branch_id=None,
-               source_subdir=None):
+               source_subdir=None, rename_tarball=None):
         if name in self.config.branches:
             module = self.config.branches[name]
             if not module:
@@ -78,10 +78,13 @@ class TarballRepository(Repository):
             size = int(size)
         if md5sum and (not hash or hashlib.__name__ == 'md5'):
             hash = 'md5:' + md5sum
+        if rename_tarball is not None:
+            rename_tarball = rename_tarball.replace('${name}', name).replace('${version}', version)
         return TarballBranch(self, module=module, version=version,
                              checkoutdir=checkoutdir,
                              source_size=size, source_hash=hash,
-                             branch_id=branch_id, source_subdir=source_subdir)
+                             branch_id=branch_id, source_subdir=source_subdir,
+                             tarball_name=rename_tarball)
 
     def branch_from_xml(self, name, branchnode, repositories, default_repo):
         try:
@@ -110,7 +113,8 @@ class TarballBranch(Branch):
     """A class representing a Tarball."""
 
     def __init__(self, repository, module, version, checkoutdir,
-                 source_size, source_hash, branch_id, source_subdir=None):
+                 source_size, source_hash, branch_id, source_subdir=None,
+                 tarball_name=None):
         Branch.__init__(self, repository, module, checkoutdir)
         self.version = version
         self.source_size = source_size
@@ -119,8 +123,11 @@ class TarballBranch(Branch):
         self.quilt = None
         self.branch_id = branch_id
         self.source_subdir = source_subdir
+        self.tarball_name = tarball_name
 
     def _local_tarball(self):
+        if self.tarball_name:
+            return os.path.join(self.config.tarballdir, self.tarball_name)
         basename = os.path.basename(self.module)
         if not basename:
             raise FatalError(_('URL has no filename component: %s') % self.module)
diff --git a/modulesets/moduleset.dtd b/modulesets/moduleset.dtd
index 6e6b8d3..09301fa 100644
--- a/modulesets/moduleset.dtd
+++ b/modulesets/moduleset.dtd
@@ -224,7 +224,8 @@
        version         CDATA   #IMPLIED
        size            CDATA   #IMPLIED
        md5sum          CDATA   #IMPLIED
-       hash            CDATA   #IMPLIED>
+       hash            CDATA   #IMPLIED
+        rename-tarball  CDATA   #IMPLIED>
        <!-- override-checkoutdir and update-new-dirs are CVS only
             source-subdir is tarballs only -->
 
diff --git a/modulesets/moduleset.rnc b/modulesets/moduleset.rnc
index 6cec970..1f73352 100644
--- a/modulesets/moduleset.rnc
+++ b/modulesets/moduleset.rnc
@@ -210,7 +210,8 @@ attlist.source &=
   attribute href { text },
   attribute size { text }?,
   attribute md5sum { text }?,
-  attribute hash { text }?
+  attribute hash { text }?,
+  attribute rename-tarball { text }?
 patches = element patches { attlist.patches, patch* }
 attlist.patches &= empty
 patch = element patch { attlist.patch, empty }


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