Class: Yast::PackagesClass

Inherits:
Module
  • Object
show all
Includes:
ERB::Util, Logger
Defined in:
src/modules/Packages.rb,
src/modules/Packages.rb

Overview

Package selections

Constant Summary collapse

RESOLVABLE_TYPES =

All known types of resolvables

[:product, :patch, :package, :pattern, :language].freeze
RESOLVABLE_SORT_ORDER =

Key to sort by resolvable selection

{ product: "source", pattern: "order" }.freeze
VNC_BASE_TAGS =

Minimum set of packages tags required to enable VNC server

["xorg-x11", "xorg-x11-Xvnc", "xorg-x11-fonts"].freeze
AUTOYAST_X11_TAGS =

Additional packages tags needed to run second stage in graphical mode

["libyui-qt", "yast2-x11"].freeze
DEFAULT_WM =

Default window manager for VNC if none is installed

"icewm".freeze
REMOTE_X11_BASE_TAGS =

Minimum set of packages required for installation with remote X11 server

["xorg-x11-server", "xorg-x11-fonts", "icewm"].freeze
GRAPHIC_PACKAGES =

Graphical packages for VNC installation

["xorg-x11-server", "xorg-x11-server-glx", "libusb", "yast2-x11"].freeze
PRODUCT_CONFLICTS =

Some products are already be “included” in other products. So they MUST not be installed anymore because the other product has a conflict to that one.

{
  # SLES_SAP contains "Conflicts: sles-release". So SLES will not be installed.
  # see https://build.suse.de/package/view_file/SUSE:SLE-12-SP2:GA/_product/SLES_SAP-release.spec?expand=1
  "SLES_SAP" => ["SLES"]
}.freeze
BASE_PRODUCT_FILE =
"/etc/products.d/baseproduct".freeze
LOG_RESOLVABLE_STATUS =

Log only resolvables with resolvable matching these below

[:selected, :removed].freeze
LOG_RESOLVABLE_TRANSACT_BY =

Log only resolvables with resolvable matching these below

[:user, :app_high].freeze
FIPS_PATTERN =

the name of the FIPS pattern

"fips".freeze
FIPS_BOOT_OPTION =

the kernel boot option which activates the FIPS behavior

"fips=1".freeze
FIPS_FILE =

the kernel file indicating whether the FIPS mode is supported and active

  • if the kernel does not support the FIPS mode the file does not exist (openSUSE)

  • if the kernel supports the FIPS mode the file exists (SLES)

    • if the FIPS mode is not active “0n” is read

    • if the FIPS mode is active “1n” is read

"/proc/sys/crypto/fips_enabled".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_proposalObject

Returns the value of attribute cached_proposal


22
23
24
# File 'src/modules/Packages.rb', line 22

def cached_proposal
  @cached_proposal
end

#missing_remote_kindObject (readonly)

Returns the value of attribute missing_remote_kind


15
16
17
# File 'src/modules/Packages.rb', line 15

def missing_remote_kind
  @missing_remote_kind
end

#missing_remote_packagesObject (readonly)

Returns the value of attribute missing_remote_packages


15
16
17
# File 'src/modules/Packages.rb', line 15

def missing_remote_packages
  @missing_remote_packages
end

Instance Method Details

#addAdditionalPackage(package) ⇒ Object

Add a package to list to be selected before proposal Can be called only before the installation proposal, later doesn't have any effect. OBSOLETE! Please, use PackagesProposal::AddResolvables() instead.


926
927
928
929
930
931
932
933
# File 'src/modules/Packages.rb', line 926

def addAdditionalPackage(package)
  Builtins.y2warning(
    "OBSOLETE! Please, use PackagesProposal::AddResolvables() instead"
  )
  @additional_packages = Builtins.add(@additional_packages, package)

  nil
end

#AddFailedMounts(summary) ⇒ Object


524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'src/modules/Packages.rb', line 524

def AddFailedMounts(summary)
  summary = deep_copy(summary)
  failed_mounts = SpaceCalculation.GetFailedMounts
  Builtins.y2milestone(
    "Failed mounts: %1: %2",
    Builtins.size(failed_mounts),
    failed_mounts
  )

  Builtins.foreach(failed_mounts) do |failed_mount|
    delim = summary.fetch("warning", "").empty? ? "" : "<BR>"
    if Builtins.contains(
      @basic_dirs,
      failed_mount.mountpoint
    )
      Ops.set(
        summary,
        "warning",
        Ops.add(
          Ops.add(Ops.get_string(summary, "warning", ""), delim),
          # error message: %1: e.g. "/usr", %2: "/dev/sda2"
          Builtins.sformat(
            _(
              "Error: Cannot check free space in basic directory %1 (device %2), " \
                "cannot start installation."
            ),
            failed_mount.mountpoint,
            fs_dev_name(failed_mount)
          )
        )
      )

      # we could not mount a basic directory, this indicates
      # a severe problem in partition setup
      Ops.set(summary, "warning_level", :blocker)
    else
      Ops.set(
        summary,
        "warning",
        Ops.add(
          Ops.add(Ops.get_string(summary, "warning", ""), delim),
          # error message: %1: e.g. "/local", %2: "/dev/sda2"
          Builtins.sformat(
            _(
              "Warning: Cannot check free space in directory %1 (device %2)."
            ),
            failed_mount.mountpoint,
            fs_dev_name(failed_mount)
          )
        )
      )

      # keep blocker, fatal and error level, they are higher than warning
      if !Builtins.contains(
        [:blocker, :fatal, :error],
        Ops.get_symbol(summary, "warning_level", :ok)
      )
        Ops.set(summary, "warning_level", :warning)
      end
    end
  end

  Builtins.y2milestone("Proposal summary: %1", summary)

  deep_copy(summary)
end

#AdjustSourcePropertiesAccordingToProduct(src_id) ⇒ Boolean

Adjusts repository name according to a first product found on the media.

See Also:

  • #481828

1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
# File 'src/modules/Packages.rb', line 1597

def AdjustSourcePropertiesAccordingToProduct(src_id)
  # This function is used from several places (also YaST Add-On)

  if src_id.nil? || Ops.less_than(src_id, 0)
    Builtins.y2error("Wrong source ID: %1", src_id)
    return nil
  end

  Builtins.y2milestone("Trying to get repository name from products")
  all_products = Pkg.ResolvableProperties("", :product, "")
  new_name = nil
  Builtins.foreach(all_products) do |one_product|
    # source ID matches
    if Ops.get_integer(one_product, "source", -1) == src_id
      name = one_product["name"] || ""
      if name != ""
        new_name = name
        Builtins.y2milestone("Product name found: %1", new_name)
        raise Break
      end
    end
  end

  # Finally, some (new) name has been adjusted
  if !new_name.nil? && new_name != ""
    Builtins.y2milestone("Adjusting repository name")
    sources_got = Pkg.SourceEditGet
    sources_set = []
    Builtins.foreach(sources_got) do |one_source|
      if Ops.get_integer(one_source, "SrcId", -1) == src_id
        Ops.set(one_source, "name", new_name)
      end
      sources_set = Builtins.add(sources_set, one_source)
    end

    return Pkg.SourceEditSet(sources_set)
    # Bad luck, nothing useful found
  else
    Builtins.y2warning("No name found")

    return false
  end
end

#architecturePackagesArray

Compute architecture packages


937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
# File 'src/modules/Packages.rb', line 937

def architecturePackages
  packages = []

  # remove unneeded / add needed packages for ppc
  if Arch.ppc
    packages = Builtins.add(packages, "mouseemu") if Arch.board_mac

    if Arch.board_mac_new || Arch.board_mac_old
      pmac_board = ""
      pmac_compatible = Convert.convert(
        SCR.Read(path(".probe.cpu")),
        from: "any",
        to:   "list <map>"
      )
      Builtins.foreach(pmac_compatible) do |pmac_compatible_tmp|
        pmac_board = Ops.get_string(pmac_compatible_tmp, "system", "")
      end

      # install pbbuttonsd on PowerBooks and iMacs
      if Builtins.issubstring(pmac_board, "PowerBook") ||
          Builtins.issubstring(pmac_board, "PowerMac2,1") ||
          Builtins.issubstring(pmac_board, "PowerMac2,2") ||
          Builtins.issubstring(pmac_board, "PowerMac4,1") ||
          Builtins.issubstring(pmac_board, "iMac,1")
        packages = Builtins.add(packages, "pbbuttonsd")
        packages = Builtins.add(packages, "powerprefs")
      end
    end

    if Arch.ppc64 && (Arch.board_chrp || Arch.board_iseries)
      packages = Builtins.add(packages, "iprutils")
    end
  end

  if Arch.ia64
    # install fpswa if the firmware has an older version
    if SCR.Execute(path(".target.bash"), "/sbin/fpswa_check_version").nonzero?
      packages = Builtins.add(packages, "fpswa")
    end
  end

  if Arch.is_xenU
    # xen-tools-domU are required for registration of a Xen VM (domU)
    packages = Builtins.add(packages, "xen-tools-domU")
  end

  # add numactl on x86_64 with SMP
  if Arch.has_smp && Arch.x86_64
    packages = Builtins.add(packages, "numactl")
    packages = Builtins.add(packages, "irqbalance")
  end

  deep_copy(packages)
end

#boardPackagesArray

Compute board (vendor) dependant packages


1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# File 'src/modules/Packages.rb', line 1043

def boardPackages
  probe = Convert.convert(
    SCR.Read(path(".probe.system")),
    from: "any",
    to:   "list <map <string, any>>"
  )
  packages = Ops.get_list(probe, [0, "requires"], [])
  Builtins.y2milestone("Board/Vendor specific packages: %1", packages)

  packages
end

#braille_packagesArray<String>

List of packages expected to be installed in order to enable braille


2445
2446
2447
2448
# File 'src/modules/Packages.rb', line 2445

def braille_packages
  tags = ["sbl"]
  find_providers(tags)
end

#check_ntp_installation_packagesString

When the NTP configuration has been modified, it checks whether the service package is selected to be installed or not.


861
862
863
864
865
866
867
868
869
870
# File 'src/modules/Packages.rb', line 861

