diff options
author | Nicolas Vigier <boklm@mageia.org> | 2011-01-04 16:15:53 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2011-01-04 16:15:53 +0000 |
commit | 88a840788e82289d417983acf4b49f2c2778296d (patch) | |
tree | 2a73dbdb181d05fc5417dbc75baf6fa0a4c73ccb /RepSys/commands | |
download | mgarepo-88a840788e82289d417983acf4b49f2c2778296d.tar mgarepo-88a840788e82289d417983acf4b49f2c2778296d.tar.gz mgarepo-88a840788e82289d417983acf4b49f2c2778296d.tar.bz2 mgarepo-88a840788e82289d417983acf4b49f2c2778296d.tar.xz mgarepo-88a840788e82289d417983acf4b49f2c2778296d.zip |
fix problem with python threads on 2010.1
Diffstat (limited to 'RepSys/commands')
-rw-r--r-- | RepSys/commands/__init__.py | 0 | ||||
-rw-r--r-- | RepSys/commands/authoremail.py | 37 | ||||
-rw-r--r-- | RepSys/commands/changed.py | 41 | ||||
-rw-r--r-- | RepSys/commands/ci.py | 35 | ||||
-rw-r--r-- | RepSys/commands/co.py | 67 | ||||
-rw-r--r-- | RepSys/commands/create.py | 34 | ||||
-rw-r--r-- | RepSys/commands/del.py | 30 | ||||
-rw-r--r-- | RepSys/commands/editlog.py | 39 | ||||
-rw-r--r-- | RepSys/commands/getspec.py | 38 | ||||
-rw-r--r-- | RepSys/commands/getsrpm.py | 100 | ||||
-rw-r--r-- | RepSys/commands/log.py | 62 | ||||
-rw-r--r-- | RepSys/commands/markrelease.py | 103 | ||||
-rw-r--r-- | RepSys/commands/patchspec.py | 38 | ||||
-rw-r--r-- | RepSys/commands/putsrpm.py | 59 | ||||
-rw-r--r-- | RepSys/commands/rpmlog.py | 68 | ||||
-rw-r--r-- | RepSys/commands/submit.py | 211 | ||||
-rw-r--r-- | RepSys/commands/switch.py | 33 | ||||
-rw-r--r-- | RepSys/commands/sync.py | 38 | ||||
-rw-r--r-- | RepSys/commands/up.py | 22 | ||||
-rw-r--r-- | RepSys/commands/upload.py | 28 |
20 files changed, 1083 insertions, 0 deletions
diff --git a/RepSys/commands/__init__.py b/RepSys/commands/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/RepSys/commands/__init__.py diff --git a/RepSys/commands/authoremail.py b/RepSys/commands/authoremail.py new file mode 100644 index 0000000..f5b8b70 --- /dev/null +++ b/RepSys/commands/authoremail.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +from RepSys import Error, config +from RepSys.command import * +import sys +import getopt + +HELP = """\ +Usage: repsys authoremail [OPTIONS] AUTHOR + +Shows the e-mail of an SVN author. It is just a simple interface to access +the [authors] section of repsys.conf. + +Options: + -h Show this message + +Examples: + repsys 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/RepSys/commands/changed.py b/RepSys/commands/changed.py new file mode 100644 index 0000000..66c1a53 --- /dev/null +++ b/RepSys/commands/changed.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +from RepSys import Error, disable_mirror +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.rpmutil import check_changed +import getopt +import sys + +HELP = """\ +Usage: repsys 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: + repsys changed http://repos/svn/cnc/snapshot/foo + repsys 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/RepSys/commands/ci.py b/RepSys/commands/ci.py new file mode 100644 index 0000000..8d373b5 --- /dev/null +++ b/RepSys/commands/ci.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +from RepSys.command import * +from RepSys.rpmutil import commit + +HELP = """\ +Usage: repsys ci [TARGET] + +Will commit recent modifications in the package. + +The difference between an ordinary "svn ci" and "repsys ci" is that it +relocates the working copy to the default repository in case the option +"mirror" is set in repsys.conf. + +Options: + -h Show this message + -m MSG Use the MSG as the log message + -F FILE Read log message from FILE + +Examples: + repsys ci + repsys 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/RepSys/commands/co.py b/RepSys/commands/co.py new file mode 100644 index 0000000..81e4140 --- /dev/null +++ b/RepSys/commands/co.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +from RepSys import Error, disable_mirror +from RepSys.command import * +from RepSys.rpmutil import checkout +import getopt +import sys + +HELP = """\ +Usage: repsys co [OPTIONS] URL [LOCALPATH] + +Checkout the package source from the Mandriva 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: + repsys co pkgname + repsys co -d 2009.0 pkgname + repsys co 2009.0/pkgame + repsys co http://repos/svn/cnc/snapshot/foo + repsys 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/RepSys/commands/create.py b/RepSys/commands/create.py new file mode 100644 index 0000000..ded8abe --- /dev/null +++ b/RepSys/commands/create.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +from RepSys import Error +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.rpmutil import create_package +import getopt +import sys + +HELP = """\ +Usage: repsys create [OPTIONS] URL + +Creates the minimal structure of a package in the repository. + +Options: + -h Show this message + +Examples: + repsys create newpkg + repsys create svn+ssh://svn.mandriva.com/svn/packages/cooker/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/RepSys/commands/del.py b/RepSys/commands/del.py new file mode 100644 index 0000000..2c6902e --- /dev/null +++ b/RepSys/commands/del.py @@ -0,0 +1,30 @@ +from RepSys import Error +from RepSys.command import * +from RepSys.rpmutil import binrepo_delete + +HELP = """\ +Usage: repsys 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/RepSys/commands/editlog.py b/RepSys/commands/editlog.py new file mode 100644 index 0000000..9d1afc5 --- /dev/null +++ b/RepSys/commands/editlog.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +from RepSys import Error +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.svn import SVN +import re + +HELP = """\ +Usage: repsys editlog [OPTIONS] [URL] REVISION + +Options: + -h Show this message + +Examples: + repsys editlog 14800 + repsys 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/RepSys/commands/getspec.py b/RepSys/commands/getspec.py new file mode 100644 index 0000000..a357ef9 --- /dev/null +++ b/RepSys/commands/getspec.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +from RepSys import Error, disable_mirror +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.rpmutil import get_spec +import getopt +import sys + +HELP = """\ +Usage: repsys 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: + repsys getspec pkgname + repsys getspec svn+ssh://svn.mandriva.com/svn/packages/cooker/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/RepSys/commands/getsrpm.py b/RepSys/commands/getsrpm.py new file mode 100644 index 0000000..1767bb7 --- /dev/null +++ b/RepSys/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 RepSys import Error, config, disable_mirror +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.rpmutil import get_srpm +import tempfile +import shutil +import getopt +import glob +import sys +import os + +HELP = """\ +Usage: repsys 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: + repsys getsrpm python + repsys getsrpm -l python + repsys getsrpm http://foo.bar/svn/cnc/snapshot/python + repsys getsrpm -p http://foo.bar/svn/cnc/releases/8cl/python + repsys 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/RepSys/commands/log.py b/RepSys/commands/log.py new file mode 100644 index 0000000..28df27d --- /dev/null +++ b/RepSys/commands/log.py @@ -0,0 +1,62 @@ +#!/usr/bin/python +from RepSys import config, mirror, disable_mirror +from RepSys.command import * +from RepSys.layout import package_url, checkout_url +from RepSys.rpmutil import sync +from RepSys.util import execcmd +import sys +import os + +HELP = """\ +Usage: repsys 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: + repsys log mutt + repsys 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/RepSys/commands/markrelease.py b/RepSys/commands/markrelease.py new file mode 100644 index 0000000..057cf1d --- /dev/null +++ b/RepSys/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 RepSys import Error +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.simplerpm import SRPM +from RepSys.rpmutil import mark_release +from RepSys.util import get_auth +import getopt +import sys +import os + +HELP = """\ +*** WARNING --- You probably SHOULD NOT use this program! --- WARNING *** + +Usage: repsys 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: + repsys markrelease -r 68 -v 1.0-1 file://svn/cnc/snapshot/foo + repsys markrelease -f @68:foo-1.0-1.src.rpm file://svn/cnc/snapshot/foo + repsys 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/RepSys/commands/patchspec.py b/RepSys/commands/patchspec.py new file mode 100644 index 0000000..9a4881b --- /dev/null +++ b/RepSys/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 RepSys import Error +from RepSys.rpmutil import patch_spec +from RepSys.command import * +from RepSys.layout import package_url +import getopt +import sys + +HELP = """\ +Usage: repsys 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: + repsys 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/RepSys/commands/putsrpm.py b/RepSys/commands/putsrpm.py new file mode 100644 index 0000000..efe1a15 --- /dev/null +++ b/RepSys/commands/putsrpm.py @@ -0,0 +1,59 @@ +#!/usr/bin/python +from RepSys import Error +from RepSys.command import * +from RepSys.layout import package_url +from RepSys.rpmutil import put_srpm +import getopt +import sys, os + +HELP = """\ +Usage: repsys 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: + repsys putsrpm pkg/SRPMS/pkg-2.0-1.src.rpm + repsys 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/RepSys/commands/rpmlog.py b/RepSys/commands/rpmlog.py new file mode 100644 index 0000000..238b675 --- /dev/null +++ b/RepSys/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 RepSys import Error, layout, disable_mirror +from RepSys.command import * +from RepSys.svn import SVN +from RepSys.log import get_changelog, split_spec_changelog +from cStringIO import StringIO +import getopt +import os +import sys + +HELP = """\ +Usage: repsys 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: + repsys rpmlog python + repsys 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/RepSys/commands/submit.py b/RepSys/commands/submit.py new file mode 100644 index 0000000..2924329 --- /dev/null +++ b/RepSys/commands/submit.py @@ -0,0 +1,211 @@ +#!/usr/bin/python +from RepSys import Error, config, layout, mirror +from RepSys.svn import SVN +from RepSys.command import * +from RepSys.rpmutil import get_spec, get_submit_info +from RepSys.util import get_auth, execcmd, get_helper +import urllib +import getopt +import sys +import re +import subprocess +import uuid + +import xmlrpclib + +HELP = """\ +Usage: repsys 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: + repsys submit + repsys submit foo + repsys submit 2009.1/foo + repsys submit foo@14800 bar baz@11001 + repsys submit https://repos/svn/mdv/cooker/foo + repsys submit -l https://repos + repsys submit 2008.1/my-packages@11011 + repsys submit --define section=main/testing -t 2008.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 repsys.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 repsys 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/RepSys/commands/switch.py b/RepSys/commands/switch.py new file mode 100644 index 0000000..998ae2c --- /dev/null +++ b/RepSys/commands/switch.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +from RepSys.command import * +from RepSys.rpmutil import switch + +HELP = """\ +Usage: repsys switch [URL] + +Relocates the working copy to the base location URL. + +If URL is not provided, it will use the option repository from repsys.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 +repsys.conf. + +If the current work is based in another URL, it will use default_parent. + +Options: + -h Show this message + +Examples: + repsys switch + repsys 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/RepSys/commands/sync.py b/RepSys/commands/sync.py new file mode 100644 index 0000000..b4bdaba --- /dev/null +++ b/RepSys/commands/sync.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +from RepSys.command import * +from RepSys.rpmutil import sync + +HELP = """\ +Usage: repsys 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: + repsys 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/RepSys/commands/up.py b/RepSys/commands/up.py new file mode 100644 index 0000000..02a1a9f --- /dev/null +++ b/RepSys/commands/up.py @@ -0,0 +1,22 @@ +from RepSys import Error +from RepSys.command import * +from RepSys.rpmutil import update + +HELP = """\ +Usage: repsys 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/RepSys/commands/upload.py b/RepSys/commands/upload.py new file mode 100644 index 0000000..6af50ea --- /dev/null +++ b/RepSys/commands/upload.py @@ -0,0 +1,28 @@ +from RepSys import Error +from RepSys.command import * +from RepSys.rpmutil import upload + +HELP = """\ +Usage: repsys 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) |