]> git.pld-linux.org Git - projects/cleanbuild.git/blob - docker-builder.sh
_binary_payload w1.gzdio
[projects/cleanbuild.git] / docker-builder.sh
1 #!/bin/sh
2 set -e
3
4 package=$1
5
6 test -n "$package" || exit 1
7
8 dir=$(pwd)
9 image=registry.gitlab.com/pld-linux/cleanbuild
10 name=cleanbuild-$package
11 topdir=$dir/rpm
12 home=/home/services/builder
13 buildsize="4G"
14
15 # cleanup first
16 docker kill $name >/dev/null 2>&1 || :
17 docker rm $name >/dev/null 2>&1 || :
18
19 install -d $topdir/logs
20
21 # start the container
22 docker run --name=$name -d \
23         -v $topdir:$home/rpm \
24         -v $dir:$home/cleanbuild \
25         -v $dir/cache/poldek:/var/cache/poldek \
26         -v $dir/cache/ccache/$package:/home/services/builder/.ccache \
27         --tmpfs $home/rpm/BUILD:rw,exec,nosuid,size=$buildsize \
28         $image
29
30 # these paths need to be accessible for builder
31 docker exec --user=root $name chown builder:builder rpm/logs rpm/BUILD .ccache
32
33 # fetch sources and install deps
34 docker exec $name builder -g -R $package
35
36 # prevent network access like pld builders do
37 docker exec --user=root $name setfacl -m u:builder:--- /etc/resolv.conf
38
39 git_tag=$(GIT_DIR=$topdir/packages/$package/.git git describe --tags --always)
40 buildlog=rpm/logs/${git_tag#auto/*/}.log
41
42 # remove .la dependencies
43 docker exec $name cleanbuild/cleanup-la
44
45 while true; do
46         docker exec $name cleanbuild/teeboth $buildlog builder -nn -bb -R $package --define 'clean exit 0' && rc=$? || rc=$?
47
48         findbr=$package.findbr.log
49         builddir=$(docker exec $name sh -c 'test ! -d rpm/BUILD/* || echo rpm/BUILD/*')
50         if [ -z "$builddir" ]; then
51                 echo >&2 "No build dir. Build failed?"
52                 exit 6
53         fi
54         # need root to run poldek
55         docker exec --user=root $name cleanbuild/findbr $builddir $buildlog > $findbr
56
57         installed_something=false
58         while read pkg msg; do
59                 ./addbr rpm/packages/$package/$package.spec "$pkg" "$msg" || continue
60                 installed_something=true
61         done < $findbr
62         rm -f $findbr
63
64         # go for another try
65         $installed_something && continue
66
67         if [ $rc -eq 0 ]; then
68                 # finished ok, cleanup
69                 docker kill $name && docker rm $name || :
70         fi
71
72         # propagate error
73         exit $rc
74 done
This page took 0.052224 seconds and 3 git commands to generate.