Class: Yast::InstURLClass
- Inherits:
-
Module
- Object
- Module
- Yast::InstURLClass
- Defined in:
- ../../src/modules/InstURL.rb
Instance Method Summary (collapse)
-
- (String) GetDevicesOption
Get device options for CD/DVD.
- - (Object) GetURLOptions(url)
-
- (String) HidePassword(url)
Hide Password.
-
- (String) installInf2Url(extra_dir)
Convert install.inf to a URL useable by the package manager.
- - (Object) main
- - (Object) RewriteCDUrl(url)
-
- (Object) SSLVerificationEnabled
check if SSL certificate check is enabled (default) or explicitely disabled by user.
Instance Method Details
- (String) GetDevicesOption
Get device options for CD/DVD
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 87 88 89 90 91 92 93 94 |
# File '../../src/modules/InstURL.rb', line 37 def GetDevicesOption = "" 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) != 0 # 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 != "" = Ops.add(, ",") if != "" = Ops.add(, d) end end = Ops.add("devices=", ) if != "" end |
- (Object) GetURLOptions(url)
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File '../../src/modules/InstURL.rb', line 97 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 |
- (String) HidePassword(url)
Hide Password
28 29 30 31 32 33 |
# File '../../src/modules/InstURL.rb', line 28 def HidePassword(url) Builtins.y2warning( "InstURL::HidePassword() is obsoleted, use URL::HidePassword() instead" ) URL.HidePassword(url) end |
- (String) installInf2Url(extra_dir)
Convert install.inf to a URL useable by the package manager
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File '../../src/modules/InstURL.rb', line 145 def installInf2Url(extra_dir) repo_url = "" # bnc #406162 repo_url_from_inf = false Builtins.foreach(["ZyppRepoURL"]) do |in_inf_key| repo_url = Linuxrc.InstallInf(in_inf_key) if repo_url != nil && repo_url != "" Builtins.y2milestone( "Using %1 directly from install.inf: %2", in_inf_key, URL.HidePassword(repo_url) ) repo_url_from_inf = true raise Break end end return repo_url if repo_url_from_inf # Initial repository hasn't been found in install.inf # Trying to guess it ... Builtins.y2warning("Initial repository not found in install.inf") = "" url_tokens = {} instmode = Linuxrc.InstallInf("InstMode") # mode instmode = "cd" if instmode == nil # defaults to "CD" if instmode == "cd" || # CD or DVD instmode == "dvd" @is_network = false = GetDevicesOption() elsif instmode == "hd" # Harddisk @is_network = false partition = Linuxrc.InstallInf("Partition") if partition != nil = Ops.add( Ops.add("device=/dev/", partition), "&filesystem=auto" ) else Builtins.y2error("no partition specified") end end Ops.set(url_tokens, "scheme", instmode) if @is_network username = Linuxrc.InstallInf("Username") if username != nil && username != "" Ops.set(url_tokens, "user", username) password = Linuxrc.InstallInf("Password") if password != nil && password != "" Ops.set(url_tokens, "pass", password) end end servername = Linuxrc.InstallInf("ServerName") server = Linuxrc.InstallInf("Server") serverip = Linuxrc.InstallInf("ServerIP") if servername != nil && servername != "" Ops.set(url_tokens, "host", servername) elsif server != nil && server != "" Ops.set(url_tokens, "host", server) elsif serverip != nil && serverip != "" Ops.set(url_tokens, "host", serverip) end end # is_network isoimg = "" serverdir = Linuxrc.InstallInf("Serverdir") if Linuxrc.InstallInf("SourceType") == "file" if serverdir != "" && serverdir != nil sd_items = Builtins.splitstring(serverdir, "/") sd_items = Builtins.filter(sd_items) { |i| i != "" } last = Ops.subtract(Builtins.size(sd_items), 1) isoimg = Ops.get(sd_items, last, "") Ops.set(sd_items, last, "") serverdir = Builtins.mergestring(sd_items, "/") end end # if (((instmode == "hd") || is_network) // if serverdir needed # && ((serverdir != nil) && (serverdir != ""))) // and is valid # { # // for smb mounts it is usual to not have a leading slash # if (substring (serverdir, 0, 1) != "/") # serverdir = "/" + serverdir; # } share = Linuxrc.InstallInf("Share") if extra_dir != "" if serverdir != nil # avoid too many slashes if Builtins.findlastof(serverdir, "/") == Ops.subtract(Builtins.size(serverdir), 1) serverdir = Builtins.substring( serverdir, 0, Ops.subtract(Builtins.size(serverdir), 1) ) end slash = "" slash = "/" if Builtins.substring(extra_dir, 0, 1) != "/" serverdir = Ops.add(Ops.add(serverdir, slash), extra_dir) slash = "" else serverdir = extra_dir end end if serverdir != nil && serverdir != "" fs = "" if instmode == "ftp" # ftp://foo/%2fbar is %2fbar on foo (relative) # ftp://foo/bar is bar on foo (absolute) # ftp://foo//bar is /bar on foo (relative) # Note: %2f is added by URL.ycp if the path starts with / if Builtins.substring(serverdir, 0, 3) == "%2f" serverdir = Ops.add("/", Builtins.substring(serverdir, 3)) end fs = serverdir elsif instmode == "smb" && share != nil && share != "" fs = Ops.add(Ops.add(share, "/"), serverdir) else fs = serverdir end Ops.set(url_tokens, "path", fs) else # FIXME don't know why it is needed # Needed as a seperator between URL and options (!) # bnc#571648 - smb installation source: linuxrc path failed for YaST repositories if instmode == "smb" && share != nil && share != "" Ops.set(url_tokens, "path", Ops.add(share, "/")) else Ops.set(url_tokens, "path", "/") end end port = Linuxrc.InstallInf("Port") Ops.set(url_tokens, "port", port) if port != nil && port != "" url = URL.Build(url_tokens) option_separator = "?" if @is_network proxy = Linuxrc.InstallInf("Proxy") if proxy != nil && proxy != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "proxy="), proxy ) option_separator = "&" end proxyport = Linuxrc.InstallInf("ProxyPort") if proxyport != nil && proxyport != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "proxyport="), proxyport ) option_separator = "&" end proxyproto = Linuxrc.InstallInf("ProxyProto") if proxyproto != nil && proxyproto != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "proxyproto="), proxyproto ) option_separator = "&" end proxyuser = Linuxrc.InstallInf("ProxyUser") if proxyuser != nil && proxyuser != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "proxyuser="), proxyuser ) option_separator = "&" end proxypassword = Linuxrc.InstallInf("ProxyPassword") if proxypassword != nil && proxypassword != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "proxypassword="), proxypassword ) option_separator = "&" end workgroup = Linuxrc.InstallInf("WorkDomain") if workgroup != nil && workgroup != "" url = Ops.add( Ops.add(Ops.add(url, option_separator), "workgroup="), workgroup ) option_separator = "&" end if instmode == "https" Builtins.y2milestone("HTTPS instmode detected") if !SSLVerificationEnabled() Builtins.y2security( "Disabling certificate check for the installation repository" ) # libzypp uses ssl_verify=no option url = Ops.add(Ops.add(url, option_separator), "ssl_verify=no") option_separator = "&" end end end # is_network if != "" url = Ops.add(Ops.add(url, option_separator), ) option_separator = "&" Builtins.y2milestone("options %1", ) end url = Builtins.sformat("iso:/?iso=%1&url=%2", isoimg, url) if isoimg != "" Builtins.y2debug("URL %1", URL.HidePassword(url)) url end |
- (Object) main
15 16 17 18 19 20 21 22 23 |
# File '../../src/modules/InstURL.rb', line 15 def main textdomain "packager" Yast.import "Linuxrc" Yast.import "URL" Yast.import "CheckMedia" @is_network = true end |
- (Object) RewriteCDUrl(url)
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File '../../src/modules/InstURL.rb', line 120 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 = GetDevicesOption() new_url = Builtins.substring(url, 0, pos) if Ops.greater_than(Builtins.size(), 0) new_url = Ops.add(Ops.add(new_url, "?"), GetDevicesOption()) else new_url = url end end else new_url = url end new_url end |
- (Object) SSLVerificationEnabled
check if SSL certificate check is enabled (default) or explicitely disabled by user
112 113 114 115 116 117 |
# File '../../src/modules/InstURL.rb', line 112 def SSLVerificationEnabled ssl_verify = Linuxrc.InstallInf("ssl_verify") Builtins.y2milestone("Option ssl_verify: %1", ssl_verify) ssl_verify != "no" end |