Bug 740795 part B - make nsinstall.py accept an "-X" flag to exclude files when copying directories recursively, r=ted
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 18 May 2012 12:42:01 -0400
changeset 98450 7bbd1cc126f3141bdd1c771a4590187f69c5bb79
parent 98449 6eb40a0f8e4cc3f8092e36f5e29645ad2851468a
child 98451 a65ea296a6ea9aa47f47840df23617bb23e4e74e
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs740795
milestone15.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 740795 part B - make nsinstall.py accept an "-X" flag to exclude files when copying directories recursively, r=ted
browser/extensions/pdfjs/LICENSE
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/bootstrap.js
browser/extensions/pdfjs/components/PdfStreamConverter.js
browser/extensions/pdfjs/content/web/debugger.js
browser/extensions/pdfjs/content/web/images/bookmark.svg
browser/extensions/pdfjs/content/web/images/check.svg
browser/extensions/pdfjs/content/web/images/comment.svg
browser/extensions/pdfjs/content/web/images/document-print.svg
browser/extensions/pdfjs/content/web/images/download.svg
browser/extensions/pdfjs/content/web/images/go-down.svg
browser/extensions/pdfjs/content/web/images/go-up.svg
browser/extensions/pdfjs/content/web/images/loading-icon.gif
browser/extensions/pdfjs/content/web/images/nav-outline.svg
browser/extensions/pdfjs/content/web/images/nav-thumbs.svg
browser/extensions/pdfjs/content/web/images/pin-down.svg
browser/extensions/pdfjs/content/web/images/pin-up.svg
browser/extensions/pdfjs/content/web/images/zoom-in.svg
browser/extensions/pdfjs/content/web/images/zoom-out.svg
browser/extensions/pdfjs/content/web/viewer-snippet-firefox-extension.html
browser/extensions/pdfjs/content/web/viewer.css
browser/extensions/pdfjs/content/web/viewer.html
browser/extensions/pdfjs/content/web/viewer.js
browser/extensions/pdfjs/extension-files
browser/extensions/pdfjs/icon.png
browser/extensions/pdfjs/icon64.png
browser/extensions/pdfjs/install.rdf.in
browser/extensions/pdfjs/test/Makefile.in
browser/extensions/pdfjs/test/browser_pdfjs_main.js
browser/extensions/pdfjs/test/file_pdfjs_test.pdf
config/nsinstall.py
config/tests/unit-nsinstall.py
--- a/config/nsinstall.py
+++ b/config/nsinstall.py
@@ -62,16 +62,18 @@ def nsinstall(argv):
   p.add_option('-d', action="store_true",
                help="Create directories in target")
   p.add_option('-R', action="store_true",
                help="Use relative symbolic links (ignored)")
   p.add_option('-l', action="store_true",
                help="Create link (ignored)")
   p.add_option('-L', action="store", metavar="linkprefix",
                help="Link prefix (ignored)")
+  p.add_option('-X', action="append", metavar="file",
+               help="Ignore a file when installing a directory recursively.")
 
   # The remaining arguments are not used in our tree, thus they're not
   # implented.
   def BadArg(option, opt, value, parser):
     parser.error('option not supported: %s' % opt)
     
   p.add_option('-C', action="callback", metavar="CWD",
                callback=BadArg,
@@ -103,22 +105,28 @@ def nsinstall(argv):
         os.chmod(args[0], options.m)
       sys.exit()
     if options.m:
       os.makedirs(args[0], options.m)
     else:
       os.makedirs(args[0])
     return 0
 
+  if options.X:
+    options.X = [os.path.abspath(p) for p in options.X]
+
   # nsinstall arg1 [...] directory
   if len(args) < 2:
     p.error('not enough arguments')
 
   def copy_all_entries(entries, target):
     for e in entries:
+      if options.X and os.path.abspath(e) in options.X:
+        continue
+
       dest = os.path.join(target,
                           os.path.basename(os.path.normpath(e)))
       handleTarget(e, dest)
       if options.m:
         os.chmod(dest, options.m)
 
   # set up handler
   if options.d:
--- a/config/tests/unit-nsinstall.py
+++ b/config/tests/unit-nsinstall.py
@@ -42,21 +42,35 @@ class TestNsinstall(unittest.TestCase):
         testdir = self.mkdirs("testdir")
         self.assertEqual(nsinstall([testfile, testdir]), 0)
         self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
 
     def test_nsinstall_basic_recursive(self):
         "Test nsinstall <dir> <dest dir>"
         sourcedir = self.mkdirs("sourcedir")
         self.touch("testfile", sourcedir)
+        Xfile = self.touch("Xfile", sourcedir)
+        copieddir = self.mkdirs("sourcedir/copieddir")
+        self.touch("testfile2", copieddir)
+        Xdir = self.mkdirs("sourcedir/Xdir")
+        self.touch("testfile3", Xdir)
+
         destdir = self.mkdirs("destdir")
-        self.assertEqual(nsinstall([sourcedir, destdir]), 0)
+
+        self.assertEqual(nsinstall([sourcedir, destdir,
+                                    '-X', Xfile,
+                                    '-X', Xdir]), 0)
+
         testdir = os.path.join(destdir, "sourcedir")
         self.assert_(os.path.isdir(testdir))
         self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
+        self.assert_(not os.path.exists(os.path.join(testdir, "Xfile")))
+        self.assert_(os.path.isdir(os.path.join(testdir, "copieddir")))
+        self.assert_(os.path.isfile(os.path.join(testdir, "copieddir", "testfile2")))
+        self.assert_(not os.path.exists(os.path.join(testdir, "Xdir")))
 
     def test_nsinstall_multiple(self):
         "Test nsinstall <three files> <dest dir>"
         testfiles = [self.touch("testfile1"),
                      self.touch("testfile2"),
                      self.touch("testfile3")]
         testdir = self.mkdirs("testdir")
         self.assertEqual(nsinstall(testfiles + [testdir]), 0)