Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions service/lib/agama/autoyast/software_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: I do not know if that logic should live here. A bit disconnected of that part currently. But I'd at least rename it to fecth_addon_repos to make it more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, idea of method is to translate autoyast entries into agama profile ones...not sure if fetch is the right verb for it

software["extraRepositories"] = repos unless repos.empty?
end
return {} if software.empty?

{ "software" => software }
Expand All @@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: we will sill using "autoyast" naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it is conversion from autoyast profile. But we can name it whatever we want...I am just not sure about better name

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
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jun 10 12:08:44 UTC 2025 - Josef Reidinger <[email protected]>

- AutoYaST support: add support for add-on elements
(gh#agama-project/agama#2458)

-------------------------------------------------------------------
Fri Jun 6 10:22:36 UTC 2025 - Knut Anderssen <[email protected]>

Expand Down
32 changes: 31 additions & 1 deletion service/share/autoyast-compat.json
Original file line number Diff line number Diff line change
@@ -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" },
{
Expand Down
27 changes: 27 additions & 0 deletions service/test/agama/autoyast/software_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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