Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-connectivity / etcd / etcd_git.bb
1 #
2 # Copyright (C) 2019 Wind River Systems, Inc.
3 #
4 #  Licensed under the Apache License, Version 2.0 (the "License");
5 #  you may not use this file except in compliance with the License.
6 #  You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #  Unless required by applicable law or agreed to in writing, software
11 #  distributed under the License is distributed on an "AS IS" BASIS,
12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #  See the License for the specific language governing permissions and
14 #  limitations under the License.
15
16 SUMMARY = "A distributed key-value store for shared config and service discovery"
17 DESCRIPTION = " \
18     etcd is a distributed reliable key-value store for the most critical data \
19     of a distributed system, with a focus on being: \
20     \
21     * Simple: well-defined, user-facing API (gRPC) \
22     * Secure: automatic TLS with optional client cert authentication \
23     * Fast: benchmarked 10,000 writes/sec \
24     * Reliable: properly distributed using Raft \
25 "
26 HOMEPAGE = "https://github.com/coreos/etcd"
27 LICENSE = "Apache-2.0"
28 LIC_FILES_CHKSUM = "file://src/import/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
29
30 SRC_URI = " \
31     git://github.com/coreos/etcd.git;branch=release-3.3 \
32     "
33
34 SRCREV = "94745a4eed0425653b3b4275a208d38babceeaec"
35 PV = "3.3.15+git${SRCPV}"
36
37 S = "${WORKDIR}/git"
38
39 inherit go goarch systemd useradd
40
41 USERADD_PACKAGES = "${PN}"
42 USERADD_PARAM_${PN} = " \
43     --system --shell ${sbindir}/nologin --comment 'etcd user' \
44     --home-dir ${localstatedir}/lib --groups etcd --gid etcd etcd \
45     "
46 GROUPADD_PARAM_${PN} = "etcd"
47
48 TARGET_CC_ARCH += "${LDFLAGS}"
49 GO_IMPORT = "import"
50
51 do_compile() {
52         export GOARCH="${TARGET_GOARCH}"
53
54         # Setup vendor directory so that it can be used in GOPATH.
55         #
56         # Go looks in a src directory under any directory in GOPATH but
57         # uses 'vendor' instead of 'vendor/src'. We can fix this with a symlink.
58         #
59         # We also need to link in the ipallocator directory as that is not under
60         # a src directory.
61         export GOPATH="${B}/src/import/"
62         mkdir -p ${B}/src/import/src/github.com/coreos/
63         ln -s ${S}/src/import ${B}/src/import/src/github.com/coreos/etcd
64
65         # Pass the needed cflags/ldflags so that cgo
66         # can find the needed headers files and libraries
67         export CGO_ENABLED="1"
68         export CFLAGS=""
69         export LDFLAGS=""
70         export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
71         export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
72
73         if [ "${TARGET_ARCH}" = "x86_64" ]; then
74                 export GOARCH="amd64"
75         elif [ "${TARGET_ARCH}" = "i586" ]; then
76                 export GOARCH="386"
77         fi
78
79         ./src/import/build
80 }
81
82 do_install() {
83         install -d ${D}/${bindir}
84         install -m 0755 ${B}/bin/etcd ${D}/${bindir}/etcd
85         install -m 0755 ${B}/bin/etcdctl ${D}/${bindir}/etcdctl
86
87         install -d ${D}${systemd_system_unitdir}
88         install -m 0644 ${S}/src/import/contrib/systemd/etcd.service ${D}${systemd_system_unitdir}
89
90         # etcd state is in /var/lib/etcd
91         install -d ${D}${sysconfdir}/tmpfiles.d
92         echo "d ${localstatedir}/lib/${BPN} 0755 etcd etcd -" \
93                 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
94
95         # we aren't creating a user, so we need to comment out this line
96         sed -i '/User/s/^/#/' ${D}${systemd_unitdir}/system/etcd.service
97 }
98
99 deltask compile_ptest_base
100
101 RDEPENDS_${PN} = "bash"
102
103 # During packaging etcd gets the warning "no GNU hash in elf binary"
104 # This issue occurs due to compiling without ldflags, but a
105 # solution has yet to be found. For now we ignore this error with
106 # the line below.
107 #INSANE_SKIP_${PN} = "ldflags"