Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-containers / registry-token-server / registry-token-server_1.0.0.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 = " Token server for use with Docker registry with Openstack Keystone back end"
17 LICENSE = "Apache-2.0"
18 LIC_FILES_CHKSUM = "file://LICENSE;md5=d2794c0df5b907fdace235a619d80314"
19
20 GO_IMPORT = "registry-token-server"
21
22 SRC_URI = "file://registry-token-server-1.0.0.tar.gz \
23            file://registry-token-server.service \
24            file://token_server.conf \
25           "
26
27 RDEPENDS_${PN}-dev_append = "systemd"
28
29 DEPENDS += "\
30         go-logrus \
31         docker-distribution \
32         go-libtrust \
33         go-patricia \
34         go-mux \
35         go-context \
36         go-phercloud \
37         "
38
39 inherit go goarch ${@bb.utils.contains('VIRTUAL-RUNTIME_init_manager','systemd','systemd','', d)}
40
41 do_compile() {
42         mkdir -p _build/src
43         ln -sfn ${WORKDIR}/${PN}-${PV} ./_build/src/registry-token-server
44   
45         # Pass the needed cflags/ldflags so that cgo
46         # can find the needed headers files and libraries
47         export GOARCH=${TARGET_GOARCH}
48         export CGO_ENABLED="1"
49         export CGO_CFLAGS="${CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
50         export CGO_LDFLAGS="${LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
51
52         export GOPATH="${WORKDIR}/build/_build:${STAGING_DIR_TARGET}/${prefix}/local/go"
53         cd _build/src/${GO_IMPORT}
54         #oe_runmake registry-token-server
55         export GOROOT=${STAGING_DIR_TARGET}/${prefix}/local/go
56         go build -o ${WORKDIR}/build/bin/registry-token-server registry-token-server
57 }
58
59 SYSTEMD_PACKAGES = "${PN}"
60 SYSTEMD_SERVICE_${PN} = "registry-token-server.service"
61 SYSTEMD_AUTO_ENABLE = "enable"
62
63 do_install() {
64         install -d ${D}/${sbindir}
65         install -m 0755 bin/registry-token-server ${D}/${sbindir}
66         install -d ${D}/${sysconfdir}/registry-token-server/registry
67         install -m 0644 ${WORKDIR}/token_server.conf ${D}/${sysconfdir}/registry-token-server/registry
68
69         if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
70             install -d ${D}${systemd_unitdir}/system
71             install -m 0644 ${WORKDIR}/registry-token-server.service ${D}${systemd_unitdir}/system/
72         fi
73 }
74