diff --git a/service/lib/agama/autoyast/software_reader.rb b/service/lib/agama/autoyast/software_reader.rb index c0699614f9..6dea219309 100755 --- a/service/lib/agama/autoyast/software_reader.rb +++ b/service/lib/agama/autoyast/software_reader.rb @@ -37,12 +37,16 @@ def initialize(profile) # # @return [Hash] Agama "software" section def read - return {} if profile["software"].nil? - software = {} - software["patterns"] = profile["software"].fetch_as_array("patterns") - software["packages"] = profile["software"].fetch_as_array("packages") + if profile["software"] + software["patterns"] = profile["software"].fetch_as_array("patterns") + software["packages"] = profile["software"].fetch_as_array("packages") + end + if profile["add-on"] + repos = process_repos + software["extraRepositories"] = repos unless repos.empty? + end return {} if software.empty? { "software" => software } @@ -51,6 +55,21 @@ def read private attr_reader :profile + + def process_repos + repos = profile["add-on"].fetch_as_array("add_on_products") + + profile["add-on"].fetch_as_array("add_on_others") + repos.each_with_index.map do |repo, index| + res = {} + res["url"] = repo["media_url"] + # alias is mandatory to craft one if needed + res["alias"] = repo["alias"] || "autoyast_#{index}" + res["priority"] = repo["priority"] if repo["priority"] + res["name"] = repo["name"] if repo["name"] + res["productDir"] = repo["product_dir"] if repo["product_dir"] + res + end + end end end end diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index 123bb2cbb5..85b13c5da3 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jun 10 12:08:44 UTC 2025 - Josef Reidinger + +- AutoYaST support: add support for add-on elements + (gh#agama-project/agama#2458) + ------------------------------------------------------------------- Mon Jun 9 06:12:23 UTC 2025 - José Iván López González diff --git a/service/share/autoyast-compat.json b/service/share/autoyast-compat.json index a447cd2d50..14e793e5b9 100644 --- a/service/share/autoyast-compat.json +++ b/service/share/autoyast-compat.json @@ -1,5 +1,35 @@ [ - { "key": "add-on", "support": "planned" }, + { + "key": "add-on", + "children": [ + { + "key": "add_on_products", + "children": [ + { "key": "media_url", "support": "yes", "agama": "url" }, + { "key": "product_dir", "support": "yes", "agama": "productDir" }, + { "key": "product", "support": "no" }, + { "key": "alias", "support": "yes" }, + { "key": "priority", "support": "yes" }, + { "key": "ask_on_error", "support": "no" }, + { "key": "confirm_license", "support": "no" }, + { "key": "name", "support": "yes" } + ] + }, + { + "key": "add_on_others", + "children": [ + { "key": "media_url", "support": "yes", "agama": "url" }, + { "key": "product_dir", "support": "yes", "agama": "productDir" }, + { "key": "product", "support": "no" }, + { "key": "alias", "support": "yes" }, + { "key": "priority", "support": "yes" }, + { "key": "ask_on_error", "support": "no" }, + { "key": "confirm_license", "support": "no" }, + { "key": "name", "support": "yes" } + ] + } + ] + }, { "key": "audit-laf", "support": "no" }, { "key": "auth-client", "support": "no" }, { diff --git a/service/test/agama/autoyast/software_reader_test.rb b/service/test/agama/autoyast/software_reader_test.rb index fec65a5d48..33eff2c5ec 100644 --- a/service/test/agama/autoyast/software_reader_test.rb +++ b/service/test/agama/autoyast/software_reader_test.rb @@ -32,6 +32,20 @@ "products" => ["SLE"], "patterns" => ["base", "gnome"], "packages" => ["vim"] + }, + "add-on" => { + "add_on_others" => [ + { + "media_url" => "https://test.com" + }, + { + "media_url" => "https://test2.com", + "product_dir" => "/prod", + "alias" => "prod2", + "priority" => 20, + "name" => "prod 2" + } + ] } } end @@ -62,5 +76,18 @@ expect(patterns).to eq(["vim"]) end end + + context "when a list of add-ons are provided" do + it "includes the list of repositories under 'software.extraRepositories'" do + repos = subject.read.dig("software", "extraRepositories") + expect(repos).to_not be_empty + end + + it "generates alias if it is not provided" do + repos = subject.read.dig("software", "extraRepositories") + repo = repos.find { |r| r["url"] == "https://test.com" } + expect(repo["alias"]).to_not be_empty + end + end end end