Debian Codegraph @

contrib/gitian/dockrun.sh

raw symbols SCIP
1 #!/bin/sh
2
3 if [ $# -ne 1 ]; then
4 echo "usage: $0 <version>"
5 exit 1
6 fi
7 VERSION=$1
8
9 DOCKER=`command -v docker`
10 CACHER=`command -v apt-cacher-ng`
11
12 if [ -z "$DOCKER" -o -z "$CACHER" ]; then
13 echo "$0: you must first install docker.io and apt-cacher-ng"
14 echo " e.g. sudo apt-get install docker.io apt-cacher-ng"
15 exit 1
16 fi
17
18 GH_USER=${GH_USER-$USER}
19
20 TAG=gitrun-bionic
21 TAG2=base-bionic-amd64
22 IMAGE=`docker images | grep $TAG`
23
24 WORKDIR=/home/ubuntu
25
26 if [ -z "$IMAGE" ]; then
27 GID=`getent group docker`
28 mkdir -p docker
29 cd docker
30
31 # container for running gitian-build.py
32 cat <<EOF > ${TAG}.Dockerfile
33 FROM ubuntu:bionic
34
35 ENV DEBIAN_FRONTEND=noninteractive
36 RUN echo 'Acquire::http { Proxy "http://172.17.0.1:3142"; };' > /etc/apt/apt.conf.d/50cacher
37 RUN echo "$GID" >> /etc/group
38 RUN apt-get update && apt-get --no-install-recommends -y install lsb-release ruby git make wget docker.io python3 curl
39
40 RUN useradd -ms /bin/bash -U ubuntu -G docker
41 USER ubuntu:docker
42 WORKDIR $WORKDIR
43
44 RUN git clone https://github.com/monero-project/gitian.sigs.git sigs; \
45 git clone https://github.com/devrandom/gitian-builder.git builder; \
46 cd builder; git checkout c0f77ca018cb5332bfd595e0aff0468f77542c23; mkdir -p inputs var; cd inputs; \
47 git clone https://github.com/monero-project/monero
48
49 CMD ["sleep", "infinity"]
50 EOF
51
52 docker build --pull -f ${TAG}.Dockerfile -t $TAG .
53
54 cd ..
55 docker run -v /var/run/docker.sock:/var/run/docker.sock -d --name gitrun $TAG
56
57 fi
58
59 IMAGE=`docker images | grep $TAG2`
60 if [ -z "$IMAGE" ]; then
61 mkdir -p docker
62 cd docker
63
64 # container for actually running each build
65 cat <<EOF > ${TAG2}.Dockerfile
66 FROM ubuntu:bionic
67
68 ENV DEBIAN_FRONTEND=noninteractive
69 RUN echo 'Acquire::http { Proxy "http://172.17.0.1:3142"; };' > /etc/apt/apt.conf.d/50cacher
70 RUN apt-get update && apt-get --no-install-recommends -y install build-essential git language-pack-en \
71 wget lsb-release curl gcc-7 g++-7 gcc g++ binutils-gold pkg-config autoconf libtool automake faketime \
72 bsdmainutils ca-certificates python cmake gperf
73
74 RUN useradd -ms /bin/bash -U ubuntu
75 USER ubuntu:ubuntu
76 WORKDIR $WORKDIR
77
78 CMD ["sleep", "infinity"]
79 EOF
80
81 docker build --pull -f ${TAG2}.Dockerfile -t $TAG2 .
82
83 cd ..
84
85 fi
86
87 RUNNING=`docker ps | grep gitrun`
88 if [ -z "$RUNNING" ]; then
89 BUILT=`docker ps -a | grep gitrun`
90 if [ -z "$BUILT" ]; then
91 docker run -v /var/run/docker.sock:/var/run/docker.sock -d --name gitrun $TAG
92 else
93 docker start gitrun
94 fi
95 fi
96 docker cp gitian-build.py gitrun:$WORKDIR/
97 docker exec -t gitrun ./gitian-build.py -d -b -D -n $OPT $GH_USER $VERSION
98 RC=$?
99 if [ $RC != 0 ]; then
100 exit $RC
101 fi
102 echo "\nBuild Results:\n"
103 docker exec gitrun sh -c "sha256sum out/$VERSION/*"
104 echo "\nIf these results look correct, type \"sign\" to sign them, otherwise ^C to stop now."
105 read check
106 if [ "$check" != "sign" ]; then
107 echo "Not signing, bye."
108 exit 1
109 fi
110
111 if [ ! -d sigs ]; then
112 git clone https://github.com/monero-project/gitian.sigs.git sigs
113 cd sigs
114 git remote add $GH_USER [email protected]:$GH_USER/gitian.sigs.git
115 cd ..
116 fi
117
118 DIRS=`docker exec gitrun sh -c "echo sigs/$VERSION-*"`
119 for i in $DIRS; do
120 docker cp gitrun:$WORKDIR/$i sigs
121 gpg --detach-sign $i/$GH_USER/*.assert
122 done
123
124 cd sigs
125 git checkout -b $VERSION
126 git add $VERSION-*
127 git commit -S -m "Add $GH_USER $VERSION"
128 git push --set-upstream $GH_USER $VERSION