Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
upgpkg: electron9 9.3.4-2
Browse files Browse the repository at this point in the history
Backport electron/electron#26508 (FS#68629).

git-svn-id: file:///srv/repos/svn-community/svn@758807 9fca08f4-af9d-4005-b8df-a31f2cc04f65
  • Loading branch information
tensor5 authored and svntogit committed Nov 22, 2020
1 parent 6adcec4 commit af6d934
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 2 deletions.
128 changes: 128 additions & 0 deletions trunk/1eb2fae007cf39d7e4fa5de4bb53a0be62b5378c.patch
@@ -0,0 +1,128 @@
From 1eb2fae007cf39d7e4fa5de4bb53a0be62b5378c Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Mon, 16 Nov 2020 11:20:42 +0900
Subject: [PATCH] fix: LC_ALL env should not be changed

---
shell/browser/electron_browser_main_parts.cc | 25 ++++++++++-----
spec-main/chromium-spec.ts | 32 +++++++++++++-------
spec/fixtures/api/locale-check/main.js | 10 ++++--
3 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc
index cd3cd1a65760..e53b22e31052 100644
--- a/shell/browser/electron_browser_main_parts.cc
+++ b/shell/browser/electron_browser_main_parts.cc
@@ -375,23 +375,34 @@ int ElectronBrowserMainParts::PreCreateThreads() {
// which keys off of getenv("LC_ALL").
// We must set this env first to make ui::ResourceBundle accept the custom
// locale.
- g_setenv("LC_ALL", locale.c_str(), TRUE);
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ base::Optional<std::string> lc_all;
+ if (!locale.empty()) {
+ std::string str;
+ if (env->GetVar("LC_ALL", &str))
+ lc_all.emplace(std::move(str));
+ env->SetVar("LC_ALL", locale.c_str());
+ }
#endif

// Load resources bundle according to locale.
std::string loaded_locale = LoadResourceBundle(locale);

-#if defined(OS_LINUX)
- // Reset to the loaded locale if the custom locale is invalid.
- if (loaded_locale != locale)
- g_setenv("LC_ALL", loaded_locale.c_str(), TRUE);
-#endif
-
// Initialize the app locale.
std::string app_locale = l10n_util::GetApplicationLocale(loaded_locale);
ElectronBrowserClient::SetApplicationLocale(app_locale);
fake_browser_process_->SetApplicationLocale(app_locale);

+#if defined(OS_LINUX)
+ // Reset to the original LC_ALL since we should not be changing it.
+ if (!locale.empty()) {
+ if (lc_all)
+ env->SetVar("LC_ALL", *lc_all);
+ else
+ env->UnSetVar("LC_ALL");
+ }
+#endif
+
// Force MediaCaptureDevicesDispatcher to be created on UI thread.
MediaCaptureDevicesDispatcher::GetInstance();

diff --git a/spec-main/chromium-spec.ts b/spec-main/chromium-spec.ts
index cfd64deabb65..510f62a0056c 100644
--- a/spec-main/chromium-spec.ts
+++ b/spec-main/chromium-spec.ts
@@ -291,22 +291,32 @@ describe('web security', () => {
describe('command line switches', () => {
describe('--lang switch', () => {
const currentLocale = app.getLocale();
- const testLocale = (locale: string, result: string, done: () => void) => {
+ const testLocale = async (locale: string, result: string, printEnv: boolean = false) => {
const appPath = path.join(fixturesPath, 'api', 'locale-check');
- const electronPath = process.execPath;
- let output = '';
- const appProcess = ChildProcess.spawn(electronPath, [appPath, `--set-lang=${locale}`]);
+ const args = [appPath, `--set-lang=${locale}`];
+ if (printEnv) {
+ args.push('--print-env');
+ }
+ const appProcess = ChildProcess.spawn(process.execPath, args);

+ let output = '';
appProcess.stdout.on('data', (data) => { output += data; });
- appProcess.stdout.on('end', () => {
- output = output.replace(/(\r\n|\n|\r)/gm, '');
- expect(output).to.equal(result);
- done();
- });
+ await emittedOnce(appProcess.stdout, 'end');
+ output = output.replace(/(\r\n|\n|\r)/gm, '');
+ expect(output).to.equal(result);
};

- it('should set the locale', (done) => testLocale('fr', 'fr', done));
- it('should not set an invalid locale', (done) => testLocale('asdfkl', currentLocale, done));
+ it('should set the locale', async () => testLocale('fr', 'fr'));
+ it('should not set an invalid locale', async () => testLocale('asdfkl', currentLocale));
+
+ const lcAll = String(process.env.LC_ALL);
+ ifit(process.platform === 'linux')('current process has a valid LC_ALL env', async () => {
+ // The LC_ALL env should not be set to DOM locale string.
+ expect(lcAll).to.not.equal(app.getLocale());
+ });
+ ifit(process.platform === 'linux')('should not change LC_ALL', async () => testLocale('fr', lcAll, true));
+ ifit(process.platform === 'linux')('should not change LC_ALL when setting invalid locale', async () => testLocale('asdfkl', lcAll, true));
+ ifit(process.platform === 'linux')('should not change LC_ALL when --lang is not set', async () => testLocale('', lcAll, true));
});

describe('--remote-debugging-port switch', () => {
diff --git a/spec/fixtures/api/locale-check/main.js b/spec/fixtures/api/locale-check/main.js
index d42b9ab1a110..929a9e0e9519 100644
--- a/spec/fixtures/api/locale-check/main.js
+++ b/spec/fixtures/api/locale-check/main.js
@@ -1,10 +1,16 @@
const { app } = require('electron');

const locale = process.argv[2].substr(11);
-app.commandLine.appendSwitch('lang', locale);
+if (locale.length !== 0) {
+ app.commandLine.appendSwitch('lang', locale);
+}

app.whenReady().then(() => {
- process.stdout.write(app.getLocale());
+ if (process.argv[3] === '--print-env') {
+ process.stdout.write(String(process.env.LC_ALL));
+ } else {
+ process.stdout.write(app.getLocale());
+ }
process.stdout.end();

app.quit();
12 changes: 10 additions & 2 deletions trunk/PKGBUILD
Expand Up @@ -4,7 +4,7 @@ pkgname=electron9
pkgver=9.3.4
_commit=979e59e871d6489b9574e849923bd2dc99ec6c58
_chromiumver=83.0.4103.122
pkgrel=1
pkgrel=2
pkgdesc='Build cross platform desktop apps with web technologies'
arch=('x86_64')
url='https://electronjs.org/'
Expand Down Expand Up @@ -34,6 +34,7 @@ source=('git+https://github.com/electron/electron.git'
'libstdc-fix-incomplete-type-in-AXTree-for-NodeSetSiz.patch'
'make-some-of-blink-custom-iterators-STL-compatible.patch'
'v8-remove-soon-to-be-removed-getAllFieldPositions.patch'
'1eb2fae007cf39d7e4fa5de4bb53a0be62b5378c.patch'
)
sha256sums=('SKIP'
'SKIP'
Expand All @@ -50,7 +51,9 @@ sha256sums=('SKIP'
'675fb3d6276cce569a641436465f58d5709d1d4a5f62b7052989479fd4aaea24'
'50687079426094f2056d1f4806dc30fc8d6bad16190520e57ba087ec5db1d778'
'3d7f20e1d2ee7d73ed25e708c0d59a0cb215fcce10a379e3d48a856533c4b0b7'
'e042024423027ad3ef729a7e4709bdf9714aea49d64cfbbf46a645a05703abc2')
'e042024423027ad3ef729a7e4709bdf9714aea49d64cfbbf46a645a05703abc2'
'18bec85fa60b28ed517f3c8be272f6dcecae2819648b9b85cb396b9af25e7270'
)

_system_libs=('ffmpeg'
'flac'
Expand Down Expand Up @@ -145,6 +148,11 @@ prepare() {
patch -Np1 -i ../use-system-libraries-in-node.patch
patch -Np1 -i ../default_app-icon.patch # Icon from .desktop file

# Backport https://github.com/electron/electron/pull/26508 (FS#68629)
cd electron
patch -Np1 -i ../../1eb2fae007cf39d7e4fa5de4bb53a0be62b5378c.patch
cd ..

echo "Patching Chromium for using system libraries..."
sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
tools/generate_shim_headers/generate_shim_headers.py
Expand Down

0 comments on commit af6d934

Please sign in to comment.