Apply upstream patch fixing issue with go>=1.4. Fixes #558344
authorKacper Kowalik <xarthisius@gentoo.org>
Thu, 27 Aug 2015 15:42:07 +0000 (10:42 -0500)
committerKacper Kowalik <xarthisius@gentoo.org>
Thu, 27 Aug 2015 15:42:38 +0000 (10:42 -0500)
Package-Manager: portage-2.2.20

app-emulation/docker/docker-1.8.1.ebuild
app-emulation/docker/files/15404-fix-go14_15.patch [new file with mode: 0644]

index 0fea9a31ac7ee226c59382e2a4c29ab01139314d..73cc01d8a979b03abc03603580f8f2cef8dc4da4 100644 (file)
@@ -20,7 +20,7 @@ else
        [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
        inherit golang-vcs-snapshot
 fi
-inherit bash-completion-r1 linux-info multilib systemd udev user
+inherit eutils bash-completion-r1 linux-info multilib systemd udev user
 
 DESCRIPTION="Docker complements kernel namespacing with a high-level API which operates at the process level"
 HOMEPAGE="https://dockerproject.org"
@@ -170,6 +170,7 @@ pkg_setup() {
 
 src_prepare() {
        cd "src/${EGO_PN}" || die
+       epatch "${FILESDIR}"/15404-fix-go14_15.patch
        # allow user patches (use sparingly - upstream won't support them)
        epatch_user
 }
diff --git a/app-emulation/docker/files/15404-fix-go14_15.patch b/app-emulation/docker/files/15404-fix-go14_15.patch
new file mode 100644 (file)
index 0000000..7cda1f9
--- /dev/null
@@ -0,0 +1,85 @@
+From f83d05c3be3c3bcc84f6fa229504848ee8078321 Mon Sep 17 00:00:00 2001
+From: Vincent Batts <vbatts@redhat.com>
+Date: Fri, 7 Aug 2015 10:18:20 -0400
+Subject: [PATCH] devicemapper: fix zero-sized field access
+
+Fixes: #15279
+
+Due to
+https://github.com/golang/go/commit/7904946eeb35faece61bbf6f5b3cc8be2f519c17
+the devices field is dropped.
+
+This solution works on go1.4 and go1.5
+
+Signed-off-by: Vincent Batts <vbatts@redhat.com>
+---
+ daemon/graphdriver/devmapper/deviceset.go | 14 +++++++++-----
+ pkg/devicemapper/devmapper_wrapper.go     | 18 +++++++++++++++---
+ 2 files changed, 24 insertions(+), 8 deletions(-)
+
+diff --git a/daemon/graphdriver/devmapper/deviceset.go b/daemon/graphdriver/devmapper/deviceset.go
+index 6dddeb1..97e2032 100644
+--- a/daemon/graphdriver/devmapper/deviceset.go
++++ b/daemon/graphdriver/devmapper/deviceset.go
+@@ -1509,12 +1509,16 @@ func (devices *DeviceSet) deactivatePool() error {
+       if err != nil {
+               return err
+       }
+-      if d, err := devicemapper.GetDeps(devname); err == nil {
+-              // Access to more Debug output
+-              logrus.Debugf("[devmapper] devicemapper.GetDeps() %s: %#v", devname, d)
++
++      if devinfo.Exists == 0 {
++              return nil
+       }
+-      if devinfo.Exists != 0 {
+-              return devicemapper.RemoveDevice(devname)
++      if err := devicemapper.RemoveDevice(devname); err != nil {
++              return err
++      }
++
++      if d, err := devicemapper.GetDeps(devname); err == nil {
++              logrus.Warnf("[devmapper] device %s still has %d active dependents", devname, d.Count)
+       }
+       return nil
+diff --git a/pkg/devicemapper/devmapper_wrapper.go b/pkg/devicemapper/devmapper_wrapper.go
+index 87c2003..44ca772 100644
+--- a/pkg/devicemapper/devmapper_wrapper.go
++++ b/pkg/devicemapper/devmapper_wrapper.go
+@@ -38,7 +38,10 @@ static void log_with_errno_init()
+ */
+ import "C"
+-import "unsafe"
++import (
++      "reflect"
++      "unsafe"
++)
+ type (
+       CDmTask C.struct_dm_task
+@@ -184,12 +187,21 @@ func dmTaskGetDepsFct(task *CDmTask) *Deps {
+       if Cdeps == nil {
+               return nil
+       }
++
++      // golang issue: https://github.com/golang/go/issues/11925
++      hdr := reflect.SliceHeader{
++              Data: uintptr(unsafe.Pointer(uintptr(unsafe.Pointer(Cdeps)) + unsafe.Sizeof(*Cdeps))),
++              Len:  int(Cdeps.count),
++              Cap:  int(Cdeps.count),
++      }
++      devices := *(*[]C.uint64_t)(unsafe.Pointer(&hdr))
++
+       deps := &Deps{
+               Count:  uint32(Cdeps.count),
+               Filler: uint32(Cdeps.filler),
+       }
+-      for _, device := range Cdeps.device {
+-              deps.Device = append(deps.Device, (uint64)(device))
++      for _, device := range devices {
++              deps.Device = append(deps.Device, uint64(device))
+       }
+       return deps
+ }