From c6a5d0995bf3ec9f21f7f24654583af84325c703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Tue, 24 Sep 2024 16:18:23 +0200 Subject: [PATCH] Disable the SLE_BCI repository after registration (PED-8817) - 4.6.3 --- package/yast2-registration.changes | 6 ++++++ package/yast2-registration.spec | 2 +- src/lib/registration/clients/inst_scc.rb | 11 +++++++++-- src/lib/registration/sw_mgmt.rb | 17 +++++++++++++++++ test/sw_mgmt_spec.rb | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/package/yast2-registration.changes b/package/yast2-registration.changes index f49e14ce..8125c09f 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.6.3 + ------------------------------------------------------------------- Wed May 29 13:34:10 UTC 2024 - Martin Vidner diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index 7e9387a5..e05f1ad4 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.6.2 +Version: 4.6.3 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