armada-app: fix build failure on centos
[pti/rtp.git] / meta-stx / recipes-core / stx-platform-armada-app / stx-platform-helm_1.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 SUMMARY = "StarlingX Platform Helm charts"
17 DESCRIPTION = "StarlingX Platform Helm charts"
18
19 LICENSE = "Apache-2.0"
20 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
21
22 DEPENDS += " \
23     helm-native \
24     openstack-helm \
25     openstack-helm-infra \
26 "
27
28 PROTOCOL = "https"
29 BRANCH = "r/stx.3.0"
30 SRCREV_platform-armada-app = "c67d1eeb605ea1da4ebb2a1219a6f54f05e3eb5e"
31 SRCREV_helm-charts = "c01426a2500269fbf1a781214a361de0796297d1"
32
33 SRC_URI = " \
34     git://opendev.org/starlingx/platform-armada-app.git;protocol=${PROTOCOL};branch=${BRANCH};name=platform-armada-app \
35     git://opendev.org/starlingx/helm-charts.git;protocol=${PROTOCOL};branch=${BRANCH};name=helm-charts;destsuffix=helm-charts \
36 "
37
38 S = "${WORKDIR}/git/stx-platform-helm/stx-platform-helm"
39
40 inherit allarch
41
42 toolkit_version = "0.1.0"
43 helm_folder = "${RECIPE_SYSROOT}${nonarch_libdir}/helm"
44 helm_repo = "stx-platform"
45
46 app_name = "platform-integ-apps"
47 app_staging = "${B}/staging"
48 app_tarball = "${app_name}.tgz"
49 app_folder = "/usr/local/share/applications/helm"
50
51 do_configure () {
52         :
53 }
54
55 do_compile () {
56         # initialize helm and build the toolkit
57         # helm init --client-only does not work if there is no networking
58         # The following commands do essentially the same as: helm init
59         export HOME="${B}/${USER}"
60         export helm_home="${B}/${USER}/.helm"
61         rm -rf ${helm_home}
62
63         mkdir  -p ${helm_home}
64         mkdir  ${helm_home}/repository
65         mkdir  ${helm_home}/repository/cache
66         mkdir  ${helm_home}/repository/local
67         mkdir  ${helm_home}/plugins
68         mkdir  ${helm_home}/starters
69         mkdir  ${helm_home}/cache
70         mkdir  ${helm_home}/cache/archive
71
72         # Stage a repository file that only has a local repo
73         cp ${S}/files/repositories.yaml ${helm_home}/repository/repositories.yaml
74
75         # Stage a local repo index that can be updated by the build
76         cp ${S}/files/index.yaml ${helm_home}/repository/local/index.yaml
77
78         # Stage helm-toolkit in the local repo
79         cp ${helm_folder}/helm-toolkit-${toolkit_version}.tgz ${S}/helm-charts/
80
81         # Host a server for the charts
82         helm serve --repo-path . &
83         sleep 1
84         helm repo rm local
85         helm repo add local http://localhost:8879/charts
86
87         # Make the charts. These produce a tgz file
88         cp -rf ${WORKDIR}/helm-charts/node-feature-discovery/node-feature-discovery/helm-charts/node-feature-discovery/ \
89                 ${S}/helm-charts/
90         cd ${S}/helm-charts
91         make rbd-provisioner
92         make ceph-pools-audit
93         make node-feature-discovery
94         cd -
95
96         # Terminate helm server (the last backgrounded task)
97         kill $!
98         rm -rf ${helm_home}
99
100         # Create a chart tarball compliant with sysinv kube-app.py
101         # Setup staging
102         mkdir -p ${app_staging}
103         cp ${S}/files/metadata.yaml ${app_staging}
104         cp ${S}/manifests/manifest.yaml ${app_staging}
105
106         mkdir -p ${app_staging}/charts
107         cp ${S}/helm-charts/*.tgz ${app_staging}/charts
108         cd ${app_staging}
109
110         # Populate metadata
111         sed -i 's/@APP_NAME@/${app_name}/g' ${app_staging}/metadata.yaml
112         sed -i 's/@APP_VERSION@/${version}-${tis_patch_ver}/g' ${app_staging}/metadata.yaml
113         sed -i 's/@HELM_REPO@/${helm_repo}/g' ${app_staging}/metadata.yaml
114
115         # package it up
116         find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
117         tar -zcf ${B}/${app_tarball} -C ${app_staging}/ .
118
119         # Cleanup staging
120         rm -fr ${app_staging}
121 }
122
123 do_install () {
124         install -d -m 755 ${D}/${app_folder}
125         install -p -D -m 755 ${B}/${app_tarball} ${D}/${app_folder}
126         install -d -m 755 ${D}/opt/extracharts
127         install -p -D -m 755 ${S}/helm-charts/node-feature-discovery-*.tgz ${D}/opt/extracharts
128 }
129
130 FILES_${PN} = " \
131     /opt/extracharts \
132     ${app_folder} \
133 "
134
135 RDEPENDS_${PN} = " \
136     helm \
137     openstack-helm \
138     openstack-helm-infra \
139 "