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

[wip] simplify deb-building with circle-ci #752

Merged
merged 22 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .circleci/config.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pids
*.pid
*.seed
*.pid.lock
*.swp

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
Expand Down
10 changes: 10 additions & 0 deletions ci_scripts/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

DIR=${1:?specify directory of ubuntu docker dir}
export BUILDER_NAME=$(basename $DIR)
export DOCKERTAG=deltachat/desktop-$BUILDER_NAME

docker build -t $DOCKERTAG $DIR

# docker pull $DOCKERTAG

7 changes: 7 additions & 0 deletions ci_scripts/build-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#/bin/bash

DIR=${1:?specify directory of ubuntu docker dir}
export BUILDER_NAME=$(basename $DIR)
export DOCKERTAG=deltachat/desktop-$BUILDER_NAME

docker run -e BUILDER_NAME --rm -it -v "${PWD}:/build" -w /build-context $DOCKERTAG bash -i -c './build.sh'
38 changes: 38 additions & 0 deletions ci_scripts/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

version: 2
jobs:
ubu1604-rpgp:
machine: True
steps:
- checkout
- run:
command: ci_scripts/build-image.sh ci_scripts/ubuntu-16_04-rpgp
- run:
command: ci_scripts/build-package.sh ci_scripts/ubuntu-16_04-rpgp

ubu1804-rpgp:
machine: True
steps:
- checkout
- run:
command: ci_scripts/build-image.sh ci_scripts/ubuntu-18_04-rpgp
- run:
command: ci_scripts/build-package.sh ci_scripts/ubuntu-18_04-rpgp

ubu1810-rpgp:
machine: True
steps:
- checkout
- run:
command: ci_scripts/build-image.sh ci_scripts/ubuntu-18_10-rpgp
- run:
command: ci_scripts/build-package.sh ci_scripts/ubuntu-18_10-rpgp


workflows:
version: 2
build_all:
jobs:
- ubu1604-rpgp
- ubu1804-rpgp
#- ubu1810-rpgp
62 changes: 62 additions & 0 deletions ci_scripts/ubuntu-16_04-rpgp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM ubuntu:16.04

ENV BUILDER_NAME="ubuntu-16_04-rpgp"

# Update system
RUN true \
&& apt update \
&& apt -y upgrade

# Install nvm & node
RUN true \
&& apt -y install wget git \
&& wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash \
&& export NVM_DIR="$HOME/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& nvm install v10

# Install @sqdependencies to build deltachat-core
RUN apt -y install g++- libssl-dev libsqlite3-dev libbz2-dev zlib1g-dev python3-dev unzip cmake pkg-config libsasl2-dev

# Install meson
RUN true \
&& apt -y install python3-pip python3.5 \
&& pip3 install meson

# Install ninja
RUN true \
&& apt install unzip \
&& wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& cp ninja /usr/bin

# Install dependencies for deltachat-node
RUN apt -y install python


# Install rust for rpgp
RUN true \
&& apt -y install curl \
&& curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2019-03-23 -y

ENV PATH=/root/.cargo/bin:$PATH

# Install rpgp
RUN true \
&& cd / \
&& git clone https://github.com/rpgp/rpgp.git

# As rpgp is currently a huge github repo, split built into two layers
RUN true \
&& cd /rpgp/pgp-ffi \
&& PREFIX=/opt/DeltaChat/rpgp make install


# Set the working directory to /app
WORKDIR /build-context

COPY . /build-context

