annotate contrib/dockerrpm @ 24968:80c9e99d68e0

dockerlib: start extracting common functions for setting up docker I'm about to start interacting with docker for Debian packaging too, so it's time to centralize this so that any bugfixes I figure out apply to both codepaths.
author Augie Fackler <augie@google.com>
date Wed, 06 May 2015 10:45:07 -0400
parents 4c490626af13
children 227b9b2a57a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
24968
80c9e99d68e0 dockerlib: start extracting common functions for setting up docker
Augie Fackler <augie@google.com>
parents: 23124
diff changeset
3 . $(dirname $0)/dockerlib.sh
80c9e99d68e0 dockerlib: start extracting common functions for setting up docker
Augie Fackler <augie@google.com>
parents: 23124
diff changeset
4
21255
62a2749895e4 build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
5 BUILDDIR=$(dirname $0)
62a2749895e4 build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
6 ROOTDIR=$(cd $BUILDDIR/..; pwd)
62a2749895e4 build: initial support for in-tree autobuilding recipes
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
7
24968
80c9e99d68e0 dockerlib: start extracting common functions for setting up docker
Augie Fackler <augie@google.com>
parents: 23124
diff changeset
8 checkdocker
22438
f5abb231b80a dockerrpm: check that docker is running correctly before building
Mads Kiilerich <madski@unity3d.com>
parents: 21642
diff changeset
9
22439
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
10 PLATFORM="$1"
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
11 [ "$PLATFORM" ] || { echo "Error: platform name must be specified"; exit 1; }
22443
d8818616c45e docker: add CentOS 5
Mads Kiilerich <madski@unity3d.com>
parents: 22441
diff changeset
12 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
13
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
14 DFILE="$ROOTDIR/contrib/docker/$PLATFORM"
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
15 [ -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
16
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
17 CONTAINER="hg-dockerrpm-$PLATFORM"
d2a00ced3cce dockerrpm: better handling of specification of docker name
Mads Kiilerich <madski@unity3d.com>
parents: 22438
diff changeset
18
22440
cf7b5c011737 dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents: 22439
diff changeset
19 DBUILDUSER=build
cf7b5c011737 dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents: 22439
diff changeset
20 (
cf7b5c011737 dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents: 22439
diff changeset
21 cat $DFILE
cf7b5c011737 dockerrpm: run docker build process as the current user, not as root
Mads Kiilerich <madski@unity3d.com>
parents: 22439
diff changeset
22 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
23 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
24 ) | $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
25
22441
bb9a06d14857 dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents: 22440
diff changeset
26 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
22443
d8818616c45e docker: add CentOS 5
Mads Kiilerich <madski@unity3d.com>
parents: 22441
diff changeset
27 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
28
bb9a06d14857 dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents: 22440
diff changeset
29 DSHARED=/mnt/shared
bb9a06d14857 dockerrpm: prepare source outside docker and just run rpmbuild inside docker
Mads Kiilerich <madski@unity3d.com>
parents: 22440
diff changeset
30 $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
31 rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean
22444
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
32
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
33 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
34 createrepo $DSHARED
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
35
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
36 cat << EOF > $RPMBUILDDIR/mercurial.repo
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
37 # Place this file in /etc/yum.repos.d/mercurial.repo
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
38 [mercurial]
23124
4c490626af13 buildrpm: fix use of invalid $PLATFORM in mercurial.repo
Mads Kiilerich <madski@unity3d.com>
parents: 22444
diff changeset
39 name=Mercurial packages for $PLATFORM
22444
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
40 # baseurl=file://$RPMBUILDDIR/
23124
4c490626af13 buildrpm: fix use of invalid $PLATFORM in mercurial.repo
Mads Kiilerich <madski@unity3d.com>
parents: 22444
diff changeset
41 baseurl=http://hg.example.com/build/$PLATFORM/
22444
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
42 skip_if_unavailable=True
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
43 gpgcheck=0
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
44 enabled=1
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
45 EOF
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
46
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
47 echo
49ea49823769 dockerrpm: create a yum/dnf repo from the generated rpms
Mads Kiilerich <madski@unity3d.com>
parents: 22443
diff changeset
48 echo "Build complete - results can be found in $RPMBUILDDIR"