Merge branch '3.1.x-stable'

main
Adriaan de Groot 7 years ago
commit 9fe85e592f

@ -43,9 +43,11 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
const QStringList& availableLocales, const QStringList& availableLocales,
const QString& countryCode ) const QString& countryCode )
{ {
LocaleConfiguration lc = LocaleConfiguration(); LocaleConfiguration lc;
// Note that the documentation how this works is in packages.conf
QString language = languageLocale.split( '_' ).first(); QString language = languageLocale.split( '_' ).first();
lc.myLanguageLocaleBcp47 = QLocale(language).bcp47Name(); lc.myLanguageLocaleBcp47 = QLocale(language).bcp47Name().toLower();
QStringList linesForLanguage; QStringList linesForLanguage;
for ( const QString &line : availableLocales ) for ( const QString &line : availableLocales )
@ -288,7 +290,7 @@ LocaleConfiguration::isEmpty() const
QMap< QString, QString > QMap< QString, QString >
LocaleConfiguration::toMap() LocaleConfiguration::toMap() const
{ {
QMap< QString, QString > map; QMap< QString, QString > map;
@ -324,3 +326,9 @@ LocaleConfiguration::toMap()
return map; return map;
} }
QString
LocaleConfiguration::toBcp47() const
{
return myLanguageLocaleBcp47;
}

@ -35,16 +35,21 @@ public:
bool isEmpty() const; bool isEmpty() const;
QMap< QString, QString > toMap() const;
// Note that the documentation how this works is in packages.conf
QString toBcp47() const;
// These become all uppercase in locale.conf, but we keep them lowercase here to // These become all uppercase in locale.conf, but we keep them lowercase here to
// avoid confusion with locale.h. // avoid confusion with locale.h.
QString lang, lc_numeric, lc_time, lc_monetary, lc_paper, lc_name, lc_address, QString lang, lc_numeric, lc_time, lc_monetary, lc_paper, lc_name, lc_address,
lc_telephone, lc_measurement, lc_identification; lc_telephone, lc_measurement, lc_identification;
QString myLanguageLocaleBcp47;
QMap< QString, QString > toMap();
// If the user has explicitly selected language (from the dialog) // If the user has explicitly selected language (from the dialog)
// or numbers format, set these to avoid implicit changes to them. // or numbers format, set these to avoid implicit changes to them.
bool explicit_lang, explicit_lc; bool explicit_lang, explicit_lc;
private:
QString myLanguageLocaleBcp47;
}; };
#endif // LOCALECONFIGURATION_H #endif // LOCALECONFIGURATION_H

@ -489,8 +489,10 @@ LocalePage::updateGlobalStorage()
->insert( "locationRegion", location.region ); ->insert( "locationRegion", location.region );
Calamares::JobQueue::instance()->globalStorage() Calamares::JobQueue::instance()->globalStorage()
->insert( "locationZone", location.zone ); ->insert( "locationZone", location.zone );
Calamares::JobQueue::instance()->globalStorage()
->insert( "locale", m_selectedLocaleConfiguration.myLanguageLocaleBcp47); const QString bcp47 = m_selectedLocaleConfiguration.toBcp47();
Calamares::JobQueue::instance()->globalStorage()->insert( "locale", bcp47 );
cDebug() << "Updated locale globals, BCP47=" << bcp47;
// If we're in chroot mode (normal install mode), then we immediately set the // If we're in chroot mode (normal install mode), then we immediately set the
// timezone on the live system. // timezone on the live system.

