Skip to content

Commit

Permalink
Merge 1c633db into e9cf5bb
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Mar 24, 2017
2 parents e9cf5bb + 1c633db commit fda60ee
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 169 deletions.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Mar 24 13:53:40 UTC 2017 - mvidner@suse.com

- Do not ignore solver problems after touching the partitioning
(bsc#1029306)
- 3.1.121.3

-------------------------------------------------------------------
Mon Mar 20 12:33:35 UTC 2017 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 3.1.121.2
Version: 3.1.121.3
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Expand Up @@ -72,7 +72,8 @@ desktop_DATA = \

ylibclientdir = "${yast2dir}/lib/packager/clients"
ylibclient_DATA = \
lib/packager/clients/pkg_finish.rb
lib/packager/clients/pkg_finish.rb \
lib/packager/clients/software_proposal.rb

ylibcfadir = "${yast2dir}/lib/packager/cfa"
ylibcfa_DATA = \
Expand Down
159 changes: 2 additions & 157 deletions src/clients/software_proposal.rb
@@ -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
169 changes: 169 additions & 0 deletions src/lib/packager/clients/software_proposal.rb
@@ -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
3 changes: 2 additions & 1 deletion test/Makefile.am
Expand Up @@ -9,7 +9,8 @@ TESTS = \
product_patterns_test.rb \
source_dialogs_test.rb \
space_calculation_test.rb \
lib/cfa/zypp_conf_test.rb
lib/cfa/zypp_conf_test.rb \
lib/clients/software_proposal_test.rb

TEST_EXTENSIONS = .rb
RB_LOG_COMPILER = rspec
Expand Down

0 comments on commit fda60ee

Please sign in to comment.