Merge pull request #22 from vector-im/dbkr/hak_linux

Build seshat on Linux
This commit is contained in:
David Baker 2020-02-19 10:00:07 +00:00 committed by GitHub
commit da5a0e63ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 99 additions and 57 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
/pkg/control /pkg/control
/.hak /.hak
/.yarnrc /.yarnrc
/docker

12
README
View File

@ -59,9 +59,21 @@ This will do a couple of things:
* Run electron-builder to build a package. The package built will match the operating system * Run electron-builder to build a package. The package built will match the operating system
you're running the build process on. you're running the build process on.
If you'd like to build the native modules (for searching in encrypted rooms):
This will take 10 minutes or so, and will require a number of native tools
to be installed, depending on your OS (eg. rust, tcl, make/nmake).
```
yarn run build:native
```
You can also build using docker, which will always produce the linux package: You can also build using docker, which will always produce the linux package:
``` ```
# Run this once to make the docker image
yarn run docker:setup
yarn run docker:install yarn run docker:install
# if you want to build the native modules (this will take a while)
yarn run docker:buildnative
yarn run docker:build yarn run docker:build
``` ```

10
dockerbuild/Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM electronuserland/builder:12
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH
RUN apt-get update && \
apt-get install -y libsqlcipher-dev && \
rm -rf /var/lib/apt/lists/* && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal

View File

@ -24,7 +24,7 @@ module.exports = async function(hakEnv, moduleInfo) {
if (hakEnv.isWin()) { if (hakEnv.isWin()) {
await buildOpenSslWin(hakEnv, moduleInfo); await buildOpenSslWin(hakEnv, moduleInfo);
await buildSqlCipherWin(hakEnv, moduleInfo); await buildSqlCipherWin(hakEnv, moduleInfo);
} else { } else if (hakEnv.isMac()) {
await buildSqlCipherUnix(hakEnv, moduleInfo); await buildSqlCipherUnix(hakEnv, moduleInfo);
} }
await buildMatrixSeshat(hakEnv, moduleInfo); await buildMatrixSeshat(hakEnv, moduleInfo);
@ -228,11 +228,15 @@ async function buildSqlCipherUnix(hakEnv, moduleInfo) {
} }
async function buildMatrixSeshat(hakEnv, moduleInfo) { async function buildMatrixSeshat(hakEnv, moduleInfo) {
const env = Object.assign({ const env = hakEnv.makeGypEnv();
if (!hakEnv.isLinux()) {
Object.assign(env, {
SQLCIPHER_STATIC: 1, SQLCIPHER_STATIC: 1,
SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'), SQLCIPHER_LIB_DIR: path.join(moduleInfo.depPrefix, 'lib'),
SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'), SQLCIPHER_INCLUDE_DIR: path.join(moduleInfo.depPrefix, 'include'),
}, hakEnv.makeGypEnv()); });
}
if (hakEnv.isWin()) { if (hakEnv.isWin()) {
env.RUSTFLAGS = '-Ctarget-feature=+crt-static -Clink-args=libcrypto.lib'; env.RUSTFLAGS = '-Ctarget-feature=+crt-static -Clink-args=libcrypto.lib';

View File

@ -18,6 +18,7 @@ const childProcess = require('child_process');
module.exports = async function(hakEnv, moduleInfo) { module.exports = async function(hakEnv, moduleInfo) {
// of course tcl doesn't have a --version // of course tcl doesn't have a --version
if (!hakEnv.isLinux()) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
const proc = childProcess.spawn('tclsh', [], { const proc = childProcess.spawn('tclsh', [], {
stdio: ['pipe', 'ignore', 'ignore'], stdio: ['pipe', 'ignore', 'ignore'],
@ -31,6 +32,7 @@ module.exports = async function(hakEnv, moduleInfo) {
}); });
proc.stdin.end(); proc.stdin.end();
}); });
}
const tools = []; const tools = [];
if (hakEnv.isWin()) { if (hakEnv.isWin()) {

View File

@ -23,7 +23,9 @@ const needle = require('needle');
const tar = require('tar'); const tar = require('tar');
module.exports = async function(hakEnv, moduleInfo) { module.exports = async function(hakEnv, moduleInfo) {
if (!hakEnv.isLinux()) {
await getSqlCipher(hakEnv, moduleInfo); await getSqlCipher(hakEnv, moduleInfo);
}
if (hakEnv.isWin()) { if (hakEnv.isWin()) {
getOpenSsl(hakEnv, moduleInfo); getOpenSsl(hakEnv, moduleInfo);

View File

@ -18,9 +18,11 @@
"start": "electron .", "start": "electron .",
"lint": "eslint src/ scripts/ hak/", "lint": "eslint src/ scripts/ hak/",
"build": "yarn run setversion && electron-builder", "build": "yarn run setversion && electron-builder",
"in-docker": "scripts/in-docker.sh", "buildnative": "yarn run hak",
"docker:build": "yarn run in-docker yarn run build", "docker:setup": "docker build -t riot-desktop-dockerbuild dockerbuild",
"docker:install": "yarn run in-docker yarn install", "docker:buildnative": "scripts/in-docker.sh yarn run hak",
"docker:build": "scripts/in-docker.sh yarn run build",
"docker:install": "scripts/in-docker.sh yarn install",
"debrepo": "scripts/mkrepo.sh", "debrepo": "scripts/mkrepo.sh",
"clean": "rimraf webapp.asar dist packages deploys", "clean": "rimraf webapp.asar dist packages deploys",
"hak": "node scripts/hak/index.js" "hak": "node scripts/hak/index.js"

View File

@ -3,7 +3,7 @@ License: Apache-2.0
Vendor: support@riot.im Vendor: support@riot.im
Architecture: amd64 Architecture: amd64
Maintainer: support@riot.im Maintainer: support@riot.im
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator3-1, libsecret-1-0 Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator3-1, libsecret-1-0, libsqlcipher0
Provides: riot-web Provides: riot-web
Conflicts: riot-web Conflicts: riot-web
Replaces: riot-web Replaces: riot-web

View File

@ -15,7 +15,7 @@ limitations under the License.
*/ */
async function build(hakEnv, moduleInfo) { async function build(hakEnv, moduleInfo) {
moduleInfo.scripts.build(hakEnv, moduleInfo); await moduleInfo.scripts.build(hakEnv, moduleInfo);
} }
module.exports = build; module.exports = build;

