Skip to content

Commit

Permalink
Allow overriding of install repos Issue#1474
Browse files Browse the repository at this point in the history
* Use agama.install_url=https://.. boot param
  • Loading branch information
lkocman committed Aug 19, 2024
1 parent 5f2b96b commit 55fcdb8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions service/lib/agama/software/product_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,28 @@
# find current contact information at www.suse.com.

require "agama/software/product"
require "agama/cmdline_args"
require "logger"

module Agama
module Software
# Builds products from the information of a config file.
class ProductBuilder
# @param config [Agama::Config]
def initialize(config)
def initialize(config, logger: Logger.new($stdout))
@config = config
@logger = logger
end

# Builds the products.
#
# @return [Array<Agama::Product>]
def build
cmdline_args = CmdlineArgs.read_from("/proc/cmdline")
@logger.info cmdline_args
config.products.map do |id, attrs|
data = product_data_from_config(id)
create_product(id, data, attrs)
create_product(id, data, attrs, cmdline_args)
end
end

Expand All @@ -45,13 +50,19 @@ def build
# @return [Agama::Config]
attr_reader :config

def create_product(id, data, attrs)
def create_product(id, data, attrs, cmdline_args)
Agama::Software::Product.new(id).tap do |product|
product.display_name = attrs["name"]
product.description = attrs["description"]
product.name = data[:name]
product.version = data[:version]
product.repositories = data[:repositories]
# Issue#1474 Use agama.install_url=https://path-to-repodata
if cmdline_args.data.has_key?("install_url")
@logger.info "Overriding default installation as args.install_url boot param is set to " + cmdline_args.data["install_url"]
product.repositories = [cmdline_args.data["install_url"],]
else
product.repositories = data[:repositories]
end
product.labels = data[:labels]
product.mandatory_packages = data[:mandatory_packages]
product.optional_packages = data[:optional_packages]
Expand Down

0 comments on commit 55fcdb8

Please sign in to comment.