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

login
register
mail settings
Submitter Augie Fackler
Date May 8, 2015, 5:10 p.m.
Message ID <0232c9960ca7e5506ab1.1431105006@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8974/
State Accepted
Headers show

Comments

Augie Fackler - May 8, 2015, 5:10 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.
Pierre-Yves David - May 8, 2015, 9:08 p.m.
On 05/08/2015 10:10 AM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@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.

These first 3 are pushed to the clowncopter. I've troubled with the next 
3. (more details coming)

Patch

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 -
 }