def _filePlacingInPackage(self, archive, sourcePath, archivePath, contents=None): Packager._filePlacingInPackage(self, archive, sourcePath, archivePath, contents) #Only md5 what's going in to the actual data archive if archive != 'data': return if sourcePath is not None: if os.path.isdir(sourcePath): self.log.devdebug("Adding directory: %s", sourcePath) return with open(sourcePath) as content: md5sum = self._fileMD5(content) elif contents is not None: if type(contents) == str: md5calc = hashlib.md5() md5calc.update(contents) md5sum = md5calc.hexdigest() else: md5sum = self._fileMD5(contents) else: self.log.warning("Neither sourcePath or contents were usable") return self.log.devdebug("Adding md5sum: %s %s", md5sum, archivePath) self._packageControl('md5sums')['entries'].append( "%s %s" % (md5sum, archivePath))
def _setupPackage(self): Packager._setupPackage(self) self._ensureDirectoryExists(self.resultdir, True) md5sumsControl = self._packageControl('md5sums') md5sumsControl['entries'] = [] with open(os.path.join(self.resultdir, 'debian-binary'), 'w') as dbfile: dbfile.write('2.0\n') self.fullPathToControl = os.path.join(self.resultdir, 'control.tar.gz') self.controlfile = tarfile.open(self.fullPathToControl, 'w:gz')
def _doMetadataMappings(self): if 'arch' in self.options: self.arch = self.options['arch'] else: self.arch = 'all' if 'priority' in self.options: priority = self.options['priority'] else: priority = 'extra' Packager._doMetadataMappings( self) #Calls _calculateFileNameAndVersioning if 'Description' in self.packageMetadata \ and 'about' in self.productMetadata: self.packageMetadata['Description'] += "\n %s" % '\n '.join( self.productMetadata['about'].replace('\n\n', '\n.\n').split('\n')) self.packageName = self.packageMetadata['Package'] self.packageMetadata['Version'] = self.fullVersion self.packageMetadata['Architecture'] = self.arch self.packageMetadata['Priority'] = priority self.packageMetadata['Urgency'] = 'low' #This will be set by changelog control = self._packageControl('control') control.update(self.packageMetadata) copyright = self._packageControl('copyright') copyright['keys'] = {} copyright['keys'][ 'Format-Specification'] = 'http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135' copyright['keys']['Name'] = self.packageName copyright['keys']['Maintainer'] = self.packageMetadata['Maintainer'] #Spits out a default changelog. Use the DebianChangeLog # aspect to get a resonable log. LOG = """%s (%s) %s; urgency=%s %s -- %s %s """ changelog = self._packageControl('changelog') changelog['default-top'] = \ LOG % ( self.packageName, self.fullVersion, "experimental", "low", " * Initial release", self.packageMetadata['Maintainer'], email.Utils.formatdate() ) return self.packageMetadata
def _calculateFileNameAndVersioning(self): #self.version = self.metadata._getDefaultDefinedVersion('+') self.format = 'gzip' Packager._calculateFileNameAndVersioning(self) self.version = self.metadata._getVersionWithFormat( ["%(epoch)s:", "%(primary)s"], True, ['epoch', 'primary'], '+') version = self.version self.filenameVersion = self.metadata._getVersionWithFormat( ["%(primary)s"], True, ['epoch', 'primary'], '+') self.packageVersion = self.options['package-version'] self.filenameFullVersion = '%s-%s' % (self.filenameVersion, self.packageVersion) self.fullVersion = '%s-%s' % (version, self.packageVersion) self.fullPackageName = '%s_%s_%s.deb' % ( self.packageName, self.filenameFullVersion, self.arch)
def _finishPackage(self): #Write any remaining information result = Packager._finishPackage(self) self._writeMD5sums(self._packageControl('md5sums')) if result: #close control archive self.controlfile.close() filelist = ['debian-binary', 'control.tar.gz', 'data.tar.gz'] if 'signer' in self.options: idname = self.options['signer'] phase = self.engine.getPhase() signerResult = self.engine.launchStep(idname, phase) if signerResult is None or not signerResult._didPass(): raise ValueError("%s step failed" % idname) signer = signerResult._getReturnValue(phase) for f in filelist: with open(os.path.join(self.resultdir, f)) as target: buf = target.read(10240) while len(buf) > 0: signer.update(buf) buf = target.read(10240) with open(os.path.join(self.resultdir, '_gpgorigin'), 'w') as g: g.write(signer.digest()) filelist.append('_gpgorigin') command = ['ar', 'rcv', self.fullPackageName] + filelist result = subprocess.call(command, stdout=self.log.out(), stderr=self.log.err(), cwd=self.resultdir) result = result == 0 return result
def _calculateFileNameAndVersioning(self): hasPackageVersion = 'package-version' in self.options hasExtension = 'extension' in self.options if 'format' in self.options: self.format = self.options['format'] else: self.format = 'gzip' if self.format == 'gzip': self.filetype = 'gz' if hasExtension: ext = self.options['extension'] else: ext = 'tar.gz' elif self.format == 'bzip2': self.filetype = 'bz' if hasExtension: ext = self.options['extension'] else: ext = 'tar.bz2' else: self.log.warning( "'format' '%s' is not understood defaulting to gzip") self.format = 'gzip' self.filetype = 'gz' if hasExtension: ext = self.options['extension'] else: ext = 'tar.gz' if not hasPackageVersion: self.options['package-version'] = '' Packager._calculateFileNameAndVersioning(self) if 'version' in self.options: self.version = self.metadata._parseVersionFormatString( self.options['version']) if not hasPackageVersion: self.fullVersion = self.version else: self.fullVersion = '%s-%s' % (self.version, self.packageVersion) self.fullPackageName = "%s-%s" % (self.packageName, self.fullVersion) self.archiveFileName = '%s.%s' % (self.fullPackageName, ext) self.fullPathToArchive = os.path.join(self.resultdir, self.archiveFileName)
def _map_path_python_lib(self, value, pathmaps, pathkeymaps): Packager._map_path_python_lib(self, value, pathmaps, pathkeymaps) pathmaps[value] = \ [ os.path.join(m, 'dist-packages') for m in pathmaps[value] ] pathkeymaps['python-lib'] = pathmaps[value]
def _calculateFileNameAndVersioning(self): Packager._calculateFileNameAndVersioning(self) self.archiveFileName = "%s.zip" % self.fullPackageName self.fullPathToArchive = os.path.join(self.resultdir, self.archiveFileName)