bug 454261: add Mercurial and long filename support to patcher - make_incremental_updates support for long filenames. r=nrthomas, patch=me
authorBen Hearsum <bhearsum@mozilla.com>
Thu, 09 Oct 2008 08:53:33 -0400
changeset 20211 0bf7accdb2c22d8e32d74c641715bb628b3d680f
parent 20210 e96a238b497b2140b48cbeabf4ddbe140b51f0bb
child 20212 559223858f49af19ba84c95892fcc6a2971ed8bc
push idunknown
push userunknown
push dateunknown
reviewersnrthomas
bugs454261
milestone1.9.1b2pre
bug 454261: add Mercurial and long filename support to patcher - make_incremental_updates support for long filenames. r=nrthomas, patch=me
tools/update-packaging/make_incremental_updates.py
--- a/tools/update-packaging/make_incremental_updates.py
+++ b/tools/update-packaging/make_incremental_updates.py
@@ -320,28 +320,35 @@ def get_buildid(work_dir, platform):
         return ''
     file = bz2.BZ2File(ini)
     for line in file:
       if line.find('BuildID') == 0:
         return line.strip().split('=')[1]
     print 'WARNING: cannot find build ID in application.ini'
     return ''
 
-def decode_filename(filename):
-    """ Breaks filename into component parts based on regex
+def decode_filename(filepath):
+    """ Breaks filename/dir structure into component parts based on regex
         for example: firefox-3.0b3pre.en-US.linux-i686.complete.mar
+        Or linux-i686/en-US/firefox-3.0b3.complete.mar
         Returns dict with keys product, version, locale, platform, type
     """
     try:
       m = re.search(
         '(?P<product>\w+)(-)(?P<version>\w+\.\w+)(\.)(?P<locale>.+?)(\.)(?P<platform>.+?)(\.)(?P<type>\w+)(.mar)',
-      filename)
+      os.path.basename(filepath))
       return m.groupdict()
     except Exception, exc:
-      raise Exception("could not parse filename %s: %s" % (filename, exc))
+      try:
+        m = re.search(
+          '(?P<platform>.+?)\/(?P<locale>.+?)\/(?P<product>\w+)-(?P<version>\w+\.\w+)\.(?P<type>\w+).mar',
+        filepath)
+        return m.groupdict()
+      except:
+        raise Exception("could not parse filepath %s: %s" % (filepath, exc))
 
 def create_partial_patches(patches):
     """ Given the patches generates a set of partial patches"""
     shas = {}
 
     work_dir_root = None
     metadata = []
     try:
@@ -359,34 +366,34 @@ def create_partial_patches(patches):
             # Each patch iteration uses its own work dir
             work_dir = os.path.join(work_dir_root,str(patch_num))
             os.mkdir(work_dir)
 
             # Extract from mar into from dir
             work_dir_from =  os.path.join(work_dir,"from");
             os.mkdir(work_dir_from)
             extract_mar(from_filename,work_dir_from)
-            from_decoded = decode_filename(os.path.basename(from_filename))
+            from_decoded = decode_filename(from_filename)
             from_buildid = get_buildid(work_dir_from, from_decoded['platform'])
             from_shasum = sha.sha(open(from_filename).read()).hexdigest()
             from_size = str(os.path.getsize(to_filename))
             
             # Extract to mar into to dir
             work_dir_to =  os.path.join(work_dir,"to")
             os.mkdir(work_dir_to)
             extract_mar(to_filename, work_dir_to)
-            to_decoded = decode_filename(os.path.basename(from_filename))
+            to_decoded = decode_filename(from_filename)
             to_buildid = get_buildid(work_dir_to, to_decoded['platform'])
             to_shasum = sha.sha(open(to_filename).read()).hexdigest()
             to_size = str(os.path.getsize(to_filename))
 
             mar_extract_time = time.time()
 
             partial_filename = create_partial_patch(work_dir_from, work_dir_to, patch_filename, shas, PatchInfo(work_dir, ['channel-prefs.js','update.manifest','removed-files'],['/readme.txt']))
-            partial_decoded = decode_filename(os.path.basename(partial_filename))
+            partial_decoded = decode_filename(partial_filename)
             partial_buildid = to_buildid
             partial_shasum = sha.sha(open(partial_filename).read()).hexdigest()
             partial_size = str(os.path.getsize(partial_filename))
 
             metadata.append({
              'to_filename': os.path.basename(to_filename),
              'from_filename': os.path.basename(from_filename),
              'partial_filename': os.path.basename(partial_filename),