Class: Yast::PackagesClass

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

Constant Summary

RESOLVABLE_TYPES =

All known types of resolvables

[:product, :patch, :package, :pattern, :language]
VNC_BASE_PACKAGES =

Minimum set of packages required to enable VNC server

["xorg-x11", "xorg-x11-Xvnc", "xorg-x11-fonts", "xinetd"]
DEFAULT_WM =

Default window manager for VNC if none is installed

"icewm"
REMOTE_X11_BASE_PACKAGES =

Minimum set of packages required for installation with remote X11 server

[ "xorg-x11-server", "xorg-x11-fonts", "icewm" ]
LOG_RESOLVABLE_STATUS =

Log only resolvables with resolvable matching these below

[:selected, :removed]
LOG_RESOLVABLE_TRANSACT_BY =

Log only resolvables with resolvable matching these below

[:user, :app_high]

Instance Method Summary (collapse)

Instance Method Details

- (Object) addAdditionalPackage(package)

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.

Parameters:

  • package (String)

    string package to be selected



852
853
854
855
856
857
858
859
# File '../../src/modules/Packages.rb', line 852

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

  nil
end

- (Object) AddFailedMounts(summary)



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

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 = Ops.greater_than(
      Builtins.size(Ops.get_string(summary, "warning", "")),
      0
    ) ? "<BR>" : ""
    if Builtins.contains(
        @basic_dirs,
        Ops.get_string(failed_mount, "mount", "")
      )
      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."
            ),
            Ops.get_string(failed_mount, "mount", ""),
            Ops.get_string(failed_mount, "device", "")
          )
        )
      )

      # 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)."
            ),
            Ops.get_string(failed_mount, "mount", ""),
            Ops.get_string(failed_mount, "device", "")
          )
        )
      )

      # 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

- (Boolean) AdjustSourcePropertiesAccordingToProduct(src_id)

Adjusts repository name according to LABEL in content file or a first product found on the media (as a fallback).

Parameters:

  • integer

    repository ID

Returns:

  • (Boolean)

    if successful

See Also:

  • #481828


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
1778
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
1804
1805
1806
1807
1808
1809
1810
1811
1812
# File '../../src/modules/Packages.rb', line 1735

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 adjust repository name for: %1", src_id)
  new_name = nil

  # At first, try LABEL from content file
  contentfile = Pkg.SourceProvideSignedFile(
    src_id, # optional
    1,
    "/content",
    true
  )
  if contentfile != nil
    contentmap = Convert.to_map(
      SCR.Read(path(".content_file"), contentfile)
    )
    if Builtins.haskey(contentmap, "LABEL") &&
        Ops.get(contentmap, "LABEL") != nil &&
        Ops.get_string(contentmap, "LABEL", "") != ""
      new_name = Ops.get_string(contentmap, "LABEL", "")

      if Builtins.regexpmatch(new_name, "^[ \t]+")
        new_name = Builtins.regexpsub(new_name, "^[ \t]+(.*)", "\\1")
      end
      if Builtins.regexpmatch(new_name, "[ \t]+$")
        new_name = Builtins.regexpsub(new_name, "(.*)[ \t]+$", "\\1")
      end

      Builtins.y2milestone("Using LABEL from content file: %1", new_name)
    else
      Builtins.y2warning("No (useful) LABEL in product content file")
    end
  end

  # As a fallback,
  if new_name == nil || new_name == ""
    Builtins.y2milestone("Trying to get repository name from products")
    all_products = Pkg.ResolvableProperties("", :product, "")
    Builtins.foreach(all_products) do |one_product|
      # source ID matches
      if Ops.get_integer(one_product, "source", -1) == src_id
        if Builtins.haskey(one_product, "name") &&
            Ops.get(one_product, "name") != nil &&
            Ops.get_string(one_product, "name", "") != ""
          new_name = Ops.get_string(one_product, "name", "")
          Builtins.y2milestone("Product name found: %1", new_name)
          raise Break
        end
      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

- (Array) architecturePackages

Compute architecture packages

Returns:

  • (Array)

    (string)



863
864
865
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
915
916
# File '../../src/modules/Packages.rb', line 863

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") != 0
      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

- (Array) boardPackages

Compute board (vendor) dependant packages

