Yocto 2.3

Move OpenBMC to Yocto 2.3(pyro).

Tested: Built and verified Witherspoon and Palmetto images
Change-Id: I50744030e771f4850afc2a93a10d3507e76d36bc
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Resolves: openbmc/openbmc#2461
diff --git a/import-layers/meta-virtualization/recipes-containers/docker/docker_git.bb b/import-layers/meta-virtualization/recipes-containers/docker/docker_git.bb
index 04dc76d..74170cb 100644
--- a/import-layers/meta-virtualization/recipes-containers/docker/docker_git.bb
+++ b/import-layers/meta-virtualization/recipes-containers/docker/docker_git.bb
@@ -18,12 +18,14 @@
  subtle and/or glaring issues. \
  "
 
-SRCREV = "7392c3b0ce0f9d3e918a321c66668c5d1ef4f689"
+SRCREV_docker = "49bf474f9ed7ce7143a59d1964ff7b7fd9b52178"
+SRCREV_libnetwork="0f534354b813003a754606689722fe253101bc4e"
 SRC_URI = "\
-	git://github.com/docker/docker.git;nobranch=1 \
-	file://docker.service \
+	git://github.com/docker/docker.git;nobranch=1;name=docker \
+	git://github.com/docker/libnetwork.git;branch=master;name=libnetwork;destsuffix=libnetwork \
 	file://docker.init \
 	file://hi.Dockerfile \
+	file://context-use-golang.org-x-net-pkg-until-we-move-to-go.patch \
 	"
 
 # Apache-2.0 for docker
@@ -32,11 +34,10 @@
 
 S = "${WORKDIR}/git"
 
-DOCKER_VERSION = "1.12.5"
-PV = "${DOCKER_VERSION}+git${SRCREV}"
+DOCKER_VERSION = "1.13.0"
+PV = "${DOCKER_VERSION}+git${SRCREV_docker}"
 
 DEPENDS = " \
-    go-cross \
     go-cli \
     go-pty \
     go-context \
@@ -50,45 +51,32 @@
     go-systemd \
     btrfs-tools \
     sqlite3 \
-    go-distribution-digest \
+    go-distribution \
+    compose-file \
+    go-connections \
+    notary \
+    grpc-go \
     "
 
-DEPENDS_append_class-target = "lvm2"
+PACKAGES =+ "${PN}-contrib"
+
+DEPENDS_append_class-target = " lvm2"
 RDEPENDS_${PN} = "curl aufs-util git util-linux iptables \
                   ${@bb.utils.contains('DISTRO_FEATURES','systemd','','cgroup-lite',d)} \
                  "
-RDEPENDS_${PN} += "containerd runc"
+RDEPENDS_${PN} += "virtual/containerd virtual/runc"
+
 RRECOMMENDS_${PN} = "kernel-module-dm-thin-pool kernel-module-nf-nat"
-RSUGGESTS_${PN} = "lxc docker-registry rt-tests"
+RSUGGESTS_${PN} = "lxc rt-tests"
 DOCKER_PKG="github.com/docker/docker"
 
+inherit systemd update-rc.d
+inherit go
+inherit goarch
+
 do_configure[noexec] = "1"
 
 do_compile() {
-	case "${TARGET_ARCH}" in
-		arm)
-			GOARCH=arm
-			case "${TUNE_PKGARCH}" in
-				cortexa*)
-					export GOARM=7
-				;;
-			esac
-		;;
-		aarch64)
-			GOARCH=arm64
-		;;
-		i586|i686)
-			GOARCH=386
-		;;
-		x86_64)
-			GOARCH=amd64
-		;;
-		*)
-			GOARCH="${TARGET_ARCH}"
-		;;
-	esac
-	export GOARCH
-
 	# Set GOPATH. See 'PACKAGERS.md'. Don't rely on
 	# docker to download its dependencies but rather
 	# use dependencies packaged independently.
@@ -96,6 +84,10 @@
 	rm -rf .gopath
 	mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
 	ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
+
+	mkdir -p .gopath/src/github.com/docker
+	ln -sf ../../../../../libnetwork .gopath/src/github.com/docker/libnetwork
+
 	export GOPATH="${S}/.gopath:${S}/vendor:${STAGING_DIR_TARGET}/${prefix}/local/go"
 	export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
 	cd -
@@ -113,42 +105,50 @@
 	# to build this:
 	DOCKER_GITCOMMIT="${SRCREV}" \
 	  ./hack/make.sh dynbinary
-}
 
-inherit systemd update-rc.d
+	# build the proxy
+	go build -o ${S}/docker-proxy github.com/docker/libnetwork/cmd/proxy
+}
 
 SYSTEMD_PACKAGES = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
 SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','docker.service','',d)}"
 
