/
Packages.rb
2715 lines (2322 loc) · 91.5 KB
/
Packages.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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
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
591
592
593
594
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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
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
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
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
862
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
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
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
991
992
993
994
995
996
997
998
999
1000
require "yast"
# html_escape()
require "erb"
require "fileutils"
require "uri"
require "cgi"
require "shellwords"
require "y2packager/medium_type"
require "y2packager/product_upgrade"
require "y2packager/resolvable"
# Yast namespace
module Yast
# Package selections
class PackagesClass < Module
include Yast::Logger
include ERB::Util
attr_reader :missing_remote_packages, :missing_remote_kind
attr_accessor :cached_proposal
# All known types of resolvables
RESOLVABLE_TYPES = [:product, :patch, :package, :pattern, :language].freeze
# Minimum set of packages tags required to enable VNC server
VNC_BASE_TAGS = ["xorg-x11-Xvnc", "xorg-x11-fonts"].freeze
# Additional packages tags needed to run second stage in graphical mode
AUTOYAST_X11_TAGS = ["libyui-qt", "yast2-x11"].freeze
# Default window manager for VNC if none is installed
DEFAULT_WM = "icewm".freeze
# Minimum set of packages required for installation with remote X11 server
REMOTE_X11_BASE_TAGS = ["xorg-x11-server", "xorg-x11-fonts", "icewm"].freeze
# Graphical packages for VNC installation
GRAPHIC_PACKAGES = ["xorg-x11-server", "xorg-x11-server-glx", "libusb", "yast2-x11"].freeze
BASE_PRODUCT_FILE = "/etc/products.d/baseproduct".freeze
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_summary = nil
# the selection used for the cached proposal
# the default values 'nil' say that the proposal hasn't been called yet
@cached_proposal = 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
# 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
# summary functions
def ResetProposalCache
Builtins.y2milestone("Reseting the software proposal cache")
@cached_proposal = nil
nil
end
# List selected resolvables of specified kind
# @param [Symbol] what symbol specifying the kind of resolvables to select
# @param [String] format string format string to print summaries in
# @return a list of selected resolvables
def ListSelected(what, format)
selected = Y2Packager::Resolvable.find(kind: what, status: :selected)
selected.select!(&:user_visible) if what == :pattern
sort_resolvable!(selected, what)
formatted_resolvables(selected, format)
end
# Count the total size of packages to be installed
# @return [String] formatted size of packages to be installed
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
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
# Count the total size of packages to be installed
# @return [Fixnum] size of packages to be installed (in bytes)
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 ["http", "https", "ftp"].include?(scheme)
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
# Return information about suboptimal distribution if relevant
# @return [String] the information string or empty string
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
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
# Return the summary output lines
# @param [Array<Symbol>] flags a list of flags, allowed are `product, `pattern, `selection,
# `size, `desktop
# @return a list of the output lines
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,
# TODO: simply delete the br once we can afford to break translations again
Ops.add(_("Patterns:<br>").chomp("<br>"), HTML.List(patterns))
)
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
# Check if selected software fits on the partitions
# @param [Boolean] init boolean true if partition sizes have changed
# @return [Boolean] true if selected software fits, false otherwise
def CheckDiskSize(init)
if init
Builtins.y2milestone("Resetting space calculation")
SpaceCalculation.GetPartitionInfo
end
SpaceCalculation.CheckDiskSize
end
# Checks which products have been selected for removal and modifies
# the warning messages accordingly.
#
# @param [Yast::ArgRef] _ret reference to map MakeProposal->Summary
def CheckOldAddOns(_ret)
Builtins.y2milestone("Currenly there is no check for old add ons")
end
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.mount_path
)
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.mount_path,
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.mount_path,
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
# Print the installatino proposal summary
# @param [Array<Symbol>] flags a list of symbols, see above
# @param [Boolean] use_cache if true, use previous proposal if possible
# @return [Hash] a map with proposal summary
def Summary(flags, use_cache)
flags = deep_copy(flags)
return { "warning" => @init_error, "warning_level" => :blocker } if !@init_error.nil?
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
# group products according to the current state
# @param [Array<Y2Packager::Resolvable>] products list of products
# @return [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
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
# create a product update summary (in rich text format)
# usable in update proposal
# @see #product_update_warning how to set and display possible issues
# @param [Array<Y2Packager::Resolvable>] products list of products
# @return [Array<String>] list of rich text descriptions
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
format(
_("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|
obsolete = Y2Packager::ProductUpgrade.will_be_obsoleted_by(product.name)
log.info "Product #{product.name} will be obsoleted by #{obsolete.inspect}"
if obsolete.empty?
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
re = HTML.Colorize(msg, "red")
else
new_products_str = new_product_names(obsolete).join(", ")
# TRANSLATORS: Old product %{old_product} will be obsoleted by %{new_product} products.
re = format(
_("Product <b>%{old_product}</b> will be updated to <b>%{new_product}</b>"),
old_product: h(product_label(product)),
new_product: h(new_products_str)
)
end
re
end
log.info "Product update summary: #{ret}"
ret
end
# create a warning for product update summary (in rich text format) if
# there is an update problem
# @see #product_update_summary how to get the summary text
# @param [Array<Y2Packager::Resolvable>] products list of products
# @return [Hash] hash with warning attributes or empty if there is no problem
def product_update_warning(products)
status = group_products_by_status(products)
ret = status[:removed].all? do |product|
product.transact_by != :solver ||
!Y2Packager::ProductUpgrade.will_be_obsoleted_by(product.name).empty?
end
return {} if ret
# 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
# return a printable name of product resolvable
# @param [Y2Packager::Resolvable] product the product
# @return [String] product name
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
# proposal control functions
def ForceFullRepropose
@full_repropose = true
nil
end
# Reset package selection, but keep the selected objects of the specified type
# @param [Array<Symbol>] keep a list of symbols specifying type of objects to be kept selected
def Reset(keep)
restore = {}
# collect the currently selected resolvables
keep.each do |type|
# get the items selected by YaST (the items selected by solver will be later selected again,
# the items selected by user are not reset by the Pkg.PkgApplReset call)
resolvables = Y2Packager::Resolvable.find(kind: type, status: :selected,
transact_by: :app_high)
restore[type] = resolvables.map(&:name)
end
# This keeps the user-made changes (BNC#446406)
Pkg.PkgApplReset
restore.each { |type, list| list.each { |name| Pkg.ResolvableInstall(name, type) } }
@system_packages_selected = false
nil
end
# Initialize add-on products provided by the repository
def InitializeAddOnProducts
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
# When the NTP configuration has been modified, it checks whether the
# service package is selected to be installed or not.
# @return [String] empty string or error message if the package is missing
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
# Checking if all needed packages for remote installation
# will be installed on the target system.
# @return [String] empty string or error message if there are missing packages
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 to 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
#-----------------------------------------------------------------------
# LOCALE FUNCTIONS
#-----------------------------------------------------------------------
# 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.
#
# @param [String] package string package to be selected
def addAdditionalPackage(package)
Builtins.y2warning(
"OBSOLETE! Please, use PackagesProposal::AddResolvables() instead"
)
@additional_packages = Builtins.add(@additional_packages, package)
nil
end
# Compute architecture packages
# @return [Array](string)
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
# Compute special packages
# @return [Array](string)
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
# CHeck whether this is a Dell system
def DellSystem
command = "/usr/sbin/hwinfo --bios | /usr/bin/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
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
# Compute board (vendor) dependent packages
# @return [Array](string)
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
# Compute packages required to access the repositories
# @return [Array](string) list of the required packages
def sourceAccessPackages
packages = []
schemes = repo_schemes
# /sbin/mount.cifs is required to mount a SMB/CIFS share
packages << "cifs-mount" if schemes.include?("smb") || schemes.include?("cifs")
# portmap is required to mount an NFS export
packages << "nfs-client" if schemes.include?("nfs")
log.info("Packages for accessing the repositories: #{packages.inspect}")
packages
end