Mercurial > hg
annotate contrib/dockerrpm @ 22443:d8818616c45e
docker: add CentOS 5
There is no official CentOS 5 docker template so we use one from saltstack.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 15 May 2014 01:48:37 +0200 |
parents | bb9a06d14857 |
children | 49ea49823769 |
rev | line source |
---|---|
22438
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
1 #!/bin/bash -e |
21255
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 |
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 BUILDDIR=$(dirname $0) |
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 ROOTDIR=$(cd $BUILDDIR/..; pwd) |
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 |
22438
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
6 if which docker.io >> /dev/null 2>&1 ; then |
21642
76a347bcdb33
docker: check for docker.io first
Matt Mackall <mpm@selenic.com>
parents:
21561
diff
changeset
|
7 DOCKER=docker.io |
22438
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
8 elif which docker >> /dev/null 2>&1 ; then |
21255
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 DOCKER=docker |
22438
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
10 else |
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
11 echo "Error: docker must be installed" |
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
12 exit 1 |
21255
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
13 fi |
62a2749895e4
build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 |
22438
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
15 $DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; } |
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
16 $DOCKER version | grep -q "^Client version:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; } |
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
17 $DOCKER version | grep -q "^Server version:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; } |
f5abb231b80a
dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents:
21642
diff
changeset
|
18 |
22439
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
19 PLATFORM="$1" |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
20 [ "$PLATFORM" ] || { echo "Error: platform name must be specified"; exit 1; } |
22443 | 21 shift # extra params are passed to buildrpm |
22439
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
22 |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
23 DFILE="$ROOTDIR/contrib/docker/$PLATFORM" |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
24 [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; } |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
25 |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
26 CONTAINER="hg-dockerrpm-$PLATFORM" |
d2a00ced3cce
dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents:
22438
diff
changeset
|
27 |
22440
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
28 DBUILDUSER=build |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
29 ( |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
30 cat $DFILE |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
31 echo RUN groupadd $DBUILDUSER -g `id -g` |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
32 echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
33 ) | $DOCKER build --tag $CONTAINER - |
cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents:
22439
diff
changeset
|
34 |
22441
bb9a06d14857
dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents:
22440
diff
changeset
|
35 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM |
22443 | 36 contrib/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $* |
22441
bb9a06d14857
dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents:
22440
diff
changeset
|
37 |
bb9a06d14857
dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents:
22440
diff
changeset
|
38 DSHARED=/mnt/shared |
bb9a06d14857
dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents:
22440
diff
changeset
|
39 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \ |
bb9a06d14857
dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents:
22440
diff
changeset
|
40 rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean |