diff --git a/devel/dump_ay_addons.rb b/devel/dump_ay_addons.rb new file mode 100755 index 000000000..0898286a5 --- /dev/null +++ b/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 + "\n" + + prefix + "#{a.identifier}\n" + + prefix + "#{a.version}\n" + + prefix + "#{a.arch}\n" + + if (!a.free) + ret += prefix + "REG_CODE_REQUIRED\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 "" + puts addons.map{ |a| dump_addon(a) }.join("\n") + puts "" +else + puts "This is a simple generator for AutoYaST addons configuration." + puts + puts "Usage: dump_ay_addons " + puts + puts " is the addons dump file, originally stored at" + puts " /var/log/YaST2/registration_addons.yml" + exit 1 +end