Skip to content

Commit

Permalink
- set vrev on current links in link files
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Mar 2, 2012
1 parent 15da5e9 commit 6860e7e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- patchinfo call can work without checked out copy now
- use qemu as fallback for building not directly supported architectures
- "results --watch" option to watch build results until they finished building
- setlinkrev and linkpac ---current is setting vrev. this requires OBS 2.1.17 or 2.3
#
# Features which requires OBS 2.3
#
Expand Down
8 changes: 6 additions & 2 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,7 @@ def do_linkpac(self, subcmd, opts, *args):
+ self.get_cmd_help('linkpac'))

rev, dummy = parseRevisionOption(opts.revision)
vrev = None

src_project = args[0]
src_package = args[1]
Expand All @@ -2369,13 +2370,16 @@ def do_linkpac(self, subcmd, opts, *args):
opts.cicount = "copy"

if opts.current and not opts.new_package:
rev = show_upstream_rev(apiurl, src_project, src_package)
rev, vrev = show_upstream_rev_vrev(apiurl, src_project, src_package, expand=1)
if rev == None or len(rev) < 32:
# vrev is only needed for srcmd5 and OBS instances < 2.1.17 do not support it
vrev = None

if rev and not checkRevision(src_project, src_package, rev):
print >>sys.stderr, 'Revision \'%s\' does not exist' % rev
sys.exit(1)

link_pac(src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount, opts.disable_publish, opts.new_package)
link_pac(src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount, opts.disable_publish, opts.new_package, vrev)

@cmdln.option('--nosources', action='store_true',
help='ignore source packages when copying build results to destination project')
Expand Down
29 changes: 22 additions & 7 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3238,6 +3238,11 @@ def show_upstream_xsrcmd5(apiurl, prj, pac, revision=None, linkrev=None, linkrep
return li.xsrcmd5


def show_upstream_rev_vrev(apiurl, prj, pac, revision=None, expand=False, linkrev=None, meta=False):
m = show_files_meta(apiurl, prj, pac, revision=revision, expand=expand, linkrev=linkrev, meta=meta)
et = ET.fromstring(''.join(m))
return et.get('rev'), et.get('vrev')

def show_upstream_rev(apiurl, prj, pac, revision=None, expand=False, linkrev=None, meta=False, include_service_files=False):
m = show_files_meta(apiurl, prj, pac, revision=revision, expand=expand, linkrev=linkrev, meta=meta)
et = ET.fromstring(''.join(m))
Expand Down Expand Up @@ -4193,7 +4198,7 @@ def link_to_branch(apiurl, project, package):
else:
raise oscerr.OscIOError(None, 'no _link file inside project \'%s\' package \'%s\'' % (project, package))

def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', cicount='', disable_publish = False, missing_target = False):
def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', cicount='', disable_publish = False, missing_target = False, vrev=''):
"""
create a linked package
- "src" is the original package
Expand Down Expand Up @@ -4246,16 +4251,21 @@ def link_pac(src_project, src_package, dst_project, dst_package, force, rev='',
sys.exit(1)

if rev:
rev = 'rev="%s"' % rev
rev = ' rev="%s"' % rev
else:
rev = ''

if vrev:
vrev = ' vrev="%s"' % vrev
else:
vrev = ''

missingok = ''
if missing_target:
missingok = 'missingok="true"'
missingok = ' missingok="true"'

if cicount:
cicount = 'cicount="%s"' % cicount
cicount = ' cicount="%s"' % cicount
else:
cicount = ''

Expand All @@ -4266,15 +4276,16 @@ def link_pac(src_project, src_package, dst_project, dst_package, force, rev='',
project = 'project="%s"' % src_project

link_template = """\
<link %s package="%s" %s %s %s>
<link %s package="%s"%s%s%s%s>
<patches>
<!-- <branch /> for a full copy, default case -->
<!-- <apply name="patch" /> apply a patch on the source directory -->
<!-- <topadd>%%define build_with_feature_x 1</topadd> add a line on the top (spec file only) -->
<!-- <add>file.patch</add> add a patch to be applied after %%setup (spec file only) -->
<!-- <delete>filename</delete> delete a file -->
</patches>
</link>
""" % (project, src_package, missingok, rev, cicount)
""" % (project, src_package, missingok, rev, vrev, cicount)

u = makeurl(apiurl, ['source', dst_project, dst_package, '_link'])
http_PUT(u, data=link_template)
Expand Down Expand Up @@ -5600,17 +5611,21 @@ def set_link_rev(apiurl, project, package, revision='', expand=False, baserev=Fa
src_project = root.get('project', project)
src_package = root.get('package', package)
linkrev=None
vrev = None
if baserev:
linkrev = 'base'
expand = True
if revision is None:
if 'rev' in root.keys():
del root.attrib['rev']
elif revision == '' or expand:
revision = show_upstream_rev(apiurl, src_project, src_package, revision=revision, linkrev=linkrev, expand=expand)
revision, vrev = show_upstream_rev_vrev(apiurl, src_project, src_package, revision=revision, linkrev=linkrev, expand=expand)

if revision:
root.set('rev', revision)
# add vrev when revision is a srcmd5
if vrev and revision and len(revision) >= 32:
root.set('vrev', vrev)

l = ET.tostring(root)
http_PUT(url, data=l)
Expand Down

0 comments on commit 6860e7e

Please sign in to comment.