diff options
-rw-r--r-- | RepSys/commands/markrelease.py | 2 | ||||
-rw-r--r-- | RepSys/commands/sync.py | 31 | ||||
-rw-r--r-- | RepSys/rpmutil.py | 54 | ||||
-rw-r--r-- | RepSys/simplerpm.py (renamed from RepSys/rpm.py) | 0 | ||||
-rw-r--r-- | RepSys/svn.py | 2 | ||||
-rwxr-xr-x | repsys | 1 | ||||
-rw-r--r-- | repsys.spec | 2 |
7 files changed, 89 insertions, 3 deletions
diff --git a/RepSys/commands/markrelease.py b/RepSys/commands/markrelease.py index 9e52a31..440775b 100644 --- a/RepSys/commands/markrelease.py +++ b/RepSys/commands/markrelease.py @@ -9,7 +9,7 @@ # from RepSys import Error from RepSys.command import * -from RepSys.rpm import SRPM +from RepSys.simplerpm import SRPM from RepSys.rpmutil import mark_release from RepSys.util import get_auth import getopt diff --git a/RepSys/commands/sync.py b/RepSys/commands/sync.py new file mode 100644 index 0000000..42ede8d --- /dev/null +++ b/RepSys/commands/sync.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +from RepSys.command import * +from RepSys.rpmutil import sync + +HELP = """\ +Usage: repsys sync + +Will add or removed from the working copy new files added or removed +from the spec file. + +"No changes are commited." + +Options: + --dry-run Print results without changing the working copy + -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") + 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/rpmutil.py b/RepSys/rpmutil.py index 12a8226..651d19f 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -2,9 +2,10 @@ from RepSys import Error, config, RepSysTree from RepSys import mirror from RepSys.svn import SVN -from RepSys.rpm import SRPM +from RepSys.simplerpm import SRPM from RepSys.log import specfile_svn2rpm from RepSys.util import execcmd +import rpm import tempfile import shutil import glob @@ -363,6 +364,57 @@ def checkout(pkgdirurl, path=None, revision=None): print "checking out from mirror", current svn.checkout(current, path, rev=revision, show=1) +def sync(dryrun=False): + svn = SVN(noauth=True) + cwd = os.getcwd() + dirname = os.path.basename(cwd) + if dirname == "SPECS" or dirname == "SOURCES": + topdir = os.pardir + else: + topdir = "" + specsdir = os.path.join(topdir, "SPECS/") + sourcesdir = os.path.join(topdir, "SOURCES/") + for path in (specsdir, sourcesdir): + if not os.path.isdir(path): + raise Error, "%s directory not found" % path + specs = glob.glob(os.path.join(specsdir, "*.spec")) + if not specs: + raise Error, "no .spec files found in %s" % specsdir + specpath = specs[0] # FIXME better way? + try: + spec = rpm.TransactionSet().parseSpec(specpath) + except rpm.error, e: + raise Error, "could not load spec file: %s" % e + sources = [name for name, x, y in spec.sources()] + sourcesst = dict((os.path.basename(path), st) + for st, path in svn.status(sourcesdir, noignore=True)) + toadd = [] + for source in sources: + sourcepath = os.path.join(sourcesdir, source) + if sourcesst.get(source): + if os.path.isfile(sourcepath): + toadd.append(sourcepath) + else: + sys.stderr.write("warning: %s not found\n" % sourcepath) + # rm entries not found in sources and still in svn + found = os.listdir(sourcesdir) + toremove = [] + for entry in found: + if entry == ".svn": + continue + status = sourcesst.get(entry) + if status is None and entry not in sources: + path = os.path.join(sourcesdir, entry) + toremove.append(path) + for path in toremove: + print "D\t%s" % path + if not dryrun: + svn.remove(path, local=True) + for path in toadd: + print "A\t%s" % path + if not dryrun: + svn.add(path, local=True) + def commit(target=".", message=None): svn = SVN(noauth=True) info = svn.info2(target) diff --git a/RepSys/rpm.py b/RepSys/simplerpm.py index d448c5f..d448c5f 100644 --- a/RepSys/rpm.py +++ b/RepSys/simplerpm.py diff --git a/RepSys/svn.py b/RepSys/svn.py index a13db8b..b4ad4e9 100644 --- a/RepSys/svn.py +++ b/RepSys/svn.py @@ -187,6 +187,8 @@ class SVN: cmd = ["status", path] if kwargs.get("verbose"): cmd.append("-v") + if kwargs.get("noignore"): + cmd.append("--no-ignore") status, output = self._execsvn(*cmd, **kwargs) if status == 0: return [x.split() for x in output.splitlines()] @@ -12,6 +12,7 @@ Usage: repsys COMMAND [COMMAND ARGUMENTS] Useful commands: co ci + sync submit create getspec diff --git a/repsys.spec b/repsys.spec index 81e251a..edb0cf8 100644 --- a/repsys.spec +++ b/repsys.spec @@ -12,7 +12,7 @@ Buildrequires: python-devel BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRequires: python BuildRequires: python-devel -Requires: python-cheetah +Requires: python-cheetah python-rpm %description Tools for Mandriva Linux repository access and management. |