Class: Yast::AutoinstSoftwareClass
- Inherits:
-
Module
- Object
- Module
- Yast::AutoinstSoftwareClass
- Defined in:
- ../../src/modules/AutoinstSoftware.rb
Instance Method Summary (collapse)
-
- (void) AddModulePackages(module_packages)
Add packages needed by modules, i.e.
-
- (void) addPostPackages(calcpost)
Add post packages.
- - (Object) AddYdepsFromProfile(entries)
-
- (Array) autoinstPackages
Compute list of packages selected by user and other packages needed for important configuration modules.
-
- (Object) AutoinstSoftware
Constructer.
- - (Object) copyFiles4ISO(target)
- - (Object) createImage(targetdir)
- - (Object) createISO
-
- (Object) Export
Export data.
- - (Object) GetArchOfELF(filename)
-
- (Boolean) GetModified
Functions which returns if the settings were modified.
-
- (Object) Import(settings)
Import data.
- - (Object) install_packages
- - (Object) locked_packages
- - (Object) main
-
- (Object) pmInit
Initialize temporary target.
- - (Object) Read
-
- (Hash) read_initial_stage
Return list of software packages, patterns which have been selected by the user and have to be installed or removed.
-
- (Hash) ReadHelper
Return list of software packages of calling client in the installed environment.
-
- (void) RemoveModulePackages(module_packages)
Remove packages not needed by modules, i.e.
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) Summary
Summary.
-
- (Boolean) Write
Configure software settings.
Instance Method Details
- (void) AddModulePackages(module_packages)
This method returns an undefined value.
Add packages needed by modules, i.e. NIS, NFS etc.
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 |
# File '../../src/modules/AutoinstSoftware.rb', line 698 def AddModulePackages(module_packages) module_packages = deep_copy(module_packages) PackageAI.toinstall = Builtins.toset( Convert.convert( Builtins.union(PackageAI.toinstall, module_packages), :from => "list", :to => "list <string>" ) ) # # Update profile # Ops.set(Profile.current, "software", Export()) nil end |
- (void) addPostPackages(calcpost)
This method returns an undefined value.
Add post packages
935 936 937 938 939 940 941 942 943 |
# File '../../src/modules/AutoinstSoftware.rb', line 935 def addPostPackages(calcpost) calcpost = deep_copy(calcpost) AutoinstData.post_packages = Convert.convert( Builtins.toset(Builtins.union(calcpost, AutoinstData.post_packages)), :from => "list", :to => "list <string>" ) nil end |
- (Object) AddYdepsFromProfile(entries)
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File '../../src/modules/AutoinstSoftware.rb', line 202 def AddYdepsFromProfile( entries ) Builtins.y2milestone("AddYdepsFromProfile entries %1", entries) ign = [ "software", "partitioning", "general", "report", "scripts", "suse_register", "files", "bootloader", "add-on", "dasd", "zfcp", "timezone" ] map = { "networking" => "yast2-network" } entries.reject! { |e| ign.include?(e) } Builtins.y2milestone("AddYdepsFromProfile entries %1", entries) pkglist = [] entries.each do |e| name = map.has_key?(e) ? map[e] : "yast2-"+e Builtins.y2milestone("AddYdepsFromProfile name %1 from %2", name, e) pkglist.push(name) if !pkglist.include?(name) end Builtins.y2milestone("AddYdepsFromProfile pkglist %1", pkglist) pkglist.each do |p| if( !PackageAI.toinstall.include?(p) && @packagesAvailable.include?(p) ) PackageAI.toinstall.push(p) end end end |
- (Array) autoinstPackages
Compute list of packages selected by user and other packages needed for important configuration modules.
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 764 def autoinstPackages allpackages = [] # the primary list of packages allpackages = Convert.convert( Builtins.union(allpackages, PackageAI.toinstall), :from => "list", :to => "list <string>" ) # In autoinst mode, a kernel should not be available # in <packages> if Builtins.size(@kernel) == 0 kernel_pkgs = Kernel.ComputePackages allpackages = Convert.convert( Builtins.union(allpackages, kernel_pkgs), :from => "list", :to => "list <string>" ) else if Pkg.IsAvailable(@kernel) allpackages = Builtins.add(allpackages, @kernel) kernel_nongpl = Ops.add(@kernel, "-nongpl") if Pkg.IsAvailable(kernel_nongpl) allpackages = Builtins.add(allpackages, kernel_nongpl) end else Builtins.y2warning("%1 not available, using kernel-default", @kernel) kernel_pkgs = Kernel.ComputePackages allpackages = Convert.convert( Builtins.union(allpackages, kernel_pkgs), :from => "list", :to => "list <string>" ) end end deep_copy(allpackages) end |
- (Object) AutoinstSoftware
Constructer
224 225 226 227 228 229 230 |
# File '../../src/modules/AutoinstSoftware.rb', line 224 def AutoinstSoftware if Stage.cont && Mode.autoinst Pkg.TargetInit("/", false) Import(Ops.get_map(Profile.current, "software", {})) end nil end |
- (Object) copyFiles4ISO(target)
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 447 def copyFiles4ISO(target) ret = true copy = Misc.SysconfigRead( path(".sysconfig.autoinstall.COPY_FOR_ISO"), "/,/boot/,/boot/__ARCH__/,/boot/__ARCH__/loader/,/media.1/,/suse/setup/descr/" ) copyList = Builtins.splitstring(copy, ",") Builtins.foreach(copyList) do |source| if Builtins.issubstring(source, "__ARCH__") source = Builtins.regexpsub( source, "(.*)__ARCH__(.*)", Builtins.sformat("\\1%1\\2", @image_arch) ) end if Builtins.substring(source, Ops.subtract(Builtins.size(source), 1)) == "/" # copy a directory (ends with / in directory.yast) SCR.Execute( path(".target.mkdir"), Ops.add(Ops.add(target, "/"), source) ) if !GetURL( Ops.add( Ops.add(Ops.add(@instsource, "/"), source), "directory.yast" ), "/tmp/directory.yast" ) Popup.Error( Builtins.sformat( _( "can not get the directory.yast file at `%1`.\nYou can create that file with 'ls -F > directory.yast' if it's missing." ), Ops.add(Ops.add(@instsource, "/"), source) ) ) ret = false raise Break end # directory.yast is our filelist files = Convert.to_string( SCR.Read(path(".target.string"), "/tmp/directory.yast") ) filesInDir = Builtins.splitstring(files, "\n") Builtins.foreach(filesInDir) do |file| # don't copy subdirs. They have to be mentioned explicit. Copy only files from that dir. Builtins.y2milestone( "will get %1 from %2 to %3", file, Ops.add(Ops.add(@instsource, "/"), source), target ) if Ops.greater_than(Builtins.size(file), 0) && Builtins.substring(file, Ops.subtract(Builtins.size(file), 1)) != "/" while ret && !GetURL( Ops.add(Ops.add(Ops.add(@instsource, "/"), source), file), Ops.add( Ops.add(Ops.add(Ops.add(target, "/"), source), "/"), file ) ) if !Popup.YesNo( Builtins.sformat( _("can not read '%1'. Try again?"), Ops.add(Ops.add(Ops.add(@instsource, "/"), source), file) ) ) ret = false end end end raise Break if !ret end else # copy a file if !GetURL( Ops.add(Ops.add(@instsource, "/"), source), Ops.add(Ops.add(target, "/"), source) ) Popup.Error( Builtins.sformat( _("can not read '%1'. ISO creation failed"), Ops.add(Ops.add(@instsource, "/"), source) ) ) ret = false raise Break end end end # lets always copy an optional(!) driverupdate file. It's very unlikely that it's in directory.yast GetURL( Ops.add(@instsource, "/driverupdate"), Ops.add(target, "/driverupdate") ) SCR.Execute( path(".target.bash"), Builtins.sformat("cp /usr/lib/YaST2/bin/fetch_image.sh %1/", target) ) ret end |
- (Object) createImage(targetdir)
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 244 def createImage(targetdir) rootdir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) zypperCall = "" outputRedirect = " 2>&1 >> /tmp/ay_image.log" finalPopup = Builtins.size(targetdir) == 0 Ops.set( @image, "script_location", Ops.get_string( @image, "script_location", "file:///usr/lib/YaST2/bin//fetch_image.sh" ) ) Ops.set( @image, "script_params", Convert.convert( Ops.get(@image, "script_params") do [ Ops.add( Ops.add( Ops.add(Ops.get_string(@image, "image_location", ""), "/"), Ops.get_string(@image, "image_name", "image") ), ".tar.gz" ) ] end, :from => "any", :to => "list <string>" ) ) SCR.Execute(path(".target.bash"), "rm -f /tmp/ay_image.log") # bind-mount devices SCR.Execute(path(".target.mkdir"), Ops.add(rootdir, "/dev")) returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Builtins.sformat("touch /%1/dev/null %1/dev/zero", rootdir) ) ) returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Builtins.sformat("mount -o bind /dev/zero /%1/dev/zero", rootdir) ) ) returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Builtins.sformat("mount -o bind /dev/null /%1/dev/null", rootdir) ) ) # Add Source: # zypper --root /space/tmp/tmproot/ ar ftp://10.10.0.100/install/SLP/openSUSE-11.2/i386/DVD1/ main zypperCall = Builtins.sformat( "ZYPP_READONLY_HACK=1 zypper --root %1 --gpg-auto-import-keys --non-interactive ar %2 main-source %3", rootdir, @instsource, outputRedirect ) Builtins.y2milestone("running %1", zypperCall) returnCode = Convert.to_integer( SCR.Execute(path(".target.bash"), zypperCall) ) if returnCode != 0 && returnCode != 4 # 4 means "already exists" Popup.Error(Builtins.sformat(_("Adding repo %1 failed"), @instsource)) end # Add add-ons addOnExport = Convert.to_map(WFM.CallFunction("add-on_auto", ["Export"])) addOns = Ops.get_list(addOnExport, "add_on_products", []) Builtins.foreach(addOns) do |addOn| zypperCall = Builtins.sformat( "ZYPP_READONLY_HACK=1 zypper --root %1 --gpg-auto-import-keys --non-interactive ar %2 %3 %4", rootdir, Ops.get_string(addOn, "media_url", ""), Ops.get_string(addOn, "product", ""), outputRedirect ) returnCode = Convert.to_integer( SCR.Execute(path(".target.bash"), zypperCall) ) if returnCode != 0 && returnCode != 4 Popup.Error( Builtins.sformat( _("Adding repo %1 failed"), Ops.get_string(addOn, "product", "") ) ) end end # Install zypperCall = Builtins.sformat( "ZYPP_READONLY_HACK=1 zypper --root %1 --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses ", rootdir ) pattern = Builtins.mergestring(@patterns, " ") Popup.ShowFeedback("Creating Image - installing patterns", "") Builtins.y2milestone("installing %1", pattern) returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Ops.add( Ops.add(Ops.add(zypperCall, "-t pattern "), pattern), outputRedirect ) ) ) Popup.ClearFeedback if returnCode != 0 Popup.Error( _( "Image creation failed while pattern installation. Please check /tmp/ay_image.log" ) ) end if Ops.greater_than(Builtins.size(PackageAI.toinstall), 0) package = Builtins.mergestring(PackageAI.toinstall, " ") Popup.ShowFeedback(_("Creating Image - installing packages"), "") returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Ops.add(Ops.add(Ops.add(zypperCall, " "), package), outputRedirect) ) ) Popup.ClearFeedback if returnCode != 0 Popup.Error( _( "Image creation failed while package installation. Please check /tmp/ay_image.log" ) ) end end @image_arch = GetArchOfELF(Builtins.sformat("%1/bin/bash", rootdir)) Builtins.y2milestone("Image architecture = %1", @image_arch) if targetdir == "" # Popup::Message( _("in the next file dialog you have to choose the target directory to save the image") ); targetdir = UI.AskForExistingDirectory("/", _("Store image to ...")) end # umount devices returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Builtins.sformat("umount %1/dev/null %1/dev/zero %1/proc", rootdir) ) ) returnCode = Convert.to_integer( SCR.Execute( path(".target.bash"), Builtins.sformat("rm -rf %1/dev", rootdir) ) ) # Compress image: # tar cfz /srv/www/htdocs/image.tar.gz --exclude="proc*" . tarCommand = Builtins.sformat( "tar cfvz %4/%3.tar.gz --exclude=\"./proc*\" --exclude=\"/%3.tar.gz\" -C %1 . %2", rootdir, outputRedirect, Ops.get_string(@image, "image_name", ""), targetdir ) Builtins.y2milestone("running %1", tarCommand) Popup.Message( Builtins.sformat( _( "You can do changes to the image now in %1/\nIf you press the ok-button, the image will be compressed and can't be changed anymore." ), rootdir ) ) Popup.ShowFeedback("Compressing Image ...", "") returnCode = Convert.to_integer( SCR.Execute(path(".target.bash"), tarCommand) ) Popup.ClearFeedback if returnCode != 0 Popup.Error( Builtins.sformat( _( "Image compressing failed in '%1'. Please check /tmp/ay_image.log" ), rootdir ) ) end Popup.Message(_("Image created successfully")) if finalPopup nil end |
- (Object) createISO
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 551 def createISO # we will have the image.tar.gz and autoinst.xml on the root of the DVD/CD isodir = "/tmp/ay_iso/" SCR.Execute(path(".target.bash"), Builtins.sformat("rm -rf %1", isodir)) SCR.Execute(path(".target.mkdir"), isodir) outputRedirect = " 2>&1 >> /tmp/ay_image.log" returnCode = 0 createImage(isodir) Popup.ShowFeedback(_("Preparing ISO Filestructure ..."), "") copyFiles4ISO(isodir) Popup.ClearFeedback # prepare and save autoinst.xml Ops.set(@image, "image_location", "file:///") Ops.set( @image, "script_params", [ Ops.add( Ops.add( Ops.add(Ops.get_string(@image, "image_location", ""), "/"), Ops.get_string(@image, "image_name", "") ), ".tar.gz" ) ] ) Ops.set(@image, "script_location", "file:///fetch_image.sh") Profile.Save(Builtins.sformat("%1/autoinst.xml", isodir)) # prepare and save isolinux.cfg boot menu of the media @isolinuxcfg = Convert.to_string( SCR.Read( path(".target.string"), Builtins.sformat( "%1/boot/%2/loader/isolinux.cfg", isodir, @image_arch ) ) ) lines = Builtins.splitstring(@isolinuxcfg, "\n") lines = Builtins.maplist(lines) do |l| if Builtins.issubstring(l, " append ") l = Ops.add(l, " autoyast=file:///autoinst.xml") end l end @isolinuxcfg = Builtins.mergestring(lines, "\n") UI.OpenDialog( Opt(:decorated), VBox( HBox( VSpacing(14), MultiLineEdit( Id(:isolinuxcfg), _("boot config for the DVD"), @isolinuxcfg ) ), PushButton(Id(:create_image), Opt(:default, :hstretch), _("Ok")), Label( Builtins.sformat( _( "You can do changes to the ISO now in %1, like adding a complete different AutoYaST XML file.\nIf you press the ok-button, the iso will be created." ), isodir ) ) ) ) UI.UserInput @isolinuxcfg = Convert.to_string(UI.QueryWidget(:isolinuxcfg, :Value)) UI.CloseDialog SCR.Write( path(".target.string"), Builtins.sformat("%1/boot/%2/loader/isolinux.cfg", isodir, @image_arch), @isolinuxcfg ) # create the actual ISO file # Popup::Message( _("Please choose a place where you want to save the ISO file in the next dialog") ); targetdir = UI.AskForExistingDirectory("/", _("Store ISO image to ...")) Popup.ShowFeedback(_("Creating ISO File ..."), "") cmd = Builtins.sformat( "mkisofs -o %1/%2.iso -R -b boot/%3/loader/isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table %4", targetdir, Ops.get_string(@image, "image_name", ""), @image_arch, isodir ) Builtins.y2milestone("executing %1", Ops.add(cmd, outputRedirect)) returnCode = Convert.to_integer(SCR.Execute(path(".target.bash"), cmd)) Popup.ClearFeedback if returnCode != 0 Popup.Error( Builtins.sformat( "ISO creation failed in '%1'. Please check /tmp/ay_image.log", isodir ) ) else Popup.Message( Builtins.sformat( _("ISO successfully created at %1"), Ops.add( Ops.add("/tmp/", Ops.get_string(@image, "image_name", "")), ".iso" ) ) ) end nil end |
- (Object) Export
Export data
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
# File '../../src/modules/AutoinstSoftware.rb', line 671 def Export s = {} Ops.set(s, "kernel", @kernel) if @kernel != "" Ops.set(s, "patterns", @patterns) if @patterns != [] Ops.set(s, "packages", PackageAI.toinstall) if PackageAI.toinstall != [] if AutoinstData.post_packages != [] Ops.set(s, "post-packages", AutoinstData.post_packages) end if PackageAI.toremove != [] Ops.set(s, "remove-packages", PackageAI.toremove) end Ops.set(s, "instsource", @instsource) Ops.set(s, "image", @image) deep_copy(s) end |
- (Object) GetArchOfELF(filename)
232 233 234 235 236 237 238 239 240 241 |
# File '../../src/modules/AutoinstSoftware.rb', line 232 def GetArchOfELF(filename) bash_out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add(Ops.add(Directory.ybindir, "/elf-arch "), filename) ) ) return "unknown" if Ops.get_integer(bash_out, "exit", 1) != 0 Builtins.deletechars(Ops.get_string(bash_out, "stdout", "unknown"), "\n") end |
- (Boolean) GetModified
Functions which returns if the settings were modified
83 84 85 |
# File '../../src/modules/AutoinstSoftware.rb', line 83 def GetModified @modified end |
- (Object) Import(settings)
Import data
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 91 def Import(settings) settings = deep_copy(settings) @Software = deep_copy(settings) @patterns = settings.fetch("patterns",[]) @instsource = settings.fetch("instsource","") notFound = "" # what is this good for? disturbs the main-repo selection # Packages::Init(true); # Packages::InitializeAddOnProducts(); @packagesAvailable = Pkg.GetPackages(:available, true) @patternsAvailable = [] allPatterns = Pkg.ResolvableDependencies("", :pattern, "") allPatterns = Builtins.filter(allPatterns) do |m| if m.fetch("user_visible",false) @patternsAvailable.push( m.fetch("name","") ) end m.fetch("user_visible",false) end regexFound = [] Ops.set( settings, "packages", Builtins.filter(Ops.get_list(settings, "packages", [])) do |want_pack| next true if !Builtins.issubstring(want_pack, "/") want_pack = Builtins.deletechars(want_pack, "/") Builtins.foreach(@packagesAvailable) do |pack| Builtins.y2milestone("matching %1 against %2", pack, want_pack) if Builtins.regexpmatch(pack, want_pack) regexFound = Builtins.add(regexFound, pack) Builtins.y2milestone("match") end end false end ) Ops.set( settings, "packages", Convert.convert( Builtins.union(Ops.get_list(settings, "packages", []), regexFound), :from => "list", :to => "list <string>" ) ) regexFound = [] @patterns = Builtins.filter(@patterns) do |want_patt| next true if !Builtins.issubstring(want_patt, "/") want_patt = Builtins.deletechars(want_patt, "/") Builtins.foreach(patternsAvailable) do |patt| Builtins.y2milestone("matching %1 against %2", patt, want_patt) if Builtins.regexpmatch(patt, want_patt) regexFound = Builtins.add(regexFound, patt) Builtins.y2milestone("match") end end false end @patterns = Convert.convert( Builtins.union(@patterns, regexFound), :from => "list", :to => "list <string>" ) Builtins.foreach(Ops.get_list(settings, "packages", [])) do |pack| if !Pkg.IsAvailable(pack) && Stage.initial notFound = Ops.add(Ops.add(notFound, pack), "\n") end end if Ops.greater_than(Builtins.size(notFound), 0) Builtins.y2error("packages not found: %1", notFound) # warning text during the installation. %1 is a list of package names Report.Error( Builtins.sformat( _( "These packages could not be found in the software repositories:\n%1" ), notFound ) ) end PackageAI.toinstall = settings.fetch("packages",[]) @kernel = settings.fetch("kernel","") AutoinstData.post_packages = settings.fetch("post-packages", []) AutoinstData.post_patterns = settings.fetch("post-patterns", []) PackageAI.toremove = settings.fetch("remove-packages", []) # Imaging # map<string, any> image = settings["system_images"]:$[]; # imaging = image["enable_multicast_images"]:false; # ft_module = image["module_name"]:""; # if (settings == $[]) # modified = false; # else # modified = true; @image = settings.fetch("image",{}) # image_location and image_name are not mandatory for # extracting an image because it can be defined in the # script too. So it will not be checked here. if @image["script_location"] && !@image["script_location"].empty? @imaging = true end true end |
- (Object) install_packages
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 953 def install_packages # user selected packages which have not been already installed packages = Pkg.FilterPackages( solver_selected = false, app_selected = true, user_selected = true, name_only = true) # user selected packages which have already been installed installed_by_user = Pkg.GetPackages(:installed, true).select{ |pkg_name| Pkg.PkgPropertiesAll(pkg_name).any? { |package| package["on_system_by_user"] } } # Filter out kernel and pattern packages kernel_packages = Pkg.PkgQueryProvides("kernel").collect { |package| package[0] }.compact.uniq pattern_packages = Pkg.PkgQueryProvides("pattern()").collect { |package| package[0] }.compact.uniq (packages + installed_by_user).uniq.select{ |pkg_name| !kernel_packages.include?(pkg_name) && !pattern_packages.include?(pkg_name) } end |
- (Object) locked_packages
945 946 947 948 949 950 951 |
# File '../../src/modules/AutoinstSoftware.rb', line 945 def locked_packages packages = Pkg.ResolvableProperties("", :package, "").select do |package| # hard AND soft locks package["transact_by"] == :user && (package["locked"] || package["status"] == :available) end packages.map! {|p| p["name"] } end |
- (Object) main
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 14 def main Yast.import "UI" Yast.import "Pkg" textdomain "autoinst" Yast.import "Profile" Yast.import "Summary" Yast.import "Stage" Yast.import "SpaceCalculation" Yast.import "Packages" Yast.import "Popup" Yast.import "Report" Yast.import "Kernel" Yast.import "AutoinstConfig" Yast.import "ProductControl" Yast.import "Storage" Yast.import "Mode" Yast.import "Misc" Yast.import "Directory" Yast.include self, "autoinstall/io.rb" # All shared data are in yast2.rpm to break cyclic dependencies Yast.import "AutoinstData" Yast.import "PackageAI" @Software = {} @image = {} @image_arch = "" # patterns @patterns = [] # Kernel, force type of kernel to be installed @kernel = "" # Packages that should be installed in continue mode # AutoinstData::post_packages = []; @ft_module = "" # Enable Imaging @imaging = false # default value of settings modified @modified = false @inst = [] @all_xpatterns = [] @packagesAvailable = [] @patternsAvailable = [] @instsource = "" @isolinuxcfg = "" AutoinstSoftware() end |
- (Object) pmInit
Initialize temporary target
920 921 922 923 924 925 926 927 928 929 |
# File '../../src/modules/AutoinstSoftware.rb', line 920 def pmInit # string tmproot = AutoinstConfig::tmpDir; # SCR::Execute(.target.mkdir, tmproot + "/root"); # Pkg::TargetInit( tmproot + "/root", true); # Pkg::TargetInit( "/", true); Pkg.TargetInit(Convert.to_string(SCR.Read(path(".target.tmpdir"))), true) Builtins.y2milestone("SourceStartCache: %1", Pkg.SourceStartCache(false)) nil end |
- (Object) Read
1082 1083 1084 |
# File '../../src/modules/AutoinstSoftware.rb', line 1082 def Read Import((Stage.initial ? read_initial_stage() : ReadHelper())) end |
- (Hash) read_initial_stage
Return list of software packages, patterns which have been selected by the user and have to be installed or removed. The evaluation will be called while the yast installation workflow.
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File '../../src/modules/AutoinstSoftware.rb', line 1063 def read_initial_stage install_patterns = Pkg.ResolvableProperties("", :pattern, "").collect do |pattern| # Do not take care about if the pattern has been selected by the user or the product # definition, cause we need a base selection here for the future # autoyast installation. (bnc#882886) if pattern["user_visible"] && (pattern["status"] == :selected || pattern["status"] == :installed) pattern["name"] end end software = {} software["packages"] = install_packages software["patterns"] = install_patterns.compact software["remove-packages"] = locked_packages Builtins.y2milestone("autoyast software selection: %1", software) deep_copy(software) end |
- (Hash) ReadHelper
Return list of software packages of calling client in the installed environment
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
# File '../../src/modules/AutoinstSoftware.rb', line 986 def ReadHelper Pkg.TargetInit("/", false) Pkg.TargetLoad Pkg.SourceStartManager(true) Pkg.PkgSolve(false) all_patterns = Pkg.ResolvableProperties("", :pattern, "") @all_xpatterns = Pkg.ResolvableDependencies("", :pattern, "") to_install_packages = install_packages patterns = [] patternsFullData = Builtins.filter(all_patterns) do |p| ret2 = false if Ops.get_symbol(p, "status", :none) == :installed && !Builtins.contains(patterns, Ops.get_string(p, "name", "no name")) patterns = Builtins.add( patterns, Ops.get_string(p, "name", "no name") ) ret2 = true end ret2 end Pkg.TargetFinish tmproot = AutoinstConfig.tmpDir SCR.Execute(path(".target.mkdir"), Ops.add(tmproot, "/rootclone")) Pkg.TargetInit(Ops.add(tmproot, "/rootclone"), true) Builtins.y2debug("SourceStartCache: %1", Pkg.SourceStartCache(false)) Pkg.SourceStartManager(true) Pkg.TargetFinish patternPackages = [] new_p = [] Builtins.foreach(patterns) do |tmp_pattern| xpattern = Builtins.filter(@all_xpatterns) do |p| Ops.get_string(p, "name", "") == tmp_pattern end found = Ops.get(xpattern, 0, {}) req = false # kick out hollow patterns (always fullfilled patterns) Builtins.foreach(Ops.get_list(found, "dependencies", [])) do |d| if Ops.get_string(d, "res_kind", "") == "package" && (Ops.get_string(d, "dep_kind", "") == "requires" || Ops.get_string(d, "dep_kind", "") == "recommends") req = true end end # workaround for our pattern design # a pattern with no requires at all is always fullfilled of course # you can fullfill the games pattern with no games installed at all new_p = Builtins.add(new_p, tmp_pattern) if req == true end patterns = deep_copy(new_p) software = {} Ops.set(software, "patterns", Builtins.sort(patterns)) # Currently we do not have any information about user deleted packages in # the installed system. # In order to prevent a reinstallation we can take the locked packages at least. # (bnc#888296) software["remove-packages"] = locked_packages software["packages"] = to_install_packages deep_copy(software) end |
- (void) RemoveModulePackages(module_packages)
This method returns an undefined value.
Remove packages not needed by modules, i.e. NIS, NFS etc.
717 718 719 720 721 722 723 724 |
# File '../../src/modules/AutoinstSoftware.rb', line 717 def RemoveModulePackages(module_packages) module_packages = deep_copy(module_packages) PackageAI.toinstall = Builtins.filter(PackageAI.toinstall) do |p| !Builtins.contains(module_packages, p) end Ops.set(Profile.current, "software", Export()) nil end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”
75 76 77 78 79 |
# File '../../src/modules/AutoinstSoftware.rb', line 75 def SetModified @modified = true nil end |
- (Object) Summary
Summary
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 730 def Summary summary = "" summary = Summary.AddHeader(summary, _("Selected Patterns")) if Ops.greater_than(Builtins.size(@patterns), 0) summary = Summary.OpenList(summary) Builtins.foreach(@patterns) do |a| summary = Summary.AddListItem(summary, a) end summary = Summary.CloseList(summary) else summary = Summary.AddLine(summary, Summary.NotConfigured) end summary = Summary.AddHeader(summary, _("Individually Selected Packages")) summary = Summary.AddLine( summary, Builtins.sformat("%1", Builtins.size(PackageAI.toinstall)) ) summary = Summary.AddHeader(summary, _("Packages to Remove")) summary = Summary.AddLine( summary, Builtins.sformat("%1", Builtins.size(PackageAI.toremove)) ) if @kernel != "" summary = Summary.AddHeader(summary, _("Force Kernel Package")) summary = Summary.AddLine(summary, Builtins.sformat("%1", @kernel)) end summary end |
- (Boolean) Write
Configure software settings
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 |
# File '../../src/modules/AutoinstSoftware.rb', line 810 def Write if @imaging if !Ops.get_boolean(@image, "run_kickoff", false) ProductControl.DisableModule("kickoff") end ProductControl.DisableModule("rpmcopy") return true end ok = true Packages.Init(true) sw_settings = Profile.current.fetch("software",{}) Pkg.SetSolverFlags({ "ignoreAlreadyRecommended" => Mode.normal, "onlyRequires" => !sw_settings.fetch("install_recommended",true) }) failed = [] # switch for recommended patterns installation (workaround for our very weird pattern design) if sw_settings.fetch("install_recommended",false) == false # set SoftLock to avoid the installation of recommended patterns (#159466) Builtins.foreach(Pkg.ResolvableProperties("", :pattern, "")) do |p| Pkg.ResolvableSetSoftLock(Ops.get_string(p, "name", ""), :pattern) end end Builtins.foreach(Builtins.toset(@patterns)) do |p| failed = Builtins.add(failed, p) if !Pkg.ResolvableInstall(p, :pattern) end if Ops.greater_than(Builtins.size(failed), 0) Builtins.y2error( "Error while setting pattern: %1", Builtins.mergestring(failed, ",") ) Report.Warning( Builtins.sformat( _("Could not set patterns: %1."), Builtins.mergestring(failed, ",") ) ) end autoinstPacks = autoinstPackages # FIXME: optimization for package list evaluation turned off because it optimized it # into an unbootable state (no kernel) bnc#427731 # # list<string> autoinstPacks = PackageAI::toinstall; Builtins.y2milestone( "Packages selected in autoinstall mode: %1", autoinstPacks ) if Ops.greater_than(Builtins.size(autoinstPacks), 0) Builtins.y2milestone( "Installing individual packages: %1", Pkg.DoProvide(autoinstPacks) ) end computed_packages = Packages.ComputeSystemPackageList Builtins.y2debug("Computed list of packages: %1", computed_packages) Pkg.DoProvide(computed_packages) Builtins.foreach(computed_packages) do |pack2| if Ops.greater_than(Builtins.size(@kernel), 0) && pack2 != @kernel && Builtins.search(pack2, "kernel-") == 0 Builtins.y2milestone("taboo for kernel %1", pack2) PackageAI.toremove = Builtins.add(PackageAI.toremove, pack2) end end # # Now remove all packages listed in remove-packages # Builtins.y2milestone("Packages to be removed: %1", PackageAI.toremove) if Ops.greater_than(Builtins.size(PackageAI.toremove), 0) Builtins.foreach(PackageAI.toremove) do |rp| #Pkg::ResolvableSetSoftLock( rp, `package ); // FIXME: maybe better Pkg::PkgTaboo(rp) ? Pkg.PkgTaboo(rp) end Pkg.DoRemove(PackageAI.toremove) end pack = Storage.AddPackageList if Ops.greater_than(Builtins.size(pack), 0) Builtins.y2milestone( "Installing storage packages: %1", Pkg.DoProvide(pack) ) end # # Solve dependencies # if !Pkg.PkgSolve(false) Report.Error( _( "The package resolver run failed. Please check your software section in the autoyast profile." ) ) end SpaceCalculation.ShowPartitionWarning ok end |