def check_ntp_installation_packages
  Yast.import "NtpClient"

  return "" unless NtpClient.modified
  return "" if pkg_will_be_installed(NtpClientClass::REQUIRED_PACKAGE)

  # TRANSLATORS: warning message
  _("The NTP configuration (chrony) has been modified, " \
    "but the package is not selected to be installed.")
end

#check_remote_installation_packagesString

Checking if all needed packages for remote installation will be installed on the target system.


866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'src/modules/Packages.rb', line 866

def check_remote_installation_packages
  @missing_remote_kind = []
  @missing_remote_packages = []

  if Linuxrc.braille
    missing = braille_packages.reject { |tag| pkg_will_be_installed(tag) }
    unless missing.empty?
      @missing_remote_packages << missing
      @missing_remote_kind << "BRAILLE"
    end
  end
  if Linuxrc.usessh
    missing = ssh_packages.reject { |tag| pkg_will_be_installed(tag) }
    unless missing.empty?
      @missing_remote_packages << missing
      @missing_remote_kind << "SSH"
    end
  end
  if Linuxrc.vnc
    missing = vnc_packages.reject { |tag| pkg_will_be_installed(tag) }
    unless missing.empty?
      @missing_remote_packages << missing
      @missing_remote_kind << "VNC"
    end
  end
  if Linuxrc.display_ip
    missing = remote_x11_packages.reject { |tag| pkg_will_be_installed(tag) }
    unless missing.empty?
      @missing_remote_packages << missing
      @missing_remote_kind << "DISPLAY_IP"
    end
  end

  missing_remote_packages.flatten!
  unless missing_remote_packages.empty?
    error_string = format(_("Cannot support %s remote access in the installed system" \
      " due missing packages \n%s. \nIt will be disabled."),
      @missing_remote_kind.join(", "), @missing_remote_packages.join(", "))
    if Mode.auto
      error_string << " \n"
      error_string << _("But the AutoYaST installation will be still finished automatically " \
        "without any user interaction.")
    end
    log.warn("Cannot support #{@missing_remote_kind} remote access in the " \
      "installed system due missing packages #{@missing_remote_packages}")
    return error_string
  end
  ""
end

#CheckDiskSize(init) ⇒ Boolean

Check if selected software fits on the partitions


431
432
433
434
435
436
437
# File 'src/modules/Packages.rb', line 431

def CheckDiskSize(init)
  if init
    Builtins.y2milestone("Resetting space calculation")
    SpaceCalculation.GetPartitionInfo
  end
  SpaceCalculation.CheckDiskSize
end

#CheckOldAddOns(ret) ⇒ Object

Checks which products have been selected for removal and modifies the warning messages accordingly.


443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'src/modules/Packages.rb', line 443

def CheckOldAddOns(ret)
  products = Pkg.ResolvableProperties("", :product, "")
  products = Builtins.filter(products) do |one_product|
    Ops.get_symbol(one_product, "status_detail", :unknown) == :S_AutoDel
  end

  # no such products
  if Builtins.size(products).zero?
    Builtins.y2milestone("No products marked for auto-removal")
    return
  end

  Builtins.y2warning("Product marked for auto-removal: %1", products)

  warning = ""

  Builtins.foreach(products) do |one_product|
    warning = Ops.add(
      Ops.add(
        Ops.add(warning, "<li>"),
        Ops.get_locale(
          one_product,
          "display_name",
          Ops.get_locale(
            one_product,
            "name",
            Ops.get_locale(one_product, "NCL", _("Unknown Product"))
          )
        )
      ),
      "</li>\n"
    )
  end

  warning = Builtins.sformat(
    _("These add-on products have been marked for auto-removal: %1"),
    Ops.add(Ops.add("<ul>\n", warning), "</ul>\n")
  )

  # raising warning level if needed
  if Ops.get(ret.value, "warning_level").nil? ||
      Builtins.contains(
        [:notice, :ok],
        Ops.get_symbol(ret.value, "warning_level", :warning)
      )
    Ops.set(ret.value, "warning_level", :warning)
  end

  if Ops.greater_than(
    Builtins.size(Ops.get_string(ret.value, "warning", "")),
    0
  )
    Ops.set(
      ret.value,
      "warning",
      Ops.add(
        Ops.add(Ops.get_string(ret.value, "warning", ""), "<br>\n"),
        if Ops.greater_than(Builtins.size(products), 1)
          # Warning message when some add-ons are marked to be removed automatically
          _(
            "Contact the vendors of these add-ons to provide you with new installation media."
          )
        else
          # Warning message when some add-ons are marked to be removed automatically
          _(
            "Contact the vendor of the add-on to provide you with a new installation media."
          )
        end
      )
    )
  end

  Ops.set(
    ret.value,
    "warning",
    Ops.add(Ops.get_string(ret.value, "warning", ""), warning)
  )

  nil
end

#ComputeAdditionalKernelPackagesArray<String>

Additional kernel packages from control file


1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'src/modules/Packages.rb', line 1079

def ComputeAdditionalKernelPackages
  final_kernel = Kernel.GetFinalKernel
  pos = Builtins.findfirstof(final_kernel, "-")
  extension = Builtins.substring(
    final_kernel,
    pos,
    Builtins.size(final_kernel)
  )
  akp = []
  if extension != ""
    kernel_packages = Convert.convert(
      ProductFeatures.GetFeature("software", "kernel_packages"),
      from: "any",
      to:   "list <string>"
    )
    if Ops.greater_than(Builtins.size(kernel_packages), 0) &&
        !kernel_packages.nil?
      akp = Builtins.maplist(kernel_packages) do |p|
        Ops.add(Ops.add(p, "-"), extension)
      end
    end
  end
  deep_copy(akp)
end

#ComputeSystemPackageListArray<String>

Build and return list of packages which depends on the the current target system and the preselected packages (architecture, X11.…)


1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
# File 'src/modules/Packages.rb', line 1126

def ComputeSystemPackageList
  install_list = architecturePackages
  install_list.concat(modePackages)

  if !@additional_packages.empty?
    log.warn("Additional packages are still in use, please, " \
      "change it to use PackagesProposal API")
    log.info("Additional packages: #{@additional_packages}")
    install_list.concat(@additional_packages)
  end

  # bnc #431580
  # New API for packages selected by other modules
  # use both mandatory and optional packages
  packages_proposal_all_packages = PackagesProposal.GetAllResolvables(:package, optional: true)
  packages_proposal_all_packages.concat(PackagesProposal.GetAllResolvables(:package))

  log.info("PackagesProposal packages: #{packages_proposal_all_packages}")
  install_list.concat(packages_proposal_all_packages)

  # Kernel is added in autoinstPackages () if autoinst is enabled
  if !Mode.update || !Mode.autoinst
    kernel_pkgs = Kernel.ComputePackages
    install_list.concat(kernel_pkgs)

    kernel_pkgs_additional = ComputeAdditionalKernelPackages()
    install_list.concat(kernel_pkgs_additional)
  end

  # TODO: um, VNC packages are also selected in modePackages(),... ???
  if Pkg.IsSelected("xorg-x11-Xvnc") && Linuxrc.vnc && !Linuxrc.serial_console
    log.info("Selecting graphic packages: #{GRAPHIC_PACKAGES}")
    install_list.concat(GRAPHIC_PACKAGES)
  end

  install_list.concat(kernelCmdLinePackages)

  install_list.concat(boardPackages)

  # add packages required to access the repository in the 2nd stage and at run-time
  install_list.concat(sourceAccessPackages)

  # and the most flexible enhancement for other products
  # NOTE: not really flexible, because it requires the client
  # in the instsys, instead use <kernel-packages> in the control file.
  pkg_mogrify_client = ProductFeatures.GetFeature("software", "packages_transmogrify")
  if !pkg_mogrify_client.empty?
    tmp_list = Convert.convert(
      WFM.CallFunction(pkg_mogrify_client, [install_list]),
      from: "any",
      to:   "list <string>"
    )

    # Make sure we did not get a nil from calling the client, i.e.
    # if the client does not exist at all..
    install_list = deep_copy(tmp_list) if !tmp_list.nil?
  end

  packages = ProductFeatures.GetFeature("software", "packages")
  if !packages.empty?
    log.info("Adding packages from control file: #{packages}")
    install_list.concat(packages)
  end

  install_list.uniq!
  log.info("Computed packages for the system: #{install_list}")
  install_list
end

#ComputeSystemPatternListObject


GLOBAL FUNCTIONS



1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
# File 'src/modules/Packages.rb', line 1108

def ComputeSystemPatternList
  pattern_list = extra_system_patterns

  # FATE #302116, BNC #431580
  # select both mandatory and optional patterns
  proposed_patterns = (resolvable_mandatory_patterns | resolvable_optional_patterns)

  log.info("PackagesProposal patterns: #{proposed_patterns}")
  pattern_list.concat(proposed_patterns)

  log.info("System patterns: #{pattern_list}")
  pattern_list
end

#CountSizeToBeDownloadedFixnum

Count the total size of packages to be installed


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
# File 'src/modules/Packages.rb', line 235

def CountSizeToBeDownloaded
  ret = 0

  # get list of remote repositories
  # consider only http(s) and ftp protocols as remote

  # all enabled sources
  repos = Pkg.SourceGetCurrent(true)
  remote_repos = []

  Builtins.foreach(repos) do |repo|
    url = Ops.get_string(Pkg.SourceGeneralData(repo), "url", "")
    scheme = Builtins.tolower(Ops.get_string(URL.Parse(url), "scheme", ""))
    if scheme == "http" || scheme == "https" || scheme == "ftp"
      Builtins.y2milestone("Found remote repository %1: %2", repo, url)
      remote_repos = Builtins.add(remote_repos, repo)
    end
  end

  # shortcut, no remote repository found
  if Builtins.size(remote_repos).zero?
    Builtins.y2milestone("No remote repository found")
    return 0
  end

  repo_mapping = SrcMapping()

  media_sizes = Pkg.PkgMediaPackageSizes
  Builtins.y2debug("Media sizes: %1", media_sizes)

  Builtins.foreach(remote_repos) do |repoid|
    repo_media_sizes = Ops.get(
      media_sizes,
      Ops.subtract(Ops.get(repo_mapping, repoid, -1), 1),
      []
    )
    Builtins.foreach(repo_media_sizes) do |media_size|
      ret = Ops.add(ret, media_size)
    end
  end

  Builtins.y2milestone(
    "Total size of packages to download: %1 (%2kB)",
    ret,
    Ops.divide(ret, 1024)
  )
  ret
