aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--RepSys/commands/putsrpm.py7
-rw-r--r--RepSys/rpmutil.py32
2 files changed, 31 insertions, 8 deletions
diff --git a/RepSys/commands/putsrpm.py b/RepSys/commands/putsrpm.py
index 5256cba..751fa0b 100644
--- a/RepSys/commands/putsrpm.py
+++ b/RepSys/commands/putsrpm.py
@@ -22,6 +22,7 @@ Options:
-c URL The URL of the base directory where the changelog will be
placed
-s Don't strip the changelog from the spec
+ -n Don't try to rename the spec file
-h Show this message
Examples:
@@ -39,15 +40,17 @@ def parse_options():
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):
+ baseurl=None, baseold=None, logmsg=None, rename=False):
for path in srpmfiles:
put_srpm(path, markrelease, striplog, branch, baseurl, baseold,
- logmsg)
+ logmsg, rename)
def main():
do_command(parse_options, put_srpm_cmd)
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)