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