[Pkg-mozext-commits] [adblock-plus] 354/464: Implement mapping of files from subrepositories

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:33 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 4f52ddc05f9e6bc6a81143a8b49d1c6bd9535b58
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Jan 14 15:40:07 2013 +0100

    Implement mapping of files from subrepositories
---
 packager.py       | 16 +++++++++++++++-
 packagerChrome.py |  2 ++
 packagerGecko.py  |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/packager.py b/packager.py
index 6a2693c..2a89977 100644
--- a/packager.py
+++ b/packager.py
@@ -18,7 +18,7 @@
 # Note: These are the base functions common to all packagers, the actual
 # packagers are implemented in packagerGecko and packagerChrome.
 
-import os, re, codecs, subprocess, json, zipfile, jinja2
+import sys, os, re, codecs, subprocess, json, zipfile, jinja2
 from StringIO import StringIO
 from ConfigParser import SafeConfigParser
 
@@ -91,9 +91,23 @@ class Files(dict):
           self.read(os.path.join(path, file), name)
     else:
       file = open(path, 'rb')
+      if relpath in self:
+        print >>sys.stderr, 'Warning: File %s defined multiple times' % relpath
       self[relpath] = file.read()
       file.close()
 
+  def readMappedFiles(self, baseDir, mappings):
+    for target, source in mappings:
+      # Make sure the file is inside an included directory
+      if '/' in target and not self.isIncluded(target):
+        continue
+      parts = source.split('/')
+      path = os.path.join(baseDir, *parts)
+      if os.path.exists(path):
+        self.read(path, target)
+      else:
+        print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % source
+
   def zip(self, outFile, sortKey=None):
     zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED)
     names = self.keys()
diff --git a/packagerChrome.py b/packagerChrome.py
index 49dc3e2..3779b1a 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -166,6 +166,8 @@ def createBuild(baseDir, outFile=None, buildNum=None, releaseBuild=False, keyFil
 
   files = Files(getPackageFiles(params), getIgnoredFiles(params))
   files['manifest.json'] = createManifest(params)
+  if metadata.has_section('mapping'):
+    files.readMappedFiles(baseDir, metadata.items('mapping'))
   files.read(baseDir)
 
   if metadata.has_section('convert_js'):
diff --git a/packagerGecko.py b/packagerGecko.py
index 6287805..22efff7 100644
--- a/packagerGecko.py
+++ b/packagerGecko.py
@@ -314,6 +314,8 @@ def createBuild(baseDir, outFile=None, locales=None, buildNum=None, releaseBuild
   files = Files(getPackageFiles(params), getIgnoredFiles(params),
                 process=lambda path, data: processFile(path, data, params))
   files['install.rdf'] = createManifest(params)
+  if metadata.has_section('mapping'):
+    files.readMappedFiles(baseDir, metadata.items('mapping'))
   files.read(baseDir, skip=('chrome'))
   for name, path in getChromeSubdirs(baseDir, params['locales']).iteritems():
     if os.path.isdir(path):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list