+SYSTEMD_AUTO_ENABLE_${PN} = "enable"
+
 INITSCRIPT_PACKAGES += "${@bb.utils.contains('DISTRO_FEATURES','sysvinit','${PN}','',d)}"
 INITSCRIPT_NAME_${PN} = "${@bb.utils.contains('DISTRO_FEATURES','sysvinit','docker.init','',d)}"
-INITSCRIPT_PARAMS_${PN} = "defaults"
+INITSCRIPT_PARAMS_${PN} = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
 
 do_install() {
 	mkdir -p ${D}/${bindir}
 	cp ${S}/bundles/latest/dynbinary-client/docker ${D}/${bindir}/docker
 	cp ${S}/bundles/latest/dynbinary-daemon/dockerd ${D}/${bindir}/dockerd
-	cp ${S}/bundles/latest/dynbinary-daemon/docker-proxy ${D}/${bindir}/docker-proxy
+	cp ${S}/docker-proxy ${D}/${bindir}/docker-proxy
 
 	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
 		install -d ${D}${systemd_unitdir}/system
 		install -m 644 ${S}/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
 		# replaces one copied from above with one that uses the local registry for a mirror
-		install -m 644 ${WORKDIR}/docker.service ${D}/${systemd_unitdir}/system
+		install -m 644 ${S}/contrib/init/systemd/docker.service ${D}/${systemd_unitdir}/system
 	else
 		install -d ${D}${sysconfdir}/init.d
 		install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
 	fi
 
-	mkdir -p ${D}/usr/share/docker/
-	cp ${WORKDIR}/hi.Dockerfile ${D}/usr/share/docker/
+	mkdir -p ${D}${datadir}/docker/
+	cp ${WORKDIR}/hi.Dockerfile ${D}${datadir}/docker/
+	install -m 0755 ${S}/contrib/check-config.sh ${D}${datadir}/docker/
 }
 
 inherit useradd
 USERADD_PACKAGES = "${PN}"
 GROUPADD_PARAM_${PN} = "-r docker"
 
-FILES_${PN} += "/lib/systemd/system/*"
+FILES_${PN} += "${systemd_unitdir}/system/*"
+
+FILES_${PN}-contrib += "${datadir}/docker/check-config.sh"
+RDEPENDS_${PN}-contrib += "bash"
 
 # DO NOT STRIP docker
 INHIBIT_PACKAGE_STRIP = "1"
