Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
250 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,2 @@ | ||
# encoding: utf-8 | ||
|
||
# Module: software_proposal.ycp | ||
# | ||
# Author: Klaus Kaempf <kkaempf@suse.de> | ||
# | ||
# Purpose: Proposal function dispatcher - software. | ||
# | ||
# See also file proposal-API.txt for details. | ||
# | ||
# $Id$ | ||
# | ||
module Yast | ||
class SoftwareProposalClient < Client | ||
def main | ||
Yast.import "Pkg" | ||
textdomain "packager" | ||
|
||
Yast.import "Packages" | ||
Yast.import "Language" | ||
Yast.import "Installation" | ||
|
||
@func = Convert.to_string(WFM.Args(0)) | ||
@param = Convert.to_map(WFM.Args(1)) | ||
@ret = {} | ||
|
||
if @func == "MakeProposal" | ||
@force_reset = Ops.get_boolean(@param, "force_reset", false) | ||
@language_changed = Ops.get_boolean(@param, "language_changed", false) | ||
|
||
@reinit = false | ||
@partition_changed = false | ||
|
||
if Installation.dirinstall_installing_into_dir | ||
# check the target directory in dirinstall mode | ||
if Packages.timestamp != Installation.dirinstall_target_time | ||
@partition_changed = true | ||
end | ||
# save information about target change time in module Packages | ||
Packages.timestamp = Installation.dirinstall_target_time | ||
else | ||
@storage_timestamp = Convert.to_integer( | ||
WFM.call("wrapper_storage", ["GetTargetChangeTime"]) | ||
) | ||
|
||
# check the partitioning in installation | ||
if Packages.timestamp != @storage_timestamp | ||
# don't set flag partition_changed if it's the first "change" | ||
@partition_changed = true if Packages.timestamp != 0 | ||
end | ||
# save information about target change time in module Packages | ||
Packages.timestamp = @storage_timestamp | ||
end | ||
|
||
if Pkg.GetPackageLocale != Language.language | ||
@language_changed = true | ||
Pkg.SetPackageLocale(Language.language) | ||
end | ||
if !Builtins.contains(Pkg.GetAdditionalLocales, Language.language) | ||
# FIXME this is temporary fix | ||
# language_changed = true; | ||
Pkg.SetAdditionalLocales( | ||
Builtins.add(Pkg.GetAdditionalLocales, Language.language) | ||
) | ||
end | ||
|
||
# if only partitioning has been changed just return the current state, | ||
# don't reset to default (bnc#450786, bnc#371875) | ||
if @partition_changed && !@language_changed && !@force_reset && !Packages.PackagesProposalChanged | ||
return Packages.Summary([ :product, :pattern, :selection, :size, :desktop ], false); | ||
end | ||
|
||
@reinit = true if @language_changed | ||
Builtins.y2milestone( | ||
"package proposal: force reset: %1, reinit: %2, language changed: %3", | ||
@force_reset, | ||
@reinit, | ||
@language_changed | ||
) | ||
@ret = Packages.Proposal( | ||
@force_reset, # user decision: reset to default | ||
@reinit, # reinitialize due to language or partition change | ||
false | ||
) # simple version | ||
|
||
if @language_changed && !@force_reset | ||
# if the language has changed the software proposal is reset to the default settings | ||
if !Builtins.haskey(@ret, "warning") | ||
# the language_changed flag has NOT been set by the NLD frame | ||
@ret = Builtins.add( | ||
@ret, | ||
"warning", | ||
_("The software proposal is reset to the default values.") | ||
) | ||
end | ||
end | ||
if Ops.greater_than(Packages.solve_errors, 0) | ||
# the proposal for the packages requires manual intervention | ||
@ret = Builtins.union( | ||
@ret, | ||
{ | ||
# warning text | ||
"warning" => _( | ||
"Cannot solve dependencies automatically. Manual intervention is required." | ||
), | ||
"warning_level" => :blocker | ||
} | ||
) | ||
end | ||
elsif @func == "AskUser" | ||
@has_next = Ops.get_boolean(@param, "has_next", false) | ||
|
||
# call some function that displays a user dialog | ||
# or a sequence of dialogs here: | ||
# | ||
# sequence = DummyMod::AskUser( has_next ); | ||
|
||
@chosen_id = Ops.get(@param, "chosen_id") | ||
if @chosen_id == "mediacheck" | ||
@result = Convert.to_symbol(WFM.CallFunction("checkmedia", WFM.Args)) | ||
@ret = { "workflow_sequence" => @result } | ||
else | ||
@result = :again | ||
@client_to_call = "inst_sw_select" | ||
|
||
while @result == :again | ||
@result = Convert.to_symbol( | ||
WFM.CallFunction(@client_to_call, [true, true]) | ||
) | ||
end | ||
|
||
# Fill return map | ||
|
||
@ret = { "workflow_sequence" => @result } | ||
end | ||
elsif @func == "Description" | ||
# disable proposal if doing image-only installation | ||
return nil if Installation.image_only | ||
# Fill return map. | ||
# | ||
# Static values do just nicely here, no need to call a function. | ||
|
||
@ret = { | ||
# this is a heading | ||
"rich_text_title" => _("Software"), | ||
# this is a menu entry | ||
"menu_title" => _("&Software"), | ||
"id" => "software_stuff" | ||
} | ||
end | ||
|
||
deep_copy(@ret) | ||
end | ||
end | ||
end | ||
|
||
Yast::SoftwareProposalClient.new.main | ||
require "packager/clients/software_proposal" | ||
Yast::SoftwareProposalClient.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
# encoding: utf-8 | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2017 SUSE LLC | ||
# | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as published by the | ||
# Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# this program; if not, contact SUSE. | ||
# | ||
# To contact SUSE about this file by physical or electronic mail, you may find | ||
# current contact information at www.suse.com. | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "installation/proposal_client" | ||
|
||
module Yast | ||
class SoftwareProposalClient < ::Installation::ProposalClient | ||
def initialize | ||
Yast.import "Pkg" | ||
textdomain "packager" | ||
|
||
Yast.import "Packages" | ||
Yast.import "Language" | ||
Yast.import "Installation" | ||
end | ||
|
||
def make_proposal(flags) | ||
@force_reset = flags.fetch("force_reset", false) | ||
|
||
@language_changed = adjust_locales | ||
@language_changed ||= flags.fetch("language_changed", false) | ||
|
||
# if only partitioning has been changed just return the current state, | ||
# don't reset to default (bnc#450786, bnc#371875) | ||
if partitioning_changed? && !@language_changed && !@force_reset && !Packages.PackagesProposalChanged | ||
@ret = Packages.Summary([ :product, :pattern, :selection, :size, :desktop ], false); | ||
else | ||
@reinit = @language_changed | ||
Builtins.y2milestone( | ||
"package proposal: force reset: %1, reinit: %2, language changed: %3", | ||
@force_reset, | ||
@reinit, | ||
@language_changed | ||
) | ||
@ret = Packages.Proposal( | ||
@force_reset, # user decision: reset to default | ||
@reinit, # reinitialize due to language or partition change | ||
false | ||
) # simple version | ||
end | ||
|
||
if @language_changed && !@force_reset | ||
# if the language has changed the software proposal is reset to the default settings | ||
if !Builtins.haskey(@ret, "warning") | ||
# the language_changed flag has NOT been set by the NLD frame | ||
@ret = Builtins.add( | ||
@ret, | ||
"warning", | ||
_("The software proposal is reset to the default values.") | ||
) | ||
end | ||
end | ||
if Ops.greater_than(Packages.solve_errors, 0) | ||
# the proposal for the packages requires manual intervention | ||
@ret = Builtins.union( | ||
@ret, | ||
{ | ||
# warning text | ||
"warning" => _( | ||
"Cannot solve dependencies automatically. Manual intervention is required." | ||
), | ||
"warning_level" => :blocker | ||
} | ||
) | ||
end | ||
@ret | ||
end | ||
|
||
def ask_user(params) | ||
chosen_id = params["chosen_id"] | ||
if chosen_id == "mediacheck" | ||
@result = Convert.to_symbol(WFM.CallFunction("checkmedia", WFM.Args)) | ||
@ret = { "workflow_sequence" => @result } | ||
else | ||
@result = :again | ||
@client_to_call = "inst_sw_select" | ||
|
||
while @result == :again | ||
@result = Convert.to_symbol( | ||
WFM.CallFunction(@client_to_call, [true, true]) | ||
) | ||
end | ||
|
||
# Fill return map | ||
|
||
@ret = { "workflow_sequence" => @result } | ||
end | ||
@ret | ||
end | ||
|
||
def description | ||
# disable proposal if doing image-only installation | ||
return nil if Installation.image_only | ||
|
||
{ | ||
# this is a heading | ||
"rich_text_title" => _("Software"), | ||
# this is a menu entry | ||
"menu_title" => _("&Software"), | ||
"id" => "software_stuff" | ||
} | ||
end | ||
|
||
private | ||
|
||
def partitioning_changed? | ||
changed = false | ||
|
||
if Installation.dirinstall_installing_into_dir | ||
# check the target directory in dirinstall mode | ||
if Packages.timestamp != Installation.dirinstall_target_time | ||
changed = true | ||
end | ||
# save information about target change time in module Packages | ||
Packages.timestamp = Installation.dirinstall_target_time | ||
else | ||
storage_timestamp = Convert.to_integer( | ||
WFM.call("wrapper_storage", ["GetTargetChangeTime"]) | ||
) | ||
|
||
# check the partitioning in installation | ||
if Packages.timestamp != storage_timestamp | ||
# don't set changed if it's the first "change" | ||
changed = true if Packages.timestamp != 0 | ||
end | ||
# save information about target change time in module Packages | ||
Packages.timestamp = storage_timestamp | ||
end | ||
|
||
changed | ||
end | ||
|
||
# Adjust package locales | ||
# @return [Boolean] has the language changed | ||
def adjust_locales | ||
language_changed = false | ||
if Pkg.GetPackageLocale != Language.language | ||
language_changed = true | ||
Pkg.SetPackageLocale(Language.language) | ||
end | ||
if !Builtins.contains(Pkg.GetAdditionalLocales, Language.language) | ||
# FIXME this is temporary fix | ||
# language_changed = true; | ||
Pkg.SetAdditionalLocales( | ||
Builtins.add(Pkg.GetAdditionalLocales, Language.language) | ||
) | ||
end | ||
language_changed | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.