Author: kkaempf Date: Mon Apr 7 12:03:38 2008 New Revision: 9414 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9414&view=rev Log: patchsolv2updateinfo.rb: Convert .solv generated by 'tools/patchxml2solv' to updateinfo.xml Other files: just small fixes to previous versions Added: trunk/sat-solver/bindings/ruby/tests/patchsolv2updateinfo.rb Modified: trunk/sat-solver/bindings/ruby/tests/_solv2patches.rb trunk/sat-solver/bindings/ruby/tests/gen_patches.rb trunk/sat-solver/bindings/ruby/tests/patch_updates.rb Modified: trunk/sat-solver/bindings/ruby/tests/_solv2patches.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/_solv2patches.rb?rev=9414&r1=9413&r2=9414&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/_solv2patches.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/_solv2patches.rb Mon Apr 7 12:03:38 2008 @@ -13,11 +13,9 @@ the_store end -def solv2patches name, arch +def solv2patches solvname, repo - pool = SatSolver::Pool.new( arch ) - repo = pool.create_repo( "patches" ) - repo.add_solv( name ) + repo.add_solv( solvname ) if solvname STDERR.puts "#{repo.size} patches and stuff" atoms = Hash.new @@ -75,13 +73,13 @@ end unless sp[0] == "atom" STDERR.puts "** Patch #{patch} requires non-atom #{sp[0]}" - exit +# exit end name = sp[1] byname = atoms[name] unless byname STDERR.puts "** Patch #{patch} requires unknown atom #{name}" - exit + break end unless req.op == SatSolver::REL_EQ STDERR.puts "** Patch #{patch} requires non-equal atom #{name}" Modified: trunk/sat-solver/bindings/ruby/tests/gen_patches.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/gen_patches.rb?rev=9414&r1=9413&r2=9414&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/gen_patches.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/gen_patches.rb Mon Apr 7 12:03:38 2008 @@ -8,5 +8,8 @@ require '_patch' require '_solv2patches' -patches = solv2patches "patches.solv", "x86_64" +pool = SatSolver::Pool.new( "x86_64" ) +repo = pool.create_repo( "patches" ) + +patches = solv2patches "patches.solv", repo patches.each { |p| puts p } Modified: trunk/sat-solver/bindings/ruby/tests/patch_updates.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/patch_updates.rb?rev=9414&r1=9413&r2=9414&view=diff ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/patch_updates.rb (original) +++ trunk/sat-solver/bindings/ruby/tests/patch_updates.rb Mon Apr 7 12:03:38 2008 @@ -73,7 +73,8 @@ # Now match updates to patches # -patches = solv2patches "patches.solv", "x86_64" +patchrepo = pool.create_repo( "patches" ) +patches = solv2patches "patches.solv", patchrepo # # Build a lookup hash Added: trunk/sat-solver/bindings/ruby/tests/patchsolv2updateinfo.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/patchsolv2updateinfo.rb?rev=9414&view=auto ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/patchsolv2updateinfo.rb (added) +++ trunk/sat-solver/bindings/ruby/tests/patchsolv2updateinfo.rb Mon Apr 7 12:03:38 2008 @@ -0,0 +1,99 @@ +$:.unshift "../../../build/bindings/ruby" + +# +# Generate 'code11 updateinfo' from (code10) patch solv +# + +# +# Output XML tag +# - indented by 2xindent spaces +# - with attrs (hash) as attributes +# if attrs include nil=>nil, close tag +# - with text as text +# +# returns: +# string for closing tag (if text non-nil and non-empty) +# nil else +# + +def xmlout tag, indent, attrs=nil + lead = "" + indent.times { lead << " " } + print "#{lead}<#{tag}" + if attrs.is_a? Hash # output attributes key="value" + doclose = false + attrs.each { |k,v| + if k.nil? + doclose = true + else + print " #{k}=\"#{v}\"" + end + } + if doclose + puts "/>" + return nil + end + elsif attrs.is_a? String + if attrs.empty? # empty string? -> close tag immediately + puts "/>" + else + puts ">#{attrs}#{tag}>" # text</tag> + end + return nil + end + puts ">" + return "#{lead}#{tag}>" # return closing tag +end + + +require 'satsolver' +require '_patch' +require '_solv2patches' + +pool = SatSolver::Pool.new( "x86_64" ) +repo = pool.create_repo( "patches" ) + +# +# convert solv file to array of Patch +# + + +Dir.foreach( "patches" ) { |solvname| +# STDERR.puts "Reading #{solvname}" + next if solvname[0,1] == "." + repo.add_solv( "patches/#{solvname}" ) +} +patches = solv2patches nil, repo + +puts "<?xml version=\"1.0\"?>" +puts "<updates>" + +indent = 1 +patches.each { |p| + endtag = xmlout "update", indent, "from" => "maint-coord@suse.de", "status"=>"stable", "type"=>p.category, "version"=>"11.0" + indent += 1 + xmlout "id", indent, "#{p.name}-#{p.evr}" + xmlout "title", indent, p.summary + xmlout "release", indent, "openSUSE 11.0" + xmlout "issued", indent, "date" => p.timestamp, nil => nil + xmlout "references", indent, "" + xmlout "description", indent, p.description + listend = xmlout "pkglist", indent + indent += 1 + collend = xmlout "collection", indent + indent += 1 + p.contains.each { |item| + vr = item.evr.split "-" + pkgend = xmlout "package", indent, "name" => item.name, "version" => vr[0], "release" => vr[1], "arch" => item.arch + xmlout "filename", indent+1, "#{item.name}-#{item.evr}.#{item.arch}.rpm" + puts pkgend + } + indent -= 1 + puts collend + indent -= 1 + puts listend + indent -= 1 + puts endtag +} + +puts "</updates>" -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org