Build chain for deb packages

This commit is contained in:
Dennis Schwerdel 2019-03-01 16:37:43 +01:00
parent c5ba4b197b
commit 73fd3134a5
4 changed files with 62 additions and 0 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ deb/vpncloud/vpncloud
deb/vpncloud/vpncloud.1*
Stats.ods
dist
builder/cache

2
builder/.dockerignore Normal file
View File

@ -0,0 +1,2 @@
cache
build.sh

27
builder/Dockerfile-deb Normal file
View File

@ -0,0 +1,27 @@
FROM debian:stable
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl ruby-ronn build-essential gcc-arm-linux-gnueabihf libc6-dev-armhf-cross \
&& rm -rf /var/cache/dpkg
RUN useradd -ms /bin/bash user
USER user
WORKDIR /home/user
ENV RUST=1.32.0
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${RUST}
ENV PATH=/home/user/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN rustup target add i686-unknown-linux-gnu \
&& rustup target add armv7-unknown-linux-gnueabihf
RUN cargo install cargo-deb \
&& rm -rf /home/user/.cargo/{git,tmp,registry}
VOLUME /home/user/.cargo/tmp
VOLUME /home/user/.cargo/git
VOLUME /home/user/.cargo/registry

32
builder/build.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
function docker_cmd() {
DIST=$1
CMD=$2
docker run -it --rm -v $(pwd)/..:/home/user/code \
-v $CACHE/registry:/home/user/.cargo/registry \
-v $CACHE/git:/home/user/.cargo/git \
-v $CACHE/tmp:/home/user/.cargo/tmp \
vpncloud-builder-$DIST bash -c "$CMD"
}
set -e
cd $(dirname $0)
VERSION=$(grep -e '^version =' ../Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
mkdir -p cache/{git,tmp,registry}
CACHE=$(pwd)/cache
mkdir -p ../dist
docker build --rm -f=Dockerfile-deb -t vpncloud-builder-deb .
# x86_64 deb
docker_cmd deb 'cd code && cargo deb'
cp ../target/debian/vpncloud_${VERSION}_amd64.deb ../dist/vpncloud_${VERSION}_amd64.deb
# arm7hf deb
docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf'
cp ../target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${VERSION}_armhf.deb ../dist/vpncloud_${VERSION}_armhf.deb