-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·55 lines (40 loc) · 1.49 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
if [ -z "$1" ]
then
echo "No argument supplied, requires build version"
exit 1
fi
set -euo pipefail
distro=$1
path=`pwd`
echo "About to launch $distro container"
container="mjolnir-build-$RANDOM"
mkdir -p /tmp/$container
function finish {
echo "Cleaning up: ($?)!"
lxc delete -f $container
rm -rf /tmp/$container
echo "finished cleaning up"
}
trap finish EXIT
echo "Named container: $container"
lxc launch ubuntu:$distro --ephemeral $container > /dev/null
echo "Launched $container"
echo "Setting up /build"
lxc exec $container -- /bin/sh -c "/bin/mkdir -p /build"
echo "Pushing files into container"
tar --exclude-vcs --exclude=target -zcf - . | lxc exec --verbose $container -- /bin/sh -c "/bin/tar zxf - -C /build"
sleep 5
. scripts/deps.sh
deps $distro $container
echo "Installing cargo-deb"
lxc exec --verbose $container -- /bin/sh -c "/root/.cargo/bin/cargo install cargo-deb"
echo "Building deb"
lxc exec --verbose $container -- /bin/sh -c "cd /build; /root/.cargo/bin/cargo build --release --all"
lxc exec --verbose $container -- /bin/sh -c "cd /build; /root/.cargo/bin/cargo build --release --examples"
lxc exec --verbose $container -- /bin/sh -c "cd /build; /root/.cargo/bin/cargo deb --no-build"
echo "Pulling debs"
lxc file pull -r $container/build/target/debian /tmp/$container
cd /tmp/$container; find debian -regex ".*mjolnir_.*.deb" -exec rename "s/mjolnir_(.*).deb/$(echo $distro)_mjolnir_\$1.deb/g" {} \;
cp /tmp/$container/debian/*.deb $path
finish