@ -332,7 +332,10 @@ def subst_locale(plist):
""" """
locale = libcalamares.globalstorage.value("locale") locale = libcalamares.globalstorage.value("locale")
if not locale: if not locale:
return plist # It is possible to skip the locale-setting entirely.
# Then pretend it is "en", so that {LOCALE}-decorated
# package names are removed from the list.
locale = "en"
ret = [] ret = []
for packagedata in plist: for packagedata in plist:
@ -378,20 +381,20 @@ def run_operations(pkgman, entry):
global group_packages, completed_packages, mode_packages global group_packages, completed_packages, mode_packages
for key in entry.keys(): for key in entry.keys():
entry[key] = subst_locale(entry[key]) package_list = subst_locale(entry[key])
group_packages = len(entry[key]) group_packages = len(package_list)
if key == "install": if key == "install":
_change_mode(INSTALL) _change_mode(INSTALL)
if all([isinstance(x, str) for x in entry[key]]): if all([isinstance(x, str) for x in package_list]):
pkgman.install(entry[key]) pkgman.install(package_list)
else: else:
for package in entry[key]: for package in package_list:
pkgman.install_package(package) pkgman.install_package(package)
elif key == "try_install": elif key == "try_install":
_change_mode(INSTALL) _change_mode(INSTALL)
# we make a separate package manager call for each package so a # we make a separate package manager call for each package so a
# single failing package won't stop all of them # single failing package won't stop all of them
for package in entry[key]: for package in package_list:
try: try:
pkgman.install_package(package) pkgman.install_package(package)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -400,10 +403,10 @@ def run_operations(pkgman, entry):
libcalamares.utils.warning(warn_text) libcalamares.utils.warning(warn_text)
elif key == "remove": elif key == "remove":
_change_mode(REMOVE) _change_mode(REMOVE)
pkgman.remove(entry[key]) pkgman.remove(package_list)
elif key == "try_remove": elif key == "try_remove":
_change_mode(REMOVE) _change_mode(REMOVE)
for package in entry[key]: for package in package_list:
try: try:
pkgman.remove([package]) pkgman.remove([package])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -412,9 +415,9 @@ def run_operations(pkgman, entry):
libcalamares.utils.warning(warn_text) libcalamares.utils.warning(warn_text)
elif key == "localInstall": elif key == "localInstall":
_change_mode(INSTALL) _change_mode(INSTALL)
pkgman.install(entry[key], from_local=True) pkgman.install(package_list, from_local=True)
completed_packages += len(entry[key]) completed_packages += len(package_list)
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages) libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
libcalamares.utils.debug(pretty_name()) libcalamares.utils.debug(pretty_name())
@ -458,7 +461,7 @@ def run():
completed_packages = 0 completed_packages = 0
for op in operations: for op in operations:
for packagelist in op.values(): for packagelist in op.values():
total_packages += len(packagelist) total_packages += len(subst_locale(packagelist))
if not total_packages: if not total_packages:
# Avoids potential divide-by-zero in progress reporting # Avoids potential divide-by-zero in progress reporting

@ -76,7 +76,7 @@ update_db: true
# pre-script: touch /tmp/installing-vi # pre-script: touch /tmp/installing-vi
# post-script: rm -f /tmp/installing-vi # post-script: rm -f /tmp/installing-vi
# #
# The pre- and post-scripts are optional, but not both optional: using # The pre- and post-scripts are optional, but you cannot leave both out: using
# "package: vi" with neither script option will trick Calamares into # "package: vi" with neither script option will trick Calamares into
# trying to install a package named "package: vi", which is unlikely to work. # trying to install a package named "package: vi", which is unlikely to work.
# #
@ -84,11 +84,16 @@ update_db: true
# packages for software based on the selected system locale. By including # packages for software based on the selected system locale. By including
# the string LOCALE in the package name, the following happens: # the string LOCALE in the package name, the following happens:
# #
# - if the system locale is English (generally US English; en_GB is a valid # - if the system locale is English (any variety), then the package is not
# localization), then the package is not installed at all, # installed at all,
# - otherwise $LOCALE or ${LOCALE} is replaced by the Bcp47 name of the selected # - otherwise $LOCALE or ${LOCALE} is replaced by the **lower-cased** BCP47
# system locale, e.g. nl_BE. Note that just plain LOCALE will not be replaced, # name of the **language** part of the selected system locale (not the
# so foo-LOCALE will be unchanged, while foo-$LOCALE will be changed. # country/region/dialect part), e.g. selecting *nl_BE* will use *nl*
# here.
#
# Take care that just plain LOCALE will not be replaced, so foo-LOCALE will
# be left unchanged, while foo-$LOCALE will be changed. However, foo-LOCALE
# **will** be removed from the list of packages, if English is selected.
# #
# The following installs localizations for vi, if they are relevant; if # The following installs localizations for vi, if they are relevant; if
# there is no localization, installation continues normally. # there is no localization, installation continues normally.
@ -127,6 +132,7 @@ update_db: true
operations: operations:
- install: - install:
- vi - vi
- vi-${LOCALE}
- wget - wget
- binutils - binutils
- remove: - remove:

@ -25,6 +25,6 @@ requirements:
# If any of these conditions are not met, the user cannot # If any of these conditions are not met, the user cannot
# continue past the welcome page. # continue past the welcome page.
required: required:
- storage # - storage
- ram - ram
- root # - root

Loading…
Cancel
Save