Returns:

  • (Array)

    (string)



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
# File '../../src/modules/Packages.rb', line 1019

def boardPackages
  packages = []

  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)

  deep_copy(packages)
end

- (Boolean) CheckContentFile(source)

Check whether content file in the specified repository is the same as the one in the ramdisk

Parameters:

  • source (Fixnum)

    integer the repository ID to check

Returns:

  • (Boolean)

    true if content files match



1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
# File '../../src/modules/Packages.rb', line 1279

def CheckContentFile(source)
  Builtins.y2milestone("Checking content file")
  instmode = Linuxrc.InstallInf("InstMode")
  if !(instmode == nil || instmode == "cd" || instmode == "dvd")
    Builtins.y2milestone(
      "Installing via network, not checking the content file"
    )
    return true
  end
  media_content = Pkg.SourceProvideSignedFile(source, 1, "/content", false)
  media = Convert.to_string(SCR.Read(path(".target.string"), media_content))
  ramdisk = Convert.to_string(SCR.Read(path(".target.string"), "/content"))
  ret = media == ramdisk
  Builtins.y2milestone("Content files are the same: %1", ret)
  ret
end

- (Boolean) CheckDiskSize(init)

Check if selected software fits on the partitions

Parameters:

  • init (Boolean)

    boolean true if partition sizes have changed

Returns:

  • (Boolean)

    true if selected software fits, false otherwise



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

- (Object) CheckOldAddOns(ret)

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

Parameters:

  • reference

    to map MakeProposal->Summary



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
# 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) == 0
    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"),
        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."
          ) :
          # 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

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

  nil
end

- (Object) ComputeAdditionalKernelPackages

Additional kernel packages from control file



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

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

- (Array<String>) ComputeSystemPackageList

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

Returns:

  • (Array<String>)

    packages



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
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
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
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File '../../src/modules/Packages.rb', line 1133