end

#CountSizeToBeInstalledString

Count the total size of packages to be installed


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'src/modules/Packages.rb', line 197

def CountSizeToBeInstalled
  sz = 0
  media_sizes = Pkg.PkgMediaSizes

  Builtins.foreach(media_sizes) do |inst_sizes|
    Builtins.foreach(inst_sizes) do |inst_size|
      sz = Ops.add(sz, inst_size)
    end
  end

  Builtins.y2milestone(
    "Total size of packages to install %1 (%2kB)",
    sz,
    Ops.divide(sz, 1024)
  )
  String.FormatSizeWithPrecision(sz, 1, true)
end

#default_patternsArray

Reads software->default_patterns and returns lisf of patterns that should be selected for installation by default


2349
2350
2351
# File 'src/modules/Packages.rb', line 2349

def default_patterns
  product_feature_items("software", "default_patterns")
end

#DellSystemObject

CHeck whether this is a Dell system


1006
1007
1008
1009
1010
1011
1012
1013
1014
# File 'src/modules/Packages.rb', line 1006

def DellSystem
  command = "/usr/sbin/hwinfo --bios | grep -q '^[[:space:]]*Vendor:.*Dell Inc\\.'"
  Builtins.y2milestone("Executing: %1", command)

  ret = SCR.Execute(path(".target.bash"), command).zero?
  Builtins.y2milestone("Detected a Dell system") if ret

  ret
end

#extra_system_patternsArray<String>

Extra patterns for the current target system


2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
# File 'src/modules/Packages.rb', line 2376

def extra_system_patterns
  pattern_list = []

  # 'laptop' selection if PCMCIA detected
  if Arch.is_laptop || Arch.has_pcmcia
    ["laptop", "Laptop"].each do |pat_name|
      pat_list = Pkg.ResolvableProperties(pat_name, :pattern, "")
      pattern_list << pat_name unless pat_list.empty?
    end
  end

  # FIPS pattern
  if (Linuxrc.InstallInf("Cmdline") || "").split.include?("fips=1")
    fips_pattern = "fips"
    if !Pkg.ResolvableProperties(fips_pattern, :pattern, "").empty?
      log.info "fips=1 boot option detected, adding '#{fips_pattern}' pattern"
      pattern_list << fips_pattern
    end
  end

  pattern_list
end

#FindAndCopySlideDir(our_slidedir, source, search_for_dir, lang_long, lang_short, fallback_lang) ⇒ Object


1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
# File 'src/modules/Packages.rb', line 1269

def FindAndCopySlideDir(our_slidedir, source, search_for_dir, lang_long,
  lang_short, fallback_lang)
  # directory used as a source of texts
  providedir = nil

  # one of the localizations (long or short)
  used_loc_dir = ""

  Builtins.foreach([lang_long, lang_short, fallback_lang]) do |try_this_lang|
    next if try_this_lang.nil? || try_this_lang == ""
    test_dir = Builtins.sformat("%1/txt/%2", search_for_dir, try_this_lang)
    Builtins.y2milestone("Checking '%1'", test_dir)
    providedir = Pkg.SourceProvideSignedDirectory(
      source,
      1,
      test_dir,
      true,
      true
    )
    if !providedir.nil?
      Builtins.y2milestone("%1 lang found", try_this_lang)
      used_loc_dir = try_this_lang
      # don't check for other langs
      raise Break
    end
  end

  # no wanted localization found
  if providedir.nil?
    Builtins.y2milestone(
      "Neither %1 nor %2 localization found",
      lang_long,
      lang_short
    )
    return false
  end

  # where texts are stored later
  loc_slidedir = Builtins.sformat("%1/txt/%2/", our_slidedir, used_loc_dir)
  WFM.Execute(
    path(".local.bash"),
    Builtins.sformat("mkdir -p '%1'", String.Quote(loc_slidedir))
  )

  # copy all files to our own cache
  copy_command = Builtins.sformat(
    "cp -r '%1/%2/txt/%3'/* '%4'",
    String.Quote(providedir),
    String.Quote(search_for_dir),
    String.Quote(used_loc_dir),
    String.Quote(loc_slidedir)
  )

  Builtins.y2milestone("Copying: %1", copy_command)
  WFM.Execute(path(".local.bash"), copy_command)

  # where images are stored
  imagesdir = Builtins.sformat("%1/pic", search_for_dir)

  imagesdir = Pkg.SourceProvideSignedDirectory(
    source,
    1,
    imagesdir,
    true,
    true
  )

  if !imagesdir.nil?
    # where images should be cached
    our_imagesdir = Builtins.sformat("%1/pic/", our_slidedir)
    WFM.Execute(
      path(".local.bash"),
      Builtins.sformat("mkdir -p '%1'", String.Quote(our_imagesdir))
    )

    copy_command = Builtins.sformat(
      "cp -r '%1/%2/pic'/* '%3'",
      String.Quote(imagesdir),
      String.Quote(search_for_dir),
      String.Quote(our_imagesdir)
    )

    Builtins.y2milestone("Copying: %1", copy_command)
    WFM.Execute(path(".local.bash"), copy_command)
  else
    Builtins.y2error("No such dir: %1", imagesdir)
  end

  true
end

#FindAndCopySlideDirWithoutCallbacks(our_slidedir, source, search_for_dir, lang_long, lang_short, fallback_lang) ⇒ Object


1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
# File 'src/modules/Packages.rb', line 1360

def FindAndCopySlideDirWithoutCallbacks(our_slidedir, source, search_for_dir,
  lang_long, lang_short, fallback_lang)
  # disable callbacks
  PackageCallbacks.RegisterEmptyProgressCallbacks

  ret = FindAndCopySlideDir(
    our_slidedir,
    source,
    search_for_dir,
    lang_long,
    lang_short,
    fallback_lang
  )

  # restore callbacks
  PackageCallbacks.RestorePreviousProgressCallbacks

  ret
end

#FindAndRememberAddOnProductsFiles(initial_repository) ⇒ Object


1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
# File 'src/modules/Packages.rb', line 1641

def FindAndRememberAddOnProductsFiles(initial_repository)
  tmp_add_on_products = nil
  @add_on_products_list = []

  filename = nil
  tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir")))

  # #303675: Support several AddOns on standard SLE medium
  # at first, try to find XML configuration
  # then as a fallback/backward compatibility the old plain configuration
  Builtins.foreach(
    [["/add_on_products.xml", "xml"], ["/add_on_products", "plain"]]
  ) do |one_aop|
    file = Ops.get(one_aop, 0, "")
    type = Ops.get(one_aop, 1, "")
    # BNC #496404: These files should not be checked for signatures
    tmp_add_on_products = Pkg.SourceProvideOptionalFile(
      initial_repository,
      1,
      file
    )
    if !tmp_add_on_products.nil?
      filename = Builtins.sformat(
        "%1/add_on_products_defined_by_repository",
        tmpdir
      )
      @add_on_products_list = Builtins.add(
        @add_on_products_list,
        "file" => filename, "type" => type
      )
      WFM.Execute(
        path(".local.bash"),
        Builtins.sformat(
          "cp '%1' '%2'",
          String.Quote(tmp_add_on_products),
          String.Quote(filename)
        )
      )
      Builtins.y2milestone(
        "Found add_on_products (repository) %1 type %2",
        tmp_add_on_products,
        type
      )
      raise Break
    end
  end

  # FATE #312263 Files in the root of inst-sys
  Builtins.foreach(
    [["/add_on_products.xml", "xml"], ["/add_on_products", "plain"]]
  ) do |one_aop|
    file = Ops.get(one_aop, 0, "")
    type = Ops.get(one_aop, 1, "")
    # In inst-sys, files are already stored locally
    if FileUtils.Exists(file)
      filename = Builtins.sformat(
        "%1/add_on_products_defined_by_inst_sys",
        tmpdir
      )
      @add_on_products_list = Builtins.add(
        @add_on_products_list,
        "file" => filename, "type" => type
      )
      WFM.Execute(
        path(".local.bash"),
        Builtins.sformat(
          "cp '%1' '%2'",
          String.Quote(file),
          String.Quote(filename)
        )
      )
      Builtins.y2milestone(
        "Found add_on_products (inst-sys) %1 type %2",
        file,
        type
      )
      raise Break
    end
  end

  Ops.greater_than(Builtins.size(@add_on_products_list), 0)
end

#ForceFullReproposeObject

proposal control functions


800
801
802
803
804
# File 'src/modules/Packages.rb', line 800

def ForceFullRepropose
  @full_repropose = true

  nil
end

#GetBaseSourceIDFixnum

Returns ID of the base product repository.


1265
1266
1267
# File 'src/modules/Packages.rb', line 1265

def GetBaseSourceID
  @base_source_id
end

#group_products_by_status(products) ⇒ Hash<Symbol,Object>

group products according to the current state


682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'src/modules/Packages.rb', line 682

def group_products_by_status(products)
  to_install = products_to_install(products)
  to_remove = products_to_remove(products)
  to_update = products_to_update(to_install, to_remove)

  # remove the updated products from selected and removed lists
  to_remove -= to_update.keys
  to_install -= to_update.values

  ret = {
    new:     to_install,
    removed: to_remove,
    kept:    kept_products(products),
    updated: to_update
  }

  log.info "Product update status: #{ret}"

  ret
end

#ImportGPGKeysObject

Import GPG keys found in the inst-sys


1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
# File 'src/modules/Packages.rb', line 1196

def ImportGPGKeys
  out = Convert.to_map(
    SCR.Execute(path(".target.bash_output"), "/bin/ls -d /*.gpg")
  )
  Builtins.foreach(
    Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
  ) { |file| Pkg.ImportGPGKey(file, true) if file != "" }

  nil
end

#InfoAboutSubOptimalDistributionString

Return information about suboptimal distribution if relevant


286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'src/modules/Packages.rb', line 286

