Skip to content

Commit

Permalink
[api] Handle multibuilds in API call to _result
Browse files Browse the repository at this point in the history
Fixes openSUSE#3026

In case of multibuilds we need to fetch the sources of the package
container, but the build results of the queried multibuild package.
This commit should do the trick.

Kudos to Michael for pointing me towards the right direction.
  • Loading branch information
bgeuken committed May 11, 2017
1 parent 3d55ed0 commit 3f1a3ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/api/app/controllers/build_controller.rb
Expand Up @@ -168,12 +168,19 @@ def result
def result_lastsuccess
required_parameters :package, :pathproject

pkg = Package.get_by_project_and_name(params[:project], params[:package],
if params[:multibuild]
partition = params[:package].rpartition(':')
package = partition.first
multibuild_suffix = partition.last
else
package = params[:package]
end
pkg = Package.get_by_project_and_name(params[:project], package,
{use_source: false, follow_project_links: true})
raise RemoteProjectError, 'The package lifes in a remote project, this is not supported atm' unless pkg

tprj = Project.get_by_name params[:pathproject]
bs = PackageBuildStatus.new(pkg).result(target_project: tprj, srcmd5: params[:srcmd5])
bs = PackageBuildStatus.new(pkg).result(target_project: tprj, srcmd5: params[:srcmd5], multibuild_suffix: multibuild_suffix)
@result = []
bs.each do |repo, status|
archs = []
Expand Down
4 changes: 3 additions & 1 deletion src/api/app/models/package_build_status.rb
Expand Up @@ -13,6 +13,7 @@ def initialize(pkg)

def result(opts = {})
@srcmd5 = opts[:srcmd5]
@multibuild_suffix = opts[:multibuild_suffix]
gather_md5sums

tocheck_repos = @pkg.project.repositories_linking_project(opts[:target_project])
Expand Down Expand Up @@ -90,8 +91,9 @@ def current_dir
def gather_current_buildcode(srep, arch)
@buildcode = "unknown"
begin
package = CGI.escape([@pkg.name, @multibuild_suffix].join(':'))
# rubocop:disable Metrics/LineLength
uri = URI("/build/#{CGI.escape(@pkg.project.name)}/_result?package=#{CGI.escape(@pkg.name)}&repository=#{CGI.escape(srep['name'])}&arch=#{CGI.escape(arch)}")
uri = URI("/build/#{CGI.escape(@pkg.project.name)}/_result?package=#{package}&repository=#{CGI.escape(srep['name'])}&arch=#{CGI.escape(arch)}")
# rubocop:enable Metrics/LineLength
resultlist = Xmlhash.parse(ActiveXML.backend.direct_http(uri))
currentcode = nil
Expand Down

0 comments on commit 3f1a3ee

Please sign in to comment.