Patchwork D3758: packaging: consistently create build user in Dockerfiles

login
register
mail settings
Submitter phabricator
Date June 25, 2018, 3:20 p.m.
Message ID <a6c8a0453c466066e31d2fe47665bb84@localhost.localdomain>
Download mbox | patch
Permalink /patch/32417/
State Not Applicable
Headers show

Comments

phabricator - June 25, 2018, 3:20 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11eda1f1b6e7: packaging: consistently create build user in Dockerfiles (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3758?vs=9110&id=9284

REVISION DETAIL
  https://phab.mercurial-scm.org/D3758

AFFECTED FILES
  contrib/packaging/docker/centos5
  contrib/packaging/docker/centos6
  contrib/packaging/docker/centos7
  contrib/packaging/docker/debian.template
  contrib/packaging/docker/fedora20
  contrib/packaging/docker/fedora21
  contrib/packaging/docker/ubuntu.template
  contrib/packaging/dockerdeb
  contrib/packaging/dockerlib.sh
  contrib/packaging/dockerrpm

CHANGE DETAILS




To: indygreg, #hg-reviewers, durin42
Cc: mercurial-devel

Patch

diff --git a/contrib/packaging/dockerrpm b/contrib/packaging/dockerrpm
--- a/contrib/packaging/dockerrpm
+++ b/contrib/packaging/dockerrpm
@@ -16,6 +16,8 @@ 
 $ROOTDIR/contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
 
 DSHARED=/mnt/shared
+DBUILDUSER=build
+
 $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
     rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean
 
diff --git a/contrib/packaging/dockerlib.sh b/contrib/packaging/dockerlib.sh
--- a/contrib/packaging/dockerlib.sh
+++ b/contrib/packaging/dockerlib.sh
@@ -26,17 +26,5 @@ 
   [ -f "$DFILE" ] || { echo "Error: docker file $DFILE not found"; exit 1; }
 
   CONTAINER="hg-dockerrpm-$1"
-  DBUILDUSER=build
-  (
-    cat $DFILE
-    if [ $(uname) = "Darwin" ] ; then
-        # The builder is using boot2docker on OS X, so we're going to
-        # *guess* the uid of the user inside the VM that is actually
-        # running docker. This is *very likely* to fail at some point.
-        echo RUN useradd $DBUILDUSER -u 1000
-    else
-        echo RUN groupadd $DBUILDUSER -g `id -g` -o
-        echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER -o
-    fi
-  ) | $DOCKER build --build-arg http_proxy --build-arg https_proxy --tag $CONTAINER -
+  cat $DFILE | $DOCKER build --build-arg http_proxy --build-arg https_proxy --tag $CONTAINER -
 }
diff --git a/contrib/packaging/dockerdeb b/contrib/packaging/dockerdeb
--- a/contrib/packaging/dockerdeb
+++ b/contrib/packaging/dockerdeb
@@ -22,6 +22,8 @@ 
 # container and hope it's writable. Whee.
 dn=$(basename $ROOTDIR)
 
+DBUILDUSER=build
+
 if [ $(uname) = "Darwin" ] ; then
     $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
             sh -c "cd /mnt/$dn && make clean && make local"
diff --git a/contrib/packaging/docker/ubuntu.template b/contrib/packaging/docker/ubuntu.template
--- a/contrib/packaging/docker/ubuntu.template
+++ b/contrib/packaging/docker/ubuntu.template
@@ -1,4 +1,8 @@ 
 FROM ubuntu:__CODENAME__
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN apt-get update && apt-get install -y \
   build-essential \
   debhelper \
diff --git a/contrib/packaging/docker/fedora21 b/contrib/packaging/docker/fedora21
--- a/contrib/packaging/docker/fedora21
+++ b/contrib/packaging/docker/fedora21
@@ -1,4 +1,8 @@ 
 FROM fedora:21
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN yum install -y \
 	gcc \
 	gettext \
diff --git a/contrib/packaging/docker/fedora20 b/contrib/packaging/docker/fedora20
--- a/contrib/packaging/docker/fedora20
+++ b/contrib/packaging/docker/fedora20
@@ -1,4 +1,8 @@ 
 FROM fedora:20
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN yum install -y \
 	gcc \
 	gettext \
diff --git a/contrib/packaging/docker/debian.template b/contrib/packaging/docker/debian.template
--- a/contrib/packaging/docker/debian.template
+++ b/contrib/packaging/docker/debian.template
@@ -1,4 +1,8 @@ 
 FROM debian:__CODENAME__
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN apt-get update && apt-get install -y \
   build-essential \
   debhelper \
diff --git a/contrib/packaging/docker/centos7 b/contrib/packaging/docker/centos7
--- a/contrib/packaging/docker/centos7
+++ b/contrib/packaging/docker/centos7
@@ -1,4 +1,8 @@ 
 FROM centos:centos7
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN yum install -y \
 	gcc \
 	gettext \
diff --git a/contrib/packaging/docker/centos6 b/contrib/packaging/docker/centos6
--- a/contrib/packaging/docker/centos6
+++ b/contrib/packaging/docker/centos6
@@ -1,4 +1,8 @@ 
 FROM centos:centos6
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN yum install -y \
 	gcc \
 	gettext \
diff --git a/contrib/packaging/docker/centos5 b/contrib/packaging/docker/centos5
--- a/contrib/packaging/docker/centos5
+++ b/contrib/packaging/docker/centos5
@@ -1,4 +1,8 @@ 
 FROM centos:centos5
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
 RUN \
 	sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/*.repo && \
 	sed -i 's/^#\(baseurl=\)http:\/\/mirror.centos.org\/centos/\1http:\/\/vault.centos.org/' /etc/yum.repos.d/*.repo && \