View File

@ -89,12 +89,17 @@ async function main() {
} }
} }
let cmds;
if (process.argv.length < 3) { if (process.argv.length < 3) {
console.log("Usage: hak <command> [modules...]"); cmds = ['check', 'fetch', 'fetchDeps', 'build', 'copy', 'link'];
process.exit(1); } else {
cmds = [process.argv[2]];
} }
const cmd = process.argv[2]; let modules = process.argv.slice(3);
if (modules.length === 0) modules = Object.keys(deps);
for (const cmd of cmds) {
if (GENERALCOMMANDS.includes(cmd)) { if (GENERALCOMMANDS.includes(cmd)) {
if (cmd === 'target') { if (cmd === 'target') {
console.log(hakEnv.getNodeTriple()); console.log(hakEnv.getNodeTriple());
@ -113,10 +118,6 @@ async function main() {
const cmdFunc = require('./' + cmd); const cmdFunc = require('./' + cmd);
let modules = process.argv.slice(3);
if (modules.length === 0) modules = Object.keys(deps);
for (const mod of modules) { for (const mod of modules) {
const depInfo = deps[mod]; const depInfo = deps[mod];
if (depInfo === undefined) { if (depInfo === undefined) {
@ -130,5 +131,6 @@ async function main() {
await cmdFunc(hakEnv, depInfo); await cmdFunc(hakEnv, depInfo);
} }
} }
}
main(); main();

View File

@ -1,12 +1,19 @@
#!/bin/bash #!/bin/bash
docker inspect riot-desktop-dockerbuild 2> /dev/null > /dev/null
if [ $? != 0 ]; then
echo "Docker image riot-desktop-builder not found. Have you run yarn run docker:setup?"
exit 1
fi
# Taken from https://www.electron.build/multi-platform-build#docker # Taken from https://www.electron.build/multi-platform-build#docker
docker run --rm -ti \ docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \ --env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \ --env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \ --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
-v ${PWD}:/project \ -v ${PWD}:/project \
-v ${PWD}/docker_node_modules:/project/node_modules \ -v ${PWD}/docker/node_modules:/project/node_modules \
-v ${PWD}/docker/.hak:/project/.hak \
-v ~/.cache/electron:/root/.cache/electron \ -v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \ -v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder "$@" riot-desktop-dockerbuild "$@"