RUN chmod +x /build-context/*.sh


44 changes: 44 additions & 0 deletions ci_scripts/ubuntu-16_04-rpgp/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"targets": [
{
"target_name": "deltachat",
"conditions": [
[ "OS == 'win'", {}],
[ "OS == 'linux'", {
"libraries": [
"-L/opt/DeltaChat/libdeltachat/lib/x86_64-linux-gnu/",
"-ldeltachat",
"-lpthread"
],
"cflags": [
"-std=gnu99",
"-I/opt/DeltaChat/libdeltachat/include",
]
}],
[ "OS == 'mac'", {
"libraries": [
"../deltachat-core/builddir/src/libdeltachat.a",
"/usr/local/Cellar/libetpan/1.9.2_1/lib/libetpan.a",
"../deltachat-core/builddir/libs/netpgp/libnetpgp.a",
"-framework CoreFoundation",
"-framework CoreServices",
"-framework Security",
"-lsasl2",
"-lssl",
"-lsqlite3",
"-lpthread"
]
}]
],
"sources": [
"./src/module.c",
"./src/eventqueue.c",
"./src/strtable.c"
],
"include_dirs": [
"deltachat-core/src",
"<!(node -e \"require('napi-macros')\")"
]
}
]
}
70 changes: 70 additions & 0 deletions ci_scripts/ubuntu-16_04-rpgp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

if [ -z ${BUILDER_NAME+x} ]; then
echo "Error: Environment variable BUILDER_NAME is unset. It should be set to
the first child folder name in \`/builder\` and is normally set in the Dockerfile
for this builder. Examples for values are \`ubuntu-16_04\` or \`ubunut-18_10-rpgp\`.";
exit 0
fi

# COMPILE DELTACHAT-CORE with RPGP
cd /
git clone https://github.com/deltachat/deltachat-core.git
cd deltachat-core/
PKG_CONFIG_PATH=/opt/DeltaChat/rpgp/lib/pkgconfig/ meson -Drpgp=true --prefix /opt/DeltaChat/libdeltachat builddir
cd builddir/
ninja install

# COMPILE DELTACHAT-NODE WITH OUR SELF COMPILED DELTACHAT-CORE
cd /
git clone https://github.com/deltachat/deltachat-node.git
cd /deltachat-node
npm install
rm -rf deltachat-core
cp -r /deltachat-core .

# COPY OVER MODIFIED BINDING.GYP
cp /build-context/binding.gyp . # replace build script with fixed for rpgp one
# rebuild bindings, for whatever reason we need to install node-gyp to make it
# work
npm install node-gyp
npx node-gyp rebuild

# BUILD DELTACHAT-DESKTOP
cd /build
rm -rf node_modules
npm install

# Replace deltachat-node with our manually compiled
rm -rf node_modules/deltachat-node
cp -r /deltachat-node node_modules

# Rebuild desktop
npm run build
npx electron-builder -c /build-context/electron-builder-ubuntu.json

# EXTRACT ALREADY BUILT .DEB
cd "/build/dist/$BUILDER_NAME"

# remove linux-unpacked files, we don't need them anymore
rm -rf linux-unpacked

NAME_DEB=`basename $(find ./ -maxdepth 1 -name *.deb -print -quit)`

mkdir -p extract/DEBIAN
dpkg-deb -x $NAME_DEB extract
dpkg-deb -e $NAME_DEB extract/DEBIAN

# Fix extracted contents
cp -r /opt/DeltaChat/rpgp extract/opt/DeltaChat
cp -r /opt/DeltaChat/libdeltachat extract/opt/DeltaChat
mv extract/opt/DeltaChat/deltachat-desktop extract/opt/DeltaChat/deltachat-desktop-electron
cp /build-context/deltachat-desktop extract/opt/DeltaChat

# Repack into .deb
rm $NAME_DEB
dpkg-deb -b extract $NAME_DEB

# Clean up extract folder
rm -rf extract

8 changes: 8 additions & 0 deletions ci_scripts/ubuntu-16_04-rpgp/deltachat-desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#/bin/bash

# Currently we rely on a wrapper script to preload bundled
# libdeltachat because of rpgp.
# ToDo: Open issue for this on -core


LD_PRELOAD="/opt/DeltaChat/libdeltachat/lib/x86_64-linux-gnu/libdeltachat.so" /opt/DeltaChat/deltachat-desktop-electron
29 changes: 29 additions & 0 deletions ci_scripts/ubuntu-16_04-rpgp/electron-builder-ubuntu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"appId": "com.deltachat.desktop",
"linux": {
"artifactName": "${productName}-${env.BUILDER_NAME}-${version}.${ext}",
"target": [
"deb"
],
"category": "Utility",
"depends": [
"libsasl2-2",
"libssl1.0.0",
"libsqlite3-0"
]
},
"files": [
"!node_modules/deltachat-node/deltachat-core${/*}",
"!**/*",
"node_modules",
"_locales/*.json",
"index.js",
"src",
"!src/renderer",
"static",
"images"
],
"directories": {
"output": "dist/${env.BUILDER_NAME}"
}
}
39 changes: 39 additions & 0 deletions ci_scripts/ubuntu-16_04/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:xenial

RUN true \
&& echo $DOCKERTAG

# Update system
RUN true \
&& apt update
# && apt -y upgrade

# Install nvm & node
RUN true \
&& apt -y install wget git \
&& wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash \
&& export NVM_DIR="$HOME/.nvm" \
&& [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& nvm install v10

# Install @sqdependencies to build deltachat-core
RUN apt -y install g++- libssl-dev libsqlite3-dev libbz2-dev zlib1g-dev python3.5-dev python-software-properties unzip cmake pkg-config libsasl2-dev

# Install meson
RUN true \
&& apt -y install python3-pip python3.5 \
&& pip3 install meson

# Install ninja
RUN true \
&& apt install unzip \
&& wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& cp ninja /usr/bin

# Set the working directory to /app
WORKDIR /build-context

COPY . /build-context

RUN chmod +x /build-context/*.sh
6 changes: 6 additions & 0 deletions ci_scripts/ubuntu-16_04/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
cd /build
rm -rf node_modules
npm install --build-from-source
npm run build
npx electron-builder -c /build-context/electron-builder-ubuntu.json
29 changes: 29 additions & 0 deletions ci_scripts/ubuntu-16_04/electron-builder-ubuntu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"appId": "com.deltachat.desktop",
"linux": {
"artifactName": "${productName}-ubuntu-16_04-${version}.${ext}",
"target": [
"deb"
],
"category": "Utility",
"depends": [
"libsasl2-2",
"libssl1.0.0",
"libsqlite3-0"
]
},
"files": [
"!node_modules/deltachat-node/deltachat-core${/*}",
"!**/*",
"node_modules",
"_locales/*.json",
"index.js",
"src",
"!src/renderer",
"static",
"images"
],
"directories": {
"output": "dist/ubuntu-16_04"
}
}
Loading