Hello community, here is the log from the commit of package yast2-country for openSUSE:Factory checked in at 2019-03-21 09:51:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-country (Old) and /work/SRC/openSUSE:Factory/.yast2-country.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-country" Thu Mar 21 09:51:48 2019 rev:201 rq:686377 version:4.1.11 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-country/yast2-country.changes 2019-02-28 21:48:46.765387351 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-country.new.28833/yast2-country.changes 2019-03-21 09:51:50.906812414 +0100 @@ -1,0 +2,15 @@ +Tue Mar 19 07:06:45 UTC 2019 - Dominique Leuenberger <[email protected]> + +- Fix command line parameter to systemd-firstboot (--root instead + of -root) (part of bsc#1121256). +- 4.1.11 + +------------------------------------------------------------------- +Fri Mar 15 12:42:06 UTC 2019 - David Díaz <[email protected]> + +- Add support to set the language as read-only in the control file, + which allows to change it during the installation without + persisting it in the installed system (bsc#1121256). +- 4.1.10 + +------------------------------------------------------------------- Old: ---- yast2-country-4.1.9.tar.bz2 New: ---- yast2-country-4.1.11.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-country.spec ++++++ --- /var/tmp/diff_new_pack.aMIn9P/_old 2019-03-21 09:51:51.382812285 +0100 +++ /var/tmp/diff_new_pack.aMIn9P/_new 2019-03-21 09:51:51.382812285 +0100 @@ -17,7 +17,7 @@ Name: yast2-country -Version: 4.1.9 +Version: 4.1.11 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-country-4.1.9.tar.bz2 -> yast2-country-4.1.11.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/language/src/modules/Language.rb new/yast2-country-4.1.11/language/src/modules/Language.rb --- old/yast2-country-4.1.9/language/src/modules/Language.rb 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/language/src/modules/Language.rb 2019-03-19 11:32:01.000000000 +0100 @@ -28,6 +28,7 @@ # # $Id$ require "yast" +require "yast2/execute" require "shellwords" @@ -44,7 +45,6 @@ Yast.import "UI" textdomain "country" - Yast.import "AsciiFile" Yast.import "Directory" Yast.import "Encoding" @@ -146,6 +146,10 @@ @english_names = {} @reset_recommended = true + + # language is read-only + @readonly = nil + Language() end @@ -913,56 +917,23 @@ end end - # Save state to target. def Save - loc = GetLocaleString(@language) - - @localed_conf = {} if @localed_conf.nil? - - if Builtins.find(loc, "zh_HK") == 0 - @localed_conf["LC_MESSAGES"] = "zh_TW" - elsif @localed_conf["LC_MESSAGES"] == "zh_TW" - # FIXME ugly hack: see bug #47711 - @localed_conf.delete("LC_MESSAGES") - end - SCR.Write(path(".sysconfig.language.INSTALLED_LANGUAGES"), @languages) SCR.Write(path(".sysconfig.language"), nil) - @localed_conf["LANG"] = loc - log.info("Locale: #{@localed_conf}") - locale_out1 = @localed_conf.map do | key, val | - "#{key}=#{val}" - end - log.info("Locale: #{locale_out1}") - locale_out=locale_out1.join(",") - log.info("Locale: #{locale_out}") + command = store_locale_command(locale) - cmd = if Stage.initial - # do use --root option, running in chroot does not work - "/usr/bin/systemd-firstboot --root #{Installation.destdir.shellescape} --locale #{loc.shellescape}" - else - # this sets both the locale (see "man localectl") - "/usr/bin/localectl set-locale #{locale_out.shellescape}" - end - log.info "Making language setting persistent: #{cmd}" - result = if Stage.initial - WFM.Execute(path(".local.bash_output"), cmd) - else - SCR.Execute(path(".target.bash_output"), cmd) - end - if result["exit"] != 0 - log.error "Language configuration not written. Failed to execute '#{cmd}'" - log.error "output: #{result.inspect}" - # TRANSLATORS: the "%s" is replaced by the executed command - Report.Error(_("Could not save the language setting, the command\n%s\nfailed.") % cmd) - else - log.info "output: #{result.inspect}" - end + log.info("Making language settings persistent: #{command.join(' ')}") - Builtins.y2milestone("Saved data for language: <%1>", loc) + Yast::Execute.locally!(command) + nil + rescue Cheetah::ExecutionFailed => e + log.error "Language configuration not written: #{e.inspect}" + log.error "stderr: #{e.stderr}" + # TRANSLATORS: the "%s" is replaced by the executed command + Report.Error(_("Could not save the language setting, the command\n%s\nfailed.") % command.join(' ')) nil end @@ -1431,6 +1402,79 @@ Builtins.getenv("TERM") == "iterm" end + # Returns the command to make language settings persistent + # + # It is different depending on the stage, since for a not installed system it is needed to use + # the `systemd-firsrboot` tool, which does not work in a chroot + # + # @param locale [String] + # + # @return [Array<String>] an array containing the command to be executed + def store_locale_command(locale) + if Stage.initial + # do use --root option, running in chroot does not work + ["/usr/bin/systemd-firstboot", "--root", Installation.destdir, "--locale", locale] + else + prepare_locale_settings(locale) + + ["/usr/bin/localectl", "set-locale", localectl_args] + end + end + + # Determines whether language is read-only for the current product + # + # @return [Boolean] true if it's read-only; false otherwise. + def readonly + @readonly unless @readonly.nil? + @readonly = ProductFeatures.GetBooleanFeature("globals", "readonly_language") + end + + # Returns the locale to use, default or chosen + # + # Based on the readonly_language feature + # + # @return [String] default language when language set to read-only; chosen language otherwise + def locale + language = readonly ? DEFAULT_FALLBACK_LANGUAGE : @language + + GetLocaleString(language) + end + + # Sets locale settings for given locale + # + # @param locale [String] + def prepare_locale_settings(locale) + @localed_conf ||= {} + @localed_conf["LANG"] = locale + + fix_lc_messages(locale) + + log.info("Locale: #{@localed_conf}") + end + + # Fix the value of LC_MESSAGES for zh_HK locale + # + # It must be zh_TW + # + # @param locale [String] + def fix_lc_messages(locale) + @localed_conf ||= {} + + if locale.start_with?("zh_HK") + @localed_conf["LC_MESSAGES"] = "zh_TW" + elsif @localed_conf["LC_MESSAGES"] == "zh_TW" + @localed_conf.delete("LC_MESSAGES") + end + end + + # Returns the locale settings as args for localectl + # + # @return [String] a comma separated locale settings string; i.e, LANG=zh_HK,LC_MESAGES=zh_TW + def localectl_args + @localed_conf.map { |k, v| "#{k}=#{v}" }.join(",") + end + + def show_fallback_to_english_warning Report.Message( _( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/language/test/Language_test.rb new/yast2-country-4.1.11/language/test/Language_test.rb --- old/yast2-country-4.1.9/language/test/Language_test.rb 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/language/test/Language_test.rb 2019-03-19 11:32:01.000000000 +0100 @@ -4,7 +4,10 @@ require_relative "test_helper" require "y2country/language_dbus" -describe "Language" do +Yast.import "ProductFeatures" +Yast.import "Language" + +describe "Yast::Language" do subject { Yast::Language } let(:languages_map) {{ @@ -41,9 +44,10 @@ before do allow(Y2Country).to receive(:read_locale_conf).and_return(nil) - Yast.import "Language" allow(subject).to receive(:languages_map).and_return(languages_map) allow(subject).to receive(:GetLanguagesMap).and_return(languages_map) + + Yast::Language.main end describe "#integrate_inst_sys_extension" do @@ -162,6 +166,121 @@ end end + describe "#Save" do + let(:readonly) { false } + let(:language) { "es_ES" } + let(:initial_stage) { false } + + before do + allow(Yast::Stage).to receive(:initial).and_return(initial_stage) + + allow(Yast::ProductFeatures).to receive(:GetBooleanFeature) + .with("globals", "readonly_language") + .and_return(readonly) + + allow(Yast::SCR).to receive(:Write) + allow(Yast::Execute).to receive(:locally!) + allow(subject).to receive(:valid_language?).with(language).and_return(true) + + subject.Set(language) + subject.SetDefault + end + + it "updates the .sysconfig.language.INSTALLED_LANGUAGES value" do + expect(Yast::SCR).to receive(:Write).with(Yast.path(".sysconfig.language.INSTALLED_LANGUAGES"), anything) + + subject.Save + end + + it "forces writting .sysconfig.language to disk" do + expect(Yast::SCR).to receive(:Write).with(Yast.path(".sysconfig.language"), nil) + + subject.Save + end + + context "when language is zh_HK" do + let(:language) { "zh_HK" } + + it "sets LC_MESSAGES to zh_TW" do + expect(Yast::Execute).to receive(:locally!).with(array_including(/LC_MESSAGES=zh_TW/)) + + subject.Save + end + end + + context "when LC_MESSAGES is zh_TW" do + before do + allow(subject).to receive(:@localed_conf).and_return({ "LC_MESSAGES" => "zh_TW" }) + end + + context "and language is not zh_HK" do + it "cleans LC_MESSAGES" do + expect(Yast::Execute).to_not receive(:locally!).with(array_including(/LC_MESSAGES=zh_TW/)) + + subject.Save + end + end + end + + context "when using the readonly_language feature" do + let(:readonly) { true } + + it "sets the default language using localectl" do + expect(Yast::Execute).to receive(:locally!) + .with(array_including(/localectl/, "set-locale", /LANG=en_US/)) + + subject.Save + end + + context "in the initial stage" do + let(:initial_stage) { true } + + it "sets the default language using systemd-firstboot" do + expect(Yast::Execute).to receive(:locally!) + .with(array_including(/systemd-firstboot/, "--root", "--locale", /en_US/)) + + subject.Save + end + end + end + + context "when not using the readonly_language feature" do + it "sets the chosen language using localectl" do + expect(Yast::Execute).to receive(:locally!) + .with(array_including(/localectl/, "set-locale", /LANG=#{language}/)) + + subject.Save + end + + context "in the initial stage" do + let(:initial_stage) { true } + + it "sets the default language using systemd-firstboot" do + expect(Yast::Execute).to receive(:locally!) + .with(array_including(/systemd-firstboot/, "--root", "--locale", /#{language}/)) + + subject.Save + end + end + end + + context "when the command fails" do + let(:exception) do + Cheetah::ExecutionFailed.new(["localectl"], 1, "stdout", "stderr", "Something went wrong") + end + + before do + allow(Yast::Execute).to receive(:locally!).and_raise(exception) + end + + it "reports an error" do + expect(Yast::Report).to receive(:Error) + + subject.Save + end + end + end + describe "#GetLocaleString" do context "when using UTF-8" do it "returns the full locale" do @@ -182,10 +301,8 @@ end context "when UTF-8 is not being used" do - around do |example| + before do subject.SetExpertValues("use_utf8" => false) # disable UTF-8 - example.run - subject.SetExpertValues("use_utf8" => true) # restore to the default value end it "returns the full language identifier with no encoding" do @@ -193,6 +310,7 @@ end end end + describe "#ResetRecommendedPackages" do it "resets the recommended packages" do allow(Yast::Pkg).to receive(:PkgSolve) @@ -212,13 +330,8 @@ allow(Yast::Stage).to receive(:normal).and_return(normal?) allow(subject).to receive(:GetTextMode).and_return(textmode?) allow(Yast::Builtins).to receive(:getenv).with("TERM").and_return(term) - end - around do |example| - old_lang = Yast::Language.language Yast::Language.language = lang - example.call - Yast::Language.language = old_lang end context "when running on normal stage" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/language/testsuite/tests/Save.out new/yast2-country-4.1.11/language/testsuite/tests/Save.out --- old/yast2-country-4.1.9/language/testsuite/tests/Save.out 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/language/testsuite/tests/Save.out 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +0,0 @@ -Read .target.size "/etc/sysconfig/language" 1 -Read .target.dir "/usr/share/YaST2/data/languages" [] -Write .sysconfig.language.INSTALLED_LANGUAGES "en_US" true -Write .sysconfig.language nil true -Execute .target.bash_output "/usr/bin/localectl set-locale LANG\\=en_US.UTF-8" $["exit":0] -Return nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/language/testsuite/tests/Save.rb new/yast2-country-4.1.11/language/testsuite/tests/Save.rb --- old/yast2-country-4.1.9/language/testsuite/tests/Save.rb 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/language/testsuite/tests/Save.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -# encoding: utf-8 - -# tests for Language::Save -# Author: [email protected] -# $Id$ -module Yast - class SaveClient < Client - def main - # testedfiles: Language.ycp - - Yast.include self, "testsuite.rb" - - @READ = { - "sysconfig" => { - "language" => { "RC_LANG" => "en_US.UTF-8", "RC_LC_MESSAGES" => "" } - }, - "target" => { - "bash_output" => {"exit" => 0}, - "size" => 1, - "yast2" => {}, - "dir" => [] - } - } - - TESTSUITE_INIT([@READ, {}, @READ], nil) - - Yast.import "Language" - - Language.languages = "en_US" - - TEST(lambda { Language.Save }, [@READ, {}, @READ], nil) - - nil - end - end -end - -Yast::SaveClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/package/yast2-country.changes new/yast2-country-4.1.11/package/yast2-country.changes --- old/yast2-country-4.1.9/package/yast2-country.changes 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/package/yast2-country.changes 2019-03-19 11:32:01.000000000 +0100 @@ -1,4 +1,19 @@ ------------------------------------------------------------------- +Tue Mar 19 07:06:45 UTC 2019 - Dominique Leuenberger <[email protected]> + +- Fix command line parameter to systemd-firstboot (--root instead + of -root) (part of bsc#1121256). +- 4.1.11 + +------------------------------------------------------------------- +Fri Mar 15 12:42:06 UTC 2019 - David Díaz <[email protected]> + +- Add support to set the language as read-only in the control file, + which allows to change it during the installation without + persisting it in the installed system (bsc#1121256). +- 4.1.10 + +------------------------------------------------------------------- Thu Feb 28 09:28:43 UTC 2019 - José Iván López González <[email protected]> - Fix OS detection and use correct keyboard file for opensuse diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-country-4.1.9/package/yast2-country.spec new/yast2-country-4.1.11/package/yast2-country.spec --- old/yast2-country-4.1.9/package/yast2-country.spec 2019-02-28 13:33:14.000000000 +0100 +++ new/yast2-country-4.1.11/package/yast2-country.spec 2019-03-19 11:32:01.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-country -Version: 4.1.9 +Version: 4.1.11 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build
