Class: Yast::WorkflowManagerClass
- Inherits:
-
Module
- Object
- Module
- Yast::WorkflowManagerClass
- Includes:
- Logger
- Defined in:
- library/control/src/modules/WorkflowManager.rb
Instance Method Summary collapse
-
#AddNewProposals(proposals) ⇒ Boolean
Add new defined proposal to the list of system proposals.
-
#addon_control_dir(src_id, cleanup: false) ⇒ String
Create a temporary directory for storing the installer extension package content.
-
#AddWorkflow(type, src_id, name) ⇒ Boolean
Stores new workflow (if such workflow exists) into the Worflow Store.
-
#CleanWorkflowsDirectory ⇒ Object
Removes all xml and ycp files from directory where.
-
#control_file(source) ⇒ String?
Download and extract the control file (installation.xml) from the add-on repository.
-
#control_file_at_dir(dir) ⇒ String
Path of the control file contained in the package that has been previously extracted to the given directory.
-
#DumpCurrentSettings ⇒ Hash{String => Object}
Returns the current settings used by WorkflowManager.
-
#FillUpInitialWorkflowSettings ⇒ Object
Fills the workflow with initial settings to start merging from scratch.
-
#find_control_file(dir) ⇒ String?
Full name of the control file located directly in the given directory.
-
#GenerateAdditionalControlFilePath(src_id, ident) ⇒ String
Creates path to a control file from parameters.
-
#GenerateWorkflowIdent(workflow_filename) ⇒ String
Returns file unique identification in format
- Returns 'nil' if file doesn't exist, it is not a 'file', etc. -
#GetAdditionalFinishSteps(which_steps) ⇒ Array<String>
Returns list of additional inst_finish steps requested by additional workflows.
-
#GetAllUsedControlFiles ⇒ Array<String>
Returns list of control-file names currently used.
-
#GetCachedWorkflowFilename(type, src_id, name = "") ⇒ String
Returns requested control filename.
-
#GetWorkflowDirectory ⇒ Object
Returns the current (default) directory where workflows are stored in.
-
#HaveAdditionalWorkflows ⇒ Boolean
Returns whether some additional control files are currently in use.
-
#IncorporateControlFileOptions(filename) ⇒ Boolean
Read and remember the registration requirement status from an installation control XML file.
-
#IntegrateWorkflow(filename) ⇒ Boolean
Integrate the changes in the workflow.
- #main ⇒ Object
-
#merge_modules_extensions(packages) ⇒ Object
Merge modules extensions.
-
#merge_product_workflow(product) ⇒ Object
Merge product's workflow.
-
#MergeProposal(base, additional_control, prod_name, domain) ⇒ Hash
Merge add-on proposal to a base proposal.
-
#MergeWorkflow(base, addon, _prod_name, domain) ⇒ Hash
Merge add-on workflow to a base workflow.
-
#MergeWorkflows ⇒ Boolean
Function uses the Base Workflow as the initial one and merges all added workflow into that workflow.
-
#PrepareProposals(proposals) ⇒ Array<Hash>
Check all proposals, split those ones which have multiple modes or architectures or stages into multiple proposals.
-
#PrepareSystemProposals ⇒ Object
Check all proposals, split those ones which have multiple modes or architectures or stages into multiple proposals.
-
#PrepareSystemWorkflows ⇒ Object
Check all workflows, split those ones which have multiple modes or architectures or stages into multiple worlflows.
-
#PrepareWorkflows(workflows) ⇒ Array<Hash>
Check all workflows, split those ones which have multiple modes or architectures or stages into multiple workflows.
-
#RedrawWizardSteps ⇒ Object
Redraws workflow steps.
-
#RemoveWorkflow(type, src_id, name) ⇒ Boolean
Removes workflow (if such workflow exists) from the Worflow Store.
-
#ReplaceProposalModule(proposal, old, new) ⇒ Object
Replace a module in a proposal with a set of other modules.
-
#ReplaceWorkflowModule(workflow, old, new, domain, keep) ⇒ Object
Replace a module in a workflow with a set of other modules.
-
#Replaceworkflows(workflows) ⇒ Boolean
Replace workflows for 2nd stage of installation.
-
#ResetWorkflow ⇒ Object
Resets the Workflow (and proposals) to use the base workflow.
-
#SetAllUsedControlFiles(new_list) ⇒ Object
Sets list of control-file names to be used.
-
#SetBaseWorkflow(force) ⇒ Object
Stores the current ProductControl settings as the initial settings.
-
#SomeWorkflowsWereChanged ⇒ Object
Returns whether some additional control files were added or removed from the last time MergeWorkflows() was called.
-
#StoreWorkflowFile(file_from, file_to) ⇒ String
Stores the workflow file to a cache.
-
#update_system_roles(system_roles) ⇒ Object
Update sytem roles according to the update section of the control file.
-
#UpdateInstallation(update_file, name, domain) ⇒ Boolean
Adapts the current workflow according to specified XML file content.
-
#UpdateInstFinish(additional_steps) ⇒ Boolean
Add specified steps to inst_finish.
-
#UpdateProductInfo(update_file, _filename) ⇒ Boolean
Update product options such as global settings, software, partitioning or network.
-
#UpdateProposals(proposals, prod_name, domain) ⇒ Boolean
Update system proposals according to proposal update metadata.
-
#UpdateWorkflows(workflows, prod_name, domain) ⇒ Boolean
Update system workflows according to workflow update metadata.
-
#WorkflowRequiresRegistration(src_id) ⇒ Boolean
Returns whether a repository workflow requires registration.
-
#WorkflowsRequiringRegistration ⇒ Object
Returns list of workflows requiring registration.
Instance Method Details
#AddNewProposals(proposals) ⇒ Boolean
Add new defined proposal to the list of system proposals
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 1127 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1100 def AddNewProposals(proposals) proposals = deep_copy(proposals) forbidden = Builtins.maplist(ProductControl.proposals) do |p| Ops.get_string(p, "name", "") end forbidden = Builtins.toset(forbidden) Builtins.foreach(proposals) do |proposal| if Builtins.contains(forbidden, Ops.get_string(proposal, "name", "")) Builtins.y2warning( "Proposal '%1' already exists, not adding", Ops.get_string(proposal, "name", "") ) else Builtins.y2milestone( "Adding new proposal %1", Ops.get_string(proposal, "name", "") ) ProductControl.proposals = Builtins.add( ProductControl.proposals, proposal ) end end true end |
#addon_control_dir(src_id, cleanup: false) ⇒ String
Create a temporary directory for storing the installer extension package content. The directory is automatically removed at exit.
466 467 468 469 470 471 472 |
# File 'library/control/src/modules/WorkflowManager.rb', line 466 def addon_control_dir(src_id, cleanup: false) # Directory.tmpdir is automatically removed at exit dir = File.join(Directory.tmpdir, "installer-extension-#{src_id}") ::FileUtils.remove_entry(dir) if cleanup && Dir.exist?(dir) ::FileUtils.mkdir_p(dir) unless Dir.exist?(dir) dir end |
#AddWorkflow(type, src_id, name) ⇒ Boolean
Stores new workflow (if such workflow exists) into the Worflow Store.
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 570 def AddWorkflow(type, src_id, name) Builtins.y2milestone( "Adding Workflow: Type %1, ID %2, Name %3", type, src_id, name ) if !Builtins.contains([:addon, :package], type) Builtins.y2error("Unknown workflow type: %1", type) return false end name = "" if type == :addon # new xml filename used_filename = GetCachedWorkflowFilename(type, src_id, name) if !used_filename.nil? && used_filename != "" @unmerged_changes = true @used_workflows = Builtins.add(@used_workflows, used_filename) Ops.set(@workflows_to_sources, used_filename, src_id) end true end |
#CleanWorkflowsDirectory ⇒ Object
Removes all xml and ycp files from directory where
FIXME: this function seems to be unused, remove it?
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 653 def CleanWorkflowsDirectory directory = GetWorkflowDirectory() Builtins.y2milestone( "Removing all xml and ycp files from '%1' directory", directory ) if FileUtils.Exists(directory) # doesn't add RPM dependency on tar cmd = Convert.to_map( SCR.Execute( path(".target.bash_ouptut"), "\n" \ "cd '%1';\n" \ "/usr/bin/test -x /usr/bin/tar && /usr/bin/tar -zcf workflows_backup.tgz *.xml *.ycp *.rb;\n" \ "/usr/bin/rm -rf *.xml *.ycp *.rb", String.Quote(directory) ) ) Builtins.y2error("Removing failed: %1", cmd) if Ops.get_integer(cmd, "exit", -1) != 0 end nil end |
#control_file(source) ⇒ String?
Download and extract the control file (installation.xml) from the add-on repository.
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 415 def control_file(source) package = case source when ::Integer product = find_product(source) return nil unless product&.product_package product_package = product.product_package # the dependencies are bound to the product's -release package release_package = Y2Packager::Resolvable.find(kind: :package, name: product_package).first # find the package name with installer update in its Provide dependencies control_file_package = find_control_package(release_package) return nil unless control_file_package control_file_package when ::String source else raise ArgumentError, "Invalid argument source #{source.inspect}" end # get the repository ID of the package src = package_repository(package) return nil unless src # ensure the previous content is removed, the src should avoid # collisions but rather be safe... dir = addon_control_dir(src, cleanup: true) fetch_package(src, package, dir) path = control_file_at_dir(dir) return nil unless File.exist?(path) log.info("installation.xml path: #{path}") path rescue Y2Packager::PackageFetchError # TRANSLATORS: an error message Report.Error(_("Downloading the installer extension package failed.")) nil rescue Y2Packager::PackageExtractionError # TRANSLATORS: an error message Report.Error(_("Extracting the installer extension failed.")) nil end |
#control_file_at_dir(dir) ⇒ String
Path of the control file contained in the package that has been previously extracted to the given directory
481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'library/control/src/modules/WorkflowManager.rb', line 481 def control_file_at_dir(dir) # Lets first try FHS compliant path for a product package (fate#325482) path = find_control_file("#{dir}/usr/share/installation-products") # If nothing there, try FHS compliant path for a role package (bsc#1114573) path ||= find_control_file("#{dir}/usr/share/system-roles") # As last resort, use the default location at /installation.xml path ||= File.join(dir, "installation.xml") path end |
#DumpCurrentSettings ⇒ Hash{String => Object}
Returns the current settings used by WorkflowManager. This function is just for debugging purpose.
Structure:
[
"workflows" : ...
"proposals" : ...
"inst_finish" : ...
"clone_modules" : ...
"system_roles" : ...
"unmerged_changes" : ...
];
1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1536 def DumpCurrentSettings { "workflows" => ProductControl.workflows, "proposals" => ProductControl.proposals, "inst_finish" => ProductControl.inst_finish, "clone_modules" => ProductControl.clone_modules, "system_roles" => ProductControl.system_roles, "unmerged_changes" => @unmerged_changes } end |
#FillUpInitialWorkflowSettings ⇒ Object
Fills the workflow with initial settings to start merging from scratch. Used workflows mustn't be cleared automatically, merging would fail!
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 299 def FillUpInitialWorkflowSettings if !@base_workflow_stored Builtins.y2error( "Base Workflow has never been stored, you should have called SetBaseWorkflow() before!" ) end ProductFeatures.Import(@wkf_initial_product_features) ProductControl.workflows = deep_copy(@wkf_initial_workflows) ProductControl.proposals = deep_copy(@wkf_initial_proposals) ProductControl.inst_finish = deep_copy(@wkf_initial_inst_finish) ProductControl.clone_modules = deep_copy(@wkf_initial_clone_modules) ProductControl.system_roles = deep_copy(@wkf_initial_system_roles) @additional_finish_steps_before_chroot = [] @additional_finish_steps_after_chroot = [] @additional_finish_steps_before_umount = [] @workflows_requiring_registration = [] @workflows_to_sources = {} # reset internal variable to force the Prepare... function @system_proposals_prepared = false PrepareSystemProposals() # reset internal variable to force the Prepare... function @system_workflows_prepared = false PrepareSystemWorkflows() nil end |
#find_control_file(dir) ⇒ String?
Full name of the control file located directly in the given directory
The content of the file is not verified to be compliant with the structure of a control file, this method simply finds the (hopefully only) XML file in the directory.
502 503 504 505 506 507 508 509 510 |
# File 'library/control/src/modules/WorkflowManager.rb', line 502 def find_control_file(dir) # sadly no glob escaping - https://bugs.ruby-lang.org/issues/8258 # but as we generate directory, it should be ok files = Dir.glob("#{dir}/*.xml") log.error "More than one XML file in #{dir}: #{files.inspect}" if files.size > 1 files.first end |
#GenerateAdditionalControlFilePath(src_id, ident) ⇒ String
Creates path to a control file from parameters. For add-on products, the 'ident' parameter is empty.
352 353 354 355 356 357 |
# File 'library/control/src/modules/WorkflowManager.rb', line 352 def GenerateAdditionalControlFilePath(src_id, ident) # special handling for Add-Ons (they have no special ident) ident = "__AddOnProduct-ControlFile__" if ident == "" Builtins.sformat("%1/%2:%3.xml", GetWorkflowDirectory(), src_id, ident) end |
#GenerateWorkflowIdent(workflow_filename) ⇒ String
Returns file unique identification in format
1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1403 def GenerateWorkflowIdent(workflow_filename) file_md5sum = FileUtils.MD5sum(workflow_filename) if file_md5sum.nil? || file_md5sum == "" Builtins.y2error( "MD5 sum of file %1 is %2", workflow_filename, file_md5sum ) return nil end file_size = FileUtils.GetSize(workflow_filename) if Ops.less_than(file_size, 0) Builtins.y2error("File size %1 is %2", workflow_filename, file_size) return nil end Builtins.sformat("%1-%2", file_md5sum, file_size) end |
#GetAdditionalFinishSteps(which_steps) ⇒ Array<String>
Returns list of additional inst_finish steps requested by additional workflows.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'library/control/src/modules/WorkflowManager.rb', line 136 def GetAdditionalFinishSteps(which_steps) ret = case which_steps when "before_chroot" @additional_finish_steps_before_chroot when "after_chroot" @additional_finish_steps_after_chroot when "before_umount" @additional_finish_steps_before_umount else Builtins.y2error("Unknown FinishSteps type: %1", which_steps) nil end deep_copy(ret) end |
#GetAllUsedControlFiles ⇒ Array<String>
Returns list of control-file names currently used
1494 1495 1496 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1494 def GetAllUsedControlFiles deep_copy(@used_workflows) end |
#GetCachedWorkflowFilename(type, src_id, name = "") ⇒ String
Returns requested control filename. Parameter 'name' is ignored for Add-Ons.
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 520 def GetCachedWorkflowFilename(type, src_id, name = "") if ![:package, :addon].include?(type) Builtins.y2error("Unknown workflow type: %1", type) return nil end disk_filename = GenerateAdditionalControlFilePath(src_id, name) # A cached copy exists if FileUtils.Exists(disk_filename) Builtins.y2milestone("Using cached file %1", disk_filename) disk_filename # Trying to get the file from source else Builtins.y2milestone("File %1 not cached", disk_filename) case type when :addon # using a file from source, works only for SUSE tags repositories use_filename = Pkg.SourceProvideDigestedFile( src_id, 1, "/installation.xml", true ) # The most generic way it to use the package referenced by the "installerextension()" # provides, this works with all repository types, including the RPM-MD repositories. use_filename ||= control_file(src_id) when :package use_filename = control_file(name) end # File exists? use_filename.nil? ? nil : StoreWorkflowFile(use_filename, disk_filename) end ensure # release the media accessors (close server connections/unmount disks) Pkg.SourceReleaseAll end |
#GetWorkflowDirectory ⇒ Object
Returns the current (default) directory where workflows are stored in.
342 343 344 |
# File 'library/control/src/modules/WorkflowManager.rb', line 342 def GetWorkflowDirectory Builtins.sformat("%1/%2", Directory.tmpdir, @control_files_dir) end |
#HaveAdditionalWorkflows ⇒ Boolean
Returns whether some additional control files are currently in use.
1517 1518 1519 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1517 def HaveAdditionalWorkflows Ops.greater_or_equal(Builtins.size(GetAllUsedControlFiles()), 0) end |
#IncorporateControlFileOptions(filename) ⇒ Boolean
Read and remember the registration requirement status from an installation control XML file. The stored values can be read by the WorkflowsRequiringRegistration() method.
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1237 def IncorporateControlFileOptions(filename) return false if filename.nil? begin update_file = XML.XMLToYCPFile(filename) rescue RuntimeError => e log.error "Unable to read the #{filename} control file: #{e.inspect}" return false end # FATE #305578: Add-On Product Requiring Registration globals = Ops.get_map(update_file, "globals", {}) if Builtins.haskey(globals, "require_registration") && Ops.get_boolean(globals, "require_registration", false) == true Builtins.y2milestone("Registration is required by %1", filename) @workflows_requiring_registration = Builtins.toset( Builtins.add(@workflows_requiring_registration, filename) ) Builtins.y2milestone( "Workflows requiring registration: %1", @workflows_requiring_registration ) else Builtins.y2milestone("Registration is not required by %1", filename) end true end |
#IntegrateWorkflow(filename) ⇒ Boolean
Integrate the changes in the workflow
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1352 def IntegrateWorkflow(filename) Builtins.y2milestone("IntegrateWorkflow %1", filename) begin update_file = XML.XMLToYCPFile(filename) rescue RuntimeError => e log.error "Failed to parse #{update_file}: #{e.inspect}" return false end name = Ops.get_string(update_file, "display_name", "") if !UpdateInstallation( Ops.get_map(update_file, "update", {}), name, Ops.get_string(update_file, "textdomain", "control") ) Builtins.y2error("Failed to update installation workflow") return false end if !UpdateProductInfo(update_file, filename) Builtins.y2error("Failed to set product options") return false end if !AddNewProposals(Ops.get_list(update_file, "proposals", [])) Builtins.y2error("Failed to add new proposals") return false end if !Replaceworkflows(Ops.get_list(update_file, "workflows", [])) Builtins.y2error("Failed to replace workflows") return false end if !UpdateInstFinish( Ops.get_map(update_file, ["update", "inst_finish"], {}) ) Builtins.y2error("Adding inst_finish steps failed") return false end true end |
#main ⇒ Object
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 46 def main Yast.import "UI" Yast.import "Pkg" textdomain "base" Yast.import "ProductControl" Yast.import "ProductFeatures" Yast.import "Label" Yast.import "Wizard" Yast.import "Directory" Yast.import "FileUtils" Yast.import "Stage" Yast.import "String" Yast.import "XML" Yast.import "Report" Yast.import "Mode" # # This API uses some new terms that need to be explained: # # * Workflow Store # - Kind of database of installation or configuration workflows # # * Base Workflow # - The initial workflow defined by the base product # - In case of running system, this will be probably empty # # * Additional Workflow # - Any workflow defined by Add-On or Pattern in installation # or Pattern in running system # # * Final Workflow # - Workflow that contains the base workflow modified by all # additional workflows # # Base Workflow Store @wkf_initial_workflows = [] @wkf_initial_proposals = [] @wkf_initial_inst_finish = [] @wkf_initial_clone_modules = [] @wkf_initial_system_roles = [] @wkf_initial_product_features = {} # Additional inst_finish settings defined by additional control files. # They are always empty at the begining. @additional_finish_steps_before_chroot = [] @additional_finish_steps_after_chroot = [] @additional_finish_steps_before_umount = [] # FATE #305578: Add-On Product Requiring Registration # $[ "workflow filename" : (boolean) require_registration ] @workflows_requiring_registration = [] @workflows_to_sources = {} @base_workflow_stored = false # Contains all currently workflows added to the Workflow Store @used_workflows = [] # Some workflow changes need merging @unmerged_changes = false # Have system proposals already been prepared for merging? @system_proposals_prepared = false # Have system workflows already been prepared for merging? @system_workflows_prepared = false @control_files_dir = "additional-control-files" # Merge counter used for logging @merge_counter = 0 # base product that got its workflow merged # @see #merge_product_workflow self.merged_base_product = nil self.merged_modules_extensions = [] end |
#merge_modules_extensions(packages) ⇒ Object
Merge modules extensions
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1572 def merge_modules_extensions(packages) log.info "Merging #{packages} workflow" merged_modules_extensions.each do |pkg| Yast::WorkflowManager.RemoveWorkflow(:package, 0, pkg) end packages.each do |pkg| AddWorkflow(:package, 0, pkg) end MergeWorkflows() RedrawWizardSteps() self.merged_modules_extensions = packages end |
#merge_product_workflow(product) ⇒ Object
Merge product's workflow
1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1550 def merge_product_workflow(product) return false unless product.installation_package log.info "Merging #{product.label} workflow" if merged_base_product Yast::WorkflowManager.RemoveWorkflow( :package, merged_base_product.installation_package_repo, merged_base_product.installation_package ) end AddWorkflow(:package, product.installation_package_repo, product.installation_package) MergeWorkflows() RedrawWizardSteps() self.merged_base_product = product end |
#MergeProposal(base, additional_control, prod_name, domain) ⇒ Hash
Merge add-on proposal to a base proposal
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 736 def MergeProposal(base, additional_control, prod_name, domain) base = deep_copy(base) additional_control = deep_copy(additional_control) # Additional proposal settings - Replacing items replaces = Builtins.listmap( Ops.get_list(additional_control, "replace_modules", []) ) do |one_addon| old = Ops.get_string(one_addon, "replace", "") new = Ops.get_list(one_addon, "modules", []) { old => new } end if Ops.greater_than( Builtins.size(replaces), 0 ) Builtins.foreach(replaces) do |old, new| base = ReplaceProposalModule(base, old, new) end end # Additional proposal settings - Removing settings removes = Ops.get_list(additional_control, "remove_modules", []) Builtins.foreach(removes) { |r| base = ReplaceProposalModule(base, r, []) } if Ops.greater_than( Builtins.size(removes), 0 ) # Additional proposal settings - - Appending settings appends = Ops.get_list(additional_control, "append_modules", []) if Ops.greater_than(Builtins.size(appends), 0) append2 = deep_copy(appends) if Ops.is_map?(Ops.get(base, ["proposal_modules", 0])) append2 = Builtins.maplist(appends) do |m| { "name" => m, "presentation_order" => 9999 } end end Ops.set( base, "proposal_modules", Builtins.merge(Ops.get_list(base, "proposal_modules", []), append2) ) if Builtins.haskey(base, "proposal_tabs") new_tab = { "label" => prod_name, "proposal_modules" => appends, "textdomain" => domain } Ops.set( base, "proposal_tabs", Builtins.add(Ops.get_list(base, "proposal_tabs", []), new_tab) ) end end Ops.set(base, "enable_skip", "no") if Ops.get_string(additional_control, "enable_skip", "yes") == "no" deep_copy(base) end |
#MergeWorkflow(base, addon, _prod_name, domain) ⇒ Hash
Merge add-on workflow to a base workflow
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 889 def MergeWorkflow(base, addon, _prod_name, domain) base = deep_copy(base) addon = deep_copy(addon) log.info "merging workflow #{addon.inspect} to #{base.inspect}" # Merging - removing steps, settings removes = Ops.get_list(addon, "remove_modules", []) if Ops.greater_than(Builtins.size(removes), 0) Builtins.y2milestone("Remove: %1", removes) Builtins.foreach(removes) do |r| base = ReplaceWorkflowModule(base, r, [], domain, false) end end # Merging - replacing steps, settings replaces = Builtins.listmap(Ops.get_list(addon, "replace_modules", [])) do |a| old = Ops.get_string(a, "replace", "") new = Ops.get_list(a, "modules", []) { old => new } end if Ops.greater_than(Builtins.size(replaces), 0) Builtins.y2milestone("Replace: %1", replaces) Builtins.foreach(replaces) do |old, new| base = ReplaceWorkflowModule(base, old, new, domain, false) end end # Merging - inserting steps, settings inserts = Builtins.listmap(Ops.get_list(addon, "insert_modules", [])) do |i| before = Ops.get_string(i, "before", "") new = Ops.get_list(i, "modules", []) { before => new } end if Ops.greater_than(Builtins.size(inserts), 0) Builtins.y2milestone("Insert: %1", inserts) Builtins.foreach(inserts) do |old, new| base = ReplaceWorkflowModule(base, old, new, domain, true) end end # Merging - appending steps, settings appends = Ops.get_list(addon, "append_modules", []) if Ops.greater_than(Builtins.size(appends), 0) Builtins.y2milestone("Append: %1", appends) Builtins.foreach(appends) do |new| Ops.set(new, "textdomain", domain) Ops.set( base, "modules", Builtins.add(Ops.get_list(base, "modules", []), new) ) end end log.info "result of merge #{base.inspect}" deep_copy(base) end |
#MergeWorkflows ⇒ Boolean
Function uses the Base Workflow as the initial one and merges all added workflow into that workflow.
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1429 def MergeWorkflows Builtins.y2milestone("Merging additional control files from scratch...") @unmerged_changes = false # Init the Base Workflow settings FillUpInitialWorkflowSettings() ret = true already_merged_workflows = [] @merge_counter += 1 add_on_counter = 1 Builtins.foreach(@used_workflows) do |one_workflow| # make sure that every workflow is merged only once # bugzilla #332436 workflow_ident = GenerateWorkflowIdent(one_workflow) if !workflow_ident.nil? && Builtins.contains(already_merged_workflows, workflow_ident) Builtins.y2milestone( "The very same workflow has been already merged, skipping..." ) next elsif !workflow_ident.nil? already_merged_workflows = Builtins.add( already_merged_workflows, workflow_ident ) else Builtins.y2error("Workflow ident is: %1", workflow_ident) end # log the installation.xml being merged control_log_dir_rotator = Yast2::ControlLogDirRotator.new control_log_dir_rotator.copy(one_workflow, "/#{format("%02d", @merge_counter)}-#{format("%02d", add_on_counter)}-installation.xml") add_on_counter += 1 IncorporateControlFileOptions(one_workflow) if !IntegrateWorkflow(one_workflow) Builtins.y2error("Merging '%1' failed!", one_workflow) Report.Error( _( "An internal error occurred when integrating additional workflow." ) ) ret = false end end ret end |
#PrepareProposals(proposals) ⇒ Array<Hash>
Check all proposals, split those ones which have multiple modes or architectures or stages into multiple proposals.
Structure:
Input: [
$["label":"Example", "name":"example","proposal_modules":["one","two"],"stage":"initial,firstboot"]
]
Output: [
$["label":"Example", "name":"example","proposal_modules":["one","two"],"stage":"initial"]
$["label":"Example", "name":"example","proposal_modules":["one","two"],"stage":"firstboot"]
]
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 196 def PrepareProposals(proposals) proposals = deep_copy(proposals) new_proposals = [] # Going through all proposals Builtins.foreach(proposals) do |one_proposal| mode = Ops.get_string(one_proposal, "mode", "") modes = Builtins.splitstring(mode, ",") modes = [""] if Builtins.size(modes) == 0 # Going through all modes in proposal Builtins.foreach(modes) do |one_mode| mp = deep_copy(one_proposal) Ops.set(mp, "mode", one_mode) arch = Ops.get_string(one_proposal, "archs", "") archs = Builtins.splitstring(arch, ",") archs = [""] if Builtins.size(archs) == 0 # Going through all architectures Builtins.foreach(archs) do |one_arch| amp = deep_copy(mp) Ops.set(amp, "archs", one_arch) stage = Ops.get_string(amp, "stage", "") stages = Builtins.splitstring(stage, ",") stages = [""] if Builtins.size(stages) == 0 # Going through all stages Builtins.foreach(stages) do |one_stage| single_proposal = deep_copy(amp) Ops.set(single_proposal, "stage", one_stage) new_proposals = Builtins.add(new_proposals, single_proposal) end end end end deep_copy(new_proposals) end |
#PrepareSystemProposals ⇒ Object
Check all proposals, split those ones which have multiple modes or architectures or stages into multiple proposals. Works with base product proposals.
235 236 237 238 239 240 241 242 |
# File 'library/control/src/modules/WorkflowManager.rb', line 235 def PrepareSystemProposals return if @system_proposals_prepared ProductControl.proposals = PrepareProposals(ProductControl.proposals) @system_proposals_prepared = true nil end |
#PrepareSystemWorkflows ⇒ Object
Check all workflows, split those ones which have multiple modes or architectures or stages into multiple worlflows. Works with base product workflows.
288 289 290 291 292 293 294 295 |
# File 'library/control/src/modules/WorkflowManager.rb', line 288 def PrepareSystemWorkflows return if @system_workflows_prepared ProductControl.workflows = PrepareWorkflows(ProductControl.workflows) @system_workflows_prepared = true nil end |
#PrepareWorkflows(workflows) ⇒ Array<Hash>
Check all workflows, split those ones which have multiple modes or architectures or stages into multiple workflows
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 'library/control/src/modules/WorkflowManager.rb', line 248 def PrepareWorkflows(workflows) workflows = deep_copy(workflows) new_workflows = [] # Going through all workflows Builtins.foreach(workflows) do |one_workflow| mode = Ops.get_string(one_workflow, "mode", "") modes = Builtins.splitstring(mode, ",") modes = [""] if Builtins.size(modes) == 0 # Going through all modes Builtins.foreach(modes) do |one_mode| mw = deep_copy(one_workflow) Ops.set(mw, "mode", one_mode) Ops.set(mw, "defaults", Ops.get_map(mw, "defaults", {})) arch = Ops.get_string(mw, ["defaults", "archs"], "") archs = Builtins.splitstring(arch, ",") archs = [""] if Builtins.size(archs) == 0 # Going through all architercures Builtins.foreach(archs) do |one_arch| amw = deep_copy(mw) Ops.set(amw, ["defaults", "archs"], one_arch) stage = Ops.get_string(amw, "stage", "") stages = Builtins.splitstring(stage, ",") stages = [""] if Builtins.size(stages) == 0 # Going through all stages Builtins.foreach(stages) do |one_stage| single_workflow = deep_copy(amw) Ops.set(single_workflow, "stage", one_stage) new_workflows = Builtins.add(new_workflows, single_workflow) end end end end deep_copy(new_workflows) end |
#RedrawWizardSteps ⇒ Object
Redraws workflow steps. Function must be called when steps (or help for steps) are active. It doesn't work in case of active another dialog.
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1334 def RedrawWizardSteps Builtins.y2milestone("Retranslating messages, redrawing wizard steps") # Make sure the labels for default function keys are retranslated, too. # Using Label::DefaultFunctionKeyMap() from Label module. UI.SetFunctionKeys(Label.DefaultFunctionKeyMap) # Activate language changes on static part of wizard dialog ProductControl.RetranslateWizardSteps Wizard.RetranslateButtons Wizard.SetFocusToNextButton true end |
#RemoveWorkflow(type, src_id, name) ⇒ Boolean
Removes workflow (if such workflow exists) from the Worflow Store. Alose removes the cached file but in the installation.
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 608 def RemoveWorkflow(type, src_id, name) Builtins.y2milestone( "Removing Workflow: Type %1, ID %2, Name %3", type, src_id, name ) if !Builtins.contains([:addon, :package], type) Builtins.y2error("Unknown workflow type: %1", type) return false end name = "" if type == :addon # cached xml file used_filename = GenerateAdditionalControlFilePath(src_id, name) if !used_filename.nil? && used_filename != "" @unmerged_changes = true @used_workflows = Builtins.filter(@used_workflows) do |one_workflow| one_workflow != used_filename end if Builtins.haskey(@workflows_to_sources, used_filename) @workflows_to_sources = Builtins.remove( @workflows_to_sources, used_filename ) end if !Stage.initial && FileUtils.Exists(used_filename) Builtins.y2milestone( "Removing cached file '%1': %2", used_filename, SCR.Execute(path(".target.remove"), used_filename) ) end end true end |
#ReplaceProposalModule(proposal, old, new) ⇒ Object
Replace a module in a proposal with a set of other modules
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 685 def ReplaceProposalModule(proposal, old, new) proposal = deep_copy(proposal) new = deep_copy(new) found = false modules = Builtins.maplist(Ops.get_list(proposal, "proposal_modules", [])) do |m| if (Ops.is_string?(m) && Convert.to_string(m) == old) || (Ops.is_map?(m) && Ops.get_string(Convert.to_map(m), "name", "") == old) found = true next deep_copy(new) unless Ops.is_map?(m) Builtins.maplist(new) do |it| Builtins.union(Convert.to_map(m), "name" => it) end else [m] end end Builtins.y2internal("Replace/Remove proposal item %1 not found", old) if !found Ops.set(proposal, "proposal_modules", Builtins.flatten(modules)) if Builtins.haskey(proposal, "proposal_tabs") Ops.set( proposal, "proposal_tabs", Builtins.maplist(Ops.get_list(proposal, "proposal_tabs", [])) do |tab| modules2 = Builtins.maplist( Ops.get_list(tab, "proposal_modules", []) ) do |m| (m == old) ? deep_copy(new) : [m] end Ops.set(tab, "proposal_modules", Builtins.flatten(modules2)) deep_copy(tab) end ) end deep_copy(proposal) end |
#ReplaceWorkflowModule(workflow, old, new, domain, keep) ⇒ Object
Replace a module in a workflow with a set of other modules
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
# File 'library/control/src/modules/WorkflowManager.rb', line 858 def ReplaceWorkflowModule(workflow, old, new, domain, keep) workflow = deep_copy(workflow) new = deep_copy(new) found = false modules = Builtins.maplist(Ops.get_list(workflow, "modules", [])) do |m| next [m] if Ops.get_string(m, "name", "") != old new_list = Builtins.maplist(new) do |n| Ops.set(n, "textdomain", domain) deep_copy(n) end found = true new_list = Builtins.add(new_list, m) if keep deep_copy(new_list) end log.warn("Insert/Replace/Remove workflow module '#{old}' not found") if !found Ops.set(workflow, "modules", Builtins.flatten(modules)) deep_copy(workflow) end |
#Replaceworkflows(workflows) ⇒ Boolean
Replace workflows for 2nd stage of installation
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1133 def Replaceworkflows(workflows) workflows = deep_copy(workflows) workflows = PrepareWorkflows(workflows) # This function doesn't update the current workflow but replaces it. # That's why it is not allowed for the first stage of the installation. workflows = Builtins.filter(workflows) do |workflow| if Ops.get_string(workflow, "stage", "") == "initial" Builtins.y2error( "Attempting to replace 1st stage workflow. This is not possible" ) Builtins.y2milestone("Workflow: %1", workflow) next false end true end sm = {} Builtins.foreach(workflows) do |workflow| Ops.set( sm, Ops.get_string(workflow, "stage", ""), Ops.get(sm, Ops.get_string(workflow, "stage", ""), {}) ) Ops.set( sm, [ Ops.get_string(workflow, "stage", ""), Ops.get_string(workflow, "mode", "") ], true ) [ Ops.get_string(workflow, "stage", ""), Ops.get_string(workflow, "mode", "") ] end Builtins.y2milestone("Existing replace workflows: %1", sm) Builtins.y2milestone( "Workflows before filtering: %1", Builtins.size(ProductControl.workflows) ) ProductControl.workflows = Builtins.filter(ProductControl.workflows) do |w| !Ops.get( sm, [Ops.get_string(w, "stage", ""), Ops.get_string(w, "mode", "")], false ) end Builtins.y2milestone( "Workflows after filtering: %1", Builtins.size(ProductControl.workflows) ) ProductControl.workflows = Convert.convert( Builtins.merge(ProductControl.workflows, workflows), from: "list", to: "list <map>" ) true end |
#ResetWorkflow ⇒ Object
Resets the Workflow (and proposals) to use the base workflow. It must be stored. Clears also all additional workflows.
334 335 336 337 338 339 |
# File 'library/control/src/modules/WorkflowManager.rb', line 334 def ResetWorkflow FillUpInitialWorkflowSettings() @used_workflows = [] nil end |
#SetAllUsedControlFiles(new_list) ⇒ Object
Sets list of control-file names to be used. ATTENTION: this is dangerous and should be used in rare cases only!
1505 1506 1507 1508 1509 1510 1511 1512 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1505 def SetAllUsedControlFiles(new_list) new_list = deep_copy(new_list) Builtins.y2milestone("New list of additional workflows: %1", new_list) @unmerged_changes = true @used_workflows = deep_copy(new_list) nil end |
#SetBaseWorkflow(force) ⇒ Object
Stores the current ProductControl settings as the initial settings. These settings are: workflows, proposals, inst_finish, and clone_modules.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'library/control/src/modules/WorkflowManager.rb', line 156 def SetBaseWorkflow(force) if @base_workflow_stored && !force Builtins.y2milestone("Base Workflow has been already set") return end @wkf_initial_product_features = ProductFeatures.Export @wkf_initial_workflows = deep_copy(ProductControl.workflows) @wkf_initial_proposals = deep_copy(ProductControl.proposals) @wkf_initial_inst_finish = deep_copy(ProductControl.inst_finish) @wkf_initial_clone_modules = deep_copy(ProductControl.clone_modules) @wkf_initial_system_roles = deep_copy(ProductControl.system_roles) @additional_finish_steps_before_chroot = [] @additional_finish_steps_after_chroot = [] @additional_finish_steps_before_umount = [] @base_workflow_stored = true nil end |
#SomeWorkflowsWereChanged ⇒ Object
Returns whether some additional control files were added or removed from the last time MergeWorkflows() was called.
1487 1488 1489 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1487 def SomeWorkflowsWereChanged @unmerged_changes end |
#StoreWorkflowFile(file_from, file_to) ⇒ String
Stores the workflow file to a cache
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 364 def StoreWorkflowFile(file_from, file_to) if file_from.nil? || file_from == "" || file_to.nil? || file_to == "" Builtins.y2error("Cannot copy '%1' to '%2'", file_from, file_to) return nil end # Return nil if cannot copy file_location = nil Builtins.y2milestone( "Copying workflow from '%1' to '%2'", file_from, file_to ) cmd = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "\n" \ "/bin/mkdir -p '%1';\n" \ "/bin/cp -v '%2' '%3';\n", String.Quote(GetWorkflowDirectory()), String.Quote(file_from), String.Quote(file_to) ) ) ) # successfully copied if Ops.get_integer(cmd, "exit", -1) == 0 file_location = file_to else Builtins.y2error("Error occurred while copying control file: %1", cmd) # Not in installation, try to skip the error if !Stage.initial && FileUtils.Exists(file_from) Builtins.y2milestone("Using fallback file %1", file_from) file_location = file_from end end file_location end |
#update_system_roles(system_roles) ⇒ Object
Update sytem roles according to the update section of the control file
The hash is expectd to have the following structure:
"insert_system_roles" => [ { "system_roles" => [ { "id" => "additional_role1" }, { "id" => "additional_role2" } ] } ]
1032 1033 1034 1035 1036 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1032 def update_system_roles(system_roles) system_roles.fetch("insert_system_roles", []).each do |insert| ProductControl.add_system_roles(insert["system_roles"]) end end |
#UpdateInstallation(update_file, name, domain) ⇒ Boolean
Adapts the current workflow according to specified XML file content
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1077 def UpdateInstallation(update_file, name, domain) log.info "Updating installation workflow: #{update_file.inspect}" update_file = deep_copy(update_file) PrepareSystemProposals() PrepareSystemWorkflows() proposals = Ops.get_list(update_file, "proposals", []) proposals = PrepareProposals(proposals) UpdateProposals(proposals, name, domain) workflows = Ops.get_list(update_file, "workflows", []) workflows = PrepareWorkflows(workflows) UpdateWorkflows(workflows, name, domain) update_system_roles(update_file.fetch("system_roles", {})) true end |
#UpdateInstFinish(additional_steps) ⇒ Boolean
Add specified steps to inst_finish. Just modifies internal variables, inst_finish grabs them itself
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1043 def UpdateInstFinish(additional_steps) additional_steps = deep_copy(additional_steps) before_chroot = Ops.get(additional_steps, "before_chroot", []) after_chroot = Ops.get(additional_steps, "after_chroot", []) before_umount = Ops.get(additional_steps, "before_umount", []) @additional_finish_steps_before_chroot = Convert.convert( Builtins.merge(@additional_finish_steps_before_chroot, before_chroot), from: "list", to: "list <string>" ) @additional_finish_steps_after_chroot = Convert.convert( Builtins.merge(@additional_finish_steps_after_chroot, after_chroot), from: "list", to: "list <string>" ) @additional_finish_steps_before_umount = Convert.convert( Builtins.merge(@additional_finish_steps_before_umount, before_umount), from: "list", to: "list <string>" ) true end |
#UpdateProductInfo(update_file, _filename) ⇒ Boolean
Update product options such as global settings, software, partitioning or network.
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1273 def UpdateProductInfo(update_file, _filename) update_file = deep_copy(update_file) # merging all 'map <string, any>' type Builtins.foreach(["globals", "software", "partitioning", "network"]) do |section| sect = ProductFeatures.GetSection(section) addon = Ops.get_map(update_file, section, {}) sect = Convert.convert( Builtins.union(sect, addon), from: "map", to: "map <string, any>" ) ProductFeatures.SetSection(section, sect) end # merging 'clone_modules' addon_clone = Ops.get_list(update_file, "clone_modules", []) ProductControl.clone_modules = Convert.convert( Builtins.merge(ProductControl.clone_modules, addon_clone), from: "list", to: "list <string>" ) # merging texts # # **Structure:** # # $[ # "congratulate" : $[ # "label" : "some text", # ], # "congratulate2" : $[ # "label" : "some other text", # "textdomain" : "control-2", // (optionally) # ], # ]; controlfile_texts = ProductFeatures.GetSection("texts") update_file_texts = Ops.get_map(update_file, "texts", {}) update_file_textdomain = Ops.get_string(update_file, "textdomain", "") # if textdomain is different to the base one # we have to put it into the map if !update_file_textdomain.nil? && update_file_textdomain != "" update_file_texts = Builtins.mapmap(update_file_texts) do |text_ident, text_def| Ops.set(text_def, "textdomain", update_file_textdomain) { text_ident => text_def } end end controlfile_texts = Convert.convert( Builtins.union(controlfile_texts, update_file_texts), from: "map", to: "map <string, any>" ) ProductFeatures.SetSection("texts", controlfile_texts) true end |
#UpdateProposals(proposals, prod_name, domain) ⇒ Boolean
Update system proposals according to proposal update metadata
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 |
# File 'library/control/src/modules/WorkflowManager.rb', line 808 def UpdateProposals(proposals, prod_name, domain) proposals = deep_copy(proposals) Builtins.foreach(proposals) do |proposal| name = Ops.get_string(proposal, "name", "") stage = Ops.get_string(proposal, "stage", "") mode = Ops.get_string(proposal, "mode", "") arch = Ops.get_string(proposal, "archs", "") found = false new_proposals = [] arch_all_prop = {} Builtins.foreach(ProductControl.proposals) do |p| if Ops.get_string(p, "stage", "") != stage || Ops.get_string(p, "mode", "") != mode || Ops.get_string(p, "name", "") != name new_proposals = Builtins.add(new_proposals, p) next end if [Ops.get_string(p, "archs", ""), "", "all"].include?(arch) p = MergeProposal(p, proposal, prod_name, domain) found = true elsif ["", "all"].include?(Ops.get_string(p, "archs", "")) arch_all_prop = deep_copy(p) end new_proposals = Builtins.add(new_proposals, p) end if !found if arch_all_prop == {} Ops.set(proposal, "textdomain", domain) else Ops.set(arch_all_prop, "archs", arch) proposal = MergeProposal(arch_all_prop, proposal, prod_name, domain) # completly new proposal end new_proposals = Builtins.add(new_proposals, proposal) end ProductControl.proposals = deep_copy(new_proposals) end true end |
#UpdateWorkflows(workflows, prod_name, domain) ⇒ Boolean
Update system workflows according to workflow update metadata
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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 |
# File 'library/control/src/modules/WorkflowManager.rb', line 958 def UpdateWorkflows(workflows, prod_name, domain) workflows = deep_copy(workflows) Builtins.foreach(workflows) do |workflow| stage = Ops.get_string(workflow, "stage", "") mode = Ops.get_string(workflow, "mode", "") arch = Ops.get_string(workflow, "archs", "") found = false new_workflows = [] arch_all_wf = {} log.info "workflow to update #{workflow.inspect}" Builtins.foreach(ProductControl.workflows) do |w| if Ops.get_string(w, "stage", "") != stage || Ops.get_string(w, "mode", "") != mode new_workflows = Builtins.add(new_workflows, w) next end if [Ops.get_string(w, ["defaults", "archs"], ""), "", "all"].include?(arch) w = MergeWorkflow(w, workflow, prod_name, domain) found = true elsif ["", "all"].include?(Ops.get_string(w, ["defaults", "archs"], "")) arch_all_wf = deep_copy(w) end new_workflows = Builtins.add(new_workflows, w) end if !found if arch_all_wf == {} # If modules has not been defined we are trying to use the appended modules workflow["modules"] = workflow["append_modules"] unless workflow["modules"] Ops.set(workflow, "textdomain", domain) Ops.set( workflow, "modules", Builtins.maplist(Ops.get_list(workflow, "modules", [])) do |mod| Ops.set(mod, "textdomain", domain) deep_copy(mod) end ) else Ops.set(arch_all_wf, ["defaults", "archs"], arch) workflow = MergeWorkflow(arch_all_wf, workflow, prod_name, domain) # completly new workflow end new_workflows = Builtins.add(new_workflows, workflow) end log.info "new workflow after update #{new_workflows}" ProductControl.workflows = deep_copy(new_workflows) end true end |
#WorkflowRequiresRegistration(src_id) ⇒ Boolean
Returns whether a repository workflow requires registration
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1210 def WorkflowRequiresRegistration(src_id) ret = false Builtins.y2milestone("Known workflows: %1", @workflows_to_sources) Builtins.y2milestone( "Workflows requiring registration: %1", @workflows_requiring_registration ) Builtins.foreach(@workflows_to_sources) do |one_workflow, id| # sources match and workflow is listed as 'requiring registration' if src_id == id && Builtins.contains(@workflows_requiring_registration, one_workflow) ret = true raise Break end end Builtins.y2milestone("WorkflowRequiresRegistration(%1): %2", src_id, ret) ret end |
#WorkflowsRequiringRegistration ⇒ Object
Returns list of workflows requiring registration
1202 1203 1204 |
# File 'library/control/src/modules/WorkflowManager.rb', line 1202 def WorkflowsRequiringRegistration deep_copy(@workflows_requiring_registration) end |