def InfoAboutSubOptimalDistribution
  if ProductFeatures.GetBooleanFeature(
    "software",
    "inform_about_suboptimal_distribution"
  ) &&
      Arch.i386
    tmp = Convert.to_string(
      SCR.Read(path(".proc.cpuinfo.value.\"0\".\"flags\""))
    )
    flags = tmp.empty? ? [] : tmp.split(" ")

    # this depends on the cpu (lm = long mode)
    if Builtins.contains(flags, "lm")
      # warning text
      return _(
        "Your computer is a 64-bit x86-64 system, " \
          "but you are trying to install a 32-bit distribution."
      )
    end
  end
  ""
end

#Init(_unused) ⇒ Object


1889
1890
1891
1892
1893
# File 'src/modules/Packages.rb', line 1889

def Init(_unused)
  Initialize(true)

  nil
end

#InitFailedObject


2256
2257
2258
2259
2260
# File 'src/modules/Packages.rb', line 2256

def InitFailed
  ret = !@init_error.nil?
  Builtins.y2milestone("Package manager initialization failed: %1", ret)
  ret
end

#Initialize(show_popup) ⇒ Object

Initialize the repositories


1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
# File 'src/modules/Packages.rb', line 1807

def Initialize(show_popup)
  if @init_called || @init_in_progress
    Builtins.y2milestone("Packages::Initialize() already called")
    return
  end

  @init_in_progress = true

  # usual mountpoint for the medium
  base_url = ""
  # url with hidden password for logging purpose
  log_url = ""

  base_url_ref = arg_ref(base_url)
  log_url_ref = arg_ref(log_url)
  Initialize_BaseInit(show_popup, base_url_ref, log_url_ref)
  base_url = base_url_ref.value
  log_url = log_url_ref.value

  if !Stage.initial
    Builtins.y2milestone("Initializing the target...")
    Pkg.TargetInitialize(Installation.destdir)
  end

  @theSources = Stage.initial ? [] : Pkg.SourceStartCache(true) # dummy in 1st stage

  again = true

  while again
    if Stage.initial
      Initialize_StageInitial(show_popup, base_url, log_url) # cont or normal mode
    else
      Initialize_StageNonInitial(show_popup, base_url, log_url)
    end

    Builtins.y2milestone("theSources %1", @theSources)
    Builtins.y2milestone("theSourceDirectories %1", @theSourceDirectories)

    if Ops.greater_or_equal(Builtins.size(@theSources), 0)
      @init_called = true
      again = false
    else
      # an error message
      errortext = Ops.add(
        Ops.add(
          Builtins.sformat(
            _(
              "Error while initializing package descriptions.\n" \
                "Check the log file %1 for more details."
            ),
            Ops.add(Directory.logdir, "/y2log")
          ),
          "\n"
        ),
        Pkg.LastError
      )

      # FIXME: somewhere get correct current_label and wanted_label
      PackageCallbacks.MediaChange(
        "NO_ERROR",
        errortext,
        base_url,
        "",
        0,
        "",
        1,
        "",
        false,
        [],
        0
      )
    end
  end

  # FATE #302123
  AddOnProduct.SetBaseProductURL(base_url)

  @init_in_progress = false

  nil
end

#Initialize_BaseInit(show_popup, base_url, log_url) ⇒ Object


1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
# File 'src/modules/Packages.rb', line 1550

def Initialize_BaseInit(show_popup, base_url, log_url)
  popup_open = false
  if show_popup
    UI.OpenDialog(
      Opt(:decorated),
      # popup - information label
      Label(_("Initializing repositories..."))
    )
    popup_open = true
  end

  PackageCallbacks.InitPackageCallbacks

  # Initialize package manager
  @init_error = nil
  Builtins.y2milestone("Packages::Initialize_BaseInit()")

  base_url.value = if Mode.test
    # Fake values for testing purposes
    "dir:///dist/next-i386"
  else
    InstURL.installInf2Url("")
  end

  # '\' is not reserved nor unreserved according to rfc https://tools.ietf.org/html/rfc3986#section-2.1
  # but ruby URI does not handle it. So to make life easier encode it (bsc#1032506)
  base_url.value.gsub!("\\", "%5C")

  # hide password from URL if present
  log_url.value = URL.HidePassword(base_url.value)
  Builtins.y2milestone("Initialize Package Manager: %1", log_url.value)

  # Set languages for packagemanager. Always set the UI language. Set
  # language for additional packages only in Stage::initial ().
  Pkg.SetTextLocale(Language.language)

  UI.CloseDialog if popup_open

  true
end

#Initialize_StageInitial(show_popup, base_url, log_url) ⇒ Object


1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
# File 'src/modules/Packages.rb', line 1724

def Initialize_StageInitial(show_popup, base_url, log_url)
  initial_repository = nil
  ImportGPGKeys()

  # Create the baseproduct link if it does not exist yet,
  # openSUSE includes the file in the inst-sys while SLES/SLED do not.
  create_baseproduct_symlink unless File.exist?(BASE_PRODUCT_FILE)

  # prefer CD/DVD media to download during installation/update
  # (BNC#780617,865819)
  Builtins.y2milestone("Prefer CD/DVD media to download")
  Pkg.SetZConfig("download_media_prefer_download" => false)

  while initial_repository.nil?
    initial_repository = Pkg.SourceCreateBase(base_url, "")
    next unless initial_repository == -1 || initial_repository.nil?
    Builtins.y2error("No repository in '%1'", log_url)
    base_url = UpdateSourceURL(base_url)
    if base_url != ""
      initial_repository = nil
    else
      @init_in_progress = false
      return
    end
  end

  # BNC #481828: Using LABEL from product
  AdjustSourcePropertiesAccordingToProduct(@base_source_id)

  @base_source_id = initial_repository
  Builtins.y2milestone("Base source ID: %1", @base_source_id)

  # Set the product before setting up add-on products
  # In the autoyast mode it could be that the proposal
  # screen will not be displayed. So the product will
  # not be set. Bug 178831
  SelectProduct()

  @theSources = [initial_repository]
  sp_source = IntegrateServicePack(show_popup, base_url)
  @theSources = Builtins.add(@theSources, sp_source) if !sp_source.nil?

  if ProductFeatures.GetFeature("software", "selection_type") == :fixed
    # selections not supported anymore, install a pattern
    Pkg.ResolvableInstall(
      ProductFeatures.GetStringFeature("software", "base_selection"),
      :pattern
    )
  end

  FindAndRememberAddOnProductsFiles(initial_repository)

  nil
end

#Initialize_StageNonInitial(_show_popup, base_url, _log_url) ⇒ Object


1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
# File 'src/modules/Packages.rb', line 1779

def Initialize_StageNonInitial(_show_popup, base_url, _log_url)
  if @theSources.nil? || Ops.less_or_equal(Builtins.size(@theSources), 0)
    Builtins.y2error("Pkg::SourceStartCache failed")
    @theSources = []
  elsif Stage.cont && # rewrite URL if cd/dvd since ide-scsi might have changed it
      (Builtins.substring(base_url, 0, 2) == "cd" ||
        Builtins.substring(base_url, 0, 3) == "dvd")
    Builtins.foreach(@theSources) do |source|
      data = Pkg.SourceGeneralData(source) # get repository data
      url = Ops.get_string(data, "url", "")
      if Builtins.substring(url, 0, 2) == "cd" || # repository comes from cd/dvd
          Builtins.substring(url, 0, 3) == "dvd"
        new_url = InstURL.RewriteCDUrl(url)
        Builtins.y2milestone(
          "rewrite url: '%1'->'%2'",
          url,
          URL.HidePassword(new_url)
        )
        Pkg.SourceChangeUrl(source, new_url)
      end
    end
  end

  nil
end

#InitializeAddOnProductsObject

Initialize add-on products provided by the repository


836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'src/modules/Packages.rb', line 836

def InitializeAddOnProducts
  SelectProduct()
  PackageCallbacks.SetMediaCallbacks

  # Set the base workflow before adding more AddOnProducts using the add_on_products file
  # Do not force "base workflow" if there is already any base one stored
  # bugzilla #269625
  WorkflowManager.SetBaseWorkflow(false)

  if @add_on_products_list != []
    Builtins.y2milestone(
      "Found list of add-on products to preselect: %1",
      @add_on_products_list
    )
    if Mode.auto
      Builtins.y2warning("This is an AutoYaST installation. "\
        "Only Add-on products will be added which have been defined "\
        "in the add-on section of the AutoYaST configuration file.")
    else
      AddOnProduct.AddPreselectedAddOnProducts(@add_on_products_list)
    end
    @add_on_products_list = [] # do not select them any more
  end

  nil
end

#InitializeCatalogsObject

Initialize the repositories with popup feedback Use Packages::Initialize (true) instead


2250
2251
2252
2253
2254
# File 'src/modules/Packages.rb', line 2250

def InitializeCatalogs
  Initialize(true)

  nil
end

#IntegrateServicePack(show_popup, base_url) ⇒ Object


1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'src/modules/Packages.rb', line 1490

def IntegrateServicePack(show_popup, base_url)
  # Check for Service Pack
  if Ops.greater_than(
    Convert.to_integer(
      WFM.Read(path(".local.size"), )
    ),
    0
  )
    Builtins.y2milestone("Service Pack data available")
    popup_open = false
    if show_popup
      UI.OpenDialog(
        Opt(:decorated),
        # popup - information label
        Label(_("Integrating booted media..."))
      )
      popup_open = true
    end
    spdir = Ops.add(@metadir, "/Service-Pack/CD1")
    WFM.Execute(path(".local.mkdir"), spdir)
    Builtins.y2milestone("Filling %1", spdir)
    WFM.Execute(
      path(".local.bash"),
      Ops.add(
        Ops.add(Ops.add("tar -zxvf ", ), " -C "),
        spdir
      )
    )
    sp_url = Ops.add("dir:", spdir)
    # close the popup in order to be able to ask about the license
    UI.CloseDialog if popup_open
    sp_source = Pkg.SourceCreate(sp_url, "")
    if sp_source == -1
      Report.Error(_("Failed to integrate the service pack repository."))
      return nil
    end
    if !AddOnProduct.AcceptedLicenseAndInfoFile(sp_source)
      Builtins.y2milestone("service pack license rejected")
      Pkg.SourceDelete(sp_source)
      return nil
    end
    if FileUtils.Exists(Ops.add(spdir, "/installation.xml"))
      WorkflowManager.AddWorkflow(:addon, sp_source, "")
      WorkflowManager.MergeWorkflows
    end
    if FileUtils.Exists(Ops.add(spdir, "/y2update.tgz"))
      AddOnProduct.UpdateInstSys(Ops.add(spdir, "/y2update.tgz"))
    end
    @theSources = Builtins.add(@theSources, sp_source)
    Builtins.y2milestone(
      "Service pack repository: %1, changing to URL: %2",
      sp_source,
      base_url
    )
    Pkg.SourceChangeUrl(sp_source, base_url)
  end

  nil
