diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index cd1e2ee9..ec6e7b2d 100644 --- a/package/yast2-registration.changes +++ b/package/yast2-registration.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Sep 24 11:43:29 UTC 2024 - Ladislav Slezák + +- Disable the SLE_BCI repository after registration (PED-8817) +- 4.7.1 + ------------------------------------------------------------------- Fri Sep 06 07:14:32 UTC 2024 - Ladislav Slezák diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index c4d199e5..94fdd888 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.7.0 +Version: 4.7.1 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only diff --git a/src/lib/registration/clients/inst_scc.rb b/src/lib/registration/clients/inst_scc.rb index 366acdb5..21c86749 100644 --- a/src/lib/registration/clients/inst_scc.rb +++ b/src/lib/registration/clients/inst_scc.rb @@ -115,8 +115,15 @@ def register_base_system base_reg_dialog = ::Registration::UI::BaseSystemRegistrationDialog.new ret = base_reg_dialog.run - # remember the created registration object for later use - @registration = base_reg_dialog.registration if ret == :next + if ret == :next + # remember the created registration object for later use + @registration = base_reg_dialog.registration + + # disable the BCI repository after registering, it is intended for + # not registered systems + Registration::SwMgmt.disable_bci + end + # tell #registration_check whether the user wants to go back (bnc#940915) @back_from_register = (ret == :back) diff --git a/src/lib/registration/sw_mgmt.rb b/src/lib/registration/sw_mgmt.rb index 547da110..fe78accb 100644 --- a/src/lib/registration/sw_mgmt.rb +++ b/src/lib/registration/sw_mgmt.rb @@ -599,6 +599,23 @@ def self.update_product_renames(renames) end end + # name of the SLE BCI repository + SLE_BCI = "SLE_BCI".freeze + + # disable the BCI repository + def self.disable_bci + enabled_repos = Yast::Pkg.SourceGetCurrent(true) + + enabled_repos.each do |repo| + repo_data = Yast::Pkg.SourceGeneralData(repo) + + if repo_data["alias"] == SLE_BCI + log.info "Disabling #{SLE_BCI} repository" + Yast::Pkg.SourceSetEnabled(repo, false) + end + end + end + # a helper method for iterating over repositories # @param repo_aliases [Array] list of repository aliases # @param block block evaluated for each found repository diff --git a/test/sw_mgmt_spec.rb b/test/sw_mgmt_spec.rb index 7b199ec7..8b7fa4de 100644 --- a/test/sw_mgmt_spec.rb +++ b/test/sw_mgmt_spec.rb @@ -746,4 +746,22 @@ end end + describe ".disable_bci" do + it "disables the SLE_BCI repository" do + expect(Yast::Pkg).to receive(:SourceGetCurrent).and_return([42]) + expect(Yast::Pkg).to receive(:SourceGeneralData).with(42).and_return("alias" => "SLE_BCI") + expect(Yast::Pkg).to receive(:SourceSetEnabled).with(42, false) + + subject.disable_bci + end + + it "does not change anything if the SLE_BCI repository is not present" do + expect(Yast::Pkg).to receive(:SourceGetCurrent).and_return([42]) + expect(Yast::Pkg).to receive(:SourceGeneralData).with(42).and_return("alias" => "repo") + expect(Yast::Pkg).not_to receive(:SourceSetEnabled) + + subject.disable_bci + end + end + end