[PATCH 3 of 6 packaging] dockerlib: fix initcontainer for boot2docker users

Augie Fackler raf at durin42.com
Fri May 8 17:10:06 UTC 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1430937377 14400
#      Wed May 06 14:36:17 2015 -0400
# Node ID 0232c9960ca7e5506ab1ec1c73e1c245de547edc
# Parent  3a363b17a66bb22e29513b12dea87275628c1416
dockerlib: fix initcontainer for boot2docker users

This allows me to build rpm packages using boot2docker on my Mac. It's
probably a very fragile hack, but it seems to work well enough for now
that I felt it was worth sharing.

diff --git a/contrib/dockerlib.sh b/contrib/dockerlib.sh
--- a/contrib/dockerlib.sh
+++ b/contrib/dockerlib.sh
@@ -29,7 +29,14 @@ function initcontainer() {
   DBUILDUSER=build
   (
     cat $DFILE
-    echo RUN groupadd $DBUILDUSER -g `id -g`
-    echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER
+    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`
+        echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER
+    fi
   ) | $DOCKER build --tag $CONTAINER -
 }



More information about the Mercurial-devel mailing list