+INSANE_SKIP_${PN} += "ldflags"
diff --git a/import-layers/meta-virtualization/recipes-containers/docker/files/context-use-golang.org-x-net-pkg-until-we-move-to-go.patch b/import-layers/meta-virtualization/recipes-containers/docker/files/context-use-golang.org-x-net-pkg-until-we-move-to-go.patch
new file mode 100644
index 0000000..240b744
--- /dev/null
+++ b/import-layers/meta-virtualization/recipes-containers/docker/files/context-use-golang.org-x-net-pkg-until-we-move-to-go.patch
@@ -0,0 +1,116 @@
+From de69555afaf05efcdeea7b7c20c6f7b12f3e1bac Mon Sep 17 00:00:00 2001
+From: Mark Asselstine <mark.asselstine@windriver.com>
+Date: Fri, 20 Jan 2017 11:58:44 -0500
+Subject: [PATCH] context: use golang.org/x/net pkg until we move to go 1.7
+
+In go 1.6 the context.go is not yet integrated and as such we will get
+build errors like:
+
+walwrap.go:4:2: cannot find package "context" in any of:
+...
+
+Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
+---
+ client/README.md                                                        | 2 +-
+ client/client.go                                                        | 2 +-
+ daemon/info_unix.go                                                     | 2 +-
+ integration-cli/docker_api_attach_test.go                               | 2 +-
+ integration-cli/docker_cli_save_load_unix_test.go                       | 2 +-
+ vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go     | 2 +-
+ vendor/github.com/docker/swarmkit/manager/state/raft/storage/walwrap.go | 2 +-
+ 7 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/client/README.md b/client/README.md
+index 059dfb3..9de54aa 100644
+--- a/client/README.md
++++ b/client/README.md
+@@ -8,7 +8,7 @@ For example, to list running containers (the equivalent of `docker ps`):
+ package main
+ 
+ import (
+-	"context"
++	"golang.org/x/net/context"
+ 	"fmt"
+ 
+ 	"github.com/docker/docker/api/types"
+diff --git a/client/client.go b/client/client.go
+index a9bdab6..95933af 100644
+--- a/client/client.go
++++ b/client/client.go
+@@ -19,7 +19,7 @@ For example, to list running containers (the equivalent of "docker ps"):
+ 	package main
+ 
+ 	import (
+-		"context"
++		"golang.org/x/net/context"
+ 		"fmt"
+ 
+ 		"github.com/docker/docker/api/types"
+diff --git a/daemon/info_unix.go b/daemon/info_unix.go
+index 9c41c0e..57f8a7b 100644
+--- a/daemon/info_unix.go
++++ b/daemon/info_unix.go
+@@ -3,7 +3,7 @@
+ package daemon
+ 
+ import (
+-	"context"
++	"golang.org/x/net/context"
+ 	"os/exec"
+ 	"strings"
+ 
+diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go
+index d43bf3a..e5802a7 100644
+--- a/integration-cli/docker_api_attach_test.go
++++ b/integration-cli/docker_api_attach_test.go
+@@ -3,7 +3,7 @@ package main
+ import (
+ 	"bufio"
+ 	"bytes"
+-	"context"
++	"golang.org/x/net/context"
+ 	"io"
+ 	"net"
+ 	"net/http"
+diff --git a/integration-cli/docker_cli_save_load_unix_test.go b/integration-cli/docker_cli_save_load_unix_test.go
+index 22445e5..d0afc8c 100644
+--- a/integration-cli/docker_cli_save_load_unix_test.go
++++ b/integration-cli/docker_cli_save_load_unix_test.go
+@@ -3,7 +3,7 @@
+ package main
+ 
+ import (
+-	"context"
++	"golang.org/x/net/context"
+ 	"fmt"
+ 	"io/ioutil"
+ 	"os"
+diff --git a/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go b/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go
+index 6b3295a..cbfcf7e 100644
+--- a/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go
++++ b/vendor/github.com/docker/swarmkit/manager/logbroker/subscription.go
+@@ -1,7 +1,7 @@
+ package logbroker
+ 
+ import (
+-	"context"
++	"golang.org/x/net/context"
+ 	"fmt"
+ 	"strings"
+ 	"sync"
+diff --git a/vendor/github.com/docker/swarmkit/manager/state/raft/storage/walwrap.go b/vendor/github.com/docker/swarmkit/manager/state/raft/storage/walwrap.go
+index 5a6c71a..efe5921 100644
+--- a/vendor/github.com/docker/swarmkit/manager/state/raft/storage/walwrap.go
++++ b/vendor/github.com/docker/swarmkit/manager/state/raft/storage/walwrap.go
+@@ -1,7 +1,7 @@
+ package storage
+ 
+ import (
+-	"context"
++	"golang.org/x/net/context"
+ 	"io"
+ 	"io/ioutil"
+ 	"os"
+-- 
+2.7.4
+
diff --git a/import-layers/meta-virtualization/recipes-containers/docker/files/docker-registry.service b/import-layers/meta-virtualization/recipes-containers/docker/files/docker-registry.service
new file mode 100644
index 0000000..7b4bc46
--- /dev/null
+++ b/import-layers/meta-virtualization/recipes-containers/docker/files/docker-registry.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=docker private registry service
+After=docker.service
+
+[Service]
+ExecStartPre=-/usr/bin/docker kill registry
+ExecStartPre=-/usr/bin/docker rm registry
+ExecStart=/usr/bin/docker run --name registry -v /mirror/registry:/tmp/ -p 5000:5000 \
+                          -e "STANDALONE=true" \
+                          -e "MIRROR_SOURCE=https://registry-1.docker.io" \
+                          -e "MIRROR_SOURCE_INDEX=https://index.docker.io" \
+                          -e "SETTINGS_FLAVOR=local" \
+                          registry
+ExecStop=-/usr/bin/docker stop registry
+Restart=always
+RestartSec=10s
+
+[Install]
+WantedBy=multi-user.target
diff --git a/import-layers/meta-virtualization/recipes-containers/docker/files/docker.init b/import-layers/meta-virtualization/recipes-containers/docker/files/docker.init
index 2e8eb9e..9c01c75 100644
--- a/import-layers/meta-virtualization/recipes-containers/docker/files/docker.init
+++ b/import-layers/meta-virtualization/recipes-containers/docker/files/docker.init
@@ -28,7 +28,6 @@
 pidfile="/var/run/$prog.pid"
 lockfile="/var/lock/subsys/$prog"
 logfile="/var/log/$prog"
-other_args="--registry-mirror=http://localhost:5000 --insecure-registry=http://localhost:5000 --raw-logs"
 
 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
@@ -39,8 +38,8 @@
 
     if ! [ -f $pidfile ]; then
         printf "Starting $prog:\t"
-        echo -e "\n$(date)\n" >> $logfile
-        "$unshare" -m -- $exec daemon $other_args &>> $logfile &
+        echo "\n$(date)\n" >> $logfile
+        "$unshare" -m -- $exec -d $other_args &>> $logfile &
         pid=$!
         touch $lockfile
         # wait up to 10 seconds for the pidfile to exist.  see