end

#kernelCmdLinePackagesObject


1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
# File 'src/modules/Packages.rb', line 1016

def kernelCmdLinePackages
  ret = []

  add_biosdevname = false
  options = SCR.Read(path(".proc.cmdline"))
  option = options.grep(/^biosdevname=/i).first if options
  value = (option[/^biosdevname=(\d+)/i, 1] if option)

  if value == "1"
    Builtins.y2milestone("Biosdevname explicitly enabled")
    add_biosdevname = true
  elsif value == "0"
    Builtins.y2milestone("Biosdevname explicitly disabled")
    add_biosdevname = false
  else
    Builtins.y2milestone("Missing biosdevname option, autodetecting...")
    add_biosdevname = true if DellSystem()
  end
  ret << "biosdevname" if add_biosdevname

  Builtins.y2milestone("Packages added by kernel command line: %1", ret)

  deep_copy(ret)
end

#ListSelected(what, format) ⇒ Object

List selected resolvables of specified kind


183
184
185
186
187
188
189
190
191
192
193
# File 'src/modules/Packages.rb', line 183

def ListSelected(what, format)
  selected = Pkg.ResolvableProperties("", what, "")

  selected.select! { |r| r["status"] == :selected }

  selected.select! { |r| r["user_visible"] } if what == :pattern

  sort_resolvable!(selected, what)

  formatted_resolvables(selected, format)
end

#LocaleVersions(lang) ⇒ Object


1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
# File 'src/modules/Packages.rb', line 1247

def LocaleVersions(lang)
  ret = [lang]
  components = Builtins.splitstring(lang, ".")
  if Ops.get(components, 0, "") != lang && Ops.get(components, 0, "") != ""
    lang = Ops.get(components, 0, "")
    ret = Builtins.add(ret, lang)
  end
  components = Builtins.splitstring(lang, "_")
  if Ops.get(components, 0, "") != lang && Ops.get(components, 0, "") != ""
    lang = Ops.get(components, 0, "")
    ret = Builtins.add(ret, lang)
  end
  deep_copy(ret)
end

#log_software_selectionObject

Reads the current user selection and dumps it to log


2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
# File 'src/modules/Packages.rb', line 2406

def log_software_selection
  log.info "-" * 10 << " Transaction Status Begin " << "-" * 10

  RESOLVABLE_TYPES.each do |type|
    resolvables = Pkg.ResolvableProperties("", type, "")
    resolvables.select! { |r| LOG_RESOLVABLE_TRANSACT_BY.include? r["transact_by"] }

    LOG_RESOLVABLE_TRANSACT_BY.each do |transact_by|
      changed_resolvables = resolvables.select { |r| r["transact_by"] == transact_by }
      next if changed_resolvables.empty?

      decided_resolvables = changed_resolvables
                            .select { |r| LOG_RESOLVABLE_STATUS.include? r["status"] }
      log_resolvables("Resolvables of type #{type} set by #{transact_by}:", decided_resolvables)

      locked_resolvables = changed_resolvables.select { |r| r["locked"] }
      log_resolvables("Locked resolvables of type #{type} set by #{transact_by}:",
        locked_resolvables)
    end
  end

  log.info "-" * 10 << " Transaction Status End " << "-" * 10
  nil
end

#mainObject


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
95
96
97
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'src/modules/Packages.rb', line 45

def main
  Yast.import "UI"
  Yast.import "Pkg"
  Yast.import "Mode"

  textdomain "packager"

  Yast.import "AddOnProduct"
  Yast.import "WorkflowManager"
  Yast.import "Arch"
  Yast.import "Directory"
  Yast.import "InstURL"
  Yast.import "Kernel"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "Linuxrc"
  Yast.import "Language"
  Yast.import "ProductFeatures"
  Yast.import "ProductControl"
  Yast.import "Report"
  Yast.import "Slides"
  Yast.import "SlideShow"
  Yast.import "SpaceCalculation"
  Yast.import "String"
  Yast.import "Popup"
  Yast.import "Label"
  Yast.import "Wizard"
  Yast.import "PackageCallbacks"
  Yast.import "Product"
  Yast.import "DefaultDesktop"
  Yast.import "SourceDialogs"
  Yast.import "FileUtils"
  Yast.import "Installation"
  Yast.import "URL"
  Yast.import "PackagesProposal"
  Yast.import "HTML"

  Yast.include self, "packager/load_release_notes.rb"

  # Force full proposal routine next run
  @full_repropose = false

  # repository has been initialized?
  @init_called = false

  # repository initialization is WIP
  @init_in_progress = false

  # Error which occurred during repository initialization
  @init_error = nil

  # cache for the proposed summary
  @cached_proposal = nil

  # the selection used for the cached proposal
  # the default values 'nil' say that the proposal hasn't been called yet
  @cached_proposal_packages = nil
  @cached_proposal_patterns = nil
  @cached_proposal_products = nil
  @cached_proposal_patches = nil
  @cached_proposal_languages = nil

  @install_sources = false # Installing source packages ?
  @timestamp = 0 # last time of getting the target map

  @metadir = "/yast-install"
  @metadir_used = false # true if meta data and inst-sys is in ramdisk

  @theSources = [] # id codes of repositories in priority order
  @theSourceDirectories = [] # product directories on repositories
  @theSourceOrder = {} # installation order

   = "/servicepack.tar.gz"

  # to remember if warning should occurre if switching base selection
  @base_selection_modified = false

  @base_selection_changed = false

  # Local variables

  @choosen_base_selection = ""

  # count of errors during packages solver
  @solve_errors = 0

  # Packages to be selected when proposing the list
  @additional_packages = []

  @system_packages_selected = false

  @add_on_products_list = []

  # list of basic system directories, if any of them cannot be mounted
  # the installation will be blocked
  @basic_dirs = [
    "/",
    "/bin",
    "/boot",
    "/etc",
    "/lib",
    "/lib64",
    "/opt",
    "/sbin",
    "/usr",
    "/var"
  ]

  @base_source_id = nil

  @old_packages_proposal = nil

  # Remote kinds (vnc, ssh,...) which cannot be used in an
  # installed system.
  @missing_remote_kind = []
  # Packages which are missed to enable remote handling in
  # an installed system.
  @missing_remote_packages = []
end

#modePackagesArray

Compute special packages


994
995
996
997
998
999
1000
1001
1002
1003
# File 'src/modules/Packages.rb', line 994

def modePackages
  packages = []
  packages << braille_packages if Linuxrc.braille
  packages << ssh_packages if Linuxrc.usessh
  packages << vnc_packages if Linuxrc.vnc
  packages << remote_x11_packages if Linuxrc.display_ip
  packages.flatten!
  log.info("Installation mode packages: #{packages}")
  packages
end

#optional_default_patternsArray

Reads software->optional_default_patterns and returns lisf of patterns that should be selected for installation by default (if they exist)


2357
2358
2359
# File 'src/modules/Packages.rb', line 2357

def optional_default_patterns
  product_feature_items("software", "optional_default_patterns")
end

#PackagesProposalChangedboolean

Check whether the list of needed packages has been changed since the last package proposal


2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
# File 'src/modules/Packages.rb', line 2023

def PackagesProposalChanged
  new_packages_proposal = PackagesProposal.GetAllResolvablesForAllTypes

  # Force reinit
  changed = new_packages_proposal != @old_packages_proposal
  Builtins.y2milestone("PackagesProposal has been changed: %1", changed)
  Builtins.y2debug("PackagesProposal: %1 -> %2", @old_packages_proposal, new_packages_proposal)

  changed
end

#product_label(product) ⇒ String

return a printable name of product resolvable


788
789
790
791
792
793
794
795
796
# File 'src/modules/Packages.rb', line 788

def product_label(product)
  display_name = product["display_name"]
  return display_name if display_name && !display_name.empty?

  short_name = product["short_name"]
  return short_name if short_name && !short_name.empty?

  product["name"]
end

#product_update_summary(products) ⇒ Array<String>

create a product update summary (in rich text format) usable in update proposal


708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
# File 'src/modules/Packages.rb', line 708

def product_update_summary(products)
  status = group_products_by_status(products)

  # newly installed products
  ret = status[:new].map do |product|
    log.info "New product will be installed: #{product}"
    _("New product <b>%s</b> will be installed") % h(product_label(product))
  end

  ret += status[:updated].map do |removed, installed|
    old_product = product_label(removed)
    new_product = product_label(installed)
    log.info "Detected product update: #{old_product} -> #{new_product}"

    if old_product == new_product
      # product update: %s is a product name
      _("Product <b>%s</b> will be updated") % h(old_product)
    else
      # product update: %{old_product} is an old product, %{new_product} is the new one
      _("Product <b>%{old_product}</b> will be updated to <b>%{new_product}</b>") % {
        old_product: h(old_product), new_product: h(new_product)
      }
    end
  end

  ret += status[:kept].map do |product|
    log.info "Unchanged product: #{product}"
    _("Product <b>%s</b> will stay installed") % h(product_label(product))
  end

  ret += status[:removed].map do |product|
    transact_by = product["transact_by"]
    log.warn "Product will be removed (by #{transact_by}): #{product}"

    # Removing another product might be an issue
    # (just warn if removed by user or by YaST)
    msg = if [:user, :app_high].include?(transact_by)
      _("<b>Warning:</b> Product <b>%s</b> will be removed.") % h(product_label(product))
    else
      _("<b>Error:</b> Product <b>%s</b> will be automatically removed.") %
        h(product_label(product))
    end

    HTML.Colorize(msg, "red")
  end

  log.info "Product update summary: #{ret}"
  ret
end

#product_update_warning(products) ⇒ Hash

create a warning for product update summary (in rich text format) if there is an update problem


763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'src/modules/Packages.rb', line 763

