aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/rpmutil.py
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2009-02-17 14:16:49 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2009-02-17 14:16:49 +0000
commit9f4c06f203f16c43f1becd55fb6590e2ff18b8c6 (patch)
treedff78d3932f0912f97b8bfae35faed25ace50be5 /RepSys/rpmutil.py
parent3a7d4937f2fbd7b80f0762258380c82e1cbffe13 (diff)
downloadmgarepo-9f4c06f203f16c43f1becd55fb6590e2ff18b8c6.tar
mgarepo-9f4c06f203f16c43f1becd55fb6590e2ff18b8c6.tar.gz
mgarepo-9f4c06f203f16c43f1becd55fb6590e2ff18b8c6.tar.bz2
mgarepo-9f4c06f203f16c43f1becd55fb6590e2ff18b8c6.tar.xz
mgarepo-9f4c06f203f16c43f1becd55fb6590e2ff18b8c6.zip
Make putsrpm rename the spec file to package-name.spec
Added command line option -n to disable it.
Diffstat (limited to 'RepSys/rpmutil.py')
-rw-r--r--RepSys/rpmutil.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py
index 0ca6bdb..c67c17e 100644
--- a/RepSys/rpmutil.py
+++ b/RepSys/rpmutil.py
@@ -171,7 +171,7 @@ def patch_spec(pkgdirurl, patchfile, log=""):
shutil.rmtree(tmpdir)
def put_srpm(srpmfile, markrelease=False, striplog=True, branch=None,
- baseurl=None, baseold=None, logmsg=None):
+ baseurl=None, baseold=None, logmsg=None, rename=True):
svn = SVN()
srpm = SRPM(srpmfile)
tmpdir = tempfile.mktemp()
@@ -258,14 +258,34 @@ def put_srpm(srpmfile, markrelease=False, striplog=True, branch=None,
if os.path.isdir(unpackdir):
shutil.rmtree(unpackdir)
+ specs = glob.glob(os.path.join(specsdir, "*.spec"))
+ if not specs:
+ raise Error, "no spec file found on %s" % specsdir
+ if len(specs) > 1:
+ raise Error, "more than one spec file found on %s" % specsdir
+ specpath = specs[0]
+ if rename:
+ specfile = os.path.basename(specpath)
+ specname = specfile[:-len(".spec")]
+ if specname != srpm.name:
+ newname = srpm.name + ".spec"
+ newpath = os.path.join(specsdir, newname)
+ sys.stderr.write("warning: renaming spec file to '%s' "
+ "(use -n to disable it)\n" % (newname))
+ os.rename(specpath, newpath)
+ try:
+ svn.remove(specpath)
+ except Error:
+ # file not tracked
+ svn.revert(specpath)
+ svn.add(newpath)
+ specpath = newpath
+
if striplog:
- specs = glob.glob(os.path.join(specsdir, "*.spec"))
- if not specs:
- raise Error, "no spec file fount on %s" % specsdir
- specpath = specs[0]
+ specpath = specpath
fspec = open(specpath)
spec, chlog = log.split_spec_changelog(fspec)
- chlog.seek(0)
+ spec.seek(0)
fspec.close()
oldurl = baseold or config.get("log", "oldurl")
pkgoldurl = mirror._joinurl(oldurl, srpm.name)