Skip to content

Commit

Permalink
Merge pull request #907 from yast/fix-product-features
Browse files Browse the repository at this point in the history
Fix ProductFeatures#InitIfNeeded
  • Loading branch information
dgdavid committed Mar 13, 2019
2 parents 1b33f0a + 55fda39 commit b7d99b0
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 4 deletions.
6 changes: 3 additions & 3 deletions library/control/src/modules/ProductFeatures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main
"disable_os_prober" => false,
"enable_local_users" => true,
# FATE #304865
"base_product_license_directory" => "/etc/YaST2/licenses/base/",
"base_product_license_directory" => "/usr/share/licenses/product/base/",
"full_system_media_name" => "",
"full_system_download_url" => "",
"save_y2logs" => true
Expand Down Expand Up @@ -168,7 +168,8 @@ def Save
# Restore product features in running system
# @note This is a stable API function
def Restore
InitFeatures(true)
InitFeatures(false)

groups = SCR.Dir(path(".product.features.section"))
Builtins.foreach(groups) do |group|
Ops.set(@features, group, Ops.get(@features, group, {}))
Expand All @@ -191,7 +192,6 @@ def Restore
# @note This is a stable API function
# Either read from /etc/YaST2/ProductFeatures or set default values
def InitIfNeeded
return if !@features.nil?
if Stage.normal || Stage.firstboot
Restore()
else
Expand Down
77 changes: 77 additions & 0 deletions library/control/test/ProductFeatures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,81 @@
end
end
end

describe "#GetFeature" do
let(:scr_root_dir) { File.join(File.dirname(__FILE__), "data") }
let(:normal_stage) { false }
let(:firstboot_stage) { false }

before do
allow(Yast::Stage).to receive(:normal).and_return(normal_stage)
allow(Yast::Stage).to receive(:firstboot).and_return(firstboot_stage)
end

around do |example|
change_scr_root(scr_root_dir, &example)
end

it "initializes feature if needed" do
expect(subject).to receive(:InitIfNeeded)

subject.GetFeature("globals", "base_product_license_directory")
end

context "in normal stage" do
let(:normal_stage) { true }

it "reads the value from the running system" do
# value read from data/etc/YaST2/ProductFeatures file
expect(subject.GetFeature("globals", "base_product_license_directory"))
.to eq("/path/to/licenses/product/base")
end
end

context "in firstboot stage" do
let(:firstboot_stage) { true }

it "reads the value from the running system" do
# value read from data/etc/YaST2/ProductFeatures file
expect(subject.GetFeature("globals", "base_product_license_directory"))
.to eq("/path/to/licenses/product/base")
end
end
end

describe "#InitIfNeeded" do
let(:normal_stage) { false }
let(:firstboot_stage) { false }

before do
allow(Yast::Stage).to receive(:normal).and_return(normal_stage)
allow(Yast::Stage).to receive(:firstboot).and_return(firstboot_stage)
end

it "ensures that features are initialized" do
expect(subject).to receive(:InitFeatures).with(false)

subject.InitIfNeeded
end

context "in normal stage" do
let(:normal_stage) { true }

it "restores the available values in the running system" do
expect(subject).to receive(:Restore)

subject.InitIfNeeded
end
end

context "in firstboot stage" do
let(:firstboot_stage) { true }

it "restores the available values in the running system" do
expect(subject).to receive(:Restore)

subject.InitIfNeeded
end
end
end
end
59 changes: 59 additions & 0 deletions library/control/test/data/etc/YaST2/ProductFeatures
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[globals]
additional_kernel_parameters = ""
addons_default = "no"
base_product_license_directory = "/path/to/licenses/product/base"
debug_deploying = "no"
default_ntp_setup = "yes"
default_target = ""
disable_os_prober = "no"
disable_register_w3m = "yes"
display_register_forcereg = "yes"
enable_autologin = "yes"
enable_clone = "no"
enable_firewall = "yes"
enable_kdump = "yes"
enable_register_hwdata = "yes"
enable_register_optional = "yes"
enable_sshd = "no"
fam_local_only = "never"
firewall_enable_ssh = "no"
incomplete_translation_treshold = "95"
inform_about_suboptimal_distribution = "yes"
kexec_reboot = "yes"
keyboard = ""
language = ""
manual_online_update = "yes"
online_repositories_default = "yes"
register_monthly = "no"
relnotesurl = ""
rle_offer_rulevel_4 = "no"
root_password_as_first_user = "yes"
root_password_ca_check = "no"
run_init_scripts_in_parallel = "yes"
run_you = "yes"
show_addons = "yes"
show_drivers_info = "no"
show_online_repositories = "yes"
skip_language_dialog = "yes"
timezone = ""
ui_mode = "simple"
vendor_url = ""
write_hostname_to_hosts = "no"
[network]
force_static_ip = "no"
network_manager = "laptop"
startmode = "ifplugd"
[partitioning]
expert_partitioner_warning = "no"
use_flexible_partitioning = "no"
vm_keep_unpartitioned_region = "no"
[software]
base_selection = ""
default_desktop = "gnome"
delete_old_packages = "yes"
external_sources_link = "https://download.opensuse.org/YaST/Repos/openSUSE_Factory_Servers.xml"
inform_about_suboptimal_distribution = "no"
online_repos_preselected = "no"
only_update_installed = "no"
packages_transmogrify = ""
software_proposal = "selection"
3 changes: 3 additions & 0 deletions library/control/testsuite/tests/restore.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Dir .product.features.section: []
Return expert
Dir .product.features.section: []
Return yes
Dir .product.features.section: []
Return true
Dir .product.features.section: []
Return 95
8 changes: 8 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Mar 13 09:02:12 UTC 2019 - David Díaz <dgonzalez@suse.com>

- Fix how a product features is read in a running system.
- Update default path for base product licenses
(fate#324053, jsc#SLE-4173).
- 4.1.63

-------------------------------------------------------------------
Tue Mar 12 08:38:32 UTC 2019 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.1.62
Version: 4.1.63
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit b7d99b0

Please sign in to comment.