#36 Files accidentaly forgotten in previous PR
Merged 4 years ago by jhutar. Opened 4 years ago by msuchy.
msuchy/rpmfluff forgot  into  master

file added
+59
@@ -0,0 +1,59 @@ 

+ # -*- coding: UTF-8 -*-

+ #

+ # Copyright (c) 2006-2016 Red Hat, Inc. All rights reserved. This copyrighted material

+ # is made available to anyone wishing to use, modify, copy, or

+ # redistribute it subject to the terms and conditions of the GNU General

+ # Public License v.2.

+ #

+ # This program is distributed in the hope that it will be useful, but WITHOUT ANY

+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A

+ # PARTICULAR PURPOSE. See the GNU General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, write to the Free Software

+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ 

+ class Trigger:

+     def __init__(self, event, triggerConds, script, program=None):

+         """For documentation on RPM triggers, see

+         U{http://www.rpm.org/support/RPM-Changes-6.html}

+ 

+         @param event: can be:

+           - "un"

+           - "in"

+           - "postun"

+         @type event: string

+ 

+         @param triggerConds: the name of the target package, potentially with a conditional, e.g.:

+           "sendmail"

+           "fileutils > 3.0, perl < 1.2"

+         @type triggerConds: string

+ 

+         @param script: textual content of the script to execute

+         @type script: string

+ 

+         @param program: the progam used to execute the script

+         @type program: string

+         """

+         self.event = event

+         self.triggerConds = triggerConds

+         self.script = script

+         self.program = program

+ 

+     def output(self, specFile, subpackageName=""):

+         # Write trigger line:

+         specFile.write("%%trigger%s %s"%(self.event, subpackageName))

+         if self.program:

+             specFile.write("-p %s"%self.program)

+         specFile.write(" -- %s\n"%self.triggerConds)

+ 

+         # Write script:

+         specFile.write("%s\n"%self.script)

+ 

+     def __str__(self):

+         result = "%%trigger%s "%(self.event)

+         if self.program:

+             result += "-p %s"%self.program

+         result += " -- %s\n"%self.triggerConds

+         result += "%s\n"%self.script

+         return result

@@ -0,0 +1,47 @@ 

+ # -*- coding: UTF-8 -*-

+ #

+ # Copyright (c) 2006-2016 Red Hat, Inc. All rights reserved. This copyrighted material

+ # is made available to anyone wishing to use, modify, copy, or

+ # redistribute it subject to the terms and conditions of the GNU General

+ # Public License v.2.

+ #

+ # This program is distributed in the hope that it will be useful, but WITHOUT ANY

+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A

+ # PARTICULAR PURPOSE. See the GNU General Public License for more details.

+ #

+ # You should have received a copy of the GNU General Public License

+ # along with this program; if not, write to the Free Software

+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

+ 

+ import shutil

+ import subprocess

+ import tempfile

+ 

+ class YumRepoBuild:

+     """Class for easily creating a yum repo from a collection of RpmBuild instances"""

+     def __init__(self, rpmBuilds):

+         """@type rpmBuilds: list of L{RpmBuild} instances"""

+         self.repoDir = tempfile.mkdtemp(prefix='rpmfluff')

+         self.rpmBuilds = rpmBuilds

+ 

+     def make(self, *arches):

+         # Build all the packages

+         for pkg in self.rpmBuilds:

+             pkg.make()

+ 

+         # Now assemble into a yum repo:

+         for pkg in self.rpmBuilds:

+             for arch in arches:

+                 if arch in pkg.get_build_archs():

+                     for subpackage in pkg.get_subpackage_names():

+                         try:

+                             shutil.copy(pkg.get_built_rpm(arch, name=subpackage), self.repoDir)

+                         except IOError:

+                             pass   # possibly repo arch set to noarch+x86_64 but RpmBuild

+                                    # built for noarch only?

+ 

+         try:

+             subprocess.check_output(["createrepo_c", self.repoDir], stderr=subprocess.STDOUT)

+         except subprocess.CalledProcessError as e:

+             raise RuntimeError('createrepo_c command failed with exit status %s: %s\n%s'

+                     % (e.returncode, e.cmd, e.output))

no initial comment

rebased onto 7b81e1c

4 years ago

Pull-Request has been merged by jhutar

4 years ago
Metadata