def product_update_warning(products)
  status = group_products_by_status(products)

  return {} if status[:removed].all? { |product| product["transact_by"] != :solver }

  # Automatic product removal MUST be confirmed by user, otherwise update
  # cannot be started.
  {
    "warning_level" => :blocker,
    # TRANSLATORS: update proposal warning, do NOT translate "-release",
    # it is part of a package name (like "sles-release")
    "warning"       => _(
      "<ul><li><b>Some products are marked for automatic removal.</b></li>\n" \
        "<ul><li>Contact the vendor of the removed add-on to provide you with a new\n" \
        "installation media</li><li>Or select the appropriate online extension or module\n" \
        "in the registration step</li><li>Or to continue with product upgrade go to the\n" \
        "software selection and mark the product (the -release package) for removal.\n" \
        "</li></ul></li></ul>"
    )
  }
end

#Proposal(force_reset, reinit, _simple) ⇒ Hash

Make a proposal for package selection


2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
# File 'src/modules/Packages.rb', line 2041

def Proposal(force_reset, reinit, _simple)
  # Handle the default desktop
  DefaultDesktop.Init

  # set ignoreAlreadyRecommended solver flag
  Pkg.SetSolverFlags("ignoreAlreadyRecommended" => Mode.normal)

  # Force reinit
  if PackagesProposalChanged()
    @old_packages_proposal = PackagesProposal.GetAllResolvablesForAllTypes
    Builtins.y2milestone("Reinit package proposal")
    reinit = true
  end

  # Reinit forced by application, see ForceFullRepropose
  if @full_repropose == true
    Builtins.y2milestone("Fully reproposing")
    force_reset = true
    @full_repropose = false
  end

  if force_reset
    Builtins.y2milestone("Forcing full reset")
    # Full reset has been forced, bnc #446406
    # It resets even the user-selected/removed resolvables
    Pkg.PkgReset
    ResetProposalCache()
    reinit = true
  end

  # if the cache is valid and reset or reinitialization is not required
  # then the cached proposal can be used
  if !@cached_proposal.nil? && force_reset == false && reinit == false
    # selected packages
    selected_packages = Pkg.GetPackages(:selected, false)

    # selected patterns
    selected_patterns = Builtins.filter(
      Pkg.ResolvableProperties("", :pattern, "")
    ) do |p|
      Ops.get_symbol(p, "status", :unknown) == :selected
    end

    # selected products
    selected_products = Builtins.filter(
      Pkg.ResolvableProperties("", :product, "")
    ) do |p|
      Ops.get_symbol(p, "status", :unknown) == :selected
    end

    # selected patches
    selected_patches = Builtins.filter(
      Pkg.ResolvableProperties("", :patch, "")
    ) do |p|
      Ops.get_symbol(p, "status", :unknown) == :selected
    end

    # selected languages
    selected_languages = Convert.convert(
      Builtins.union([Pkg.GetPackageLocale], Pkg.GetAdditionalLocales),
      from: "list",
      to:   "list <string>"
    )

    # if the package selection has not been changed the cache is up to date
    if selected_packages == @cached_proposal_packages &&
        selected_patterns == @cached_proposal_patterns &&
        selected_products == @cached_proposal_products &&
        selected_patches == @cached_proposal_patches &&
        selected_languages == @cached_proposal_languages
      Builtins.y2milestone("using cached software proposal")
      return deep_copy(@cached_proposal)
    # do not show the error message during the first proposal
    # (and the only way to change to software selection manually -> software_proposal/AskUser)
    #
    # 'nil' is the default value
    # See also ResetProposalCache()
    elsif !@cached_proposal_packages.nil? &&
        !@cached_proposal_patterns.nil? &&
        !@cached_proposal_products.nil? &&
        !@cached_proposal_patches.nil? &&
        !@cached_proposal_languages.nil?
      Builtins.y2error(
        "invalid cache: the software selection has been chaged"
      )
      # bnc #436925
      Report.Message(
        _(
          "The software selection has been changed externally.\n" \
            "Software proposal will be called again."
        )
      )
    end
  else
    Builtins.y2milestone(
      "the cached proposal is empty or reset is required"
    )
  end

  if Installation.dirinstall_installing_into_dir && !force_reset && @init_called
    return Summary([:product, :pattern, :size, :desktop], false)
  end

  UI.OpenDialog(
    Opt(:decorated),
    # popup label
    Label(_("Evaluating package selection..."))
  )

  Builtins.y2milestone(
    "Packages::Proposal: force_reset %1, reinit %2, lang '%3'",
    force_reset,
    reinit,
    Language.language
  )

  # Soft proposal reset
  if !Mode.autoinst && reinit
    Builtins.y2milestone("Re/Proposing software selection")
    Kernel.ProbeKernel
    Reset([:product])
    reinit = true
  end

  initial_run = reinit || !@init_called
  Initialize(true)

  if !@init_error.nil?
    UI.CloseDialog
    return Summary([], false)
  end

  if initial_run
    # autoyast can configure AdditionalLocales
    # we don't want to overwrite this
    Pkg.SetAdditionalLocales([Language.language]) if !Mode.autoinst
  end

  SelectProduct()

  if ProductFeatures.GetFeature("software", "selection_type") == :auto
    Builtins.y2milestone("Doing pattern-based software selection")

    SelectSystemPackages(@system_packages_selected && !initial_run)
    SelectSystemPatterns(@system_packages_selected && !initial_run)
    @system_packages_selected = true
  elsif ProductFeatures.GetFeature("software", "selection_type") == :fixed
    Builtins.y2milestone("Selection type: fixed")
  else
    Builtins.y2error(
      "unknown value %1 for ProductFeatures::GetFeature (software, selection_type)",
      Convert.to_symbol(
        ProductFeatures.GetFeature("software", "selection_type")
      )
    )
  end

  @solve_errors = Pkg.PkgSolveErrors if !Pkg.PkgSolve(false)

  # Question: is `desktop appropriate for SLE?
  ret = Summary([:product, :pattern, :size, :desktop], false)
  # TODO: simple proposal

  # cache the proposal
  @cached_proposal = deep_copy(ret)

  # remember the status
  @cached_proposal_packages = Pkg.GetPackages(:selected, false)
  @cached_proposal_patterns = Builtins.filter(
    Pkg.ResolvableProperties("", :pattern, "")
  ) do |p|
    Ops.get_symbol(p, "status", :unknown) == :selected
  end
  @cached_proposal_products = Builtins.filter(
    Pkg.ResolvableProperties("", :product, "")
  ) do |p|
    Ops.get_symbol(p, "status", :unknown) == :selected
  end
  @cached_proposal_patches = Builtins.filter(
    Pkg.ResolvableProperties("", :patch, "")
  ) do |p|
    Ops.get_symbol(p, "status", :unknown) == :selected
  end
  @cached_proposal_languages = Convert.convert(
    Builtins.union([Pkg.GetPackageLocale], Pkg.GetAdditionalLocales),
    from: "list",
    to:   "list <string>"
  )

  UI.CloseDialog

  Builtins.y2milestone("Software proposal: %1", ret)

  deep_copy(ret)
end

#proposal_for_updateObject

Make a proposal for package selection during update

As a side effect, it stores the current proposal.


2242
2243
2244
2245
2246
# File 'src/modules/Packages.rb', line 2242

def proposal_for_update
  return unless PackagesProposalChanged()
  @old_packages_proposal = PackagesProposal.GetAllResolvablesForAllTypes
  Packages.SelectSystemPackages(false)
end

#remote_x11_packagesArray<String>

List of packages expected to be installed in order to use a remote X11 server


2467
2468
2469
2470
2471
# File 'src/modules/Packages.rb', line 2467

def remote_x11_packages
  tags = REMOTE_X11_BASE_TAGS.dup
  tags.concat(AUTOYAST_X11_TAGS) if Mode.autoinst
  find_providers(tags)
end

#repo_schemesArray<String>

Return the URL schemes for the currently defined repositories (only enabled repositories are evaluated). For ISO repositories the base URL schema is returned (i.e. the location of the ISO), invalid URLs are ignored.


1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
# File 'src/modules/Packages.rb', line 1085

def repo_schemes
  schemes = []

  # all enabled repositories
  Pkg.SourceGetCurrent(true).each do |repo|
    url = Pkg.SourceURL(repo)

    begin
      uri = URI(url)

      # handle the ISO scheme specifically
      # Note: scheme is converted to lowercase by Ruby
      if uri.scheme == "iso" && uri.query
        # parse the query string into a hash, extract the base URL from the query
        # CGI.parse output is a hash: key => [val1, val2, ...]
        params = CGI.parse(uri.query)
        # expect only one "url" parameter
        scheme = URI(params["url"].first).scheme if params["url"] && !params["url"].empty?
      else
        scheme = uri.scheme
      end

      schemes << scheme if scheme && !schemes.include?(scheme)
    # normally should not happen, the URLs from libzypp should be always valid
    rescue URI::InvalidURIError => e
      log.error(e.message)
    end
  end

  schemes
end

#Reset(keep) ⇒ Object

Reset package selection, but keep the selected objects of the specified type


808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
# File 'src/modules/Packages.rb', line 808

def Reset(keep)
  restore = []

  # collect the currently selected resolvables
  keep.each do |type|
    resolvables = Pkg.ResolvableProperties("", type, "")

    resolvables.each do |resolvable|
      # only selected items but ignore the selections done by solver,
      # during restoration they would be changed to be selected by YaST and they
      # will be selected by solver again anyway
      next if resolvable["status"] != :selected || resolvable["transact_by"] == :solver

      restore << [resolvable["name"], type]
    end
  end

  # This keeps the user-made changes (BNC#446406)
  Pkg.PkgApplReset

  restore.each { |name, type| Pkg.ResolvableInstall(name, type) }

  @system_packages_selected = false

  nil
end

#ResetProposalCacheObject

summary functions


167
168
169
170
171
172
173
174
175
176
177
# File 'src/modules/Packages.rb', line 167

def ResetProposalCache
  Builtins.y2milestone("Reseting the software proposal cache")

  @cached_proposal_packages = nil
  @cached_proposal_patterns = nil
  @cached_proposal_products = nil
  @cached_proposal_patches = nil
  @cached_proposal_languages = nil

  nil
end

#resolvable_mandatory_patternsArray

Get all the mandatory patterns


2369
2370
2371
# File 'src/modules/Packages.rb', line 2369

