Class: Yast::InstURLClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
src/modules/InstURL.rb

Overview

Convert /etc/install.inf data to URL

Instance Method Summary collapse

Instance Method Details

#fallback_repo?Boolean

Where there is a fallback repository in the int-sys

See Also:


177
178
179
# File 'src/modules/InstURL.rb', line 177

def fallback_repo?
  ::File.exist?(FALLBACK_REPO_PATH)
end

#fallback_repo_urlURI::Generic

URL of the fallback repository, located in the int-sys, that is used to get the products information when the NOREPO option has been passed to the installer (fate#325482)


168
169
170
# File 'src/modules/InstURL.rb', line 168

def fallback_repo_url
  ::URI.parse("dir://#{FALLBACK_REPO_PATH}")
end

#GetDevicesOptionString

Get device options for CD/DVD


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'src/modules/InstURL.rb', line 31

def GetDevicesOption
  options = ""
  devicelist = Convert.convert(
    SCR.Read(path(".probe.cdrom")),
    from: "any",
    to:   "list <map>"
  )
  devlist = Builtins.maplist(devicelist) do |d|
    Ops.get_string(d, "dev_name", "")
  end

  ready = []
  Builtins.foreach(devicelist) do |d|
    dname = Ops.get_string(d, "dev_name", "")
    if Ops.get_boolean(d, "notready", true) == false && !dname.nil? &&
        dname != ""
      ready = Builtins.add(ready, dname)
    end
  end

  devlist = deep_copy(ready) if Builtins.size(ready).nonzero?

  # add the Linuxrc medium to the beginning
  repo_url = Linuxrc.InstallInf("RepoURL")

  repo_url = "" if repo_url.nil?

  if Builtins.regexpmatch(Builtins.tolower(repo_url), "^cd:") ||
      Builtins.regexpmatch(Builtins.tolower(repo_url), "^dvd:")
    Builtins.y2milestone(
      "Found CD/DVD device in Linuxrc RepoURL: %1",
      repo_url
    )
    linuxrc_device = Builtins.regexpsub(repo_url, "device=(.*)$", "\\1")
    if !linuxrc_device.nil? && linuxrc_device != ""
      linuxrc_device = Ops.add("/dev/", linuxrc_device)
      Builtins.y2milestone("Using Linuxrc device: %1", linuxrc_device)

      # remove the device if it is already in the list
      devlist = Builtins.filter(devlist) { |d| d != linuxrc_device }
      # put the linuxrc device at the beginning
      devlist = Builtins.prepend(devlist, linuxrc_device)

      Builtins.y2milestone("Using CD/DVD device list: %1", devlist)
    end
  end

  Builtins.foreach(devlist) do |d|
    if d != ""
      options = Ops.add(options, ",") if options != ""
      options = Ops.add(options, d)
    end
  end
  options = Ops.add("devices=", options) if options != ""
  options
end

#GetURLOptions(url) ⇒ Object


89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'src/modules/InstURL.rb', line 89

def GetURLOptions(url)
  option_map = {}
  pos = Builtins.findfirstof(url, "?")
  if !pos.nil?
    opts = Builtins.substring(url, pos, Builtins.size(url))
    optpairs = Builtins.splitstring(opts, "?")
    option_map = Builtins.listmap(optpairs) do |op|
      tmp = Builtins.splitstring(op, "=")
      { Ops.get(tmp, 0, "") => Ops.get(tmp, 1, "") }
    end
  end
  deep_copy(option_map)
end

#HidePassword(url) ⇒ String

Hide Password


22
23
24
25
26
27
# File 'src/modules/InstURL.rb', line 22

def HidePassword(url)
  Builtins.y2warning(
    "InstURL::HidePassword() is obsoleted, use URL::HidePassword() instead"
  )
  URL.HidePassword(url)
end

#installInf2Url(extra_dir = "") ⇒ String

Convert install.inf to a URL useable by the package manager

Return an empty string if no repository URL has been defined.


137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'src/modules/InstURL.rb', line 137

def installInf2Url(extra_dir = "")
  return @installInf2Url unless @installInf2Url.nil?

  @installInf2Url = Linuxrc.InstallInf("ZyppRepoURL")

  if @installInf2Url.to_s.empty?
    # Make it compatible with the current behaviour when
    # install.inf does not exist.
    log.warn "No URL specified through ZyppRepoURL"
    @installInf2Url = "cd:///"
  end

  # The URL is parsed/build only if needed to avoid potential problems with corner cases.
  @installInf2Url = add_extra_dir_to_url(@installInf2Url, extra_dir) unless extra_dir.empty?
  @installInf2Url = add_ssl_verify_no_to_url(@installInf2Url) unless SSLVerificationEnabled()

  log.info "Using install URL: #{URL.HidePassword(@installInf2Url)}"
  @installInf2Url
end

#mainObject


10
11
12
13
14
15
16
17
# File 'src/modules/InstURL.rb', line 10

def main
  textdomain "packager"
  Yast.import "Linuxrc"
  Yast.import "URL"
  Yast.import "CheckMedia"

  @installInf2Url = nil
end

#RewriteCDUrl(url) ⇒ Object


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'src/modules/InstURL.rb', line 112

def RewriteCDUrl(url)
  tokens = URL.Parse(url)
  new_url = ""
  if Ops.get_string(tokens, "scheme", "") == "cd" ||
      Ops.get_string(tokens, "scheme", "") == "dvd"
    Builtins.y2milestone("Old options: %1", GetURLOptions(url))
    pos = Builtins.findfirstof(url, "?")
    if !pos.nil?
      new_options = GetDevicesOption()
      new_url = Builtins.substring(url, 0, pos)
      new_url = if Ops.greater_than(Builtins.size(new_options), 0)
        Ops.add(Ops.add(new_url, "?"), GetDevicesOption())
      else
        url
      end
    end
  else
    new_url = url
  end
  new_url
end

#SSLVerificationEnabledObject

check if SSL certificate check is enabled (default) or explicitely disabled by user


104
105
106
107
108
109
# File 'src/modules/InstURL.rb', line 104

def SSLVerificationEnabled
  ssl_verify = Linuxrc.InstallInf("ssl_verify")
  Builtins.y2milestone("Option ssl_verify: %1", ssl_verify)

  ssl_verify != "no"
end