Add initial meta-stx to support StarlingX build
[pti/rtp.git] / meta-stx / recipes-support / openldap / openldap_%.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
18 SRC_URI += " \
19         file://rootdn-should-not-bypass-ppolicy.patch \
20         file://0021-openldap-and-stx-source-and-config-files.patch \
21         file://stx-slapd.service \
22         "
23
24 inherit pkgconfig useradd
25
26 USERADD_PACKAGES = "${PN}"
27 USERADD_PARAM_${PN} = "-r -g ldap -u 55 -d / -s /sbin/nologin -c 'OpenLDAP server' ldap"
28 GROUPADD_PARAM_${PN} = "-r -g 55 ldap"
29
30 PACKAGECONFIG_CONFARGS_remove = "--with-tls=gnutls "
31 DEPENDS += " \
32         openssl \
33         glibc \
34         mariadb \
35         mariadb-native \
36         libtirpc \
37         "
38
39 RDEPENDS_${PN}_append = " bash"
40
41 # Do not remove libtool la files slapd.conf uses ppolicy.la 
42 REMOVE_LIBTOOL_LA = "0"
43
44
45 # Defaults:
46 #       --enable-bdb=no
47 #       --enable-hdb=no
48 #       --enable-bdb=no
49 #       --enable-monitor=mod 
50 ######
51 # Stx :
52 #       --enable-wrappers=yes
53 #       --enable-moznss-compatibility=yes
54
55 #################
56 # TODO:
57 #       mysql_config: native command missing
58
59 EXTRA_OECONF += " \
60                 --enable-syslog \
61                 --enable-proctitle \
62                 --enable-ipv6 \
63                 --enable-local \
64                 --enable-slapd \
65                 --enable-dynacl \
66                 --enable-aci \
67                 --enable-cleartext \
68                 --enable-crypt \
69                 --enable-lmpasswd \
70                 --enable-modules \
71                 --enable-rewrite \
72                 --enable-rlookups \
73                 --disable-slp \
74                 --enable-wrappers=no \
75                 --enable-backends=mod \
76                 --enable-bdb=yes \
77                 --enable-hdb=yes \
78                 --enable-mdb=yes \
79                 --enable-monitor=yes \
80                 --disable-ndb \
81                 --enable-overlays=mod \
82                 --disable-static \
83                 --enable-shared \
84                 --with-cyrus-sasl \
85                 --without-fetch \
86                 --with-tls=openssl \
87                 "
88 #       --enable-moznss-compatibility=no 
89 # NEW:
90 # --enable-lmpasswd 
91 # --enable-slapi
92 # --enable-wrappers
93 # --enable-moznss-compatibility=yes
94
95 do_configure_append () {
96    cd ${S}
97    ln -f -s ${S}/contrib/slapd-modules/smbk5pwd/smbk5pwd.c servers/slapd/overlays
98    ln -f -s ${S}/contrib/slapd-modules/allop/allop.c servers/slapd/overlays
99    ln -f -s ${S}/contrib/slapd-modules/passwd/sha2/sha2.c servers/slapd/overlays
100    ln -f -s ${S}/contrib/slapd-modules/passwd/sha2/sha2.h servers/slapd/overlays
101    ln -f -s ${S}/contrib/slapd-modules/passwd/sha2/slapd-sha2.c servers/slapd/overlays
102 }
103
104
105 # If liblmdb is needed, then patch the Makefile
106 #do_compile_append () {
107 #   cd ${S}/ltb-project-openldap-ppolicy-check-password-1.1
108 #   oe_runmake
109 #}
110
111 do_install_append () {
112         
113         # For this we need to build ltb-project-openldap
114         #install -m 755 check_password.so.%{check_password_version} %{buildroot}%{_libdir}/openldap/
115
116         cd ${S}/stx-sources
117         install -m 0755 -d ${D}/var/run/openldap
118         install -m 0755 -d ${D}/${sysconfdir}/tmpfiles.d
119         install -m 0755 ${S}/stx-sources/slapd.tmpfiles ${D}/${sysconfdir}/tmpfiles.d/slapd.conf 
120         install -m 0755 ${S}/stx-sources/openldap.tmpfiles ${D}/${sysconfdir}/tmpfiles.d/openldap.conf 
121         install -m 0755 ${S}/stx-sources/ldap.conf ${D}/${sysconfdir}/tmpfiles.d/ldap.conf 
122
123         # The database directory MUST exist prior to running slapd AND
124         # should only be accessible by the slapd and slap tools.
125         # Mode 700 recommended.
126         echo "d /var/lib/openldap-data 0700 ldap ldap -" >> ${D}/${sysconfdir}/tmpfiles.d/slapd.conf
127
128         install -m 0644 libexec-functions ${D}/${libexecdir}/openldap/functions
129         install -m 0755 libexec-convert-config.sh ${D}/${libexecdir}/openldap/convert-config.sh
130         install -m 0755 libexec-check-config.sh ${D}/${libexecdir}/openldap/check-config.sh
131         install -m 0755 libexec-upgrade-db.sh ${D}/${libexecdir}/openldap/upgrade-db.sh
132
133         install -m 0755 libexec-create-certdb.sh ${D}/${libexecdir}/openldap/create-certdb.sh
134         install -m 0755 libexec-generate-server-cert.sh ${D}/${libexecdir}/openldap/generate-server-cert.sh
135         install -m 0755 libexec-update-ppolicy-schema.sh ${D}/${libexecdir}/openldap/update-ppolicy-schema.sh
136
137         install -m 0644  ${S}/../stx-slapd.service ${D}/${systemd_system_unitdir}/stx-slapd.service
138         install -m 0755 -d ${D}/${sysconfdir}/sysconfig
139         install -m 0644 slapd.sysconfig ${D}/${sysconfdir}/sysconfig/slapd
140         install -m 0755 -d ${D}/${datadir}/openldap-servers
141         install -m 0644 slapd.ldif ${D}/${datadir}/openldap-servers/slapd.ldif
142         install -m 0750 -d ${D}/${sysconfdir}/openldap/slapd.d
143         rm -rf ${D}/var/run
144
145         #cd ${S}/
146         #oe_runmake -e -C servers/slapd/overlays  DESTDIR=${D} install
147         sed -i -e 's:\(/sbin/runuser\):/usr\1:g' ${D}/usr/libexec/openldap/functions
148
149 }
150
151 #pkg_postinst_ontarget_libldap-2.4_append () {
152 #       cp /usr/share/starlingx/slapd.service ${systemd_system_unitdir}/slapd.service
153 #       chmod 644 ${systemd_system_unitdir}/slapd.service
154 #       cp ${datadir}/starlingx/slapd.sysconfig ${sysconfdir}/sysconfig/slapd
155 #       systemctl daemon-reload
156 #       chmod 755 /etc/openldap
157 #       chmod 755 /etc/openldap/slapd.d
158 #}
159
160 FILES_${PN}_append = " \
161         ${datadir}/openldap-servers/ \
162         ${libexecdir}/openldap/ \
163         ${sysconfdir}/sysconfig \
164         ${sysconfdir}/tmpfiles.d \
165         ${systemd_system_unitdir}/stx-slapd.service \
166         "
167
168 # *.la are openldap modules, so re-define
169 # to remove the *.la from -dev package
170 FILES_${PN}-dev = " \
171         ${includedir} \
172         ${FILES_SOLIBSDEV} \
173         ${libdir}/*.la \
174         ${libexecdir}/openldap/*${SOLIBSDEV} \
175         "