def _test(self, version, expected): from irgsh.utils import get_package_version f = open(self.changelog, 'wb') f.write('''python-irgsh (%s) lucid; urgency=low * Next generation of IRGSH -- Fajran Iman Rusadi <*****@*****.**> Sun, 27 Feb 2011 22:27:19 +0100''' % version) f.close() pkg, ver = get_package_version(self.tmp) self.assertEqual(pkg, 'python-irgsh') self.assertEqual(ver, expected)
def prepare_source(self, target, logger=None): try: tmp = tempfile.mkdtemp('-irgsh-srcpkg-prepare') self.log.debug('Preparing source code directory') # Download and extract source source_path = os.path.join(tmp, 'source') os.makedirs(source_path) self.log.debug('Downloading source code, type: %s' % self.source_type) source = self.download_source(source_path, logger) self.log.debug('Source code downloaded') # Download orig orig = None orig_path = os.path.join(tmp, 'orig') os.makedirs(orig_path) if self.orig is not None: self.log.debug('Downloading original file') orig = self.download_orig(orig_path, logger) self.log.debug('Original file downloaded') # Download additional orig extra_orig = [] if len(self.extra_orig) > 0: self.log.debug('Downloading additional original files') extra_orig = self.download_extra_orig(orig_path, logger) self.log.debug('additional original files downloaded') # Combine source and orig(s) combined_path = os.path.join(tmp, 'combine') os.makedirs(combined_path) self.log.debug('Combining source and orig, type: %s' % self.source_type) combined_path = self.combine(source, orig, extra_orig, combined_path, logger) self.log.debug('Source and orig combined') # Check for debian directory combined_path = find_debian(combined_path) if combined_path is None: raise ValueError, 'Unable to find debian directory' # Get version information package, version = get_package_version(combined_path) self.log.debug('Package: %s_%s' % (package, version)) # Move source directory self.log.debug('Moving source code directory') final_path = os.path.join(target, '%s-%s' % (package, version)) shutil.move(combined_path, final_path) # Move and rename orig file, if available if orig is not None: upstream = version.split('-')[0] fname, ext = os.path.splitext(self.orig) orig_path = os.path.join(target, '%s_%s.orig.tar%s' % \ (package, upstream, ext)) shutil.move(orig, orig_path) # Move additional orig files for orig in extra_orig: shutil.move(orig, target) return package, version except Exception, e: raise SourcePackagePreparationError(e)