Skip to content

Commit

Permalink
Merge ad1d390 into e1d8d11
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 7, 2022
2 parents e1d8d11 + ad1d390 commit 0c673d5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Nov 7 10:06:19 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

- Do not add an empty repository to the system when upgrading
a registered system using the Full installation medium
(bsc#1204399)
- 4.5.8

-------------------------------------------------------------------
Mon Oct 31 15:44:55 UTC 2022 - Martin Vidner <mvidner@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.5.7
Version: 4.5.8
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
19 changes: 15 additions & 4 deletions src/lib/y2packager/medium_type.rb
Expand Up @@ -28,9 +28,9 @@ class << self
# URL is not set (nil) or is empty.
#
# @return [Symbol] Symbol describing the medium, one of `:offline`,
# `:online` or `:standard`
# `:online` or `:standard`
def type
@type ||= detect_medium_type
@type ||= detected_type
end

# Returns the cached medium type value. If the medium detection has not been
Expand All @@ -42,14 +42,25 @@ def type_value
@type
end

# Similar to {.type} method, but returns the cached original value of the
# detected medium type. Useful after changing the type via `type=` method.
# Raises an exception if the installation URL is not set (`nil`) or is empty.
#
# @see .type
# @return [Symbol] Symbol describing the medium, one of `:offline`,
# `:online` or `:standard`
def detected_type
@detected_type ||= detect_medium_type
end

# Possible types for type value
POSSIBLE_TYPES = [:online, :offline, :standard].freeze

# Allows to overwrite detected medium type. Useful e.g. when upgrade of
# registered system with Full medium should act like Online medium.
# @param type [Symbol] possible values are `:online`, `:offline` and `:standard`
def type=(type)
log.info "Overwritting medium to #{type}"
log.info "Overriding the medium type from #{@type.inspect} to #{type.inspect}"

if !POSSIBLE_TYPES.include?(type)
raise ArgumentError, "Not allowed MediumType #{type.inspect}"
Expand Down Expand Up @@ -106,7 +117,7 @@ def skip_step?
# Detect the medium type.
#
# @return [Symbol] Symbol describing the medium, one of `:offline`,
# `:online` or `:standard`
# `:online` or `:standard`
def detect_medium_type
url = Yast::InstURL.installInf2Url("")

Expand Down
2 changes: 1 addition & 1 deletion src/modules/Packages.rb
Expand Up @@ -1663,7 +1663,7 @@ def Initialize_StageInitial(show_popup, base_url, log_url, product_dir = "/")
return
# TODO: the offline medium contains an empty repository in the root,
# that should be removed in the future, remove this workaround as well
elsif Y2Packager::MediumType.offline? && product_dir == "/"
elsif Y2Packager::MediumType.detected_type == :offline && product_dir == "/"
log.info "Ignoring the root repository on the offline medium"
return
end
Expand Down
1 change: 1 addition & 0 deletions test/medium_type_test.rb
Expand Up @@ -11,6 +11,7 @@
after do
# the computed value is cached, we need to reset it manually for the next test
described_class.instance_variable_set(:@type, nil)
described_class.instance_variable_set(:@detected_type, nil)
end

describe "#type" do
Expand Down

0 comments on commit 0c673d5

Please sign in to comment.