diff options
author | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-03 21:03:27 +0000 |
---|---|---|
committer | Bogdano Arendartchuk <bogdano@mandriva.org> | 2007-05-03 21:03:27 +0000 |
commit | 928b0bed6fff9a002fcd10533fd1fa464e1bc10b (patch) | |
tree | 4341cb184f0d27e846b730ead9c94a9ebe38bf47 /RepSys/rpmutil.py | |
parent | 023b84f8f91df6f3062ff2992d1ebe3e94254532 (diff) | |
download | mgarepo-928b0bed6fff9a002fcd10533fd1fa464e1bc10b.tar mgarepo-928b0bed6fff9a002fcd10533fd1fa464e1bc10b.tar.gz mgarepo-928b0bed6fff9a002fcd10533fd1fa464e1bc10b.tar.bz2 mgarepo-928b0bed6fff9a002fcd10533fd1fa464e1bc10b.tar.xz mgarepo-928b0bed6fff9a002fcd10533fd1fa464e1bc10b.zip |
Added one cheap copy of the sync subcommand from mdvsys.
It required two sensitive changes:
- in order to parse the spec file, "rpm" module was used, so this is the
brand new package dependency; and
- as RepSys already had one "rpm" module, we had to rename it to
"simplerpm" in order to allow access to the module from python-rpm (I
think py2.4 is still used a lot so we can't use absolute imports)
Diffstat (limited to 'RepSys/rpmutil.py')
-rw-r--r-- | RepSys/rpmutil.py | 54 |
1 files changed, 53 insertions, 1 deletions
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) |