[meta-virtualization] [m-c-s][PATCH 2/6] consul: consule-migrate: move from meta-overc

Mark Asselstine mark.asselstine at windriver.com
Tue Sep 18 13:27:27 PDT 2018


After several requests to make the consul recipe available outside of
meta-overc and the OverC framework we are moving the consul recipes
here. These are a copy from meta-overc (HEAD 6afe8d2c12ac).

NOTE that not all the DEPENDS have been copied as we will follow this
commit with work to make use of SRC_URIs for dependencies. See the
associated commit(s) which will follow this one.

Signed-off-by: Mark Asselstine <mark.asselstine at windriver.com>
---
 recipes-connectivity/consul/consul-migrate_git.bb  | 26 +++++++++
 recipes-connectivity/consul/consul_git.bb          | 67 ++++++++++++++++++++++
 ...prepared_query-make-compatible-with-go1.5.patch | 31 ++++++++++
 recipes-connectivity/consul/files/consul.service   | 12 ++++
 4 files changed, 136 insertions(+)
 create mode 100644 recipes-connectivity/consul/consul-migrate_git.bb
 create mode 100644 recipes-connectivity/consul/consul_git.bb
 create mode 100644 recipes-connectivity/consul/files/0001-prepared_query-make-compatible-with-go1.5.patch
 create mode 100644 recipes-connectivity/consul/files/consul.service

