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

Commit

Permalink
Fix crashes by building a statically linked sqlcipher.
Browse files Browse the repository at this point in the history
This remove the need to preload one to avoid conflicts with gtk linkings.

Thanks go to heftig for the actual patch for this.

git-svn-id: file:///srv/repos/svn-community/svn@1142216 9fca08f4-af9d-4005-b8df-a31f2cc04f65
  • Loading branch information
ArchangeGabriel authored and svntogit committed Mar 5, 2022
1 parent ea74b6e commit 7bf5e3e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 5 deletions.
11 changes: 7 additions & 4 deletions trunk/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ _electron=electron17
pkgbase=element.io
pkgname=(element-web element-desktop)
pkgver=1.10.6
pkgrel=1
pkgrel=2
pkgdesc="Glossy Matrix collaboration client — "
arch=(x86_64)
url="https://element.io"
license=(Apache)
makedepends=(npm git yarn python rust sqlcipher ${_electron} nodejs-lts-gallium)
makedepends=(npm git yarn python rust tcl ${_electron} nodejs-lts-gallium)
_url="https://github.com/vector-im/element"
source=(element-web-${pkgver}.tar.gz::${_url}-web/archive/v${pkgver}.tar.gz
element-web-${pkgver}.tar.gz.asc::${_url}-web/releases/download/v${pkgver}/v${pkgver}-src.tar.gz.asc
element-desktop-${pkgver}.tar.gz::${_url}-desktop/archive/v${pkgver}.tar.gz
element-desktop-${pkgver}.tar.gz.asc::${_url}-desktop/releases/download/v${pkgver}/v${pkgver}-src.tar.gz.asc
autolaunch.patch
encapsulate-sqlcipher.diff
io.element.Element.desktop
element-desktop.sh)
sha256sums=('0afbddbaf9215b6aa6e566a9456a1186262245d472d457954febb7b4e12d345f'
'SKIP'
'388931f2de254f66499ac79d047e4402cba9fc7b289de60e27720bfdca012000'
'SKIP'
'aaae4ffa41590361dac0c159aecc1166f69e459e89faa9d5cab1202f0277e06f'
'3b2112d25b258b67d18b9329faeb9e5c5b218732c9c020ee01911347a90a1cb8'
'0103f28a32fe31f698836516783c1c70a76a0117b5df7fd0af5c422c224220f9'
'4c931121009985e7d3f73928c9db88508eedd974a7741e635bb290e3a2cd75db')
'c1bd9ace215e3ec9af14d7f28b163fc8c8b42e23a2cf04ce6f4ce2fcc465feba')
validpgpkeys=(712BFBEE92DCA45252DB17D7C7BE97EFA179B100) # Element Releases <releases@riot.im>

