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:
parent
5f2e9ac766
commit
adf9e633f9
@ -351,6 +351,8 @@ class Osc(cmdln.Cmdln):
|
|||||||
print >>sys.stderr, 'or admin@opensuse.org.'
|
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):
|
def do_updatepacmetafromspec(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Update package meta information from a specfile
|
"""${cmd_name}: Update package meta information from a specfile
|
||||||
|
|
||||||
@ -361,11 +363,14 @@ class Osc(cmdln.Cmdln):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
args = parseargs(args)
|
args = parseargs(args)
|
||||||
|
if opts.specfile and (len(args) == 1):
|
||||||
|
specfile = opts.specfile
|
||||||
|
else:
|
||||||
|
specfile = None
|
||||||
pacs = findpacs(args)
|
pacs = findpacs(args)
|
||||||
|
|
||||||
for p in pacs:
|
for p in pacs:
|
||||||
|
|
||||||
p.read_meta_from_spec()
|
p.read_meta_from_spec(specfile)
|
||||||
p.update_pac_meta()
|
p.update_pac_meta()
|
||||||
|
|
||||||
|
|
||||||
|
36
osc/core.py
36
osc/core.py
@ -484,15 +484,19 @@ rev: %s
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def read_meta_from_spec(self):
|
def read_meta_from_spec(self, spec = None):
|
||||||
specfile = os.path.join(self.dir, self.name + '.spec')
|
if spec:
|
||||||
name, summary, descr = read_meta_from_spec(specfile)
|
specfile = spec
|
||||||
|
else:
|
||||||
if name != self.name:
|
specfile = os.path.join(self.dir, self.name + '.spec')
|
||||||
print >>sys.stderr, 'name from spec does not match name of package... this is probably a problem'
|
summary, descr = read_meta_from_spec(specfile)
|
||||||
|
|
||||||
|
if not summary and not descr:
|
||||||
|
print >>sys.stderr, 'aborting'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
self.summary = summary
|
else:
|
||||||
self.descr = descr
|
self.summary = summary
|
||||||
|
self.descr = descr
|
||||||
|
|
||||||
|
|
||||||
def update_pac_meta(self, template=new_package_templ):
|
def update_pac_meta(self, template=new_package_templ):
|
||||||
@ -997,7 +1001,7 @@ def read_meta_from_spec(specfile):
|
|||||||
|
|
||||||
if not os.path.isfile(specfile):
|
if not os.path.isfile(specfile):
|
||||||
print 'file \'%s\' is not a readable file' % specfile
|
print 'file \'%s\' is not a readable file' % specfile
|
||||||
return (None, None, None)
|
return (None, None)
|
||||||
|
|
||||||
lines = open(specfile).readlines()
|
lines = open(specfile).readlines()
|
||||||
|
|
||||||
@ -1005,20 +1009,28 @@ def read_meta_from_spec(specfile):
|
|||||||
if line.startswith('Name:'):
|
if line.startswith('Name:'):
|
||||||
name = line.split(':')[1].strip()
|
name = line.split(':')[1].strip()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
summary = None
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.startswith('Summary:'):
|
if line.startswith('Summary:'):
|
||||||
summary = line.split(':')[1].strip()
|
summary = line.split(':')[1].strip()
|
||||||
break
|
break
|
||||||
|
if summary == None:
|
||||||
|
print 'cannot find \'Summary:\' tag'
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
descr = []
|
descr = []
|
||||||
start = lines.index('%description\n') + 1
|
try:
|
||||||
|
start = lines.index('%description\n') + 1
|
||||||
|
except ValueError:
|
||||||
|
print 'cannot find %description'
|
||||||
|
return (None, None)
|
||||||
for line in lines[start:]:
|
for line in lines[start:]:
|
||||||
if line.startswith('%'):
|
if line.startswith('%'):
|
||||||
break
|
break
|
||||||
descr.append(line)
|
descr.append(line)
|
||||||
|
|
||||||
return name, summary, descr
|
return (summary, descr)
|
||||||
|
|
||||||
|
|
||||||
def get_user_meta(apiurl, user):
|
def get_user_meta(apiurl, user):
|
||||||
|
Loading…
Reference in New Issue
Block a user