def ComputeSystemPackageList
  install_list = architecturePackages

  install_list = Convert.convert(
    Builtins.union(install_list, modePackages),
    :from => "list",
    :to   => "list <string>"
  )

  # No longer needed - partitions_proposal uses PackagesProposal now
  # to gather the list of pkgs needed by y2-storage (#433001)
  #list<string> storage_packages = (list<string>)WFM::call("wrapper_storage", ["AddPackageList"]);

  if Ops.greater_than(Builtins.size(@additional_packages), 0)
    Builtins.y2warning(
      "Additional packages are still in use, please, change it to use PackagesProposal API"
    )
    Builtins.y2milestone("Additional packages: %1", @additional_packages)
    install_list = Convert.convert(
      Builtins.union(install_list, @additional_packages),
      :from => "list",
      :to   => "list <string>"
    )
  end

  # bnc #431580
  # New API for packages selected by other modules
  packages_proposal_all_packages = PackagesProposal.GetAllResolvables(
    :package
  )
  if Ops.greater_than(Builtins.size(packages_proposal_all_packages), 0)
    Builtins.y2milestone(
      "PackagesProposal::GetAllResolvables returned: %1",
      packages_proposal_all_packages
    )
    install_list = Convert.convert(
      Builtins.union(install_list, packages_proposal_all_packages),
      :from => "list",
      :to   => "list <string>"
    )
  else
    Builtins.y2milestone("No packages required by PackagesProposal")
  end

  # Kernel is added in autoinstPackages () if autoinst is enabled
  if !Mode.update || !Mode.autoinst
    kernel_pkgs = Kernel.ComputePackages
    kernel_pkgs_additional = ComputeAdditionalKernelPackages()
    install_list = Convert.convert(
      Builtins.union(install_list, kernel_pkgs),
      :from => "list",
      :to   => "list <string>"
    )
    if Ops.greater_than(Builtins.size(kernel_pkgs_additional), 0) &&
        kernel_pkgs_additional != nil
      install_list = Convert.convert(
        Builtins.union(install_list, kernel_pkgs_additional),
        :from => "list",
        :to   => "list <string>"
      )
    end
  end

  if Pkg.IsSelected("xorg-x11-Xvnc") && Linuxrc.vnc
    install_list = Convert.convert(
      Builtins.union(install_list, graphicPackages),
      :from => "list",
      :to   => "list <string>"
    )
  else
    Builtins.y2milestone("Not selecting graphic packages")
  end

  if Pkg.IsSelected("java")
    install_list = Convert.convert(
      Builtins.union(install_list, javaPackages),
      :from => "list",
      :to   => "list <string>"
    )
  else
    Builtins.y2milestone("Not selecting java packages")
  end

  install_list = Convert.convert(
    Builtins.union(install_list, kernelCmdLinePackages),
    :from => "list",
    :to   => "list <string>"
  )

  install_list = Convert.convert(
    Builtins.union(install_list, boardPackages),
    :from => "list",
    :to   => "list <string>"
  )

  # add packages required to access the repository in the 2nd stage and at run-time
  install_list = Convert.convert(
    Builtins.union(install_list, sourceAccessPackages),
    :from => "list",
    :to   => "list <string>"
  )

  # 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.
  if ProductFeatures.GetFeature("software", "packages_transmogrify") != ""
    tmp_list = Convert.convert(
      WFM.CallFunction(
        ProductFeatures.GetStringFeature(
          "software",
          "packages_transmogrify"
        ),
        [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 = Convert.convert(
    ProductFeatures.GetFeature("software", "packages"),
    :from => "any",
    :to   => "list <string>"
  )
  if Ops.greater_than(Builtins.size(packages), 0) && packages != nil
    Builtins.y2milestone("Adding packages from control file: %1", packages)
    install_list = Convert.convert(
      Builtins.union(install_list, packages),
      :from => "list",
      :to   => "list <string>"
    )
  end

  install_list = Builtins.toset(install_list)
  Builtins.y2milestone("auto-adding packages: %1", install_list)
  deep_copy(install_list)
end

- (Object) ComputeSystemPatternList



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
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
# File '../../src/modules/Packages.rb', line 1088

def ComputeSystemPatternList
  pattern_list = []
  # also add the 'laptop' selection if PCMCIA detected
  if Arch.is_laptop || Arch.has_pcmcia
    Builtins.foreach(["laptop", "Laptop"]) do |pat_name|
      pat_list = Pkg.ResolvableProperties(pat_name, :pattern, "")
      if Ops.greater_than(Builtins.size(pat_list), 0)
        pattern_list = Builtins.add(pattern_list, pat_name)
      end
    end
  end

  # select 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

  # FATE #302116
  # BNC #431580
  required_patterns = PackagesProposal.GetAllResolvables(:pattern)
  if required_patterns != nil && required_patterns != []
    Builtins.y2milestone(
      "Patterns required by PackagesProposal: %1",
      required_patterns
    )
    pattern_list = Convert.convert(
      Builtins.merge(pattern_list, required_patterns),
      :from => "list",
      :to   => "list <string>"
    )
  end

  Builtins.y2milestone("System patterns: %1", pattern_list)
  deep_copy(pattern_list)
end

- (Object) ContentFileProductLabel



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

def ContentFileProductLabel
  language = Language.language
  locales = LocaleVersions(Language.language)
  ret = ""
  Builtins.foreach(locales) do |loc|
    if ret == ""
      val = Convert.to_string(
        SCR.Read(Builtins.add(path(".content"), Ops.add("LABEL.", loc)))
      )
      if val != "" && val != nil
        ret = val
        next ret
      end
    end
  end
  Convert.to_string(SCR.Read(path(".content.LABEL")))
end

- (Fixnum) CountSizeToBeDownloaded

Count the total size of packages to be installed

Returns:

  • (Fixnum)

    size of packages to be installed (in bytes)



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

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) == 0
    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

- (String) CountSizeToBeInstalled

Count the total size of packages to be installed

Returns:

  • (String)

    formatted size of packages to be installed



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

def CountSizeToBeInstalled
  sz = 0
  media_sizes = Pkg.PkgMediaSizes

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


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

- (Array) default_patterns

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

Returns:

  • (Array)

    list of patterns



2507
2508
2509
# File '../../src/modules/Packages.rb', line 2507

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

- (Object) DellSystem

CHeck whether this is a Dell system



958
959
960
961
962
963
964
965
966
# File '../../src/modules/Packages.rb', line 958

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) == 0
  Builtins.y2milestone("Detected a Dell system") if ret

  ret
end

- (Object) FindAndCopySlideDir(our_slidedir, source, search_for_dir, lang_long, lang_short, fallback_lang)



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

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

- (Object) FindAndCopySlideDirWithoutCallbacks(our_slidedir, source, search_for_dir, lang_long, lang_short, fallback_lang)



1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
# File '../../src/modules/Packages.rb', line 1480

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

- (Object) FindAndRememberAddOnProductsFiles(initial_repository)



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
1888
1889
1890
1891
1892
1893
1894
1895
# File '../../src/modules/Packages.rb', line 1814

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

- (Object) ForceFullRepropose

proposal control functions



783
784
785
786
787
# File '../../src/modules/Packages.rb', line 783

def ForceFullRepropose
  @full_repropose = true

  nil
end

- (Fixnum) GetBaseSourceID

Returns ID of the base product repository.

Returns:

  • (Fixnum)

    base source ID



1384
1385
1386
# File '../../src/modules/Packages.rb', line 1384

def GetBaseSourceID
  @base_source_id
end

- (Array) graphicPackages

graphicPackages () Compute graphic (x11) packages

Returns:

  • (Array)

    (string) list of rpm packages needed



922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File '../../src/modules/Packages.rb', line 922

def graphicPackages
  packages = []

  # don't setup graphics if running via serial console
  if !Linuxrc.serial_console
    packages = [
      "xorg-x11-server",
      "xorg-x11-server-glx",
      "libusb",
      "yast2-x11"
    ]
  end

  Builtins.y2milestone("X11 Packages to install: %1", packages)

  packages
end

- (Hash<Symbol,Object>) group_products_by_status(products)

group products according to the current state

Parameters:

  • products (Array<Hash>)

    list of products (returned by Pkg.ResolvableProperties call)

Returns:

  • (Hash<Symbol,Object>)

    grouped products the keys are :new, :removed, :kept, :updated For each key the value is a list of products, except for :updated key which contains a Hash with old_product => new_product mapping



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
# File '../../src/modules/Packages.rb', line 670

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

- (Object) ImportGPGKeys

Import GPG keys found in the inst-sys



1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
# File '../../src/modules/Packages.rb', line 1297

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

- (String) InfoAboutSubOptimalDistribution

Return information about suboptimal distribution if relevant

Returns:

  • (String)

    the information string or empty string



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

def InfoAboutSubOptimalDistribution
  # warn about suboptimal distribution
  # this depends on the kernel
  dp = Convert.to_string(SCR.Read(path(".content.DISTPRODUCT")))
  dp = "" if dp == nil

  if ProductFeatures.GetBooleanFeature(
      "software",
      "inform_about_suboptimal_distribution"
    ) &&
      Arch.i386 &&
      Builtins.issubstring(dp, "DVD")
    tmp = Convert.to_string(
      SCR.Read(path(".proc.cpuinfo.value.\"0\".\"flags\""))
    )
    flags = Ops.greater_than(Builtins.size(tmp), 0) ?
      Builtins.splitstring(tmp, " ") :
      []

    # 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

- (Object) Init(unused)



2073
2074
2075
2076
2077
# File '../../src/modules/Packages.rb', line 2073

def Init(unused)
  Initialize(true)

  nil
end

- (Object) InitFailed



2415
2416
2417
2418
2419
# File '../../src/modules/Packages.rb', line 2415

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

- (Object) Initialize(show_popup)

Initialize the repositories

Parameters:

  • show_popup (Boolean)

    boolean true to display information about initialization



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
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
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
# File '../../src/modules/Packages.rb', line 1992

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.\nCheck the log file %1 for more details."
            ),
            Ops.add(Directory.logdir, "/y2log")
          ),
          "\n"
        ),
        Pkg.LastError
      )

      # FIXME somewhere get correct current_label and wanted_label
      result = 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

