Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-containers / docker-distribution / docker-distribution_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 HOMEPAGE = "http://github.com/docker/distribution"
17 SUMMARY = "The Docker toolset to pack, ship, store, and deliver content"
18 LICENSE = "Apache-2.0"
19 LIC_FILES_CHKSUM = "file://LICENSE;md5=d2794c0df5b907fdace235a619d80314"
20
21 GO_PKG_PATH = "github.com/docker/distribution"
22 GO_IMPORT = "import"
23
24 SRCREV_distribution="48294d928ced5dd9b378f7fd7c6f5da3ff3f2c89"
25 SRC_URI = " \
26         git://github.com/docker/distribution.git;branch=release/2.6;name=distribution;destsuffix=git/src/${GO_PKG_PATH} \
27         file://${BPN}.service \
28         file://config.yml \
29         "
30
31 PV = "v2.6.2"
32 S = "${WORKDIR}/git/src/${GO_PKG_PATH}"
33
34 inherit goarch
35 inherit go
36
37 # This disables seccomp and apparmor, which are on by default in the
38 # go package. 
39 EXTRA_OEMAKE="BUILDTAGS=''"
40
41 do_compile() {
42         export GOARCH="${TARGET_GOARCH}"
43         export GOPATH="${WORKDIR}/git/"
44         export GOROOT="${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
45         # Pass the needed cflags/ldflags so that cgo
46         # can find the needed headers files and libraries
47         export CGO_ENABLED="1"
48         export CFLAGS=""
49         export LDFLAGS=""
50         export CGO_CFLAGS="${BUILDSDK_CFLAGS} --sysroot=${STAGING_DIR_TARGET}"
51         export GO_GCFLAGS=""
52         export CGO_LDFLAGS="${BUILDSDK_LDFLAGS} --sysroot=${STAGING_DIR_TARGET}"
53
54         cd ${S}
55
56         oe_runmake binaries
57 }
58
59 do_install() {
60         install -d ${D}/${bindir}
61         install ${S}/bin/registry ${D}/${bindir}
62
63         if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
64             install -d ${D}${systemd_system_unitdir}
65             install -m 644 ${WORKDIR}/${BPN}.service ${D}/${systemd_system_unitdir}
66         fi
67
68         install -d ${D}/${sysconfdir}/${BPN}/registry/
69         install ${WORKDIR}/config.yml ${D}/${sysconfdir}/${BPN}/registry/config.yml
70
71         # storage for the registry containers
72         install -d ${D}/${localstatedir}/lib/registry/
73 }
74
75 INSANE_SKIP_${PN} += "ldflags already-stripped"
76
77 FILES_${PN} = "\
78         ${bindir}/* \
79         ${systemd_system_unitdir}/${BPN}.service \
80         ${sysconfdir}/${BPN}/* \
81         ${localstatedir}/lib/registry/ \
82         "
83
84 SYSTEMD_SERVICE_${BPN} = "${@bb.utils.contains('DISTRO_FEATURES','systemd','${BPN}.service','',d)}"
85 SYSTEMD_AUTO_ENABLE_${BPN} = "disable"
86
87
88 SYSROOT_PREPROCESS_FUNCS += "docker_distribution_sysroot_preprocess"
89
90 docker_distribution_sysroot_preprocess () {
91     install -d ${SYSROOT_DESTDIR}${prefix}/local/go/src/${GO_PKG_PATH}
92     cp -r ${S} ${SYSROOT_DESTDIR}${prefix}/local/go/src/$(dirname ${GO_PKG_PATH})
93 }