aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/commands
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2011-01-11 00:35:59 +0000
committerNicolas Vigier <boklm@mageia.org>2011-01-11 00:35:59 +0000
commitad7fb7807ceaee96521d779993a5e1b28650723f (patch)
tree2ece42aa7e83b7fdb51702b298aa3eec95da3573 /MgaRepo/commands
parent715e125cc8d0b3fc4a79752e28a8b76a4ce97d5a (diff)
downloadmgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar
mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.gz
mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.bz2
mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.tar.xz
mgarepo-ad7fb7807ceaee96521d779993a5e1b28650723f.zip
rename repsys to mgarepo, RepSys to MgaRepo, and update docs and examples for Mageia
Diffstat (limited to 'MgaRepo/commands')
-rw-r--r--MgaRepo/commands/__init__.py0
-rw-r--r--MgaRepo/commands/authoremail.py37
-rw-r--r--MgaRepo/commands/changed.py41
-rw-r--r--MgaRepo/commands/ci.py35
-rw-r--r--MgaRepo/commands/co.py67
-rw-r--r--MgaRepo/commands/create.py34
-rw-r--r--MgaRepo/commands/del.py30
-rw-r--r--MgaRepo/commands/editlog.py39
-rw-r--r--MgaRepo/commands/getspec.py38
-rw-r--r--MgaRepo/commands/getsrpm.py100
-rw-r--r--MgaRepo/commands/log.py62
-rw-r--r--MgaRepo/commands/markrelease.py103
-rw-r--r--MgaRepo/commands/patchspec.py38
-rw-r--r--MgaRepo/commands/putsrpm.py59
-rw-r--r--MgaRepo/commands/rpmlog.py68
-rw-r--r--MgaRepo/commands/submit.py211
-rw-r--r--MgaRepo/commands/switch.py33
-rw-r--r--MgaRepo/commands/sync.py38
-rw-r--r--MgaRepo/commands/up.py22
-rw-r--r--MgaRepo/commands/upload.py28
20 files changed, 1083 insertions, 0 deletions
diff --git a/MgaRepo/commands/__init__.py b/MgaRepo/commands/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MgaRepo/commands/__init__.py
diff --git a/MgaRepo/commands/authoremail.py b/MgaRepo/commands/authoremail.py
new file mode 100644
index 0000000..edfe332
--- /dev/null
+++ b/MgaRepo/commands/authoremail.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+from MgaRepo import Error, config
+from MgaRepo.command import *
+import sys
+import getopt
+
+HELP = """\
+Usage: mgarepo authoremail [OPTIONS] AUTHOR
+
+Shows the e-mail of an SVN author. It is just a simple interface to access
+the [authors] section of mgarepo.conf.
+
+Options:
+ -h Show this message
+
+Examples:
+ mgarepo authoremail john
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.author = args[0]
+ return opts
+
+def print_author_email(author):
+ email = config.get("users", author)
+ if not email:
+ raise Error, "author not found"
+ print email
+
+def main():
+ do_command(parse_options, print_author_email)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/changed.py b/MgaRepo/commands/changed.py
new file mode 100644
index 0000000..a17226b
--- /dev/null
+++ b/MgaRepo/commands/changed.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+from MgaRepo import Error, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import check_changed
+import getopt
+import sys
+
+HELP = """\
+Usage: mgarepo changed [OPTIONS] URL
+
+Shows if there are pending changes since the last package release.
+
+Options:
+ -a Check all packages in given URL
+ -s Show differences
+ -M Do not use the mirror (use the main repository)
+ -h Show this message
+
+Examples:
+ mgarepo changed http://repos/svn/cnc/snapshot/foo
+ mgarepo changed -a http://repos/svn/cnc/snapshot
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-a", dest="all", action="store_true")
+ parser.add_option("-s", dest="show", action="store_true")
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(args[0])
+ opts.verbose = 1 # Unconfigurable
+ return opts
+
+def main():
+ do_command(parse_options, check_changed)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/ci.py b/MgaRepo/commands/ci.py
new file mode 100644
index 0000000..e64ac4e
--- /dev/null
+++ b/MgaRepo/commands/ci.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+from MgaRepo.command import *
+from MgaRepo.rpmutil import commit
+
+HELP = """\
+Usage: mgarepo ci [TARGET]
+
+Will commit recent modifications in the package.
+
+The difference between an ordinary "svn ci" and "mgarepo ci" is that it
+relocates the working copy to the default repository in case the option
+"mirror" is set in mgarepo.conf.
+
+Options:
+ -h Show this message
+ -m MSG Use the MSG as the log message
+ -F FILE Read log message from FILE
+
+Examples:
+ mgarepo ci
+ mgarepo ci SPECS/package.spec SPECS/package-patch.patch
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-m", dest="message", default=None)
+ parser.add_option("-F", dest="logfile", type="string",
+ default=None)
+ opts, args = parser.parse_args()
+ if len(args):
+ opts.target = args[0]
+ return opts
+
+def main():
+ do_command(parse_options, commit)
diff --git a/MgaRepo/commands/co.py b/MgaRepo/commands/co.py
new file mode 100644
index 0000000..e7c9aec
--- /dev/null
+++ b/MgaRepo/commands/co.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+from MgaRepo import Error, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.rpmutil import checkout
+import getopt
+import sys
+
+HELP = """\
+Usage: mgarepo co [OPTIONS] URL [LOCALPATH]
+
+Checkout the package source from the Mageia repository.
+
+If the 'mirror' option is enabled, the package is obtained from the mirror
+repository.
+
+You can specify the distro branch to checkout from by using distro/pkgname.
+
+Options:
+ -d The distribution branch to checkout from
+ -b The package branch
+ -r REV Revision to checkout
+ -S Do not download sources from the binaries repository
+ -L Do not make symlinks of the binaries downloaded in SOURCES/
+ -s Only checkout the SPECS/ directory
+ -M Do not use the mirror (use the main repository)
+ --check Check integrity of files fetched from the binary repository
+ -h Show this message
+
+Examples:
+ mgarepo co pkgname
+ mgarepo co -d 2009.0 pkgname
+ mgarepo co 2009.0/pkgame
+ mgarepo co http://repos/svn/cnc/snapshot/foo
+ mgarepo co http://repos/svn/cnc/snapshot/foo foo-pkg
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-r", dest="revision")
+ parser.add_option("-S", dest="use_binrepo", default=True,
+ action="store_false")
+ parser.add_option("--check", dest="binrepo_check", default=False,
+ action="store_true")
+ parser.add_option("-L", dest="binrepo_link", default=True,
+ action="store_false")
+ parser.add_option("--distribution", "-d", dest="distro", default=None)
+ parser.add_option("--branch", "-b", dest="branch", default=None)
+ parser.add_option("-s", "--spec", dest="spec", default=False,
+ action="store_true")
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ opts, args = parser.parse_args()
+ if len(args) not in (1, 2):
+ raise Error, "invalid arguments"
+ # here we don't use package_url in order to notify the user we are
+ # using the mirror
+ opts.pkgdirurl = args[0]
+ if len(args) == 2:
+ opts.path = args[1]
+ else:
+ opts.path = None
+ return opts
+
+def main():
+ do_command(parse_options, checkout)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/create.py b/MgaRepo/commands/create.py
new file mode 100644
index 0000000..da8f16c
--- /dev/null
+++ b/MgaRepo/commands/create.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import create_package
+import getopt
+import sys
+
+HELP = """\
+Usage: mgarepo create [OPTIONS] URL
+
+Creates the minimal structure of a package in the repository.
+
+Options:
+ -h Show this message
+
+Examples:
+ mgarepo create newpkg
+ mgarepo create svn+ssh://svn.mageia.org/svn/packages/cauldron/newpkg
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(args[0], mirrored=False)
+ opts.verbose = 1 # Unconfigurable
+ return opts
+
+def main():
+ do_command(parse_options, create_package)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/del.py b/MgaRepo/commands/del.py
new file mode 100644
index 0000000..79d9d3f
--- /dev/null
+++ b/MgaRepo/commands/del.py
@@ -0,0 +1,30 @@
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.rpmutil import binrepo_delete
+
+HELP = """\
+Usage: mgarepo del [OPTIONS] [PATH]
+
+Remove a given file from the binary sources repository.
+
+Changes in the sources file will be left uncommited.
+
+Options:
+ -c automatically commit the 'sources' file
+ -h help
+
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-c", dest="commit", default=False,
+ action="store_true")
+ opts, args = parser.parse_args()
+ if len(args):
+ opts.paths = args
+ else:
+ raise Error, "you need to provide a path"
+ return opts
+
+def main():
+ do_command(parse_options, binrepo_delete)
diff --git a/MgaRepo/commands/editlog.py b/MgaRepo/commands/editlog.py
new file mode 100644
index 0000000..c58c16b
--- /dev/null
+++ b/MgaRepo/commands/editlog.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.svn import SVN
+import re
+
+HELP = """\
+Usage: mgarepo editlog [OPTIONS] [URL] REVISION
+
+Options:
+ -h Show this message
+
+Examples:
+ mgarepo editlog 14800
+ mgarepo editlog https://repos/svn/cnc/snapshot 14800
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args) == 2:
+ pkgdirurl, revision = args
+ elif len(args) == 1:
+ pkgdirurl, revision = "", args[0]
+ else:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(pkgdirurl, mirrored=False)
+ opts.revision = re.compile(r".*?(\d+).*").sub(r"\1", revision)
+ return opts
+
+def editlog(pkgdirurl, revision):
+ svn = SVN()
+ svn.propedit("svn:log", pkgdirurl, rev=revision)
+
+def main():
+ do_command(parse_options, editlog)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/getspec.py b/MgaRepo/commands/getspec.py
new file mode 100644
index 0000000..08407bc
--- /dev/null
+++ b/MgaRepo/commands/getspec.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+from MgaRepo import Error, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import get_spec
+import getopt
+import sys
+
+HELP = """\
+Usage: mgarepo getspec [OPTIONS] REPPKGURL
+
+Prints the .spec file of a given package.
+
+Options:
+ -t DIR Use DIR as target for spec file (default is ".")
+ -M Do not use the mirror (use the main repository)
+ -h Show this message
+
+Examples:
+ mgarepo getspec pkgname
+ mgarepo getspec svn+ssh://svn.mageia.org/svn/packages/cauldron/pkgname
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-t", dest="targetdir", default=".")
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(args[0])
+ return opts
+
+def main():
+ do_command(parse_options, get_spec)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/getsrpm.py b/MgaRepo/commands/getsrpm.py
new file mode 100644
index 0000000..6c238ba
--- /dev/null
+++ b/MgaRepo/commands/getsrpm.py
@@ -0,0 +1,100 @@
+#!/usr/bin/python
+#
+# This program will extract given version/revision of the named package
+# from the Conectiva Linux repository system.
+#
+from MgaRepo import Error, config, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import get_srpm
+import tempfile
+import shutil
+import getopt
+import glob
+import sys
+import os
+
+HELP = """\
+Usage: mgarepo getsrpm [OPTIONS] REPPKGURL
+
+Generates the source RPM (.srpm) file of a given package.
+
+Options:
+ -c Use files in current/ directory (default)
+ -p Use files in pristine/ directory
+ -v VER Use files from the version specified by VER (e.g. 2.2.1-2cl)
+ -r REV Use files from current directory, in revision REV (e.g. 1001)
+ -t DIR Put SRPM file in directory DIR when done (default is ".")
+ -P USER Define the RPM packager inforamtion to USER
+ -s FILE Run script with "FILE TOPDIR SPECFILE" command
+ -n Rename the package to include the revision number
+ -l Use subversion log to build rpm %changelog
+ -T FILE Template to be used to generate the %changelog
+ -M Do not use the mirror (use the main repository)
+ -h Show this message
+ -S Do not download sources from the binary repository
+ --check Check integrity of files fetched from the binary repository
+ --strict Check if the given revision contains changes in REPPKGURL
+
+Examples:
+ mgarepo getsrpm python
+ mgarepo getsrpm -l python
+ mgarepo getsrpm http://foo.bar/svn/cnc/snapshot/python
+ mgarepo getsrpm -p http://foo.bar/svn/cnc/releases/8cl/python
+ mgarepo getsrpm -r 1001 file:///svn/cnc/snapshot/python
+"""
+
+def mode_callback(option, opt, val, parser, mode):
+ opts = parser.values
+ opts.mode = mode
+ if mode == "version":
+ try:
+ opts.version, opts.release = val.split("-", 1)
+ except ValueError:
+ raise Error, "wrong version, use something like 2.2-1mdk"
+ elif mode == "revision":
+ opts.revision = val
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["mode"] = "current"
+ parser.defaults["version"] = None
+ parser.defaults["release"] = None
+ parser.defaults["revision"] = None
+ parser.defaults["submit"] = False
+ callback_options = dict(action="callback", callback=mode_callback,
+ type="string", dest="__ignore")
+ parser.add_option("-c", callback_kwargs={"mode": "current"}, nargs=0,
+ **callback_options)
+ parser.add_option("-p", callback_kwargs={"mode": "pristine"}, nargs=0,
+ **callback_options)
+ parser.add_option("-r", callback_kwargs={"mode": "revision"}, nargs=1,
+ **callback_options)
+ parser.add_option("-v", callback_kwargs={"mode": "version"}, nargs=1,
+ **callback_options)
+ parser.add_option("-t", dest="targetdirs", action="append", default=[])
+ parser.add_option("-s", dest="scripts", action="append", default=[])
+ parser.add_option("-P", dest="packager", default="")
+ parser.add_option("-n", dest="revname", action="store_true")
+ parser.add_option("-l", dest="svnlog", action="store_true")
+ parser.add_option("-T", dest="template", type="string", default=None)
+ parser.add_option("-S", dest="use_binrepo", default=True,
+ action="store_false")
+ parser.add_option("--check", dest="binrepo_check", default=False,
+ action="store_true")
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ parser.add_option("--strict", dest="strict", default=False,
+ action="store_true")
+ opts, args = parser.parse_args()
+ del opts.__ignore
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(args[0])
+ opts.verbose = 1
+ return opts
+
+def main():
+ do_command(parse_options, get_srpm)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/log.py b/MgaRepo/commands/log.py
new file mode 100644
index 0000000..69058b9
--- /dev/null
+++ b/MgaRepo/commands/log.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+from MgaRepo import config, mirror, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.layout import package_url, checkout_url
+from MgaRepo.rpmutil import sync
+from MgaRepo.util import execcmd
+import sys
+import os
+
+HELP = """\
+Usage: mgarepo log [OPTIONS] [PACKAGE]
+
+Shows the SVN log for a given package.
+
+Options:
+ -h Show this message
+ -v Show changed paths
+ -l LIMIT Limit of log entries to show
+ -r REV Show a specific revision
+ -M Do not use the mirror (use the main repository)
+
+Examples:
+ mgarepo log mutt
+ mgarepo log 2009.1/mutt
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-v", dest="verbose", action="store_true",
+ default=False)
+ parser.add_option("-l", "--limit", dest="limit", type="int",
+ default=None)
+ parser.add_option("-r", dest="revision", type="string", default=None)
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ opts, args = parser.parse_args()
+ if len(args):
+ opts.pkgdirurl = package_url(args[0])
+ else:
+ parser.error("log requires a package name")
+ return opts
+
+def svn_log(pkgdirurl, verbose=False, limit=None, revision=None):
+ mirror.info(pkgdirurl)
+ url = checkout_url(pkgdirurl)
+ svncmd = config.get("global", "svn-command", "svn")
+ args = [svncmd, "log", url]
+ if verbose:
+ args.append("-v")
+ if limit:
+ args.append("-l")
+ args.append(limit)
+ if revision:
+ args.append("-r")
+ args.append(revision)
+ if os.isatty(sys.stdin.fileno()):
+ args.append("| less")
+ rawcmd = " ".join(args)
+ execcmd(rawcmd, show=True)
+
+def main():
+ do_command(parse_options, svn_log)
diff --git a/MgaRepo/commands/markrelease.py b/MgaRepo/commands/markrelease.py
new file mode 100644
index 0000000..857d38d
--- /dev/null
+++ b/MgaRepo/commands/markrelease.py
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+#
+# This program will append a release to the Conectiva Linux package
+# repository system. It's meant to be a startup system to include
+# pre-packaged SRPMS in the repository, thus, you should not commit
+# packages over an ongoing package structure (with changes in current/
+# directory and etc). Also, notice that packages must be included in
+# cronological order.
+#
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.simplerpm import SRPM
+from MgaRepo.rpmutil import mark_release
+from MgaRepo.util import get_auth
+import getopt
+import sys
+import os
+
+HELP = """\
+*** WARNING --- You probably SHOULD NOT use this program! --- WARNING ***
+
+Usage: mgarepo markrelease [OPTIONS] REPPKGURL
+
+This subcommand creates a 'tag' for a given revision of a given package.
+
+The tag will be stored in the directory releases/ inside the package
+structure.
+
+Options:
+ -f FILE Try to extract information from given file
+ -r REV Revision which will be used to make the release copy tag
+ -v VER Version which will be used to make the release copy tag
+ -n Append package name to provided URL
+ -h Show this message
+
+Examples:
+ mgarepo markrelease -r 68 -v 1.0-1 file://svn/cnc/snapshot/foo
+ mgarepo markrelease -f @68:foo-1.0-1.src.rpm file://svn/cnc/snapshot/foo
+ mgarepo markrelease -r 68 -f foo-1.0.src.rpm file://svn/cnc/snapshot/foo
+"""
+
+def version_callback(option, opt, val, parser):
+ opts = parser.values
+ try:
+ opts.version, opts.release = val.split("-", 1)
+ except ValueError:
+ raise Error, "wrong version, use something like 1:2.2-1mdk"
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["version"] = None
+ parser.defaults["release"] = None
+ parser.add_option("-v", action="callback", callback=version_callback,
+ nargs=1, type="string", dest="__ignore")
+ parser.add_option("-r", dest="revision")
+ parser.add_option("-f", dest="filename")
+ parser.add_option("-n", dest="appendname", action="store_true")
+ opts, args = parser.parse_args()
+
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+
+ opts.pkgdirurl = package_url(args[0], mirrored=False)
+
+ filename = opts.filename
+ appendname = opts.appendname
+ del opts.filename, opts.appendname, opts.__ignore
+
+ if filename:
+ if not os.path.isfile(filename):
+ raise Error, "file not found: "+filename
+ if not opts.revision:
+ basename = os.path.basename(filename)
+ end = basename.find(":")
+ if basename[0] != "@" or end == -1:
+ raise Error, "couldn't guess revision from filename"
+ opts.revision = basename[1:end]
+ srpm = None
+ if not opts.version:
+ srpm = SRPM(filename)
+ if srpm.epoch:
+ opts.version = "%s:%s" % (srpm.epoch, srpm.version)
+ else:
+ opts.version = srpm.version
+ opts.release = srpm.release
+ if appendname:
+ if not srpm:
+ srpm = SRPM(filename)
+ opts.pkgdirurl = "/".join([opts.pkgdirurl, srpm.name])
+ elif appendname:
+ raise Error, "option -n requires option -f"
+ elif not opts.revision:
+ raise Error, "no revision provided"
+ elif not opts.version:
+ raise Error, "no version provided"
+ #get_auth()
+ return opts
+
+def main():
+ do_command(parse_options, mark_release)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/patchspec.py b/MgaRepo/commands/patchspec.py
new file mode 100644
index 0000000..9a5811c
--- /dev/null
+++ b/MgaRepo/commands/patchspec.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+#
+# This program will try to patch a spec file from a given package url.
+#
+from MgaRepo import Error
+from MgaRepo.rpmutil import patch_spec
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+import getopt
+import sys
+
+HELP = """\
+Usage: mgarepo patchspec [OPTIONS] REPPKGURL PATCHFILE
+
+It will try to patch a spec file from a given package url.
+
+Options:
+ -l LOG Use LOG as log message
+ -h Show this message
+
+Examples:
+ mgarepo patchspec http://repos/svn/cnc/snapshot/foo
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-l", dest="log", default="")
+ opts, args = parser.parse_args()
+ if len(args) != 2:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = package_url(args[0], mirrored=False)
+ opts.patchfile = args[1]
+ return opts
+
+def main():
+ do_command(parse_options, patch_spec)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/putsrpm.py b/MgaRepo/commands/putsrpm.py
new file mode 100644
index 0000000..68d87d0
--- /dev/null
+++ b/MgaRepo/commands/putsrpm.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.layout import package_url
+from MgaRepo.rpmutil import put_srpm
+import getopt
+import sys, os
+
+HELP = """\
+Usage: mgarepo putsrpm [OPTIONS] SOURCERPMS
+
+Will import source RPMs into the SVN repository.
+
+If the package was already imported, it will add the new files and remove
+those not present in the source RPM.
+
+Options:
+ -m LOG Log message used when commiting changes
+ -t Create version-release tag on releases/
+ -b NAME The distribution branch to place it
+ -d URL The URL of base directory where packages will be placed
+ -c URL The URL of the base directory where the changelog will be
+ placed
+ -s Don't strip the changelog from the spec
+ (nor import it into misc/)
+ -n Don't try to rename the spec file
+ -h Show this message
+
+Examples:
+ mgarepo putsrpm pkg/SRPMS/pkg-2.0-1.src.rpm
+ mgarepo putsrpm -b 2009.1 foo-1.1-1.src.rpm
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-l", dest="logmsg", default="")
+ parser.add_option("-t", dest="markrelease", action="store_true",
+ default=False)
+ parser.add_option("-s", dest="striplog", action="store_false",
+ default=True)
+ parser.add_option("-b", dest="branch", type="string", default=None)
+ parser.add_option("-d", dest="baseurl", type="string", default=None)
+ parser.add_option("-c", dest="baseold", type="string", default=None)
+ parser.add_option("-n", dest="rename", action="store_false",
+ default=True)
+ opts, args = parser.parse_args()
+ opts.srpmfiles = args
+ return opts
+
+def put_srpm_cmd(srpmfiles, markrelease=False, striplog=True, branch=None,
+ baseurl=None, baseold=None, logmsg=None, rename=False):
+ for path in srpmfiles:
+ put_srpm(path, markrelease, striplog, branch, baseurl, baseold,
+ logmsg, rename)
+
+def main():
+ do_command(parse_options, put_srpm_cmd)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/rpmlog.py b/MgaRepo/commands/rpmlog.py
new file mode 100644
index 0000000..ae8997d
--- /dev/null
+++ b/MgaRepo/commands/rpmlog.py
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+#
+# This program will convert the output of "svn log" to be suitable
+# for usage in an rpm %changelog session.
+#
+from MgaRepo import Error, layout, disable_mirror
+from MgaRepo.command import *
+from MgaRepo.svn import SVN
+from MgaRepo.log import get_changelog, split_spec_changelog
+from cStringIO import StringIO
+import getopt
+import os
+import sys
+
+HELP = """\
+Usage: mgarepo rpmlog [OPTIONS] REPPKGDIRURL
+
+Prints the RPM changelog of a given package.
+
+Options:
+ -r REV Collect logs from given revision to revision 0
+ -n NUM Output only last NUM entries
+ -T FILE %changelog template file to be used
+ -o Append old package changelog
+ -p Append changelog found in .spec file
+ -s Sort changelog entries, even from the old log
+ -M Do not use the mirror (use the main repository)
+ -h Show this message
+
+Examples:
+ mgarepo rpmlog python
+ mgarepo rpmlog http://svn.mandriva.com/svn/packages/cooker/python
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("-r", dest="revision")
+ parser.add_option("-n", dest="size", type="int")
+ parser.add_option("-T", "--template", dest="template", type="string")
+ parser.add_option("-o", dest="oldlog", default=False,
+ action="store_true")
+ parser.add_option("-p", dest="usespec", default=False,
+ action="store_true")
+ parser.add_option("-s", dest="sort", default=False,
+ action="store_true")
+ parser.add_option("-M", "--no-mirror", action="callback",
+ callback=disable_mirror)
+ opts, args = parser.parse_args()
+ if len(args) != 1:
+ raise Error, "invalid arguments"
+ opts.pkgdirurl = layout.package_url(args[0])
+ return opts
+
+def rpmlog(pkgdirurl, revision, size, template, oldlog, usespec, sort):
+ another = None
+ if usespec:
+ svn = SVN()
+ specurl = layout.package_spec_url(pkgdirurl)
+ rawspec = svn.cat(specurl, rev=revision)
+ spec, another = split_spec_changelog(StringIO(rawspec))
+ newlog = get_changelog(pkgdirurl, another=another, rev=revision,
+ size=size, sort=sort, template=template, oldlog=oldlog)
+ sys.stdout.writelines(newlog)
+
+def main():
+ do_command(parse_options, rpmlog)
+
+# vim:sw=4:ts=4:et
diff --git a/MgaRepo/commands/submit.py b/MgaRepo/commands/submit.py
new file mode 100644
index 0000000..79afd21
--- /dev/null
+++ b/MgaRepo/commands/submit.py
@@ -0,0 +1,211 @@
+#!/usr/bin/python
+from MgaRepo import Error, config, layout, mirror
+from MgaRepo.svn import SVN
+from MgaRepo.command import *
+from MgaRepo.rpmutil import get_spec, get_submit_info
+from MgaRepo.util import get_auth, execcmd, get_helper
+import urllib
+import getopt
+import sys
+import re
+import subprocess
+import uuid
+
+import xmlrpclib
+
+HELP = """\
+Usage: mgarepo submit [OPTIONS] [URL[@REVISION] ...]
+
+Submits the package from URL to the submit host.
+
+The submit host will try to build the package, and upon successful
+completion will 'tag' the package and upload it to the official
+repositories.
+
+The package name can refer to an alias to a group of packages defined in
+the section submit-groups of the configuration file.
+
+The status of the submit can visualized at:
+
+http://kenobi.mandriva.com/bs/output.php
+
+If no URL and revision are specified, the latest changed revision in the
+package working copy of the current directory will be used.
+
+Options:
+ -t TARGET Submit given package URL to given target
+ -l Just list available targets
+ -r REV Provides a revision number (when not providing as an
+ argument)
+ -s The host in which the package URL will be submitted
+ (defaults to the host in the URL)
+ -a Submit all URLs at once (depends on server-side support)
+ -i SID Use the submit identifier SID
+ -h Show this message
+ --distro The distribution branch where the packages come from
+ --define Defines one variable to be used by the submit scripts
+ in the submit host
+
+Examples:
+ mgarepo submit
+ mgarepo submit foo
+ mgarepo submit 1/foo
+ mgarepo submit foo@14800 bar baz@11001
+ mgarepo submit https://repos/svn/mga/cauldron/foo
+ mgarepo submit -l https://repos
+ mgarepo submit 1/my-packages@11011
+ mgarepo submit --define section=core/testing -t 1
+"""
+
+DEFAULT_TARGET = "Cooker"
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.defaults["revision"] = None
+ parser.add_option("-t", dest="target", default=None)
+ parser.add_option("-l", action="callback", callback=list_targets)
+ parser.add_option("-r", dest="revision", type="string", nargs=1)
+ parser.add_option("-s", dest="submithost", type="string", nargs=1,
+ default=None)
+ parser.add_option("-i", dest="sid", type="string", nargs=1,
+ default=None)
+ parser.add_option("-a", dest="atonce", action="store_true", default=False)
+ parser.add_option("--distro", dest="distro", type="string",
+ default=None)
+ parser.add_option("--define", action="append", default=[])
+ opts, args = parser.parse_args()
+ if not args:
+ name, url, rev = get_submit_info(".")
+ args = ["%s@%s" % (url, str(rev))]
+ print "Submitting %s at revision %s" % (name, rev)
+ print "URL: %s" % url
+ if opts.revision is not None:
+ # backwards compatibility with the old -r usage
+ if len(args) == 1:
+ args[0] = args[0] + "@" + opts.revision
+ else:
+ raise Error, "can't use -r REV with more than one package name"
+ del opts.revision
+ if len(args) == 2:
+ # prevent from using the old <name> <rev> syntax
+ try:
+ rev = int(args[1])
+ except ValueError:
+ # ok, it is a package name, let it pass
+ pass
+ else:
+ raise Error, "the format <name> <revision> is deprecated, "\
+ "use <name>@<revision> instead"
+ # expand group aliases
+ expanded = []
+ for nameurl in args:
+ expanded.extend(expand_group(nameurl))
+ if expanded != args:
+ print "Submitting: %s" % " ".join(expanded)
+ args = expanded
+ # generate URLs for package names:
+ opts.urls = [mirror.strip_username(
+ layout.package_url(nameurl, distro=opts.distro, mirrored=False))
+ for nameurl in args]
+ # find the revision if not specified:
+ newurls = []
+ for url in opts.urls:
+ if not "@" in url:
+ print "Fetching revision..."
+ courl = layout.checkout_url(url)
+ log = SVN().log(courl, limit=1)
+ if not log:
+ raise Error, "can't find a revision for %s" % courl
+ ci = log[0]
+ print "URL:", url
+ print "Commit:",
+ print "%d | %s" % (ci.revision, ci.author),
+ if ci.lines:
+ line = " ".join(ci.lines).strip()
+ if len(line) > 57:
+ line = line[:57] + "..."
+ print "| %s" % line,
+ print
+ url = url + "@" + str(ci.revision)
+ newurls.append(url)
+ opts.urls[:] = newurls
+ # choose a target if not specified:
+ if opts.target is None and opts.distro is None:
+ target = layout.distro_branch(opts.urls[0]) or DEFAULT_TARGET
+ print "Implicit target: %s" % target
+ opts.target = target
+ del opts.distro
+ return opts
+
+def expand_group(group):
+ name, rev = layout.split_url_revision(group)
+ distro = None
+ if "/" in name:
+ distro, name = name.rsplit("/", 1)
+ found = config.get("submit-groups", name)
+ packages = [group]
+ if found:
+ packages = found.split()
+ if rev:
+ packages = [("%s@%s" % (package, rev))
+ for package in packages]
+ if distro:
+ packages = ["%s/%s" % (distro, package)
+ for package in packages]
+ return packages
+
+def list_targets(option, opt, val, parser):
+ host = config.get("submit", "host")
+ if host is None:
+ raise Error, "no submit host defined in mgarepo.conf"
+ createsrpm = get_helper("create-srpm")
+ #TODO make it configurable
+ command = "ssh %s %s --list" % (host, createsrpm)
+ execcmd(command, show=True)
+ sys.exit(0)
+
+def submit(urls, target, define=[], submithost=None, atonce=False, sid=None):
+ if submithost is None:
+ submithost = config.get("submit", "host")
+ if submithost is None:
+ # extract the submit host from the svn host
+ type, rest = urllib.splittype(pkgdirurl)
+ host, path = urllib.splithost(rest)
+ user, host = urllib.splituser(host)
+ submithost, port = urllib.splitport(host)
+ del type, user, port, path, rest
+ # runs a create-srpm in the server through ssh, which will make a
+ # copy of the rpm in the export directory
+ createsrpm = get_helper("create-srpm")
+ baseargs = ["ssh", submithost, createsrpm, "-t", target]
+ if not sid:
+ sid = uuid.uuid4()
+ define.append("sid=%s" % sid)
+ for entry in reversed(define):
+ baseargs.append("--define")
+ baseargs.append(entry)
+ cmdsargs = []
+ if len(urls) == 1:
+ # be compatible with server-side mgarepo versions older than 1.6.90
+ url, rev = layout.split_url_revision(urls[0])
+ baseargs.append("-r")
+ baseargs.append(str(rev))
+ baseargs.append(url)
+ cmdsargs.append(baseargs)
+ elif atonce:
+ cmdsargs.append(baseargs + urls)
+ else:
+ cmdsargs.extend((baseargs + [url]) for url in urls)
+ for cmdargs in cmdsargs:
+ command = subprocess.list2cmdline(cmdargs)
+ status, output = execcmd(command)
+ if status == 0:
+ print "Package submitted!"
+ else:
+ sys.stderr.write(output)
+ sys.exit(status)
+
+def main():
+ do_command(parse_options, submit)
+
+# vim:et:ts=4:sw=4
diff --git a/MgaRepo/commands/switch.py b/MgaRepo/commands/switch.py
new file mode 100644
index 0000000..ccca76e
--- /dev/null
+++ b/MgaRepo/commands/switch.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+from MgaRepo.command import *
+from MgaRepo.rpmutil import switch
+
+HELP = """\
+Usage: mgarepo switch [URL]
+
+Relocates the working copy to the base location URL.
+
+If URL is not provided, it will use the option repository from mgarepo.conf
+as default, or, if the current working copy is already based in
+default_parent, it will use the location from the mirror option from
+mgarepo.conf.
+
+If the current work is based in another URL, it will use default_parent.
+
+Options:
+ -h Show this message
+
+Examples:
+ mgarepo switch
+ mgarepo switch https://mirrors.localnetwork/svn/packages/
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if len(args):
+ opts.mirrorurl = args[0]
+ return opts
+
+def main():
+ do_command(parse_options, switch)
diff --git a/MgaRepo/commands/sync.py b/MgaRepo/commands/sync.py
new file mode 100644
index 0000000..1198f3f
--- /dev/null
+++ b/MgaRepo/commands/sync.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+from MgaRepo.command import *
+from MgaRepo.rpmutil import sync
+
+HELP = """\
+Usage: mgarepo sync
+
+Will add or remove from the working copy those files added or removed
+in the spec file.
+
+It will not commit the changes.
+
+Options:
+ -c Commit the changes, as in ci
+ --dry-run Print results without changing the working copy
+ --download -d
+ Try to download the source files not found
+ -h Show this message
+
+Examples:
+ mgarepo sync
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ parser.add_option("--dry-run", dest="dryrun", default=False,
+ action="store_true")
+ parser.add_option("-c", dest="ci", default=False,
+ action="store_true")
+ parser.add_option("-d", "--download", dest="download", default=False,
+ action="store_true")
+ opts, args = parser.parse_args()
+ if len(args):
+ opts.target = args[0]
+ return opts
+
+def main():
+ do_command(parse_options, sync)
diff --git a/MgaRepo/commands/up.py b/MgaRepo/commands/up.py
new file mode 100644
index 0000000..646a79f
--- /dev/null
+++ b/MgaRepo/commands/up.py
@@ -0,0 +1,22 @@
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.rpmutil import update
+
+HELP = """\
+Usage: mgarepo up [PATH]
+
+Update the package working copy and synchronize all binaries.
+
+Options:
+ -h help
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ if args:
+ opts.target = args[0]
+ return opts
+
+def main():
+ do_command(parse_options, update)
diff --git a/MgaRepo/commands/upload.py b/MgaRepo/commands/upload.py
new file mode 100644
index 0000000..dfcae5d
--- /dev/null
+++ b/MgaRepo/commands/upload.py
@@ -0,0 +1,28 @@
+from MgaRepo import Error
+from MgaRepo.command import *
+from MgaRepo.rpmutil import upload
+
+HELP = """\
+Usage: mgarepo upload [OPTIONS] [PATH]
+
+Upload a given file to the binary sources repository.
+
+It will also update the contents of the 'binrepo.lst' file and leave it
+uncommited.
+
+If the path is a directory, all the contents of the directory will be
+uploaded or removed.
+
+Options:
+ -h help
+
+"""
+
+def parse_options():
+ parser = OptionParser(help=HELP)
+ opts, args = parser.parse_args()
+ opts.paths = args
+ return opts
+
+def main():
+ do_command(parse_options, upload)