1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

added --specfile option to updatepacmetafromspec. Now the name of the spec can differ from the package name.

This commit is contained in:
Marcus Hüwe 2007-06-30 15:39:47 +00:00
parent 5f2e9ac766
commit adf9e633f9
2 changed files with 31 additions and 14 deletions

View File

@ -351,6 +351,8 @@ class Osc(cmdln.Cmdln):
print >>sys.stderr, 'or admin@opensuse.org.'
@cmdln.option('', '--specfile', metavar='FILE',
help='Path to specfile. (if you pass more than working copy this option is ignored)')
def do_updatepacmetafromspec(self, subcmd, opts, *args):
"""${cmd_name}: Update package meta information from a specfile
@ -361,11 +363,14 @@ class Osc(cmdln.Cmdln):
"""
args = parseargs(args)
if opts.specfile and (len(args) == 1):
specfile = opts.specfile
else:
specfile = None
pacs = findpacs(args)
for p in pacs:
p.read_meta_from_spec()
p.read_meta_from_spec(specfile)
p.update_pac_meta()

View File

@ -484,13 +484,17 @@ rev: %s
return r
def read_meta_from_spec(self):
def read_meta_from_spec(self, spec = None):
if spec:
specfile = spec
else:
specfile = os.path.join(self.dir, self.name + '.spec')
name, summary, descr = read_meta_from_spec(specfile)
summary, descr = read_meta_from_spec(specfile)
if name != self.name:
print >>sys.stderr, 'name from spec does not match name of package... this is probably a problem'
if not summary and not descr:
print >>sys.stderr, 'aborting'
sys.exit(1)
else:
self.summary = summary
self.descr = descr
@ -997,7 +1001,7 @@ def read_meta_from_spec(specfile):
if not os.path.isfile(specfile):
print 'file \'%s\' is not a readable file' % specfile
return (None, None, None)
return (None, None)
lines = open(specfile).readlines()
@ -1006,19 +1010,27 @@ def read_meta_from_spec(specfile):
name = line.split(':')[1].strip()
break
summary = None
for line in lines:
if line.startswith('Summary:'):
summary = line.split(':')[1].strip()
break
if summary == None:
print 'cannot find \'Summary:\' tag'
return (None, None)
descr = []
try:
start = lines.index('%description\n') + 1
except ValueError:
print 'cannot find %description'
return (None, None)
for line in lines[start:]:
if line.startswith('%'):
break
descr.append(line)
return name, summary, descr
return (summary, descr)
def get_user_meta(apiurl, user):