diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2008-02-08 00:43:26 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2008-02-08 00:43:26 +0000 |
commit | 1e929f67375b699cdcac0b1557d115eed7035ae8 (patch) | |
tree | 63dd50265afd2b2385badb46476ff607ca5e10f4 | |
parent | 5eb9f215eca3378738cddce68ce0977c6069357c (diff) | |
download | mgarepo-1e929f67375b699cdcac0b1557d115eed7035ae8.tar mgarepo-1e929f67375b699cdcac0b1557d115eed7035ae8.tar.gz mgarepo-1e929f67375b699cdcac0b1557d115eed7035ae8.tar.bz2 mgarepo-1e929f67375b699cdcac0b1557d115eed7035ae8.tar.xz mgarepo-1e929f67375b699cdcac0b1557d115eed7035ae8.zip |
Added option -d to sync, to download the missing files
It also added a configuration option download-command, in the [global]
section to define which command will be used to download. The default is
wget.
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | RepSys/commands/sync.py | 4 | ||||
-rw-r--r-- | RepSys/rpmutil.py | 31 | ||||
-rw-r--r-- | repsys-example.conf | 3 |
4 files changed, 32 insertions, 7 deletions
@@ -14,6 +14,7 @@ - if REPSYS_CONF is set, /etc/repsys.conf and ~/.repsys/config will not be readed anymore - changed the built-in template to the current default.chlog +- added option -d to repsys sync, to download the missing source files - added option -F to repsys ci to set a log message file - added option --strict to getsrpm to check if the revision provided matches the package URL; diff --git a/RepSys/commands/sync.py b/RepSys/commands/sync.py index 42ede8d..a51db22 100644 --- a/RepSys/commands/sync.py +++ b/RepSys/commands/sync.py @@ -12,6 +12,8 @@ from the spec file. Options: --dry-run Print results without changing the working copy + --download -d + Try to download the source files not found -h Show this message Examples: @@ -22,6 +24,8 @@ def parse_options(): parser = OptionParser(help=HELP) parser.add_option("--dry-run", dest="dryrun", 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] diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py index 6fae669..3bb1b50 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -9,6 +9,7 @@ from RepSys.command import default_parent import rpm import tempfile import shutil +import string import glob import sys import os @@ -409,7 +410,7 @@ def _getpkgtopdir(basedir=None): topdir = "" return topdir -def sync(dryrun=False): +def sync(dryrun=False, download=False): svn = SVN() topdir = _getpkgtopdir() # run svn info because svn st does not complain when topdir is not an @@ -429,18 +430,34 @@ def sync(dryrun=False): spec = rpm.TransactionSet().parseSpec(specpath) except rpm.error, e: raise Error, "could not load spec file: %s" % e - sources = [os.path.basename(name) - for name, no, flags in spec.sources()] - sourcesst = dict((os.path.basename(path), st) + sources = dict((os.path.basename(name), name) + for name, no, flags in spec.sources()) + sourcesst = dict((os.path.basename(path), (path, st)) for st, path in svn.status(sourcesdir, noignore=True)) toadd = [] - for source in sources: + for source, url in sources.iteritems(): sourcepath = os.path.join(sourcesdir, source) - if sourcesst.get(source): + pst = sourcesst.get(source) + if pst: if os.path.isfile(sourcepath): toadd.append(sourcepath) else: - sys.stderr.write("warning: %s not found\n" % sourcepath) + sys.stderr.write("warning: %s not found, skipping\n" % sourcepath) + elif download and not os.path.isfile(sourcepath): + print "%s not found, downloading from %s" % (sourcepath, url) + fmt = config.get("global", "download-command", + "wget -c -O '$dest' $url") + context = {"dest": sourcepath, "url": url} + try: + cmd = string.Template(fmt).substitute(context) + except KeyError, e: + raise Error, "invalid variable %r in download-command "\ + "configuration option" % e + execcmd(cmd, show=True) + if os.path.isfile(sourcepath): + toadd.append(sourcepath) + else: + raise Error, "file not found: %s" % sourcepath # rm entries not found in sources and still in svn found = os.listdir(sourcesdir) toremove = [] diff --git a/repsys-example.conf b/repsys-example.conf index 99c5d30..99c44f5 100644 --- a/repsys-example.conf +++ b/repsys-example.conf @@ -3,6 +3,9 @@ verbose = no default_parent = svn+ssh://svn.mandriva.com/svn/packages/cooker url-map = svn\+ssh://svn\.mandriva\.com/(.*) file:///\1 #tempdir = /tmp +## the command used to download files when using repsys sync -d +#download-command = wget -c -O '$dest' $url + [log] oldurl = svn+ssh://svn.mandriva.com/svn/packages/misc |