def resolvable_mandatory_patterns
  PackagesProposal.GetAllResolvables(:pattern)
end

#resolvable_optional_patternsArray


2362
2363
2364
# File 'src/modules/Packages.rb', line 2362

def resolvable_optional_patterns
  PackagesProposal.GetAllResolvables(:pattern, optional: true)
end

#select_system_patterns_actions(pattern_names, reselect:) ⇒ Array<Array(String,Symbol)>

Determine what should be done about each pattern


1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
# File 'src/modules/Packages.rb', line 1887

def select_system_patterns_actions(pattern_names, reselect:)
  mandatory_patterns = nil
  pattern_names.map do |pattern_name|
    props = Pkg.ResolvableProperties(pattern_name, :pattern, "")
    prop = props.first
    if props.empty?
      mandatory_patterns ||= default_patterns | resolvable_mandatory_patterns
      action = if mandatory_patterns.include?(pattern_name)
        :missing
      else
        :missing_optional
      end
    elsif !reselect && prop["status"] == :available && prop["transact_by"] == :user
      action = :skipped_by_user
    elsif !reselect
      action = :install
    elsif props.any? { |descr| descr["status"] == :selected }
      action = :reselect
    else
      action = :skipped_reselection
    end
    [pattern_name, action]
  end.to_h
end

#SelectKernelPackagesObject

see bug 302398


2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
# File 'src/modules/Packages.rb', line 2263

def SelectKernelPackages
  provides = Pkg.PkgQueryProvides("kernel")
  # e.g.: [["kernel-bigsmp", `CAND, `NONE], ["kernel-default", `CAND, `CAND],
  # ["kernel-default", `BOTH, `INST]]
  Builtins.y2milestone("provides: %1", provides)

  # these kernels would be installed
  kernels = Builtins.filter(provides) do |l|
    Ops.get_symbol(l, 1, :NONE) == :BOTH ||
      Ops.get_symbol(l, 1, :NONE) == Ops.get_symbol(l, 2, :NONE)
  end

  if Builtins.size(kernels) != 1
    Builtins.y2warning("not exactly one package provides tag kernel")
  end

  selected_kernel = Ops.get_string(kernels, [0, 0], "none")
  recom_kernel = Kernel.ComputePackages
  recommended_kernel = Ops.get(recom_kernel, 0, "")

  Builtins.y2milestone(
    "Selected kernel: %1, recommended kernel: %2",
    selected_kernel,
    recom_kernel
  )

  # when the recommended Kernel is not available (installable)
  if recommended_kernel != "" && !Pkg.IsAvailable(recommended_kernel)
    recommended_kernel = selected_kernel
  end

  # recommended package is different to the selected one
  # select the recommended one
  if recommended_kernel != "" && recommended_kernel != selected_kernel
    # list of kernels to be installed
    kernels_to_be_installed = Convert.convert(
      Builtins.maplist(kernels) { |one_kernel| Ops.get(one_kernel, 0) },
      from: "list",
      to:   "list <string>"
    )
    kernels_to_be_installed = Builtins.filter(kernels_to_be_installed) do |one_kernel|
      !one_kernel.nil? && one_kernel != ""
    end

    # remove all kernels (with some exceptions)
    Builtins.foreach(kernels_to_be_installed) do |one_kernel|
      # XEN can be installed in parallel
      next if one_kernel == "kernel-xen"
      next if one_kernel == "kernel-xenpae"
      # don't remove the recommended one
      next if one_kernel == recommended_kernel
      # remove all packages of that kernel
      packages_to_remove = Kernel.ComputePackagesForBase(one_kernel, false)
      if !packages_to_remove.nil? &&
          Ops.greater_than(Builtins.size(packages_to_remove), 0)
        Builtins.y2milestone(
          "Removing installed packages %1",
          packages_to_remove
        )
        Pkg.DoRemove(packages_to_remove)
      end
    end

    # compute recommended kernel packages
    kernel_packs = Kernel.ComputePackages

    Builtins.y2milestone("Install kernel packages: %1", kernel_packs)

    # installing all recommended packages
    Builtins.foreach(kernel_packs) do |p|
      if Pkg.PkgAvailable(p)
        Builtins.y2milestone("Selecting package %1 for installation", p)
        Pkg.PkgInstall(p)
      else
        Builtins.y2error("Package %1 is not available", p)
      end
    end
  end

  nil
end

#SelectProductBoolean

Select the base product on the media for installation


1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
# File 'src/modules/Packages.rb', line 1897

def SelectProduct
  Initialize(true)

  if Stage.cont
    log.info("Second stage - skipping product selection")
    return true
  end

  products = Pkg.ResolvableProperties("", :product, "")

  if !products || products.empty?
    log.info("No product found on media")
    return true
  end

  # no product selected -> select them all
  ret = true
  unless products.any? { |p| p["status"] == :selected }
    log.info("No product selected so far...")
    selected_products = []
    products.each do |p|
      product_name = p["name"] || ""
      if p["status"] == :installed
        log.info("Ignoring already installed product: #{product_name}")
      else
        log.info("Selecting product #{product_name}")
        selected_products << product_name
      end
    end

    # Due selecting all available products there can be products which
    # are conflicting.
    # E.g products are already be "included" by other products. So they MUST
    # not be installed anymore.
    selected_products.reject! do |product1|
      selected_products.any? do |product2|
        conflicts = product_conflicts?(product1, product2)
        if conflicts
          log.info("Product #{product1} conflicts with #{product2} and will not be installed.")
        end
        conflicts
      end
    end
    ret = selected_products.all? { |name| Pkg.ResolvableInstall(name, :product) }
  end

  ret
end

#SelectSystemPackages(reselect) ⇒ Object

Select system packages


1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
# File 'src/modules/Packages.rb', line 1986

def SelectSystemPackages(reselect)
  system_packages = ComputeSystemPackageList()
  if !reselect
    Builtins.y2milestone("Selecting system packages %1", system_packages)
  else
    Builtins.y2milestone(
      "Re-selecting new versions of system packages %1",
      system_packages
    )
    # first deselect the package (and filter selected ones)
    system_packages = Builtins.filter(system_packages) do |p|
      if Pkg.IsProvided(p) || Pkg.IsSelected(p)
        Pkg.PkgDelete(p)
        next true
      end
      false
    end
    Builtins.y2milestone(
      "System packages to be reselected: %1",
      system_packages
    )
  end
  res = Pkg.DoProvide(system_packages)
  Builtins.foreach(res) do |s, a|
    Builtins.y2warning("Pkg::DoProvide failed for %1: %2", s, a)
  end if Ops.greater_than(
    Builtins.size(res),
    0
  )

  nil
end

#SelectSystemPatterns(reselect) ⇒ Object

Selects system-specific and default patterns for installation


1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
# File 'src/modules/Packages.rb', line 1949

def SelectSystemPatterns(reselect)
  patterns = patterns_to_install.dup
  log.info "Selecting system patterns #{patterns}"

  if !reselect
    patterns.each do |pattern_name|
      prop = Pkg.ResolvableProperties(pattern_name, :pattern, "").first

      if prop.nil?
        report_missing_pattern(pattern_name)
        next
      elsif prop["status"] == :available && prop["transact_by"] == :user
        log.info "Skipping pattern #{pattern_name} deselected by user"
      else
        Pkg.ResolvableInstall(pattern_name, :pattern)
      end
    end
  else
    patterns.select! do |pattern_name|
      descrs = Pkg.ResolvableProperties(pattern_name, :pattern, "")
      report_missing_pattern(pattern_name) if descrs.empty?
      descrs.any? { |descr| descr["status"] == :selected }
    end

    log.info "Selected patterns to be reselected: #{patterns}"

    patterns.each do |pattern_name|
      Pkg.ResolvableRemove(pattern_name, :pattern)
      Pkg.ResolvableInstall(pattern_name, :pattern)
    end
  end

  nil
end

#SlideShowSetUp(wanted_language) ⇒ Object


1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
# File 'src/modules/Packages.rb', line 1380

def SlideShowSetUp(wanted_language)
  # bnc #432668
  # Do not call init
  if Mode.live_installation
    Builtins.y2milestone("live_installation, not calling Init")
    # bnc #427935
    # Initialize the base_source_id first
  else
    Init(true)
  end

  # Do not reinitialize the SlideShow if not needed
  # bnc #444612
  if Ops.greater_than(Builtins.size(SlideShow.GetSetup), 0)
    Builtins.y2milestone("SlideShow has been already set, skipping...")
    return
  end

  source = @base_source_id

  lang_long = ""
  lang_short = ""

  # de_DE.UTF-8 -> de_DE
  # es_ES       -> es_ES
  # blah        -> ""
  if !wanted_language.nil? && wanted_language != ""
    Builtins.y2milestone("Selected language: %1", wanted_language)

    if Builtins.regexpmatch(wanted_language, "^.+_.+$")
      lang_long = wanted_language
    elsif !wanted_language.nil? && wanted_language != "" &&
        Builtins.regexpmatch(wanted_language, "^.+_.+..*$")
      lang_long = Builtins.regexpsub(
        wanted_language,
        "^(.+)_(.+)..*",
        "\\1_\\2"
      )
    end

    if !lang_long.nil? && lang_long != "" &&
        Builtins.regexpmatch(lang_long, ".*_.*")
      lang_short = Builtins.regexpsub(lang_long, "(.*)_.*", "\\1")
    elsif !wanted_language.nil? && wanted_language != ""
      lang_short = wanted_language
    end

    Builtins.y2milestone(
      "Slide Show lang_long: %1, lang_short: %2",
      lang_long,
      lang_short
    )
  else
    Builtins.y2error("Wrong language definition: %1", wanted_language)
  end

  # setup slidedir
  productmap = Pkg.SourceProductData(source)
  datadir = Ops.get_string(productmap, "datadir", "suse")

  # target slideshow directory
  our_slidedir = Builtins.sformat(
    "%1/slidedir/",
    Convert.to_string(WFM.Read(path(".local.tmpdir"), ""))
  )
  WFM.Execute(
    path(".local.bash"),
    Builtins.sformat("mkdir -p '%1'", our_slidedir)
  )

  # media directory
  # bugzilla #305097
  #
  # bugzilla #326327
  # try to download only slides that are needed (by selected language)
  # no images are cached
  search_for_dir = Builtins.sformat("/%1/setup/slide/", datadir)
  FindAndCopySlideDirWithoutCallbacks(
    our_slidedir,
    source,
    search_for_dir,
    lang_long,
    lang_short,
    Slides.fallback_lang
  )
  # Language has to be set otherwise it uses a fallback language
  # BNC #444612 comment #2
  SlideShow.SetLanguage(Language.language)

  Builtins.y2milestone(
    "Setting up the slide directory local copy: %1",
    our_slidedir
  )
  Slides.SetSlideDir(our_slidedir)

  if load_release_notes(source)
    # TRANSLATORS: beginning of the rich text with the release notes
    SlideShow.relnotes = Ops.add(
      _(
        "<p><b>The release notes for the initial release are part of the installation\n" \
          "media. If an Internet connection is available during configuration, you can\n" \
          "download updated release notes from the SUSE Linux Web server.</b></p>\n"
      ),
      @media_text
    )
  end

  nil
