Mailinglist Archive: opensuse-buildservice (216 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] Add support for searching binary packages
  • From: Michal Marek <mmarek@xxxxxxx>
  • Date: Tue, 2 Mar 2010 21:49:56 +0100
  • Message-id: <1267562996-15222-1-git-send-email-mmarek@xxxxxxx>
This adds the software.o.o search to osc. Usage:

osc search --binary <package>
osc search --baseproject=<distribution> <package>

The output lists the filepaths below download.o.o/repositories, which is
good enough for my use case, but improvements are welcome :).
---
osc/commandline.py | 19 +++++++++++++++----
osc/core.py | 17 ++++++++++++++---
2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/osc/commandline.py b/osc/commandline.py
index 23cfbe1..08eb871 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -4064,6 +4064,10 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
help='shorthand for --bugowner --package')
@cmdln.option('--csv', action='store_true',
help='generate output in CSV (separated by |)')
+ @cmdln.option('--binary', action='store_true',
+ help='search binary packages')
+ @cmdln.option('-B', '--baseproject', metavar='PROJECT',
+ help='search packages built for PROJECT (implies
--binary)')
@cmdln.alias('sm')
@cmdln.alias('se')
def do_search(self, subcmd, opts, *args):
@@ -4078,15 +4082,15 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
osc maintained \'source package name\'
osc se ...
${cmd_option_list}
-
- osc search does not find binary rpm names. Use
- http://software.opensuse.org/search?q=binaryname
"""

if opts.mine:
opts.bugowner = True
opts.package = True

+ if opts.baseproject:
+ opts.binary = True
+
for_user = False
if opts.involved or opts.bugowner or opts.maintainer:
for_user = True
@@ -4120,6 +4124,11 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
if opts.package:
search_list.append('@name')
search_for.append('package')
+ if opts.binary:
+ search_for = [ 'published/binary/id' ]
+ search_list = [ '@name' ]
+ if opts.baseproject:
+ extra_limiter='path/project="%s"' % opts.baseproject
if opts.limit_to_attribute:
extra_limiter='attribute/@name="%s"' % (opts.limit_to_attribute)
if not opts.substring:
@@ -4176,8 +4185,10 @@ Please submit there instead, or use --nodevelproject to
force direct submission.

if kind == 'package':
headline = [ '# Project', '# Package' ]
- else:
+ if kind == 'project':
headline = [ '# Project' ]
+ if kind == 'published/binary/id':
+ headline = [ '# Path' ]
if opts.verbose:
headline.append('# Title')
if opts.repos_baseurl:
diff --git a/osc/core.py b/osc/core.py
index 4dc3657..d27f1a5 100644
--- a/osc/core.py
+++ b/osc/core.py
@@ -4142,11 +4142,18 @@ def search(apiurl, search_list, kind, search_term,
verbose = False, exact_matche
role_filter = role_filter.split(':')

predicate = build_xpath_predicate(search_list, search_term, exact_matches,
extra_limiter)
+ element = kind
+ if kind == 'published/binary/id':
+ element = 'binary'
+ # hack: remove the surrounding [ ... ], the api does not like it in
+ # /search/published/binary/id
+ predicate.pop()
+ predicate.pop(0)
u = makeurl(apiurl, ['search', kind], ['match=%s' %
quote_plus(''.join(predicate))])
f = http_GET(u)
root = ET.parse(f).getroot()
result = []
- for node in root.findall(kind):
+ for node in root.findall(element):
if role_filter:
skip = 1
for p in node.findall('person'):
@@ -4161,9 +4168,13 @@ def search(apiurl, search_list, kind, search_term,
verbose = False, exact_matche
project = node.get('project')
package = node.get('name')
result.append(package)
- else:
+ result.append(project)
+ if kind == 'project':
project = node.get('name')
- result.append(project)
+ result.append(project)
+ if kind == 'published/binary/id':
+ filepath = node.get('filepath')
+ result.append(filepath)
if verbose:
title = node.findtext('title').strip()
if len(title) > 60:
--
1.6.3.2

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >