mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- implement POSTing of local specfile to get real buildinfo
- extend urlopen() so it takes data for optional POST - extend get_buildinfo() to take optional specfile argument - osc.build.main: send specfile to server - buildinfo(): accept specfile as third argument, and document it
This commit is contained in:
parent
7a8c7664da
commit
aa248dde9f
@ -279,7 +279,7 @@ def main(argv):
|
||||
|
||||
print 'Getting buildinfo from server'
|
||||
bi_file = NamedTemporaryFile(suffix='.xml', prefix='buildinfo.', dir = '/tmp')
|
||||
os.system('osc buildinfo %s %s > %s' % (repo, arch, bi_file.name))
|
||||
os.system('osc buildinfo %s %s %s > %s' % (repo, arch, spec, bi_file.name))
|
||||
bi = Buildinfo(bi_file.name)
|
||||
|
||||
|
||||
|
@ -635,9 +635,18 @@ To find out <platform> and <arch>, you can use 'osc results'
|
||||
|
||||
def buildinfo(args):
|
||||
"""buildinfo: Shows the build "info" which is used in building a package
|
||||
You need to call the command inside a package directory.
|
||||
This command is mostly used internally by the 'build' command.
|
||||
It needs to be called inside a package directory.
|
||||
|
||||
usage: osc buildinfo <platform> <arch>
|
||||
usage: osc buildinfo <platform> <arch> [specfile]
|
||||
|
||||
The [specfile] argument is optional. <specfile> is a local specfile which is
|
||||
sent to the server, and the buildinfo will be based on it.
|
||||
If the argument is not supplied, the buildinfo is derived from the specfile
|
||||
which is currently in the package.
|
||||
|
||||
The returned data is XML and contains a list of the packages used in building,
|
||||
their source, and the expanded BuildRequires.
|
||||
"""
|
||||
wd = os.curdir
|
||||
package = store_read_package(wd)
|
||||
@ -655,14 +664,28 @@ usage: osc buildinfo <platform> <arch>
|
||||
|
||||
platform = args[0]
|
||||
arch = args[1]
|
||||
print ''.join(get_buildinfo(project, package, platform, arch))
|
||||
|
||||
# were we given a specfile (third argument)?
|
||||
try:
|
||||
spec = open(args[2]).read()
|
||||
except IndexError:
|
||||
spec = None
|
||||
except IOError, e:
|
||||
sys.exit(e)
|
||||
|
||||
print ''.join(get_buildinfo(project, package, platform, arch, specfile=spec))
|
||||
|
||||
|
||||
def buildconfig(args):
|
||||
"""buildconfig: Shows the build configuration which is used in building a package
|
||||
You need to call the command inside a package directory.
|
||||
This command is mostly used internally by the 'build' command.
|
||||
It needs to be called inside a package directory.
|
||||
|
||||
usage: osc buildconfig <platform> <arch>
|
||||
|
||||
The returned data is the project-wide build configuration in a format which is
|
||||
directly readable by the build script. It contains RPM macros and BuildRequires
|
||||
expansions, for example.
|
||||
"""
|
||||
wd = os.curdir
|
||||
package = store_read_package(wd)
|
||||
|
@ -573,11 +573,12 @@ def makeurl(l):
|
||||
return urlunsplit((scheme, netloc, '/'.join(l), '', ''))
|
||||
|
||||
|
||||
def urlopen(url):
|
||||
def urlopen(url, data=None):
|
||||
"""wrapper around urllib2.urlopen for error handling"""
|
||||
|
||||
try:
|
||||
fd = urllib2.urlopen(url)
|
||||
# adding data to the request makes it a POST
|
||||
fd = urllib2.urlopen(url, data=data)
|
||||
|
||||
except urllib2.HTTPError, e:
|
||||
print >>sys.stderr, 'Error: can\'t get \'%s\'' % url
|
||||
@ -1131,10 +1132,10 @@ def get_log(prj, package, platform, arch, offset):
|
||||
return f.read()
|
||||
|
||||
|
||||
def get_buildinfo(prj, package, platform, arch):
|
||||
def get_buildinfo(prj, package, platform, arch, specfile=None):
|
||||
# http://api.opensuse.org/rpm/Subversion/Apache_SuSE_Linux_10.1/i586/subversion/buildinfo
|
||||
u = makeurl(['rpm', prj, platform, arch, package, 'buildinfo'])
|
||||
f = urlopen(u)
|
||||
f = urlopen(u, data=specfile)
|
||||
return f.read()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user