Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-devtools / python / python-django-horizon_15.1.0.bbappend
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 SRC_URI += " \
18         file://${BPN}/guni_config.py \
19         file://${BPN}/horizon-assets-compress \
20         file://${BPN}/horizon-clearsessions \
21         file://${BPN}/horizon.init \
22         file://${BPN}/horizon-patching-restart \
23         file://${BPN}/openstack-dashboard-httpd-2.4.conf \
24         file://${BPN}/openstack-dashboard-httpd-logging.conf \
25         file://${BPN}/python-django-horizon-logrotate.conf \
26         file://${BPN}/python-django-horizon-systemd.conf \
27         "
28
29 do_configure_prepend () {
30         cd ${S}
31
32         # STX remove troublesome files introduced by tox
33         rm -f openstack_dashboard/test/.secret_key_store
34         rm -f openstack_dashboard/test/*.secret_key_store.lock
35         rm -f openstack_dashboard/local/.secret_key_store
36         rm -f openstack_dashboard/local/*.secret_key_store.lock
37         rm -rf horizon.egg-info
38
39         # drop config snippet
40         cp -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-logging.conf .
41         cp -p ${WORKDIR}/${BPN}/guni_config.py .
42
43         # customize default settings
44         # WAS [PATCH] disable debug, move web root
45         sed -i "/^DEBUG =.*/c\DEBUG = False" openstack_dashboard/local/local_settings.py.example
46         sed -i "/^WEBROOT =.*/c\WEBROOT = '/dashboard/'" openstack_dashboard/local/local_settings.py.example
47         sed -i "/^.*ALLOWED_HOSTS =.*/c\ALLOWED_HOSTS = ['horizon.example.com', 'localhost']" openstack_dashboard/local/local_settings.py.example
48         sed -i "/^.*LOCAL_PATH =.*/c\LOCAL_PATH = '/tmp'" openstack_dashboard/local/local_settings.py.example
49         sed -i "/^.*POLICY_FILES_PATH =.*/c\POLICY_FILES_PATH = '/etc/openstack-dashboard'" openstack_dashboard/local/local_settings.py.example
50
51         sed -i "/^BIN_DIR = .*/c\BIN_DIR = '/usr/bin'" openstack_dashboard/settings.py
52         sed -i "/^COMPRESS_PARSER = .*/a COMPRESS_OFFLINE = True" openstack_dashboard/settings.py
53
54         # set COMPRESS_OFFLINE=True
55         sed -i 's:COMPRESS_OFFLINE.=.False:COMPRESS_OFFLINE = True:' openstack_dashboard/settings.py
56
57         # STX: MANIFEST needs .eslintrc files for angular
58         echo "include .eslintrc"   >> MANIFEST.in
59
60         # MANIFEST needs to include json and pot files under openstack_dashboard
61         echo "recursive-include openstack_dashboard *.json *.pot .eslintrc"   >> MANIFEST.in
62
63         # MANIFEST needs to include pot files  under horizon
64         echo "recursive-include horizon *.pot .eslintrc"   >> MANIFEST.in
65 }
66
67 do_install_append () {
68         cd ${S}
69
70         # STX
71         install -d -m 755 ${D}/opt/branding
72         mkdir -p ${D}${sysconfdir}/rc.d/init.d
73         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon.init ${D}${sysconfdir}/rc.d/init.d/horizon
74         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-clearsessions ${D}/${bindir}/horizon-clearsessions
75         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-patching-restart ${D}/${bindir}/horizon-patching-restart
76         install -m 755 -D -p ${WORKDIR}/${BPN}/horizon-assets-compress ${D}/${bindir}/horizon-assets-compress
77
78         # drop httpd-conf snippet
79         install -m 0644 -D -p ${WORKDIR}/${BPN}/openstack-dashboard-httpd-2.4.conf ${D}${sysconfdir}/httpd/conf.d/openstack-dashboard.conf
80         install -d -m 755 ${D}${datadir}/openstack-dashboard
81         install -d -m 755 ${D}${sysconfdir}/openstack-dashboard
82
83         # create directory for systemd snippet
84         mkdir -p ${D}${systemd_system_unitdir}/httpd.service.d/
85         cp ${WORKDIR}/${BPN}/python-django-horizon-systemd.conf ${D}${systemd_system_unitdir}/httpd.service.d/openstack-dashboard.conf
86
87         # Copy everything to /usr/share
88         mv ${D}${libdir}/python2.7/site-packages/openstack_dashboard \
89            ${D}${datadir}/openstack-dashboard
90         cp manage.py ${D}${datadir}/openstack-dashboard
91
92         # STX
93         cp guni_config.py ${D}${datadir}/openstack-dashboard
94         rm -rf ${D}${libdir}/python2.7/site-packages/openstack_dashboard
95
96         # remove unnecessary .po files
97         find ${D} -name django.po -exec rm '{}' \;
98         find ${D} -name djangojs.po -exec rm '{}' \;
99
100         # Move config to /etc, symlink it back to /usr/share
101         mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/local/local_settings.py.example ${D}${sysconfdir}/openstack-dashboard/local_settings
102
103         mv ${D}${datadir}/openstack-dashboard/openstack_dashboard/conf/*.json ${D}${sysconfdir}/openstack-dashboard
104         cp -a  ${S}/openstack_dashboard/conf/cinder_policy.d ${D}${sysconfdir}/openstack-dashboard
105         cp -a  ${S}/openstack_dashboard/conf/nova_policy.d ${D}${sysconfdir}/openstack-dashboard
106
107         # copy static files to ${datadir}/openstack-dashboard/static
108         mkdir -p ${D}${datadir}/openstack-dashboard/static
109         cp -a openstack_dashboard/static/* ${D}${datadir}/openstack-dashboard/static
110         cp -a horizon/static/* ${D}${datadir}/openstack-dashboard/static
111
112         # create /var/run/openstack-dashboard/ and /var/log/horizon
113         install -m 0755 -d ${D}/${sysconfdir}/tmpfiles.d
114         echo "d ${localstatedir}/run/openstack-dashboard 0755 root root -" >> ${D}/${sysconfdir}/tmpfiles.d/openstack-dashboard.conf
115         echo "d ${localstatedir}/log/horizon 0755 root root -" >> ${D}/${sysconfdir}/tmpfiles.d/openstack-dashboard.conf
116
117         # place logrotate config:
118         mkdir -p ${D}${sysconfdir}/logrotate.d
119         cp -a ${WORKDIR}/${BPN}/python-django-horizon-logrotate.conf ${D}${sysconfdir}/logrotate.d/openstack-dashboard
120
121         chown -R root:root ${D}
122 }
123
124 FILES_${PN} += "\
125         ${datadir}/openstack-dashboard \
126         ${systemd_system_unitdir} \
127         ${localstatedir} \
128         /opt \
129         "
130
131 RPROVIDES_${PN} = "openstack-dashboard"