- (Object) Initialize_BaseInit(show_popup, base_url, log_url)



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
1723
1724
1725
1726
# File '../../src/modules/Packages.rb', line 1688

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()")

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

  # 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)

  if popup_open
    UI.CloseDialog
    popup_open = false
  end

  true
end

- (Object) Initialize_StageInitial(show_popup, base_url, log_url)



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
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
# File '../../src/modules/Packages.rb', line 1897

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

  # 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, "")
    if 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
    if !CheckContentFile(initial_repository)
      label = ContentFileProductLabel()
      # bug #159754, release the mounted CD
      Pkg.SourceReleaseAll
      Pkg.SourceDelete(initial_repository)
      initial_repository = nil
      if !Popup.ContinueCancel(
          # message popup, %1 is product name
          Builtins.sformat(_("Insert %1 CD 1"), label)
        )
        @init_error = Builtins.sformat(_("%1 CD 1 not found"), label)
        @init_in_progress = false
        return
      end
    end
  end

  # BNC #481828: Using LABEL from content file as a repository name
  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

- (Object) Initialize_StageNonInitial(show_popup, base_url, log_url)



1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
# File '../../src/modules/Packages.rb', line 1964

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

- (Object) InitializeAddOnProducts

Initialize add-on products provided by the repository



820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File '../../src/modules/Packages.rb', line 820

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
    )
    AddOnProduct.AddPreselectedAddOnProducts(@add_on_products_list)
    @add_on_products_list = [] # do not select them any more
  end

  nil