diff --git a/recipes-connectivity/consul/consul-migrate_git.bb b/recipes-connectivity/consul/consul-migrate_git.bb
new file mode 100644
index 0000000..4cc53b2
--- /dev/null
+++ b/recipes-connectivity/consul/consul-migrate_git.bb
@@ -0,0 +1,26 @@
+SUMMARY = "Provides data migration for Consul server nodes"
+HOMEPAGE = "https://github.com/hashicorp/consul-migrate"
+LICENSE = "MPL-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b278a92d2c1509760384428817710378"
+
+DEPENDS += "raft raft-boltdb raft-mdb"
+
+PKG_NAME = "github.com/hashicorp/consul-migrate"
+SRC_URI = "git://${PKG_NAME}.git"
+SRCREV = "678fb10cdeae25ab309e99e655148f0bf65f9710"
+
+inherit golang
+
+SYSROOT_PREPROCESS_FUNCS += "consul_migrate_sysroot_preprocess"
+
+export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
+
+consul_migrate_sysroot_preprocess () {
+    install -d ${SYSROOT_DESTDIR}${prefix}/local/go/src/${PKG_NAME}
+    cp -a ${D}${prefix}/local/go/src/${PKG_NAME} ${SYSROOT_DESTDIR}${prefix}/local/go/src/$(dirname ${PKG_NAME})
+    install -d ${SYSROOT_DESTDIR}${prefix}/bin
+    cp -a ${D}${prefix}/bin/* ${SYSROOT_DESTDIR}${prefix}/bin/
+}
+
+CLEANBROKEN = "1"
+INSANE_SKIP_${PN} = "ldflags"
diff --git a/recipes-connectivity/consul/consul_git.bb b/recipes-connectivity/consul/consul_git.bb
new file mode 100644
index 0000000..bcfb5aa
--- /dev/null
+++ b/recipes-connectivity/consul/consul_git.bb
@@ -0,0 +1,67 @@
+DESCRIPTION = "A tool for discovering and configuring services in your infrastructure"
+HOMEPAGE = "https://www.consul.io/"
+LICENSE = "MPL-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b278a92d2c1509760384428817710378"
+
+DEPENDS += "circbuf \
+    consul-migrate \
+    go-checkpoint \
+    go-msgpack \
+    go-metrics \
+    go-bindata \
+    go-sys \
+    go-syslog \
+    dockerclient \
+    logutils \
+    memberlist \
+    raft \
+    raft-boltdb \
+    scada-client \
+    serf-go \
+    yamux \
+    muxado \
+    dns \
+    cli \
+    mapstructure \
+    copystructure \
+    reflectwalk \
+    columnize \
+    go-radix \
+    golang-lru \
+    hashicorp-hil \
+    hashicorp-hcl \
+    hashicorp-go-cleanhttp \
+    hashicorp-go-memdb \
+    hashicorp-go-reap \
+    hashicorp-go-uuid \
+    net-rpc-msgpackrpc \
+    "
+
+PKG_NAME = "github.com/hashicorp/consul"
+SRC_URI = "git://${PKG_NAME}.git \
+           file://consul.service \
+           file://0001-prepared_query-make-compatible-with-go1.5.patch \
+          "
+SRCREV = "f97afda8e15046b41d951bf3b4220372c45df7ab"
+
+CCACHE = ""
+
+inherit systemd golang
+
+INSANE_SKIP_${PN} += "ldflags"
+
+SYSTEMD_SERVICE_${PN} = "consul.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "enable"
+
+export GOROOT="${STAGING_DIR_NATIVE}/${nonarch_libdir}/${HOST_SYS}/go"
+
+#Stops go from installing and testing the package
+do_configure(){
+}
+
+do_install_append() {
+    install -d ${D}/${systemd_unitdir}/system
+    cp ${WORKDIR}/consul.service ${D}/${systemd_unitdir}/system
+}
+
+FILES_${PN} += "${systemd_unitdir}/system"
diff --git a/recipes-connectivity/consul/files/0001-prepared_query-make-compatible-with-go1.5.patch b/recipes-connectivity/consul/files/0001-prepared_query-make-compatible-with-go1.5.patch
new file mode 100644
index 0000000..a66e1dc
--- /dev/null
+++ b/recipes-connectivity/consul/files/0001-prepared_query-make-compatible-with-go1.5.patch
@@ -0,0 +1,31 @@
+From fb11d9e31788c912f94faf8b188278d54dc9a8f1 Mon Sep 17 00:00:00 2001
+From: Bruce Ashfield <bruce.ashfield at windriver.com>
+Date: Wed, 20 Apr 2016 16:34:50 -0400
+Subject: [PATCH] prepared_query: make compatible with go1.5
+
+The copying of a regex is only in go 1.6. We can take the chance of
+lock contention, so we drop the copy and use the regex directly.
+
+Signed-off-by: Bruce Ashfield <bruce.ashfield at windriver.com>
+---
+ consul/prepared_query/template.go | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/consul/prepared_query/template.go b/consul/prepared_query/template.go
+index 984f0bcf9cc6..1c61910c1526 100644
+--- a/consul/prepared_query/template.go
++++ b/consul/prepared_query/template.go
+@@ -116,8 +116,8 @@ func (ct *CompiledTemplate) Render(name string) (*structs.PreparedQuery, error)
+ 	// from multiple goroutines.
+ 	var matches []string
+ 	if ct.re != nil {
+-		re := ct.re.Copy()
+-		matches = re.FindStringSubmatch(name)
++		// re := ct.re.Copy()
++		matches = ct.re.FindStringSubmatch(name)
+ 	}
+ 
+ 	// Create a safe match function that can't fail at run time. It will
+-- 
+2.4.0.53.g8440f74
+
diff --git a/recipes-connectivity/consul/files/consul.service b/recipes-connectivity/consul/files/consul.service
new file mode 100644
index 0000000..c9494e3
--- /dev/null
+++ b/recipes-connectivity/consul/files/consul.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Launch Consul Cluster
+
+[Service]
+Restart=on-failure
+RestartSec=45
+ExecStartPre=/bin/sh -c 'echo -ne \'{"data_dir":\"/var/consul","server":true,"bootstrap_expect":1,\' > /tmp/consul.conf'
+ExecStartPre=/bin/sh -c 'echo -ne \'"bind_addr":"\'$(ifconfig br0 | awk \'/inet addr/{print substr($2,6)}\')\'"}\' >> /tmp/consul.conf'
+ExecStart=/usr/bin/consul agent -config-file=/tmp/consul.conf
+
+[Install]
+WantedBy=multi-user.target
-- 
2.7.4



More information about the meta-virtualization mailing list