Class: Y2Packager::ReleaseNotesFetchers::Url

Inherits:
Base
  • Object
show all
Defined in:
library/packages/src/lib/y2packager/release_notes_fetchers/url.rb

Overview

This class reads release notes from the relnotes_url product property

The code was extracted from the old version of the InstDownloadReleaseNotesClient and adapted. See https://github.com/yast/yast-installation/blob/62596684d6de242667a0957765c85712874e77ef/src/lib/installation/clients/inst_download_release_notes.rb

See Also:

Constant Summary collapse

CURL_GIVE_UP_RETURN_CODES =

When cURL returns one of those codes, the download won't be retried

See Also:

  • curl
{
  5  => "Couldn't resolve proxy.",
  6  => "Couldn't resolve host.",
  7  => "Failed to connect to host.",
  28 => "Operation timeout."
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#product

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Y2Packager::ReleaseNotesFetchers::Base

Class Method Details

.add_to_blacklist(url) ⇒ Object

Add an URL to the blacklist

Parameters:

  • url (String)

    URL



63
64
65
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 63

def add_to_blacklist(url)
  blacklist << url
end

.blacklistArray<String>

Blacklist of URLs that failed to download and should not be retried

Returns:

  • (Array<String>)

    List of URLs



56
57
58
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 56

def blacklist
  @blacklist ||= []
end

.blacklisted?(url) ⇒ Boolean

Determine whether an URL is blacklisted or not

Returns:

  • (Boolean)


70
71
72
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 70

def blacklisted?(url)
  blacklist.include?(url)
end

.clear_blacklistObject

Clear products blackist



75
76
77
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 75

def clear_blacklist
  blacklist.clear
end

.disable!Object

Disable downloading release notes due to communication errors



39
40
41
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 39

def disable!
  @enabled = false
end

.enable!Object

Enable downloading release notes

This method is intended to be used during testing.



34
35
36
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 34

def enable!
  @enabled = true
end

.enabled?Boolean

Determine if release notes would be downloaded

Returns:

  • (Boolean)

See Also:



47
48
49
50
51
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 47

def enabled?
  return true if @enabled.nil?

  @enabled
end

Instance Method Details

#latest_version:latest

Return release notes latest version identifier

Release notes that lives in relnotes_url are considered always to be the latest version, hence this method always returns :latest.

Returns:

  • (:latest)


134
135
136
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 134

def latest_version
  :latest
end

#release_notes(prefs) ⇒ String?

Get release notes for the given product

Release notes are downloaded and extracted to work directory. When release notes for a language "xx_XX" are not found, it will fallback to "xx".

Parameters:

Returns:

  • (String, nil)

    Release notes or nil if a release notes were not found (no package providing release notes or notes not found in the package)



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'library/packages/src/lib/y2packager/release_notes_fetchers/url.rb', line 98

def release_notes(prefs)
  if !self.class.enabled?
    log.info("Skipping release notes download due to previous download issues")
    return nil
  end

  if self.class.blacklisted?(relnotes_url)
    log.info("Skipping release notes download for #{product.name} due to previous issues")
    return nil
  end

  if !relnotes_url_valid?
    log.warn("Skipping release notes download for #{product.name}: '#{relnotes_url}'")
    return nil
  end

  relnotes = fetch_release_notes(prefs)

  if relnotes
    log.info "Got release notes for #{product.name} from URL #{relnotes_url} " \
             "with #{prefs}"
    return relnotes
  end

  log.warn("Release notes for product #{product.name} not found. " \
           "Blacklisting #{relnotes_url}...")
  self.class.add_to_blacklist(relnotes_url)
  nil
end