vpncloud/builder/build.sh

56 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2019-03-01 15:37:43 +00:00
#!/bin/bash
function docker_cmd() {
DIST=$1
CMD=$2
2020-01-25 12:54:44 +00:00
mkdir -p $CACHE/$DIST/{target,registry,git,tmp}
2019-03-01 15:37:43 +00:00
docker run -it --rm -v $(pwd)/..:/home/user/code \
2020-01-25 12:54:44 +00:00
-v $CACHE/$DIST/target:/home/user/code/target \
-v $CACHE/$DIST/registry:/home/user/.cargo/registry \
-v $CACHE/$DIST/git:/home/user/.cargo/git \
-v $CACHE/$DIST/tmp:/home/user/.cargo/tmp \
2019-03-01 15:37:43 +00:00
vpncloud-builder-$DIST bash -c "$CMD"
}
set -e
cd $(dirname $0)
VERSION=$(grep -e '^version =' ../Cargo.toml | sed -e 's/version = "\(.*\)"/\1/')
2020-10-09 20:46:44 +00:00
DEB_VERSION=$(echo "$VERSION" | sed -e 's/-/~/g')
if echo "$VERSION" | fgrep -q "-"; then
RPM_VERSION=$(echo "$VERSION" | sed -e 's/-/-0./g')
else
RPM_VERSION="$VERSION-1"
fi
2019-03-01 15:37:43 +00:00
2020-01-25 12:54:44 +00:00
mkdir -p cache/{rpm,deb}
2019-03-01 15:37:43 +00:00
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'
2020-10-09 20:46:44 +00:00
cp $CACHE/deb/target/debian/vpncloud_${DEB_VERSION}_amd64.deb ../dist/vpncloud_${DEB_VERSION}_amd64.deb
2019-03-01 15:37:43 +00:00
2020-02-20 21:52:40 +00:00
# i386 deb
docker_cmd deb 'cd code && cargo deb --target i686-unknown-linux-gnu'
2020-10-09 20:46:44 +00:00
cp $CACHE/deb/target/i686-unknown-linux-gnu/debian/vpncloud_${DEB_VERSION}_i386.deb ../dist/vpncloud_${DEB_VERSION}_i386.deb
2020-02-20 21:52:40 +00:00
2019-03-01 15:37:43 +00:00
# arm7hf deb
docker_cmd deb 'cd code && cargo deb --target armv7-unknown-linux-gnueabihf'
2020-10-09 20:46:44 +00:00
cp $CACHE/deb/target/armv7-unknown-linux-gnueabihf/debian/vpncloud_${DEB_VERSION}_armhf.deb ../dist/vpncloud_${DEB_VERSION}_armhf.deb
2019-03-02 00:12:42 +00:00
2020-01-24 13:26:23 +00:00
# aarch64 deb
docker_cmd deb 'cd code && cargo deb --target aarch64-unknown-linux-gnu'
2020-10-09 20:46:44 +00:00
cp $CACHE/deb/target/aarch64-unknown-linux-gnu/debian/vpncloud_${DEB_VERSION}_arm64.deb ../dist/vpncloud_${DEB_VERSION}_arm64.deb
2020-01-24 13:26:23 +00:00
2019-03-02 00:12:42 +00:00
docker build --rm -f=Dockerfile-rpm -t vpncloud-builder-rpm .
# x86_64 rpm
docker_cmd rpm 'cd code && cargo rpm build'
2020-10-09 20:46:44 +00:00
cp $CACHE/rpm/target/release/rpmbuild/RPMS/x86_64/vpncloud-${RPM_VERSION}.x86_64.rpm ../dist/vpncloud_${RPM_VERSION}.x86_64.rpm