##// END OF EJS Templates
packaging: consistently create build user in Dockerfiles...
Gregory Szorc -
r38475:11eda1f1 default
parent child Browse files
Show More
@@ -1,23 +1,27 b''
1 1 FROM centos:centos5
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN \
3 7 sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo && \
4 8 sed -i 's/^#\(baseurl=\)http:\/\/mirror.centos.org\/centos/\1http:\/\/vault.centos.org/' /etc/yum.repos.d/*.repo && \
5 9 sed -i 's/\$releasever/5.11/' /etc/yum.repos.d/*.repo
6 10
7 11 RUN yum install -y \
8 12 gcc \
9 13 gettext \
10 14 make \
11 15 python-devel \
12 16 python-docutils \
13 17 rpm-build \
14 18 tar
15 19
16 20 # For creating repo meta data
17 21 RUN yum install -y \
18 22 bzip2-devel \
19 23 createrepo \
20 24 ncurses-devel \
21 25 openssl-devel \
22 26 readline-devel \
23 27 zlib-devel
@@ -1,20 +1,24 b''
1 1 FROM centos:centos6
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN yum install -y \
3 7 gcc \
4 8 gettext \
5 9 make \
6 10 python-devel \
7 11 python-docutils \
8 12 rpm-build \
9 13 tar
10 14
11 15 # For creating repo meta data
12 16 RUN yum install -y createrepo
13 17
14 18 # For python
15 19 RUN yum install -y \
16 20 bzip2-devel \
17 21 ncurses-devel \
18 22 openssl-devel \
19 23 readline-devel \
20 24 zlib-devel
@@ -1,12 +1,16 b''
1 1 FROM centos:centos7
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN yum install -y \
3 7 gcc \
4 8 gettext \
5 9 make \
6 10 python-devel \
7 11 python-docutils \
8 12 rpm-build \
9 13 tar
10 14
11 15 # For creating repo meta data
12 16 RUN yum install -y createrepo
@@ -1,12 +1,16 b''
1 1 FROM debian:__CODENAME__
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN apt-get update && apt-get install -y \
3 7 build-essential \
4 8 debhelper \
5 9 devscripts \
6 10 dh-python \
7 11 less \
8 12 python \
9 13 python-all-dev \
10 14 python-docutils \
11 15 unzip \
12 16 zip
@@ -1,11 +1,15 b''
1 1 FROM fedora:20
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN yum install -y \
3 7 gcc \
4 8 gettext \
5 9 make \
6 10 python-devel \
7 11 python-docutils \
8 12 rpm-build
9 13
10 14 # For creating repo meta data
11 15 RUN yum install -y createrepo
@@ -1,11 +1,15 b''
1 1 FROM fedora:21
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN yum install -y \
3 7 gcc \
4 8 gettext \
5 9 make \
6 10 python-devel \
7 11 python-docutils \
8 12 rpm-build
9 13
10 14 # For creating repo meta data
11 15 RUN yum install -y createrepo
@@ -1,12 +1,16 b''
1 1 FROM ubuntu:__CODENAME__
2
3 RUN groupadd -g 1000 build && \
4 useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
5
2 6 RUN apt-get update && apt-get install -y \
3 7 build-essential \
4 8 debhelper \
5 9 devscripts \
6 10 dh-python \
7 11 less \
8 12 python \
9 13 python-all-dev \
10 14 python-docutils \
11 15 unzip \
12 16 zip
@@ -1,35 +1,37 b''
1 1 #!/bin/bash -eu
2 2
3 3 . $(dirname $0)/dockerlib.sh
4 4 . $(dirname $0)/packagelib.sh
5 5
6 6 BUILDDIR=$(dirname $0)
7 7 export ROOTDIR=$(cd $BUILDDIR/../.. > /dev/null; pwd)
8 8
9 9 checkdocker
10 10
11 11 DISTID="$1"
12 12 CODENAME="$2"
13 13 PLATFORM="$1-$2"
14 14 shift; shift # extra params are passed to build process
15 15
16 16 OUTPUTDIR=${OUTPUTDIR:=$ROOTDIR/packages/$PLATFORM}
17 17
18 18 initcontainer $PLATFORM
19 19
20 20 # debuild only appears to be able to save built debs etc to .., so we
21 21 # have to share the .. of the current directory with the docker
22 22 # container and hope it's writable. Whee.
23 23 dn=$(basename $ROOTDIR)
24 24
25 DBUILDUSER=build
26
25 27 if [ $(uname) = "Darwin" ] ; then
26 28 $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
27 29 sh -c "cd /mnt/$dn && make clean && make local"
28 30 fi
29 31 $DOCKER run -u $DBUILDUSER --rm -v $ROOTDIR/..:/mnt $CONTAINER \
30 32 sh -c "cd /mnt/$dn && DEB_BUILD_OPTIONS='${DEB_BUILD_OPTIONS:=}' contrib/packaging/builddeb --build --distid $DISTID --codename $CODENAME $@"
31 33 contrib/packaging/builddeb --cleanup --distid $DISTID --codename $CODENAME
32 34 if [ $(uname) = "Darwin" ] ; then
33 35 $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
34 36 sh -c "cd /mnt/$dn && make clean"
35 37 fi
@@ -1,42 +1,30 b''
1 1 #!/bin/sh -eu
2 2
3 3 # This function exists to set up the DOCKER variable and verify that
4 4 # it's the binary we expect. It also verifies that the docker service
5 5 # is running on the system and we can talk to it.
6 6 function checkdocker() {
7 7 if which docker.io >> /dev/null 2>&1 ; then
8 8 DOCKER=docker.io
9 9 elif which docker >> /dev/null 2>&1 ; then
10 10 DOCKER=docker
11 11 else
12 12 echo "Error: docker must be installed"
13 13 exit 1
14 14 fi
15 15
16 16 $DOCKER -h 2> /dev/null | grep -q Jansens && { echo "Error: $DOCKER is the Docking System Tray - install docker.io instead"; exit 1; }
17 17 $DOCKER version | grep -Eq "^Client( version)?:" || { echo "Error: unexpected output from \"$DOCKER version\""; exit 1; }
18 18 $DOCKER version | grep -Eq "^Server( version)?:" || { echo "Error: could not get docker server version - check it is running and your permissions"; exit 1; }
19 19 }
20 20
21 21 # Construct a container and leave its name in $CONTAINER for future use.
22 22 function initcontainer() {
23 23 [ "$1" ] || { echo "Error: platform name must be specified"; exit 1; }
24 24
25 25 DFILE="$ROOTDIR/contrib/packaging/docker/$1"
26 26 [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; }
27 27
28 28 CONTAINER="hg-dockerrpm-$1"
29 DBUILDUSER=build
30 (
31 cat $DFILE
32 if [ $(uname) = "Darwin" ] ; then
33 # The builder is using boot2docker on OS X, so we're going to
34 # *guess* the uid of the user inside the VM that is actually
35 # running docker. This is *very likely* to fail at some point.
36 echo RUN useradd $DBUILDUSER -u 1000
37 else
38 echo RUN groupadd $DBUILDUSER -g `id -g` -o
39 echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER -o
40 fi
41 ) | $DOCKER build --build-arg http_proxy --build-arg https_proxy --tag $CONTAINER -
29 cat $DFILE | $DOCKER build --build-arg http_proxy --build-arg https_proxy --tag $CONTAINER -
42 30 }
@@ -1,37 +1,39 b''
1 1 #!/bin/bash -e
2 2
3 3 . $(dirname $0)/dockerlib.sh
4 4
5 5 BUILDDIR=$(dirname $0)
6 6 export ROOTDIR=$(cd $BUILDDIR/../..; pwd)
7 7
8 8 checkdocker
9 9
10 10 PLATFORM="$1"
11 11 shift # extra params are passed to buildrpm
12 12
13 13 initcontainer $PLATFORM
14 14
15 15 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
16 16 $ROOTDIR/contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
17 17
18 18 DSHARED=/mnt/shared
19 DBUILDUSER=build
20
19 21 $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
20 22 rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean
21 23
22 24 $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
23 25 createrepo $DSHARED
24 26
25 27 cat << EOF > $RPMBUILDDIR/mercurial.repo
26 28 # Place this file in /etc/yum.repos.d/mercurial.repo
27 29 [mercurial]
28 30 name=Mercurial packages for $PLATFORM
29 31 # baseurl=file://$RPMBUILDDIR/
30 32 baseurl=http://hg.example.com/build/$PLATFORM/
31 33 skip_if_unavailable=True
32 34 gpgcheck=0
33 35 enabled=1
34 36 EOF
35 37
36 38 echo
37 39 echo "Build complete - results can be found in $RPMBUILDDIR"
General Comments 0
You need to be logged in to leave comments. Login now