[Pkg-bazaar-commits] ./bzr-builddeb/trunk.old r247: Use standard locations for the directories.

James Westby jw+debian at jameswestby.net
Wed Dec 10 08:32:52 UTC 2008


------------------------------------------------------------
revno: 247
committer: James Westby <jw+debian at jameswestby.net>
branch nick: 2.0
timestamp: Tue 2008-08-26 16:41:59 +0100
message:
  Use standard locations for the directories.
  
  We still use ../build-area for the building so as not to clobber
  anything, but it uses .. for the tarballs and result directories.
  
  This makes the workflow much more standard and less surprising.
modified:
  __init__.py
  builder.py
  changes.py
  errors.py
  tests/blackbox/test_builddeb.py
  tests/blackbox/test_do.py
  tests/test_builder.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-03-19 22:40:15 +0000
+++ b/__init__.py	2008-08-26 15:41:59 +0000
@@ -83,7 +83,8 @@
 local_conf = os.path.join(builddeb_dir, 'local.conf')
 
 default_build_dir = '../build-area'
-default_orig_dir = '../tarballs'
+default_orig_dir = '..'
+default_result_dir = '..'
 
 
 class cmd_builddeb(Command):
@@ -104,12 +105,12 @@
   Specify the command to use when building using the --builder option,
 
   You can also specify directories to use for different things. --build-dir
-  is the directory to build the packages beneath, defaults to ../build-area.
-  --orig-dir specifies the directory that contains the .orig.tar.gz files 
-  for use in merge mode, defaults to ../tarballs. --result-dir specifies where
-  the resulting package files should be placed, defaults to whatever is 
-  used for the build directory. --result-dir will have problems if you use a
-  build command that places the results in a different directory.
+  is the directory to build the packages beneath, which defaults to
+  '../build-area'. '--orig-dir' specifies the directory that contains the
+  .orig.tar.gz files , which defaults to '..'. '--result-dir' specifies where
+  the resulting package files should be placed, which defaults to '..'.
+  --result-dir will have problems if you use a build command that places
+  the results in a different directory.
 
   The --reuse option will be useful if you are in merge mode, and the upstream
   tarball is very large. It attempts to reuse a build directory from an earlier
@@ -302,6 +303,8 @@
         build.clean()
       if result is not None:
         build.move_result(result)
+      else:
+        build.move_result(default_result_dir, allow_missing=True)
 
 
 register_command(cmd_builddeb)

=== modified file 'builder.py'
--- a/builder.py	2008-03-06 15:46:17 +0000
+++ b/builder.py	2008-08-26 15:41:59 +0000
@@ -41,6 +41,7 @@
                     NoSourceDirError,
                     BuildFailedError,
                     StopBuild,
+                    MissingChanges,
                     )
 from bzrlib.plugins.builddeb.util import recursive_copy, tarball_name
 
@@ -307,15 +308,21 @@
     info("Cleaning build dir: %s", source_dir)
     shutil.rmtree(source_dir)
 
-  def move_result(self, result):
+  def move_result(self, result, allow_missing=False):
     """Moves the files that resulted from the build to the given dir.
 
     The files are found by reading the changes file.
     """
+    package = self._properties.package()
+    version = self._properties.full_version()
+    try:
+        changes = DebianChanges(package, version,
+                self._properties.build_dir())
+    except MissingChanges:
+        if allow_missing:
+            return
+        raise
     info("Placing result in %s", result)
-    package = self._properties.package()
-    version = self._properties.full_version()
-    changes = DebianChanges(package, version, self._properties.build_dir())
     files = changes.files()
     if not os.path.exists(result):
       os.makedirs(result)

=== modified file 'changes.py'
--- a/changes.py	2008-03-05 17:00:51 +0000
+++ b/changes.py	2008-08-26 15:41:59 +0000
@@ -25,7 +25,7 @@
 
 from bzrlib.trace import mutter
 
-from bzrlib.plugins.builddeb.errors import DebianError
+from bzrlib.plugins.builddeb.errors import DebianError, MissingChanges
 
 class DebianChanges(deb822.Changes):
   """Abstraction of the .changes file. Use it to find out what files were 
@@ -57,7 +57,7 @@
       changes = os.path.join(dir,changes)
     mutter("Looking for %s", changes)
     if not os.path.exists(changes):
-      raise DebianError("Could not find .changes file: %s" % changes)
+      raise MissingChanges(changes)
     fp = open(changes)
     deb822.Changes.__init__(self, fp)
     self._filename = changes

=== modified file 'errors.py'
--- a/errors.py	2008-01-25 18:15:53 +0000
+++ b/errors.py	2008-08-26 15:41:59 +0000
@@ -85,4 +85,12 @@
   def __init__(self, path):
     self.path = path
 
+
+class MissingChanges(BzrError):
+  _fmt = """Could not find .changes file: %(changes)s."""
+
+  def __init__(self, changes):
+    self.changes = changes
+
+
 # vim: ts=2 sts=2 sw=2

=== modified file 'tests/blackbox/test_builddeb.py'
--- a/tests/blackbox/test_builddeb.py	2008-03-19 21:33:05 +0000
+++ b/tests/blackbox/test_builddeb.py	2008-08-26 15:41:59 +0000
@@ -113,10 +113,9 @@
                               self.uncommited_file])
 
   def orig_dir(self):
-    return os.path.join('..', 'tarballs')
+    return '..'
 
   def make_upstream_tarball(self):
-    os.mkdir(self.orig_dir())
     f = open(os.path.join(self.orig_dir(), self.package_name + "_" +
                           str(self.package_version.upstream_version) +
                           ".orig.tar.gz"), 'wb')

=== modified file 'tests/blackbox/test_do.py'
--- a/tests/blackbox/test_do.py	2007-10-29 18:00:52 +0000
+++ b/tests/blackbox/test_do.py	2008-08-26 15:41:59 +0000
@@ -77,9 +77,8 @@
       f.close()
 
   def make_upstream_tarball(self):
-    os.mkdir('../tarballs')
     self.build_tree(['test-0.1/', 'test-0.1/a'])
-    tar = tarfile.open(os.path.join('../tarballs/', 'test_0.1.orig.tar.gz'),
+    tar = tarfile.open(os.path.join('..', 'test_0.1.orig.tar.gz'),
                        'w:gz')
     try:
       tar.add('test-0.1')

=== modified file 'tests/test_builder.py'
--- a/tests/test_builder.py	2008-03-06 15:46:17 +0000
+++ b/tests/test_builder.py	2008-08-26 15:41:59 +0000
@@ -425,7 +425,7 @@
   def test_move_result_errors_on_missing_changes_file(self):
     """Test that the move_result errors if the changes file is missing."""
     builder = self.get_builder()
-    self.assertRaises(errors.DebianError, builder.move_result, self.result_dir)
+    self.assertRaises(errors.MissingChanges, builder.move_result, self.result_dir)
 
   def test_move_result_errors_on_missing_result_file(self):
     """Test that the move_result errors if one of the files is missing."""



More information about the Pkg-bazaar-commits mailing list