comparison treepkg/packager.py @ 274:2676abfc0e1d

Refactoring: Implement do_package in treepkg.packager.SourcePackager. The actual implementation in the derived classes is almost identical in all cases so it's better to have as much of the implementation in the base class. The update_version_numbers method is not called directly by the base class code so is removed from the base class. OTOH, prepare_sources_for_tarball has been added as a more general variant of update_version_numbers that is actually called by the default implementation of do_package.
author Bernhard Herzog <bh@intevation.de>
date Thu, 07 May 2009 15:19:15 +0000
parents e574b03a2957
children f3dee156e3e3
comparison
equal deleted inserted replaced
273:4b700b39c32f 274:2676abfc0e1d
33 class SourcePackager(object): 33 class SourcePackager(object):
34 34
35 # Derived classes must supply the package basename 35 # Derived classes must supply the package basename
36 pkg_basename = None 36 pkg_basename = None
37 37
38 # Derived classes may want to override this message
39 changemsg_template = "Update to revision %(revision)d"
40
41
38 track = _fromparent("track") 42 track = _fromparent("track")
39 revision = _fromparent("revision") 43 revision = _fromparent("revision")
40 status = _fromparent("status") 44 status = _fromparent("status")
41 log_dir = _fromparent("log_dir") 45 log_dir = _fromparent("log_dir")
42 work_dir = _fromparent("work_dir") 46 work_dir = _fromparent("work_dir")
78 82
79 os.rename(temp_dir, pkgbasedir) 83 os.rename(temp_dir, pkgbasedir)
80 return pkgbaseversion, pkgbasedir 84 return pkgbaseversion, pkgbasedir
81 85
82 86
83 def update_version_numbers(self, pkgbasedir): 87 def prepare_sources_for_tarball(self, pkgbasedir):
84 """Updates the version numbers in the code in pkgbasedir. 88 """Prepare the exported sources prior to creating the tarball.
85 89
86 The default implementation does nothing. Derived classes should 90 The default implementation does nothing. Derived classes should
87 override this method if necessary. 91 override this method if necessary to e.g. update the version
92 numbers in the code.
88 """ 93 """
89 94
90 def create_tarball(self, tarballname, workdir, basedir, compression="gz"): 95 def create_tarball(self, tarballname, workdir, basedir, compression="gz"):
91 """Creates a new tarball. 96 """Creates a new tarball.
92 97
187 finally: 192 finally:
188 logging.info("Removing workdir %r", self.work_dir) 193 logging.info("Removing workdir %r", self.work_dir)
189 shutil.rmtree(self.work_dir) 194 shutil.rmtree(self.work_dir)
190 195
191 def do_package(self): 196 def do_package(self):
192 """Does the work of creating a source package 197 """Does the work of creating a source package."""
193 This method must be overriden by derived classes. 198 pkgbaseversion, pkgbasedir = self.export_sources()
194 199
195 The method should do the work in self.work_dir. When the 200 pkgbasename = self.pkg_basename + "_" + pkgbaseversion
196 package is done, the source package files should be in 201 origtargz = os.path.join(self.work_dir,
197 self.src_dir. 202 pkgbasename + ".orig.tar.gz")
198 """ 203
199 raise NotImplementedError 204 self.prepare_sources_for_tarball(pkgbasedir)
205
206 self.create_tarball(origtargz, self.work_dir,
207 os.path.basename(pkgbasedir))
208
209 changemsg = self.changemsg_template % dict(revision=self.revision)
210 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
211 changemsg)
212
213 self.create_source_package(pkgbasedir, origtargz)
214 self.move_source_package(pkgbasename)
200 215
201 216
202 class BinaryPackager(object): 217 class BinaryPackager(object):
203 218
204 track = _fromparent("track") 219 track = _fromparent("track")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)