Skip to content

Commit

Permalink
"release_type" attribute compatible with SUSEConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Aug 21, 2015
1 parent f81f631 commit a97837e
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/lib/registration/sw_mgmt.rb
Expand Up @@ -50,8 +50,11 @@ class SwMgmt

ZYPP_DIR = "/etc/zypp"

FAKE_BASE_PRODUCT = { "name" => "SLES", "arch" => "x86_64", "version" => "12",
"release_type" => "DVD", "version_version" => "12" }
FAKE_BASE_PRODUCT = { "name" => "SLES", "arch" => "x86_64", "version" => "12-0",
"flavor" => "DVD", "version_version" => "12", "register_release" => "",
"register_target" => "sle-12-x86_64" }

OEM_DIR = "/var/lib/suseRegister/OEM"

def self.init
# false = do not allow continuing without the libzypp lock
Expand Down Expand Up @@ -145,17 +148,15 @@ def self.product_label(base_product)
end

def self.base_product_to_register
# just for debugging:
return FAKE_BASE_PRODUCT if ENV["FAKE_BASE_PRODUCT"]

base_product = find_base_product
# use FAKE_BASE_PRODUCT just for debugging
base_product = ENV["FAKE_BASE_PRODUCT"] ? FAKE_BASE_PRODUCT : find_base_product

# filter out not needed data
product_info = {
"name" => base_product["name"],
"arch" => base_product["arch"],
"version" => ::Registration::Helpers.base_version(base_product["version"]),
"release_type" => base_product["flavor"]
"version" => base_product["version_version"],
"release_type" => get_release_type(base_product)
}

log.info("Base product to register: #{product_info}")
Expand Down Expand Up @@ -449,6 +450,20 @@ def self.products_from_repo(repo_id)
end
end

private_class_method :each_repo
def self.get_release_type(product)
if product["product_line"]
oem_file = File.join(OEM_DIR, product["product_line"])

if File.exist?(oem_file)
# read only the first line
line = File.open(oem_file, &:readline)
return line.chomp if line
end
end

product["register_release"]
end

private_class_method :each_repo, :get_release_type
end
end

0 comments on commit a97837e

Please sign in to comment.