aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@gmail.com>2009-11-25 23:27:24 +0100
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-05-30 16:05:07 +0200
commitcaf97c8e8cd2b6d8a7819848888556064b403c14 (patch)
tree3b9b5cac21535771292faa3048be306e73ffb16c /MgaRepo
parentdfa7261e4f28ab48825d3ffd158ee7dcef688650 (diff)
downloadmgarepo-caf97c8e8cd2b6d8a7819848888556064b403c14.tar
mgarepo-caf97c8e8cd2b6d8a7819848888556064b403c14.tar.gz
mgarepo-caf97c8e8cd2b6d8a7819848888556064b403c14.tar.bz2
mgarepo-caf97c8e8cd2b6d8a7819848888556064b403c14.tar.xz
mgarepo-caf97c8e8cd2b6d8a7819848888556064b403c14.zip
start on a build option, creating an equivalent of 'mdvsys build'
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/commands/buildrpm.py31
-rw-r--r--MgaRepo/rpmutil.py37
2 files changed, 68 insertions, 0 deletions
diff --git a/MgaRepo/commands/buildrpm.py b/MgaRepo/commands/buildrpm.py
new file mode 100644
index 0000000..8bb681d
--- /dev/null
+++ b/MgaRepo/commands/buildrpm.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+#
+from MgaRepo import Error, config
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import build_rpm
+import tempfile
+import shutil
+from optparse import *
+import glob
+import sys
+import os
+
+HELP = """\
+Usage: repsys buildrpm [OPTIONS]
+
+Builds the binary RPM(s) (.rpm) file(s) of a given package.
+"""
+
+def parse_options():
+ parser = OptionParser(HELP)
+ parser.add_option("-b", dest="build_cmd", default="a")
+ parser.add_option("-P", dest="packager", default="")
+ parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
+ opts, args = parser.parse_args()
+ return opts
+
+def main():
+ do_command(parse_options, build_rpm)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 1b6f261..201ba0b 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -375,6 +375,43 @@ def put_srpm(srpmfile, markrelease=False, striplog=True, branch=None,
log="Copying release %s-%s to releases/ directory." %
(version, srpm.release))
+def build_rpm(build_cmd="a",
+ verbose=False,
+ packager = "",
+ macros = []):
+ top = os.getcwd()
+ topdir = "_topdir %s" % top
+ builddir = "_builddir %s/%s" % (top, "BUILD")
+ rpmdir = "_rpmdir %s/%s" % (top, "RPMS")
+ sourcedir = "_sourcedir %s/%s" % (top, "SOURCES")
+ specdir = "_specdir %s/%s" % (top, "SPECS")
+ srcrpmdir = "_srcrpmdir %s/%s" % (top, "SRPMS")
+ patchdir = "_patchdir %s/%s" % (top, "SOURCES")
+
+ build = os.path.join(top, "BUILD")
+ if not os.path.exists(build):
+ os.mkdir(build)
+ specsdir = os.path.join(top, "SPECS")
+ speclist = glob.glob(os.path.join(specsdir, "*.spec"))
+ if not speclist:
+ raise Error("no spec files found")
+ spec = speclist[0]
+
+ rpmdefs = [("--define", expr) for expr in (topdir, builddir, rpmdir,
+ sourcedir, specdir, srcrpmdir, patchdir)]
+
+ if packager:
+ rpmdefs.append(("--define", "packager %s" % packager))
+
+ rpmbuild = config.get("helper", "rpmbuild", "rpmbuild")
+ args = [rpmbuild, "-bb", spec]
+ for pair in rpmdefs:
+ args.extend(pair)
+ for pair in macros:
+ args.extend(("--define", "%s %s" % pair))
+ os.environ["LC_ALL"] = "C"
+ execcmd(*args, show=verbose)
+
def create_package(pkgdirurl, log="", verbose=0):
svn = detectVCS(pkgdirurl)
tmpdir = tempfile.mktemp()