prepare() {
Expand All @@ -39,6 +41,7 @@ prepare() {

cd ../element-desktop-${pkgver}
patch -p1 < ../autolaunch.patch
patch -p1 < ../encapsulate-sqlcipher.diff
sed -i 's|"target": "deb"|"target": "dir"|' package.json
sed -i 's|"https://packages.element.io/desktop/update/"|null|' element.io/release/config.json
yarn install --no-fund
Expand Down Expand Up @@ -70,7 +73,7 @@ package_element-web() {
package_element-desktop() {
pkgdesc+="desktop version."
replaces=(riot-desktop)
depends=("element-web=${pkgver}" ${_electron} sqlcipher)
depends=("element-web=${pkgver}" ${_electron})
backup=('etc/element/config.json')

cd element-desktop-${pkgver}
Expand Down
2 changes: 1 addition & 1 deletion trunk/element-desktop.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

LD_PRELOAD=/usr/lib/libsqlcipher.so exec @ELECTRON@ /usr/lib/element/app.asar --disable-dev-mode "$@"
exec @ELECTRON@ /usr/lib/element/app.asar --disable-dev-mode "$@"
105 changes: 105 additions & 0 deletions trunk/encapsulate-sqlcipher.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
diff --git i/hak/matrix-seshat/build.ts w/hak/matrix-seshat/build.ts
index 8d50bb1..33ad8d5 100644
--- i/hak/matrix-seshat/build.ts
+++ w/hak/matrix-seshat/build.ts
@@ -26,7 +26,7 @@ export default async function(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promi
if (hakEnv.isWin()) {
await buildOpenSslWin(hakEnv, moduleInfo);
await buildSqlCipherWin(hakEnv, moduleInfo);
- } else if (hakEnv.isMac()) {
+ } else {
await buildSqlCipherUnix(hakEnv, moduleInfo);
}
await buildMatrixSeshat(hakEnv, moduleInfo);
@@ -179,12 +179,17 @@ async function buildSqlCipherUnix(hakEnv, moduleInfo) {
'--prefix=' + moduleInfo.depPrefix + '',
'--enable-tempstore=yes',
'--enable-shared=no',
+ '--enable-tcl=no',
];

if (hakEnv.isMac()) {
args.push('--with-crypto-lib=commoncrypto');
}

+ if (hakEnv.isLinux()) {
+ args.push('--with-pic=yes');
+ }
+
if (!hakEnv.isHost()) {
// In the nonsense world of `configure`, it is assumed you are building
// a compiler like `gcc`, so the `host` option actually means the target
@@ -265,12 +270,14 @@ async function buildMatrixSeshat(hakEnv, moduleInfo) {
// it for now: we should confirm how much of this it still actually needs.
const env = hakEnv.makeGypEnv();

- if (!hakEnv.isLinux()) {
- Object.assign(env, {
- SQLCIPHER_STATIC: 1,
- SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'),
- SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'),
- });
+ Object.assign(env, {
+ SQLCIPHER_STATIC: 1,
+ SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'),
+ SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'),
+ });
+
+ if (hakEnv.isLinux()) {
+ env.RUSTFLAGS = '-Clink-arg=-Wl,-Bsymbolic -Clink-arg=-Wl,--exclude-libs,ALL'
}

if (hakEnv.isWin()) {
diff --git i/hak/matrix-seshat/check.ts w/hak/matrix-seshat/check.ts
index d34247f..ad6533a 100644
--- i/hak/matrix-seshat/check.ts
+++ w/hak/matrix-seshat/check.ts
@@ -22,21 +22,19 @@ import { DependencyInfo } from '../../scripts/hak/dep';

export default async function(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
// of course tcl doesn't have a --version
- if (!hakEnv.isLinux()) {
- await new Promise<void>((resolve, reject) => {
- const proc = childProcess.spawn('tclsh', [], {
- stdio: ['pipe', 'ignore', 'ignore'],
- });
- proc.on('exit', (code) => {
- if (code !== 0) {
- reject("Can't find tclsh - have you installed TCL?");
- } else {
- resolve();
- }
- });
- proc.stdin.end();
+ await new Promise<void>((resolve, reject) => {
+ const proc = childProcess.spawn('tclsh', [], {
+ stdio: ['pipe', 'ignore', 'ignore'],
});
- }
+ proc.on('exit', (code) => {
+ if (code !== 0) {
+ reject("Can't find tclsh - have you installed TCL?");
+ } else {
+ resolve();
+ }
+ });
+ proc.stdin.end();
+ });

const tools = [
['rustc', '--version'],
diff --git i/hak/matrix-seshat/fetchDeps.ts w/hak/matrix-seshat/fetchDeps.ts
index a2fcf34..1ae1286 100644
--- i/hak/matrix-seshat/fetchDeps.ts
+++ w/hak/matrix-seshat/fetchDeps.ts
@@ -25,9 +25,7 @@ import HakEnv from '../../scripts/hak/hakEnv';
import { DependencyInfo } from '../../scripts/hak/dep';

export default async function(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
- if (!hakEnv.isLinux()) {
- await getSqlCipher(hakEnv, moduleInfo);
- }
+ await getSqlCipher(hakEnv, moduleInfo);

if (hakEnv.isWin()) {
await getOpenSsl(hakEnv, moduleInfo);

0 comments on commit 7bf5e3e

Please sign in to comment.