diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-07-20 21:25:23 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-07-20 21:25:23 +0100 |
commit | c4d471083b4f756057543d3d288b2837eb73b965 (patch) | |
tree | b6866853edb107af248af6ba28406b36adf3120c | |
parent | 976de7acf514742b109fc3c6f89e7fe889f47d9c (diff) | |
download | unperish-c4d471083b4f756057543d3d288b2837eb73b965.tar.gz |
Change subcommands so they only change stuff if target is missing.
This is important because commands are now running each other
automatically, and it's stupid to re-run the same command over
and over again, running the same external commands over and over,
if there is no change, or, worse, there is change.
So now we, for example, only build the debian tarball if it is
missing, and otherwise it is a no-op.
(Over and over again when unperish is run many times; there's
already a mechanism for skipping stuff that's been run once during
one run of unperish. But that does not help if we're doing, for
example, one deb build for Debian upload, and another for
code.liw.fi upload.)
-rwxr-xr-x | unperish | 59 |
1 files changed, 41 insertions, 18 deletions
@@ -128,6 +128,26 @@ class Unperish(cliapp.Application): def dirname(self): return '%s-%s' % (self.upstream_name, self.upstream_version) + @property + def dsc(self): + return '%s_%s.dsc' % (self.debian_source_package, self.debian_version) + + @property + def changes(self): + arch = self.runcmd(['dpkg', '--print-architecture']).strip() + return '%s_%s_%s.changes' % (self.debian_source_package, + self.debian_version, + arch) + + def already_exists(self, filename): + '''Does a file already exist?''' + if os.path.exists(filename): + logging.debug('Already exists: %s' % filename) + return True + else: + logging.debug('Does not already exist: %s' % filename) + return False + def cmd_dump_meta(self, args): '''Print out contents of project meta file (project.meta).''' self.meta.write(self.output) @@ -142,17 +162,21 @@ class Unperish(cliapp.Application): if not self.settings['dsc']: raise cliapp.AppException('Need --dsc option for dget') - self.runcmd(['dget', '--download-only', self.settings['dsc']], - cwd=self.settings['build-area']) + basename = os.path.basename(self.settings['dsc']) + if not self.already_exists(self.join(basename)): + self.runcmd(['dget', '--download-only', self.settings['dsc']], + cwd=self.settings['build-area']) def cmd_export(self, args): '''Export unpacked source directory to build area.''' - self.runcmd(['bzr', 'export', self.join(self.dirname)]) + if not self.already_exists(self.join(self.dirname)): + self.runcmd(['bzr', 'export', self.join(self.dirname)]) def cmd_debian_tarball(self, args): '''Generate Debian tarball (.orig.tar.gz) in build area.''' origtar = self.join(self.debian_tarball) - self.runcmd(['bzr', 'export', origtar]) + if not self.already_exists(origtar): + self.runcmd(['bzr', 'export', origtar]) def cmd_dch(self, args): '''Add a debian/changelog entry for new upload target.''' @@ -163,25 +187,24 @@ class Unperish(cliapp.Application): def cmd_dsc(self, args): '''Create Debian source package (.dsc) in build area.''' self.run_subcommand('export') - self.run_subcommand('dch') self.run_subcommand('debian-tarball') - self.runcmd(['dpkg-source', '-b', self.dirname], - cwd=self.settings['build-area']) + if not self.already_exists(self.join(self.dsc)): + self.runcmd(['dpkg-source', '-b', self.dirname], + cwd=self.settings['build-area']) def cmd_deb(self, args): '''Build Debian binary packages (.deb) in build area.''' self.run_subcommand('dsc') - pat = '%s_%s.dsc' % (self.debian_source_package, self.debian_version) - dsc = glob.glob(self.join(pat))[0] - argv = ['sudo', - 'pbuilder', - '--build', - '--basetgz', self.settings['basetgz'], - '--buildresult', self.settings['build-area'], - '--logfile', self.join('pbuilder.log'), - '--debbuildopts', '-sa', - dsc] - self.runcmd(argv, cwd=self.settings['build-area']) + if not self.already_exists(self.join(self.changes)): + argv = ['sudo', + 'pbuilder', + '--build', + '--basetgz', self.settings['basetgz'], + '--buildresult', self.settings['build-area'], + '--logfile', self.join('pbuilder.log'), + '--debbuildopts', '-sa', + self.join(self.dsc)] + self.runcmd(argv, cwd=self.settings['build-area']) def cmd_lintian(self, args): '''Run lintian on .changes/.deb/.dsc files.''' |