end

- (Object) InitializeCatalogs

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



2409
2410
2411
2412
2413
# File '../../src/modules/Packages.rb', line 2409

def InitializeCatalogs
  Initialize(true)

  nil
end

- (Object) IntegrateServicePack(show_popup, base_url)



1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
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
# File '../../src/modules/Packages.rb', line 1624

def IntegrateServicePack(show_popup, base_url)
  # Check for Service Pack
  servicepack_available = false
  if Ops.greater_than(
      Convert.to_integer(
        WFM.Read(path(".local.size"), @servicepack_metadata)
      ),
      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 ", @servicepack_metadata), " -C "),
        spdir
      )
    )
    sp_url = Ops.add("dir:", spdir)
    # close the popup in order to be able to ask about the license
    if popup_open
      popup_open = false
      UI.CloseDialog
    end
    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

- (Array) javaPackages

Compute special java packages

Returns:

  • (Array)

    (string)



999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
# File '../../src/modules/Packages.rb', line 999

def javaPackages
  return [] if !Arch.alpha

  packages = []

  cpus = Convert.to_list(SCR.Read(path(".probe.cpu")))
  model = Ops.get_string(cpus, [0, "model"], "EV4")
  cputype = Builtins.substring(model, 2, 1)

  if cputype == "6" || cputype == "7" || cputype == "8"
    packages = ["cpml_ev6"]
  else
    packages = ["cpml_ev5"]
  end
  deep_copy(packages)
end

- (Object) kernelCmdLinePackages



968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
# File '../../src/modules/Packages.rb', line 968

def kernelCmdLinePackages
  ret = []

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

  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

- (Object) ListSelected(what, format)

List selected resolvables of specified kind

Parameters:

  • what (Symbol)

    symbol specifying the kind of resolvables to select

  • format (String)

    string format string to print summaries in

Returns:

  • a list of selected resolvables



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

def ListSelected(what, format)
  format = "%1" if format == "" || format == nil
  selected = Pkg.ResolvableProperties("", what, "")

  # ignore hidden patterns
  if what == :pattern
    selected = Builtins.filter(selected) do |r|
      Ops.get(r, "user_visible") == true
    end

    # order patterns according to "order" flag
    selected = Builtins.sort(selected) do |x, y|
      xo = Builtins.tointeger(Ops.get_string(x, "order", ""))
      yo = Builtins.tointeger(Ops.get_string(y, "order", ""))
      if xo == nil || yo == nil
        # order is not an integer, compare as strings
        next Ops.less_than(
          Ops.get_string(x, "order", ""),
          Ops.get_string(y, "order", "")
        )
      else
        next Ops.less_than(xo, yo)
      end
    end
  end

  selected = Builtins.filter(selected) do |r|
    Ops.get(r, "status") == :selected
  end

  ret = Builtins.maplist(selected) do |r|
    disp = Ops.get_string(r, "summary", Ops.get_string(r, "name", ""))
    Builtins.sformat(format, disp)
  end
  deep_copy(ret)
end

- (Object) LocaleVersions(lang)



1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
# File '../../src/modules/Packages.rb', line 1348

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

- (Object) log_software_selection

