Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |