Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert back to using libsqlcipher0 for Debian & Ubuntu packages of Desktop #367

Merged
merged 5 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
pull_request: { }
push:
branches: [ develop, master ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
windows:
strategy:
Expand Down Expand Up @@ -67,7 +70,13 @@ jobs:
run: "yarn build --publish never -w ${{ matrix.build-args }}"

linux:
name: Linux
strategy:
matrix:
include:
- sqlcipher: system
- sqlcipher: static
static: 1
name: 'Linux (sqlcipher: ${{ matrix.sqlcipher }})'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -84,6 +93,10 @@ jobs:
with:
toolchain: stable

- name: Install libsqlcipher-dev
if: matrix.sqlcipher == 'system'
run: sudo apt-get install -y libsqlcipher-dev

- uses: actions/setup-node@v3
with:
cache: "yarn"
Expand All @@ -94,6 +107,8 @@ jobs:

- name: Build Natives
run: "yarn build:native"
env:
SQLCIPHER_STATIC: ${{ matrix.static }}

- name: Build App
run: "yarn build --publish never"
Expand Down
4 changes: 3 additions & 1 deletion dockerbuild/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RUN apt-get -qq update && apt-get -qq dist-upgrade && \
# libsecret-1-dev and libgnome-keyring-dev are required even for prebuild keytar
apt-get -qq install --no-install-recommends qtbase5-dev bsdtar build-essential autoconf libssl-dev gcc-multilib g++-multilib lzip rpm python libcurl4 git git-lfs ssh unzip tcl \
libsecret-1-dev libgnome-keyring-dev \
libopenjp2-tools && \
libopenjp2-tools \
# Used by seshat (when not SQLCIPHER_STATIC) \
libsqlcipher-dev && \
# git-lfs
git lfs install && \
apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/*
Expand Down
13 changes: 12 additions & 1 deletion docs/native-node-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using yarn at the root of this project:

yarn add matrix-seshat

You will have to rebuild the native libraries against electron's version of
You will have to rebuild the native libraries against electron's version
of node rather than your system node, using the `electron-build-env` tool.
This is also needed to when pulling in changes to Seshat using `yarn link`.

Expand All @@ -66,6 +66,17 @@ as usual using:

yarn start

### Statically linking libsqlcipher

On Windows & macOS we always statically link libsqlcipher for it is not generally available.
On Linux by default we will use a system package, on debian & ubuntu this is `libsqlcipher0`,
but this is problematic for some other packages.
By including `SQLCIPHER_STATIC=1` in the build environment, the build scripts will statically link sqlcipher,
note that this will want a `libcrypto1.1` shared library available in the system.

More info can be found at https://github.com/matrix-org/seshat/issues/102
and https://github.com/vector-im/element-web/issues/20926.

## Compiling for specific architectures

### macOS
Expand Down
4 changes: 2 additions & 2 deletions element.io/nightly/control.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Vendor: support@element.io
Architecture: amd64
Maintainer: support@element.io
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libsecret-1-0
Recommends: libappindicator3-1
Recommends: libappindicator3-1, libsqlcipher0
Section: net
Priority: extra
Homepage: https://element.io/
Description:
Description:
riot.im A feature-rich client for Matrix.org (nightly unstable build).
4 changes: 2 additions & 2 deletions element.io/release/control.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Vendor: support@element.io
Architecture: amd64
Maintainer: support@element.io
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libsecret-1-0
Recommends: libappindicator3-1
Recommends: libappindicator3-1, libsqlcipher0
Replaces: riot-desktop (<< 1.7.0), riot-web (<< 1.7.0)
Breaks: riot-desktop (<< 1.7.0), riot-web (<< 1.7.0)
Section: net
Priority: extra
Homepage: https://element.io/
Description:
Description:
A feature-rich client for Matrix.org
26 changes: 16 additions & 10 deletions hak/matrix-seshat/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
} else if (hakEnv.wantsStaticSqlCipherUnix()) {
await buildSqlCipherUnix(hakEnv, moduleInfo);
}
await buildMatrixSeshat(hakEnv, moduleInfo);
Expand Down Expand Up @@ -186,8 +186,12 @@ async function buildSqlCipherUnix(hakEnv: HakEnv, moduleInfo: DependencyInfo) {
args.push('--with-crypto-lib=commoncrypto');
}

if (hakEnv.isLinux()) {
args.push('--with-pic=yes');
if (hakEnv.wantsStaticSqlCipherUnix()) {
args.push('--enable-tcl=no');

if (hakEnv.isLinux()) {
args.push('--with-pic=yes');
}
}

if (!hakEnv.isHost()) {
Expand All @@ -210,7 +214,7 @@ async function buildSqlCipherUnix(hakEnv: HakEnv, moduleInfo: DependencyInfo) {
args.push(`CFLAGS=${cflags.join(' ')}`);
}

const ldflags = [];
const ldflags: string[] = [];

if (hakEnv.isMac()) {
ldflags.push('-framework Security');
Expand Down Expand Up @@ -270,13 +274,15 @@ async function buildMatrixSeshat(hakEnv: HakEnv, moduleInfo: DependencyInfo) {
// it for now: we should confirm how much of this it still actually needs.
const env = hakEnv.makeGypEnv();

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() || hakEnv.wantsStaticSqlCipherUnix()) {
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()) {
if (hakEnv.isLinux() && hakEnv.wantsStaticSqlCipherUnix()) {
// Ensure Element uses the statically-linked seshat build, and prevent other applications
// from attempting to use this one. Detailed explanation:
//
Expand Down
28 changes: 15 additions & 13 deletions hak/matrix-seshat/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ import HakEnv from '../../scripts/hak/hakEnv';
import { DependencyInfo } from '../../scripts/hak/dep';

export default async function(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<void> {
// of course tcl doesn't have a --version
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();
}
if (hakEnv.wantsStaticSqlCipher()) {
// of course tcl doesn't have a --version
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();
});
proc.stdin.end();
});
}

const tools = [
['rustc', '--version'],
Expand Down
12 changes: 7 additions & 5 deletions hak/matrix-seshat/fetchDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import HakEnv from '../../scripts/hak/hakEnv';
import { DependencyInfo } from '../../scripts/hak/dep';

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

if (hakEnv.isWin()) {
await getOpenSsl(hakEnv, moduleInfo);
Expand All @@ -36,7 +38,7 @@ async function getSqlCipher(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise
const version = moduleInfo.cfg.dependencies.sqlcipher;
const sqlCipherDir = path.join(moduleInfo.moduleTargetDotHakDir, `sqlcipher-${version}`);

let haveSqlcipher;
let haveSqlcipher: boolean;
try {
await fsProm.stat(sqlCipherDir);
haveSqlcipher = true;
Expand All @@ -47,7 +49,7 @@ async function getSqlCipher(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise
if (haveSqlcipher) return;

const sqlCipherTarball = path.join(moduleInfo.moduleDotHakDir, `sqlcipher-${version}.tar.gz`);
let haveSqlcipherTar;
let haveSqlcipherTar: boolean;
try {
await fsProm.stat(sqlCipherTarball);
haveSqlcipherTar = true;
Expand Down Expand Up @@ -97,7 +99,7 @@ async function getOpenSsl(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<v
const version = moduleInfo.cfg.dependencies.openssl;
const openSslDir = path.join(moduleInfo.moduleTargetDotHakDir, `openssl-${version}`);

let haveOpenSsl;
let haveOpenSsl: boolean;
try {
await fsProm.stat(openSslDir);
haveOpenSsl = true;
Expand All @@ -108,7 +110,7 @@ async function getOpenSsl(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise<v
if (haveOpenSsl) return;

const openSslTarball = path.join(moduleInfo.moduleDotHakDir, `openssl-${version}.tar.gz`);
let haveOpenSslTar;
let haveOpenSslTar: boolean;
try {
await fsProm.stat(openSslTarball);
haveOpenSslTar = true;
Expand Down
30 changes: 19 additions & 11 deletions scripts/hak/hakEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,48 @@ export default class HakEnv {
this.dotHakDir = path.join(this.projectRoot, '.hak');
}

async init() {
public async init() {
this.runtime = await getRuntime(this.projectRoot);
this.runtimeVersion = await getRuntimeVersion(this.projectRoot);
}

getRuntimeAbi(): string {
public getRuntimeAbi(): string {
return nodePreGypVersioning.get_runtime_abi(
this.runtime,
this.runtimeVersion,
);
}

// {node_abi}-{platform}-{arch}
getNodeTriple(): string {
public getNodeTriple(): string {
return this.getRuntimeAbi() + '-' + this.target.platform + '-' + this.target.arch;
}

getTargetId(): TargetId {
public getTargetId(): TargetId {
return this.target.id;
}

isWin(): boolean {
public isWin(): boolean {
return this.target.platform === 'win32';
}

isMac(): boolean {
public isMac(): boolean {
return this.target.platform === 'darwin';
}

isLinux(): boolean {
public isLinux(): boolean {
return this.target.platform === 'linux';
}

getTargetArch(): Arch {
public getTargetArch(): Arch {
return this.target.arch;
}

isHost(): boolean {
public isHost(): boolean {
return isHostId(this.target.id);
}

makeGypEnv(): Record<string, string> {
public makeGypEnv(): Record<string, string> {
return Object.assign({}, process.env, {
npm_config_arch: this.target.arch,
npm_config_target_arch: this.target.arch,
Expand All @@ -107,7 +107,15 @@ export default class HakEnv {
});
}

getNodeModuleBin(name: string): string {
public getNodeModuleBin(name: string): string {
return path.join(this.projectRoot, 'node_modules', '.bin', name);
}

public wantsStaticSqlCipherUnix(): boolean {
return this.isMac() || process.env.SQLCIPHER_STATIC == '1';
}

public wantsStaticSqlCipher(): boolean {
return this.isWin() || this.wantsStaticSqlCipherUnix();
}
}