changeset 296:ce7be2fb93ee

Make it easy to install extra binaries into subdirectories of extra-pkg. This makes it easier to manage the extra-pkg directory when it contains manually added packages and automatically added packages from one of the package tracks by putting the automatically added packages into extra-pkg/auto and manually added packages into extra-pkg/manual. To this end, add parameter subdir to PBuilder.add_binaries_to_extra_pkg method with default value "auto". Adapt the test case accordingly. Also add the command line argument --subdir to bin/treepkgbuilder.py add-binaries command, this time with default value "manual".
author Bernhard Herzog <bh@intevation.de>
date Wed, 18 Nov 2009 18:11:22 +0000
parents dcdf23dece2d
children 4dd6ec3a1151
files bin/treepkgbuilder.py test/test_builder.py treepkg/builder.py
diffstat 3 files changed, 29 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/bin/treepkgbuilder.py	Tue Oct 06 13:34:49 2009 +0000
+++ b/bin/treepkgbuilder.py	Wed Nov 18 18:11:22 2009 +0000
@@ -85,9 +85,20 @@
 
     names = ("add-binaries",)
 
+    def create_parser(self):
+        parser = super(AddBinariesCommand, self).create_parser()
+        parser.set_defaults(subdir="manual")
+        parser.add_option("--subdir",
+                          help=("The subdirectory of extra-pkg into which"
+                                " the packages are to be copied"
+                                " (default 'manual')."))
+        return parser
+
+
     def run(self):
         builder = self.get_builder()
-        builder.add_binaries_to_extra_pkg(self.rest)
+        builder.add_binaries_to_extra_pkg(self.rest,
+                                          subdirectory=self.opts.subdir)
 
 
 class UpdateCommand(Command):
--- a/test/test_builder.py	Tue Oct 06 13:34:49 2009 +0000
+++ b/test/test_builder.py	Wed Nov 18 18:11:22 2009 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008 by Intevation GmbH
+# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
 # Authors:
 # Bernhard Herzog <bh@intevation.de>
 #
@@ -375,6 +375,9 @@
         builder.add_binaries_to_extra_pkg([self.minimal_package_deb])
 
         self.assertEquals(sorted(os.listdir(self.extra_pkg_dir)),
-                          ["Packages", "Release", "minimal_1.0-1_i386.deb"])
+                          ["Packages", "Release", "auto"])
+        self.assertEquals(sorted(os.listdir(os.path.join(self.extra_pkg_dir,
+                                                         "auto"))),
+                          ["minimal_1.0-1_i386.deb"])
         self.check_command_line(['/usr/sbin/pbuilder', 'update',
                                  '--configfile', self.pbuilderrc])
--- a/treepkg/builder.py	Tue Oct 06 13:34:49 2009 +0000
+++ b/treepkg/builder.py	Wed Nov 18 18:11:22 2009 +0000
@@ -193,19 +193,22 @@
                 if os.path.splitext(filename)[1] not in (".deb", ".changes"):
                     os.remove(os.path.join(binary_dir, filename))
 
-    def add_binaries_to_extra_pkg(self, filenames):
+    def add_binaries_to_extra_pkg(self, filenames, subdirectory="auto"):
         """Adds binary packages to the extra-pkg directory.
         The filenames parameter should be sequence of absolute
-        filenames.  The files named will be copied to the extra-pkg
-        directory which is assumed to reside in the same directory as
-        the pbuilderrc.  Afterwards, the method generates a Packages
-        file in the directory and runs pbuilder update.  All of this
-        assumes that pbuilder was set up the way bin/initpbuilder.py
-        does.
+        filenames.  The files named will be copied to a subdirectory of
+        the extra-pkg directory which is assumed to reside in the same
+        directory as the pbuilderrc.  The subdirectory is specified with
+        the subdirectory parameter and defaults to 'auto'.  Afterwards,
+        the method generates a Packages file in the directory and runs
+        pbuilder update.  All of this assumes that pbuilder was set up
+        the way bin/initpbuilder.py does.
         """
+        target_dir = os.path.join(self.extra_pkg_dir, subdirectory)
+        util.ensure_directory(target_dir)
         for filename in filenames:
-            logging.info("Copying %s into %s", filename, self.extra_pkg_dir)
-            shutil.copy(filename, self.extra_pkg_dir)
+            logging.info("Copying %s into %s", filename, target_dir)
+            shutil.copy(filename, target_dir)
 
         logging.info("Running apt-ftparchive in %s", self.extra_pkg_dir)
         self.update_extra_pkg_dir()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)