| |
@@ -13,8 +13,10 @@
|
| |
# along with this program; if not, write to the Free Software
|
| |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| |
|
| |
+ import codecs
|
| |
import os
|
| |
import os.path
|
| |
+ import random
|
| |
import re
|
| |
import shutil
|
| |
import subprocess
|
| |
@@ -233,7 +235,7 @@
|
| |
"""
|
| |
@return: get a subpackage by suffix (e.g. "devel"), or None/"" for the base package
|
| |
"""
|
| |
- if suffix==None or suffix=='':
|
| |
+ if suffix == None or suffix == '':
|
| |
return self.basePackage
|
| |
|
| |
for sub in self.subPackages:
|
| |
@@ -298,7 +300,6 @@
|
| |
self.section_postun += postunLine
|
| |
|
| |
def gather_spec_file(self, tmpDir):
|
| |
- import codecs
|
| |
if self.specbasename and self.specbasename != '':
|
| |
specFileName = os.path.join(tmpDir, "%s.spec" % self.specbasename)
|
| |
else:
|
| |
@@ -450,13 +451,13 @@
|
| |
if not name:
|
| |
name = self.name
|
| |
|
| |
- if arch=="SRPMS":
|
| |
- archSuffix="src"
|
| |
+ if arch == "SRPMS":
|
| |
+ archSuffix = "src"
|
| |
else:
|
| |
- archSuffix=arch
|
| |
+ archSuffix = arch
|
| |
|
| |
- builtRpmName="%s-%s-%s.%s.rpm"%(name, self.version, expand_macros(self.release), archSuffix)
|
| |
- if arch=="SRPMS":
|
| |
+ builtRpmName = "%s-%s-%s.%s.rpm"%(name, self.version, expand_macros(self.release), archSuffix)
|
| |
+ if arch == "SRPMS":
|
| |
builtRpmDir = self.get_srpms_dir()
|
| |
else:
|
| |
builtRpmDir = os.path.join(self.get_rpms_dir(), arch)
|
| |
@@ -549,7 +550,7 @@
|
| |
self.basePackage.add_conflicts(conflicts)
|
| |
|
| |
def add_build_requires(self, requirement):
|
| |
- self.basePackage.section_requires += "BuildRequires: %s\n"%requirement
|
| |
+ self.basePackage.section_requires += "BuildRequires: %s\n"%requirement
|
| |
|
| |
def add_trigger(self, trigger):
|
| |
"Add a trigger"
|
| |
@@ -638,15 +639,15 @@
|
| |
self.section_install += "chmod %s $RPM_BUILD_ROOT/%s\n"%(mode, self.escape_path(installPath))
|
| |
|
| |
sub = self.get_subpackage(subpackageSuffix)
|
| |
- tag=""
|
| |
+ tag = ""
|
| |
if owner or group:
|
| |
tag += '%%attr(-,%s,%s) ' % (owner or '-', group or '-')
|
| |
if isConfig:
|
| |
- tag+="%config "
|
| |
+ tag += "%config "
|
| |
if isDoc:
|
| |
- tag+="%doc "
|
| |
+ tag += "%doc "
|
| |
if isGhost:
|
| |
- tag+="%ghost "
|
| |
+ tag += "%ghost "
|
| |
sub.section_files += '%s"/%s"\n'%(tag, installPath)
|
| |
|
| |
def add_installed_directory(self,
|
| |
@@ -670,36 +671,35 @@
|
| |
sub = self.get_subpackage(subpackageSuffix)
|
| |
tag = ""
|
| |
if isConfig:
|
| |
- tag+="%config "
|
| |
+ tag += "%config "
|
| |
if isDoc:
|
| |
- tag+="%doc "
|
| |
+ tag += "%doc "
|
| |
if isGhost:
|
| |
- tag+="%ghost "
|
| |
+ tag += "%ghost "
|
| |
sub.section_files += '%s"/%s"\n'%(tag, installedPath)
|
| |
self.add_payload_check(installedPath, subpackageSuffix)
|
| |
|
| |
def add_simple_payload_file(self):
|
| |
"""Trivial hook for adding a simple file to payload, hardcoding all params"""
|
| |
- self.add_installed_file(installPath = 'usr/share/doc/hello-world.txt',
|
| |
- sourceFile = SourceFile('hello-world.txt', 'hello world\n'),
|
| |
+ self.add_installed_file(installPath='usr/share/doc/hello-world.txt',
|
| |
+ sourceFile=SourceFile('hello-world.txt', 'hello world\n'),
|
| |
isDoc=True)
|
| |
|
| |
def add_simple_payload_file_random(self, size=100):
|
| |
"""Trivial hook for adding a simple file to payload, random (ASCII printable chars) content of specified size (default is 100 bytes), name based on the packages ENVRA and count of the source files (to be unique)"""
|
| |
- import random
|
| |
random.seed()
|
| |
content = ''
|
| |
for _ in range(size):
|
| |
content = content + chr(random.randrange(32, 127))
|
| |
name = "%s-%s-%s-%s-%s-%s.txt" % (self.epoch, self.name, self.version, expand_macros(self.release), self.get_build_archs()[0], len(self.sources))
|
| |
- self.add_installed_file(installPath = 'usr/share/doc/%s' % name,
|
| |
- sourceFile = SourceFile(name, content),
|
| |
+ self.add_installed_file(installPath='usr/share/doc/%s' % name,
|
| |
+ sourceFile=SourceFile(name, content),
|
| |
isDoc=True)
|
| |
|
| |
def add_simple_compilation(self,
|
| |
sourceFileName="main.c",
|
| |
sourceContent=hello_world,
|
| |
- compileFlags = "",
|
| |
+ compileFlags="",
|
| |
installPath="usr/bin/hello-world",
|
| |
createParentDirs=True,
|
| |
subpackageSuffix=None):
|
| |
@@ -717,8 +717,8 @@
|
| |
def add_simple_library(self,
|
| |
sourceFileName="foo.c",
|
| |
sourceContent=simple_library_source,
|
| |
- compileFlags = "",
|
| |
- libraryName = 'libfoo.so',
|
| |
+ compileFlags="",
|
| |
+ libraryName='libfoo.so',
|
| |
installPath="usr/lib/libfoo.so",
|
| |
createParentDirs=True,
|
| |
subpackageSuffix=None):
|
| |
@@ -765,7 +765,6 @@
|
| |
# (which would lead to duplicates in the merged log).
|
| |
# So we rot13 the desired message, and echo that through a shell
|
| |
# rot13 (using tr), getting the desired output to stderr
|
| |
- import codecs
|
| |
rot13Message = codecs.getencoder('rot-13')(message)[0]
|
| |
self.section_build += "echo '%s' | tr 'a-zA-Z' 'n-za-mN-ZA-N' 1>&2\n" % rot13Message
|
| |
|
| |
See individual commits.