Reads the current user selection and dumps it to log



2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
# File '../../src/modules/Packages.rb', line 2526

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

- (Object) main



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

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

  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_metadata = "/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
end

- (Array) modePackages

Compute special packages

Returns:

  • (Array)

    (string)



943
944
945
946
947
948
949
950
951
952
953
954
955
# File '../../src/modules/Packages.rb', line 943

def modePackages
  packages = []

  packages.concat(vnc_packages) if Linuxrc.vnc
  #this means we have a remote X server
  packages.concat(remote_x11_packages) if Linuxrc.display_ip
  packages << "sbl" if Linuxrc.braille
  packages << "openssh" if Linuxrc.usessh

  Builtins.y2milestone("Installation mode packages: %1", packages)

  packages
end

- (Array) optional_default_patterns

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

Returns:

  • (Array)

    list of patterns



2515
2516
2517
# File '../../src/modules/Packages.rb', line 2515

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

- (boolean) PackagesProposalChanged

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

Returns:

  • (boolean)

    true if PackagesProposal has been changed



2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
# File '../../src/modules/Packages.rb', line 2194

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

- (String) product_label(product)

return a printable name of product resolvable

Parameters:

  • product (Hash)

    the product (returned by Pkg.ResolvableProperties call)

Returns:

  • (String)

    product name



771
772
773
774
775
776
777
778
779
# File '../../src/modules/Packages.rb', line 771

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

- (Array<String>) product_update_summary(products)

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

Parameters:

  • products (Array<Hash>)

    list of products (returned by Pkg.ResolvableProperties call)

Returns:

  • (Array<String>)

    list of rich text descriptions

See Also:



696
697
698
699
700
701
702
703
704
705
706
707
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
# File '../../src/modules/Packages.rb', line 696

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}"

    (old_product == new_product) ?
      # product update: %s is a product name
    _("Product <b>%s</b> will be updated") % h(old_product) :
      # 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

  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 = (transact_by == :user || transact_by == :app_high) ?
      _("<b>Warning:</b> Product <b>%s</b> will be removed.") % h(product_label(product)) :
      _("<b>Error:</b> Product <b>%s</b> will be automatically removed.</font>") \
        % h(product_label(product))

    HTML.Colorize(msg, "red")
  end

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

- (Hash) product_update_warning(products)

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

Parameters:

  • products (Array<Hash>)

    list of products (returned by Pkg.ResolvableProperties call)

Returns:

  • (Hash)

    hash with warning attributes or empty if there is no problem

