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 94556 ffaf38d1e36d9eab5532b4ea20f48103cc96da27
parent 94555 edb5a8927daef77d674fd98d18c5382322666e92
child 94557 d50e4a17308b13c66ad800483fe9b69f304f9a5d
push idunknown
push userunknown
push dateunknown
reviewersted
bugs740795
milestone15.0a1
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
@@ -29,16 +29,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,
@@ -70,22 +72,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)