From 7b81e1cab956b030352d3627dc10f71f10567f01 Mon Sep 17 00:00:00 2001 From: Miroslav Suchý Date: May 27 2020 20:26:12 +0000 Subject: files I forgot to add to 54714a5 --- diff --git a/rpmfluff/trigger.py b/rpmfluff/trigger.py new file mode 100644 index 0000000..168ce95 --- /dev/null +++ b/rpmfluff/trigger.py @@ -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 diff --git a/rpmfluff/yumrepobuild.py b/rpmfluff/yumrepobuild.py new file mode 100644 index 0000000..f325131 --- /dev/null +++ b/rpmfluff/yumrepobuild.py @@ -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))