end

#sourceAccessPackagesArray

Compute packages required to access the repositories


1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# File 'src/modules/Packages.rb', line 1057

def sourceAccessPackages
  # TODO: rather check all registered repositories...
  ret = []

  instmode = Linuxrc.InstallInf("InstMode")
  Builtins.y2milestone("Installation mode: %1", instmode)

  if instmode == "smb" || instmode == "cifs"
    # /sbin/mount.cifs is required to mount a SMB/CIFS share
    ret = ["cifs-mount"]
  elsif instmode == "nfs"
    # portmap is required to mount an NFS export
    ret = ["nfs-client"]
  end

  Builtins.y2milestone("Packages for accessing the repository: %1", ret)

  deep_copy(ret)
end

#SrcMappingObject


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'src/modules/Packages.rb', line 215

def SrcMapping
  index = 0

  src_list = Pkg.PkgMediaNames
  Builtins.y2debug("source names: %1", src_list)

  srcid_to_current_src_no = Builtins.listmap(src_list) do |src|
    index = Ops.add(index, 1)
    { Ops.get_integer(src, 1, -1) => index }
  end

  Builtins.y2milestone(
    "Repository mapping information: %1",
    srcid_to_current_src_no
  )
  deep_copy(srcid_to_current_src_no)
end

#ssh_packagesArray<String>

List of packages expected to be installed in order to enable ssh.


2435
2436
2437
2438
2439
# File 'src/modules/Packages.rb', line 2435

def ssh_packages
  # "ip" tool is needed by the YaST2.ssh start script (bnc#920175)
  tags = ["openssh", "iproute2"]
  find_providers(tags)
end

#Summary(flags, use_cache) ⇒ Hash

Print the installatino proposal summary


595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'src/modules/Packages.rb', line 595

def Summary(flags, use_cache)
  flags = deep_copy(flags)
  if !@init_error.nil?
    return { "warning" => @init_error, "warning_level" => :blocker }
  end
  ret = {}

  if !CheckDiskSize(!use_cache)
    fixed_selection = ProductFeatures.GetFeature("software", "selection_type") == :fixed
    ret = {
      "warning"       => if fixed_selection
                           # summary warning
                           _("Not enough disk space.")
                         else
                           # summary warning
                           _(
                             "Not enough disk space. Remove some packages " \
                               "in the single selection."
                           )
                         end,
      "warning_level" => Mode.update ? :error : :blocker
    }
  else
    # check available free space (less than 25% and less than 750MB) (see bnc#178357)
    free_space = SpaceCalculation.CheckDiskFreeSpace(25, 750 * 1024)

    if Ops.greater_than(Builtins.size(free_space), 0)
      warning = ""

      Builtins.foreach(free_space) do |df|
        partition = Ops.get_string(df, "dir", "")
        # add a backslash if it's missing
        if partition == "" || Builtins.substring(partition, 0, 1) != "/"
          partition = Ops.add("/", partition)
        end
        free_pct = Ops.get_integer(df, "free_percent", 0)
        free_kB = Ops.get_integer(df, "free_size", 0)
        w = Builtins.sformat(
          _("Only %1 (%2%%) free space available on partition %3.<BR>"),
          String.FormatSize(Ops.multiply(free_kB, 1024)),
          free_pct,
          partition
        )
        warning = Ops.add(warning, w)
      end

      if warning != ""
        Ops.set(ret, "warning", warning)
        Ops.set(ret, "warning_level", :warning)
      end
    end
  end

  # Check the YaST required packages.
  missing_resolvables = check_missing_resolvables
  if !missing_resolvables.empty?
    texts = missing_resolvables.map { |type, list| format_missing_resolvables(type, list) }
    texts << _("Please manually select the needed items to install.")

    # include the existing warning if defined
    texts.unshift(ret["warning"]) if ret["warning"]

    ret["warning"] = texts.join("<br>")
    ret["warning_level"] = :blocker
  end

  # add failed mounts
  ret = AddFailedMounts(ret)

  # FATE #304488
  if Mode.update
    ret_ref = arg_ref(ret)
    CheckOldAddOns(ret_ref)
    ret = ret_ref.value
  end

  Ops.set(ret, "raw_proposal", SummaryOutput(flags))
  Ops.set(ret, "help", SummaryHelp(flags))
  deep_copy(ret)
end

#SummaryHelp(flags) ⇒ Object


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
# File 'src/modules/Packages.rb', line 309

def SummaryHelp(flags)
  flags = deep_copy(flags)
  ret = ""

  if Builtins.contains(flags, :pattern)
    # help text for software proposal
    ret = Ops.add(
      ret,
      _(
        "<P>The pattern list states which functionality will be available " \
          "after installing the system.</P>"
      )
    )
  end

  if Builtins.contains(flags, :size)
    ret = Ops.add(
      Ops.add(
        ret,
        # (see bnc#178357 why these numbers)
        # translators: help text for software proposal
        _(
          "<P>The proposal reports the total size of files which will be installed " \
            "to the system. However, the system will contain some other files " \
            "(temporary and working files) so the used space will be slightly larger " \
            "than the proposed value. Therefore it is a good idea to have at least " \
            "25% (or about 300MB) free space before starting the installation.</P>"
        )
      ),
      # help text for software proposal
      _(
        "<P>The total 'size to download' is the size of the packages which will be\n" \
          "downloaded from remote (network) repositories. This value is important if " \
          "the connection is slow or if there is a data limit for downloading.</P>\n"
      )
    )
  end

  # add a header if the result is not empty
  if ret != ""
    # help text for software proposal - header
    ret = Ops.add(_("<P><B>Software Proposal</B></P>"), ret)
  end

  ret
end

#SummaryOutput(flags) ⇒ Object

Return the summary output lines


360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'src/modules/Packages.rb', line 360

def SummaryOutput(flags)
  flags = deep_copy(flags)
  output = [InfoAboutSubOptimalDistribution()]
  if Builtins.contains(flags, :product)
    # installation proposal - SW summary, %1 is name of the installed product
    # (e.g. openSUSE 10.3, SUSE Linux Enterprise ...)
    output = Convert.convert(
      Builtins.merge(output, ListSelected(:product, _("Product: %1"))),
      from: "list",
      to:   "list <string>"
    )
  end

  if Builtins.contains(flags, :desktop)
    # BNC #422077, Desktop doesn't need to be defined, e.g. in SLED
    # BNC #431336 ... and even if it is defined, it needn't be visible
    ddd = DefaultDesktop.Description
    if ddd != ""
      # installation proposal - SW summary, %1 is name of the selected desktop or
      # system type (e.g. KDE)
      output = Builtins.add(
        output,
        Builtins.sformat(_("System Type: %1"), ddd)
      )
    end
  end

  if Builtins.contains(flags, :pattern)
    patterns = ListSelected(:pattern, "+  %1")

    if Ops.greater_than(Builtins.size(patterns), 0)
      output = Builtins.add(
        output,
        Ops.add(_("Patterns:<br>"), Builtins.mergestring(patterns, "<br>"))
      )
    end
  end

  if Builtins.contains(flags, :size)
    output = Builtins.add(
      output,
      # installation proposal - SW summary, %1 is size of the selected packages (in MB or GB)
      Builtins.sformat(
        _("Size of Packages to Install: %1"),
        CountSizeToBeInstalled()
      )
    )

    # add download size
    download_size = CountSizeToBeDownloaded()
    if Ops.greater_than(download_size, 0)
      output = Builtins.add(
        output,
        # installation proposal - SW summary, %1 is download size of the selected packages
        # which will be installed from an ftp or http repository (in MB or GB)
        Builtins.sformat(
          _("Downloading from Remote Repositories: %1"),
          String.FormatSizeWithPrecision(download_size, 1, true)
        )
      )
    end
  end

  output = Builtins.filter(output) { |o| o != "" && !o.nil? }

  deep_copy(output)
end

#UpdateSourceURL(url) ⇒ Object


1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
# File 'src/modules/Packages.rb', line 1207

def UpdateSourceURL(url)
  ret = ""
  while ret == ""
    msg = Ops.add(
      Ops.add(
        Ops.add(
          Ops.add(
            Ops.add(
              Ops.add(
                Builtins.sformat(
                  _("Unable to create repository\nfrom URL '%1'."),
                  URL.HidePassword(url)
                ),
                "\n\n"
              ),
              _("Details:")
            ),
            "\n"
          ),
          Pkg.LastError
        ),
        "\n\n"
      ),
      _("Try again?")
    )

    if Popup.YesNo(msg)
      ret = SourceDialogs.EditPopup(url)
    else
      # error in proposal, %1 is URL
      @init_error = Builtins.sformat(
        _("No repository found at '%1'."),
        URL.HidePassword(url)
      )
      return ""
    end
  end
  ret
end

#vnc_packagesArray<String>

List of packages expected to be installed in order to enable remote administration (VNC)


2454
2455
2456
2457
2458
2459
2460
2461
# File 'src/modules/Packages.rb', line 2454

def vnc_packages
  tags = VNC_BASE_TAGS.dup
  # At least one windowmanager must be installed (#427044)
  # If none is there, use a fallback
  tags << DEFAULT_WM unless has_window_manager?
  tags.concat(AUTOYAST_X11_TAGS) if Mode.autoinst
  find_providers(tags)
end