Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-support / openstack-barbican-api / openstack-barbican-api.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 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
17
18 LICENSE = "Apache-2.0"
19 LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=89aea4e17d99a7cacdbeed46a0096b10"
20
21 SRC_URI = " \
22         file://LICENSE \
23         file://barbican.conf \
24         file://gunicorn-config.py \
25         file://barbican-api-paste.ini \
26         file://openstack-barbican-api.service \
27         "
28
29 do_configure() {
30         :
31 }
32
33
34 do_compile() {
35         :
36 }
37
38
39 do_install() {
40
41         install -m 0755 -d ${D}/${datadir}/starlingx/barbican/
42         install -m 0755 -d ${D}/${datadir}/starlingx/barbican/backup/
43         install -m 0755 -d ${D}/${systemd_system_unitdir}/
44         install -m 0644 ${WORKDIR}/barbican.conf ${D}/${datadir}/starlingx/barbican
45         install -m 0644 ${WORKDIR}/barbican-api-paste.ini ${D}/${datadir}/starlingx/barbican
46         install -m 0644 ${WORKDIR}/gunicorn-config.py ${D}/${datadir}/starlingx/barbican
47         install -m 0644 ${WORKDIR}/openstack-barbican-api.service ${D}/${systemd_system_unitdir}/openstack-barbican-api.service
48 }
49
50 pkg_postinst_ontarget_${PN}() {
51
52         tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.$(date +%s).tar.gz ./etc/barbican
53
54         if [ ! -f /usr/share/starlingx/barbican/backup/barbican.default.tar.gz ]; then 
55                 tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz ./etc/barbican
56         fi;
57
58         rm -rf /etc/barbican/
59
60         # Restore to default settings
61         tar -C / -xzpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz
62
63         cp /usr/share/starlingx/barbican/barbican-api-paste.ini /etc/barbican/
64         cp /usr/share/starlingx/barbican/barbican.conf /etc/barbican/
65         cp /usr/share/starlingx/barbican/gunicorn-config.py /etc/barbican/
66         systemctl daemon-reload
67 }
68
69 pkg_prerm_ontarget_${PN}() {
70         tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.$(date +%s).tar.gz ./etc/barbican
71         rm -rf /etc/barbican/
72
73         # Restore to default settings
74         tar -C / -xzpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz
75 }
76
77 FILES_${PN} = " \
78         ${datadir}/starlingx/barbican/ \
79         ${systemd_system_unitdir}/openstack-barbican-api.service \
80         "