Bug 1530016 - Drop bogus entries from the generated-sources tarball. r=froydnj
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 27 Feb 2019 17:45:27 +0000
changeset 519364 31a79abb583d5a0c98be5bef9f20058908ee4d58
parent 519363 19b29b2e2f5e651518b4ca8e111c3c1dcf61b8c7
child 519365 dd683ef8b0001a7f2915fdef956f8b4c01219db9
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1530016
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530016 - Drop bogus entries from the generated-sources tarball. r=froydnj On Android we apparently try to include the cpufeatures.c file from the NDK as part of the generated-sources tarball. While this works, it makes tar drop the bogus entry for safety reasons when unpacking the archive. It also makes tar return an error, which is undesirable for searchfox. It's better to just skip the entry when building the tarball. Differential Revision: https://phabricator.services.mozilla.com/D20942
python/mozbuild/mozbuild/action/package_generated_sources.py
--- a/python/mozbuild/mozbuild/action/package_generated_sources.py
+++ b/python/mozbuild/mozbuild/action/package_generated_sources.py
@@ -5,26 +5,38 @@
 from __future__ import absolute_import, print_function, unicode_literals
 
 import argparse
 import json
 import os.path
 import sys
 
 import buildconfig
+import mozpack.path as mozpath
 from mozpack.archive import create_tar_gz_from_files
+from mozpack.files import BaseFile
 from mozbuild.generated_sources import get_generated_sources
 
 
 def main(argv):
     parser = argparse.ArgumentParser(
         description='Produce archive of generated sources')
     parser.add_argument('outputfile', help='File to write output to')
     args = parser.parse_args(argv)
 
+    objdir_abspath = mozpath.abspath(buildconfig.topobjdir)
+    def is_valid_entry(entry):
+        if isinstance(entry[1], BaseFile):
+            entry_abspath = mozpath.abspath(entry[1].path)
+        else:
+            entry_abspath = mozpath.abspath(entry[1])
+        if not entry_abspath.startswith(objdir_abspath):
+            print("Warning: omitting generated source [%s] from archive" % entry_abspath, file=sys.stderr)
+            return False
+        return True
 
-    files = dict(get_generated_sources())
+    files = dict(filter(is_valid_entry, get_generated_sources()))
     with open(args.outputfile, 'wb') as fh:
         create_tar_gz_from_files(fh, files, compresslevel=5)
 
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))