Skip to content

Commit

Permalink
Added devel/dump_ay_addons.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 24, 2017
1 parent 1872567 commit 1fc99e1
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions devel/dump_ay_addons.rb
@@ -0,0 +1,68 @@
#! /usr/bin/ruby

# This is a simple generator for creating the addons list displayed at
# https://github.com/yast/yast-registration/wiki/Available-SCC-Extensions-for-Use-in-Autoyast

require "yast"
require "registration/addon"

# Monkey Patch to workaround issue in ruby 2.4 Psych (bsc#1048526)
# when fixed or if suseconnect is changed then remove
# (copied from test/spec_helper.rb)
module SUSE
module Connect
module Remote
class Product
alias_method :initialize_orig, :initialize
def initialize(arg = {})
initialize_orig(arg)
end
end

class Service
alias_method :initialize_orig, :initialize
def initialize(arg = { "product" => {} })
initialize_orig(arg)
end
end
end
end
end

INDENT_WIDTH = 4

# dump addon data on STDOUT, recursively dumps the dependant addons
def dump_addon(a)
prefix = " " * INDENT_WIDTH

ret = prefix + "<!-- #{a.name} -->\n" +
prefix + "<name>#{a.identifier}</name>\n" +
prefix + "<version>#{a.version}</version>\n" +
prefix + "<arch>#{a.arch}</arch>\n"

if (!a.free)
ret += prefix + "<reg_code>REG_CODE_REQUIRED</reg_code>\n"
end

ret
end

if ARGV[0]
addons = YAML.load_file(ARGV[0])
# select everything
addons.each(&:selected)
# sort the addons
addons = Registration::Addon.registration_order(Registration::Addon.selected)

puts "<addons config:type=\"list\">"
puts addons.map{ |a| dump_addon(a) }.join("\n")
puts "</addons>"
else
puts "This is a simple generator for AutoYaST addons configuration."
puts
puts "Usage: dump_ay_addons <file_path>"
puts
puts " <file_path> is the addons dump file, originally stored at"
puts " /var/log/YaST2/registration_addons.yml"
exit 1
end

0 comments on commit 1fc99e1

Please sign in to comment.