barbican: fixes to enable barbican-api execution
[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 0755 -d ${D}/var/log/barbican/
45         install -m 0644 ${WORKDIR}/barbican.conf ${D}/${datadir}/starlingx/barbican
46         install -m 0644 ${WORKDIR}/barbican-api-paste.ini ${D}/${datadir}/starlingx/barbican
47         install -m 0644 ${WORKDIR}/gunicorn-config.py ${D}/${datadir}/starlingx/barbican
48         install -m 0644 ${WORKDIR}/openstack-barbican-api.service ${D}/${systemd_system_unitdir}/openstack-barbican-api.service
49 }
50
51 pkg_postinst_ontarget_${PN}() {
52
53         tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.$(date +%s).tar.gz ./etc/barbican
54
55         if [ ! -f /usr/share/starlingx/barbican/backup/barbican.default.tar.gz ]; then 
56                 tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz ./etc/barbican
57         fi;
58
59         rm -rf /etc/barbican/
60
61         # Restore to default settings
62         tar -C / -xzpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz
63
64         cp /usr/share/starlingx/barbican/barbican-api-paste.ini /etc/barbican/
65         cp /usr/share/starlingx/barbican/barbican.conf /etc/barbican/
66         cp /usr/share/starlingx/barbican/gunicorn-config.py /etc/barbican/
67         systemctl daemon-reload
68 }
69
70 pkg_prerm_ontarget_${PN}() {
71         tar -C / -czpf /usr/share/starlingx/barbican/backup/barbican.$(date +%s).tar.gz ./etc/barbican
72         rm -rf /etc/barbican/
73
74         # Restore to default settings
75         tar -C / -xzpf /usr/share/starlingx/barbican/backup/barbican.default.tar.gz
76 }
77
78 FILES_${PN} = " \
79         ${datadir}/starlingx/barbican/ \
80         ${systemd_system_unitdir}/openstack-barbican-api.service \
81     /var/log/barbican \
82         "