diff options
author | Per Øyvind Karlsen <proyvind@moondrake.org> | 2016-06-03 18:10:43 +0200 |
---|---|---|
committer | Per Øyvind Karlsen <proyvind@moondrake.org> | 2016-06-03 18:10:43 +0200 |
commit | 06c158c149c5d3e44634135632812d3a65dd255e (patch) | |
tree | 6dd3124ce887aaf724b385b33443956ee24a2844 | |
parent | 3dac8f9086fdde5a9d5380c454bb9cef85451db6 (diff) | |
download | mgarepo-06c158c149c5d3e44634135632812d3a65dd255e.tar mgarepo-06c158c149c5d3e44634135632812d3a65dd255e.tar.gz mgarepo-06c158c149c5d3e44634135632812d3a65dd255e.tar.bz2 mgarepo-06c158c149c5d3e44634135632812d3a65dd255e.tar.xz mgarepo-06c158c149c5d3e44634135632812d3a65dd255e.zip |
implement support for applying %changelog with 'mgarepo buildrpm -l'
-rw-r--r-- | MgaRepo/commands/buildrpm.py | 9 | ||||
-rw-r--r-- | MgaRepo/rpmutil.py | 20 |
2 files changed, 27 insertions, 2 deletions
diff --git a/MgaRepo/commands/buildrpm.py b/MgaRepo/commands/buildrpm.py index 79653e8..337ae2a 100644 --- a/MgaRepo/commands/buildrpm.py +++ b/MgaRepo/commands/buildrpm.py @@ -12,11 +12,13 @@ Builds the binary RPM(s) (.rpm) file(s) of a given package. Options: -bX Build stage option, where X is stage, default is -bb -I Don't automatically try install missing build dependencies - -l Disable rpmlint check of packages built + -L Disable rpmlint check of packages built -P USER Define the RPM packager information to USER -d Use DNF -q Quiet build output -s Jump to specific build stage (--short-circuit) + -l Use subversion log to build rpm %changelog + -F Do not use full name & email for packagers in %changelog """ @@ -24,11 +26,14 @@ def parse_options(): parser = OptionParser(HELP) parser.add_option("-b", dest="build_cmd", default="a") parser.add_option("-I", dest="installdeps", action="store_false", default=True) - parser.add_option("-l", dest="rpmlint", action="store_false", default=True) + parser.add_option("-L", dest="rpmlint", action="store_false", default=True) parser.add_option("-P", dest="packager", default="") parser.add_option("-d", "--dnf", dest="use_dnf", action="store_true", default=False) parser.add_option("-q", "--quiet", dest="verbose", action="store_false", default=True) parser.add_option("-s", "--short-circuit", dest="short_circuit", action="store_true", default=False) + parser.add_option("-l", dest="svnlog", action="store_true", default=False) + parser.add_option("-F", dest="fullnames", default=True, + action="store_false") opts, args = parser.parse_args() return opts diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py index 3a10380..92f663d 100644 --- a/MgaRepo/rpmutil.py +++ b/MgaRepo/rpmutil.py @@ -382,6 +382,8 @@ def build_rpm(build_cmd="b", packager = None, installdeps = True, use_dnf = False, + svnlog = False, + fullnames = True, macros = []): top = os.getcwd() topdir = "_topdir %s" % top @@ -401,6 +403,21 @@ def build_rpm(build_cmd="b", raise Error("no spec files found") spec = speclist[0] + # If we're building package with %changelog, we'll make a temporary + # copy of the spec file with %changelog applied that we'll use for + # building. This way we avoid modifying files in repository. + # TODO: implement support for external changelog in rpm + if svnlog: + vcs = detectVCS(top) + specsdir = tempfile.mkdtemp() + shutil.copy(spec, specsdir) + specdir = "_specdir "+specsdir + spec = os.path.join(specsdir,os.path.basename(spec)) + info = vcs.info2(top) + pkgdirurl = layout.remove_current(info["URL"]) + log.specfile_svn2rpm(pkgdirurl, spec, rev=None, submit=False, + template=None, macros=macros, exported=top, fullnames=fullnames) + rpmdefs = [("--define", expr) for expr in (topdir, builddir, rpmdir, sourcedir, specdir, srcrpmdir, patchdir)] @@ -449,6 +466,9 @@ def build_rpm(build_cmd="b", status, output = execcmd(*cmd, show=verbose, collecter=True, noerror=True) status, output = execcmd(*args + ["-b"+build_cmd], show=verbose) + if svnlog: + if os.path.isdir(specsdir): + shutil.rmtree(specsdir) def create_package(pkgdirurl, log="", verbose=0): svn = detectVCS(pkgdirurl) |