See Also:



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
# File '../../src/modules/Packages.rb', line 747

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.
  return {
    "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

- (Hash) Proposal(force_reset, reinit, simple)

Make a proposal for package selection

Parameters:

  • force

    reset (fully resets the proposal and creates a new one)

  • re-initialize (soft-reset, doesn't reset resolbavle manually selected by user)

Returns:

  • (Hash)

    for the API proposal



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
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
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
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
# File '../../src/modules/Packages.rb', line 2211

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.\nSoftware 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

- (Object) remote_x11_packages

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



2566
2567
2568
2569
2570
# File '../../src/modules/Packages.rb', line 2566

def remote_x11_packages
  packages = REMOTE_X11_BASE_PACKAGES.dup
  packages << "yast2-x11" if Mode.autoinst
  packages
end

- (Object) Reset(keep)

Reset package selection, but keep objects of specified type

Parameters:

  • keep (Array<Symbol>)

    a list of symbols specifying type of objects to be kept



791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
# File '../../src/modules/Packages.rb', line 791

def Reset(keep)
  keep = deep_copy(keep)
  restore = []
  Builtins.foreach(keep) do |type|
    selected = Pkg.ResolvableProperties("", type, "")
    Builtins.foreach(selected) do |s|
      restore = Builtins.add(
        restore,
        { "type" => type, "name" => Ops.get_string(s, "name", "") }
      )
    end
  end

  # This reset keep user-made changes
  # BNC #446406
  Pkg.PkgApplReset
  Builtins.foreach(restore) do |res|
    Pkg.ResolvableInstall(
      Ops.get_string(res, "name", ""),
      Ops.get_symbol(res, "type")
    )
  end

  @system_packages_selected = false

  nil
end

- (Object) ResetProposalCache

summary functions



141
142
143
144
145
146
147
148
149
150
151
# File '../../src/modules/Packages.rb', line 141

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

- (Object) SelectKernelPackages

see bug 302398



2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
# File '../../src/modules/Packages.rb', line 2422

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

- (Boolean) SelectProduct

Select the base product on the media for installation

Returns:

  • (Boolean)

    true on success



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

def SelectProduct
  Initialize(true)

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

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

  if Builtins.size(products) == 0
    Builtins.y2milestone("No product found on media")
    return true
  end

  selected_products = Builtins.filter(products) do |p|
    Ops.get(p, "status") == :selected
  end
  # no product selected -> select them all
  ret = true
  if Builtins.size(selected_products) == 0
    Builtins.y2milestone("No product selected so far...")
    Builtins.foreach(products) do |p|
      product_name = Ops.get_string(p, "name", "")
      if !Builtins.regexpmatch(product_name, "-migration$")
        Builtins.y2milestone("Selecting product %1", product_name)
        ret = Pkg.ResolvableInstall(product_name, :product) && ret
      else
        Builtins.y2milestone("Ignoring migration product: %1", product_name)
      end
    end
  end

  ret
end

- (Object) SelectSystemPackages(reselect)

Select system packages

Parameters:

  • reselect (Boolean)

    boolean true to select only those which are alrady selected



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

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

- (Object) SelectSystemPatterns(reselect)

Selects system-specific and default patterns for installation

Parameters:

  • reselect (Boolean)

    whether to re-select all already selected patterns



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

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

- (Object) SlideShowSetUp(wanted_language)



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
1549
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
1590
1591
1592
1593
1594
1595
1596
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
# File '../../src/modules/Packages.rb', line 1499

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)

  # fallback solution disabled
  #     if (success != true) {
  # 	y2milestone ("Using fallback solution, language is not supported");
  # 	string fallback_slidedir = Pkg::SourceProvideDirectory (source, 1, search_for_dir, true, true);
  #
  # 	if (fallback_slidedir == nil) {
  # 	    y2milestone ("No slide directory '%1' found in repository '%2'.",
  # 		search_for_dir, source);
  # 	} else {
  # 	    // copy all files to our own cache
  # 	    y2milestone ("Copying %1/* to %2/", fallback_slidedir, String::Quote (our_slidedir));
  # 	    WFM::Execute (.local.bash, sformat ("cp -r %1/* '%2/'", fallback_slidedir, String::Quote (our_slidedir)));
  # 	}
  #     }

  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

- (Array) sourceAccessPackages

Compute packages required to access the repository

Returns:

  • (Array)

    (string) list of the required packages



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
# File '../../src/modules/Packages.rb', line 1036

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

- (Object) SrcMapping



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

def SrcMapping
  srcid_to_current_src_no = {}
  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

- (Object) Summary(flags, use_cache)

Print the installatino proposal summary

Parameters:

  • flags (Array<Symbol>)

    a list of symbols, see above

  • use_cache (Boolean)

    if true, use previous proposal if possible



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

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)
    ret = {
      "warning"       => ProductFeatures.GetFeature(
        "software",
        "selection_type"
      ) == :fixed ?
        # summary warning
        _("Not enough disk space.") :
        # summary warning
        _(
          "Not enough disk space. Remove some packages in the single selection."
        ),
      "warning_level" => Mode.update ? :warning : :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

  # 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

- (Object) SummaryHelp(flags)



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

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\ndownloaded 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

- (Object) SummaryOutput(flags)

Return the summary output lines

Parameters:

  • flags (Array<Symbol>)

    a list of flags, allowed are product,pattern, selection, size, `desktop

Returns:

  • a list of the output lines



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 361

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

- (Object) UpdateSourceURL(url)



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

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

- (Object) vnc_packages

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



2553
2554
2555
2556
2557
2558
2559
2560
# File '../../src/modules/Packages.rb', line 2553

def vnc_packages
  packages = VNC_BASE_PACKAGES.dup
  # At least one windowmanager must be installed (#427044)
  # If none is there, use a fallback
  packages << DEFAULT_WM unless has_window_manager?
  packages << "yast2-x11" if Mode.autoinst
  packages
end