Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-extended / registry-token-server / registry-token-server_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 DESCRIPTION = "StarlingX distributedcloud packages collection"
17 HOMEPAGE = "https://opendev.org/starlingx"
18 SECTION = "network"
19 LICENSE = "Apache-2.0"
20 LIC_FILES_CHKSUM = "file://src/registry-token-server/registry-token-server/src/LICENSE;md5=d2794c0df5b907fdace235a619d80314"
21
22 PROTOCOL = "https"
23 BRANCH = "r/stx.3.0"
24 SRCNAME = "containers"
25 SRCREV = "1a4b803e946b488c1f3adb25ab0614d1b0c3c9b8"
26 PV = "1.0.0+git${SRCPV}"
27 S = "${WORKDIR}/git"
28
29 SRC_URI = "git://opendev.org/starlingx/${SRCNAME}.git;protocol=${PROTOCOL};rev=${SRCREV};branch=${BRANCH}"
30
31 GO_IMPORT = "registry-token-server"
32
33 RDEPENDS_${PN}-dev_append = " \
34         systemd \
35         "
36
37 DEPENDS += "\
38         go-logrus \
39         docker-distribution \
40         go-libtrust \
41         go-patricia \
42         go-mux \
43         go-context \
44         go-phercloud \
45         "
46
47 RDEPENDS_${PN} = " \
48         docker-distribution \
49         docker-ce \
50         "
51
52 inherit go goarch ${@bb.utils.contains('VIRTUAL-RUNTIME_init_manager','systemd','systemd','', d)}
53
54 do_compile() {
55         mkdir -p _build/src
56         ln -sfn ${S}/src/registry-token-server/registry-token-server/src/ ./_build/src/registry-token-server
57   
58         # Pass the needed cflags/ldflags so that cgo
59         # can find the needed headers files and libraries
60         export GOARCH=${TARGET_GOARCH}
61         export CGO_ENABLED="1"
62         export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
63         export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
64
65         export GOPATH="${WORKDIR}/build/_build:${STAGING_DIR_TARGET}/${prefix}/local/go"
66         cd _build/src/${GO_IMPORT}
67         #oe_runmake registry-token-server
68         export GOROOT=${STAGING_DIR_TARGET}/${prefix}/local/go
69         go build -o ${WORKDIR}/build/bin/registry-token-server registry-token-server
70 }
71
72 SYSTEMD_PACKAGES = "${PN}"
73 SYSTEMD_SERVICE_${PN} = "registry-token-server.service"
74 SYSTEMD_AUTO_ENABLE = "disable"
75
76 do_install() {
77         SRCPATH="${S}/src/registry-token-server/registry-token-server/centos/files"
78         install -d ${D}/${bindir}
79         install -m 0755 bin/registry-token-server ${D}/${bindir}
80         install -d -m 0755 ${D}/${sysconfdir}/registry-token-server/registry
81         install -m 0644 ${SRCPATH}//token_server.conf ${D}/${sysconfdir}/registry-token-server/registry
82
83         if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
84             install -d ${D}${systemd_unitdir}/system
85             install -m 0644 ${SRCPATH}/registry-token-server.service ${D}${systemd_unitdir}/system/
86         fi
87 }
88