af-main: add RDEPENDS on bash
[AGL/meta-agl.git] / meta-app-framework / recipes-core / af-main / af-main_1.0.bb
1 require af-main_${PV}.inc 
2
3 # NOTE: using libcap-native and setcap in install doesn't work
4 # NOTE: there is no SYSTEMD_USER_SERVICE_...
5 # NOTE: maybe setting afm_name to agl-framework is cleaner but has implications
6 # NOTE: there is a hack of security for using groups and dbus (to be checked)
7 # NOTE: using ZIP programs creates directories with mode 777 (very bad)
8
9 inherit cmake pkgconfig useradd systemd
10 BBCLASSEXTEND = "native"
11
12 SECTION = "base"
13
14 DEPENDS = "openssl libxml2 xmlsec1 systemd libzip json-c systemd security-manager libcap-native af-binder"
15 DEPENDS_class-native = "openssl libxml2 xmlsec1 libzip json-c"
16
17 EXTRA_OECMAKE_class-native  = "\
18         -DUSE_LIBZIP=1 \
19         -DUSE_SIMULATION=1 \
20         -DUSE_SDK=1 \
21         -Dafm_name=${afm_name} \
22         -Dafm_confdir=${afm_confdir} \
23         -Dafm_datadir=${afm_datadir} \
24 "
25
26 EXTRA_OECMAKE = "\
27         -DUSE_LIBZIP=1 \
28         -DUSE_SIMULATION=0 \
29         -DUSE_SDK=0 \
30         -Dafm_name=${afm_name} \
31         -Dafm_confdir=${afm_confdir} \
32         -Dafm_datadir=${afm_datadir} \
33         -Dsystemd_units_root=${systemd_units_root} \
34         -DUNITDIR_USER=${systemd_user_unitdir} \
35         -DUNITDIR_SYSTEM=${systemd_system_unitdir} \
36 "
37
38 USERADD_PACKAGES = "${PN}"
39 USERADD_PARAM_${PN} = "-g ${afm_name} -d ${afm_datadir} -r ${afm_name}"
40 GROUPADD_PARAM_${PN} = "-r ${afm_name}"
41
42 SYSTEMD_SERVICE_${PN} = "afm-system-daemon.service"
43 SYSTEMD_AUTO_ENABLE = "enable"
44
45 FILES_${PN} += "\
46         ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_user_unitdir}/afm-user-daemon.service', '', d)} \
47 "
48 RDEPENDS_${PN}_append_smack = " smack-userspace bash"
49 DEPENDS_append_smack = " smack-userspace-native"
50
51 # short hacks here
52 SRC_URI += "\
53         file://Hack-to-allow-the-debugging.patch \
54 "
55
56 # tools used to install wgt at first boot
57 SRC_URI += "\
58         file://afm-install \
59 "
60
61 do_install_append_class-target() {
62     install -d ${D}${bindir}
63     install -d -m 0775 ${D}${systemd_units_root}/system
64     install -d -m 0775 ${D}${systemd_units_root}/user
65     install -d -m 0775 ${D}${systemd_units_root}/system/default.target.wants
66     install -d -m 0775 ${D}${systemd_units_root}/user/default.target.wants
67     install -d -m 0775 ${D}${systemd_units_root}/system/sockets.target.wants
68     install -d -m 0775 ${D}${systemd_units_root}/user/sockets.target.wants
69     install -d ${D}${afm_datadir}/applications
70     install -d ${D}${afm_datadir}/icons
71     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
72         mkdir -p ${D}${sysconfdir}/systemd/system/default.target.wants
73         mkdir -p ${D}${sysconfdir}/systemd/user/default.target.wants
74         ln -sf ${systemd_user_unitdir}/afm-user-daemon.service ${D}${sysconfdir}/systemd/user/default.target.wants
75     fi
76     install -m 0755 ${WORKDIR}/afm-install ${D}${bindir}
77     echo "QT_WAYLAND_SHELL_INTEGRATION=ivi-shell" > ${D}${afm_confdir}/unit.env.d/qt-for-ivi-shell
78 }
79
80 do_install_append_porter() {
81     echo "LD_PRELOAD=/usr/lib/libEGL.so" > ${D}${afm_confdir}/unit.env.d/preload-libEGL
82 }
83
84 pkg_postinst_${PN}() {
85     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
86         for SYS in "system" "user";do
87            for DEST in "sockets.target.wants" "default.target.wants" ".";do
88               chgrp ${afm_name} $D${systemd_units_root}/${SYS}/${DEST};
89            done
90         done
91     fi
92     for DEST in "applications" "icons" ".";do
93         chown ${afm_name}:${afm_name} $D${afm_datadir}/${DEST};
94     done
95     setcap cap_mac_override,cap_dac_override=ep $D${bindir}/afm-system-daemon
96 }
97
98 pkg_postinst_${PN}_smack() {
99     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
100         for SYS in "system" "user";do
101            for DEST in "sockets.target.wants" "default.target.wants" ".";do
102               chgrp ${afm_name} $D${systemd_units_root}/${SYS}/${DEST};
103               chsmack -a 'System::Shared' -t $D${systemd_units_root}/${SYS}/${DEST};
104            done
105         done
106     fi
107     for DEST in "applications" "icons" ".";do
108         chown ${afm_name}:${afm_name} $D${afm_datadir}/${DEST};
109         chsmack -a 'System::Shared' -t $D${afm_datadir}/${DEST};
110     done
111     setcap cap_mac_override,cap_dac_override=ep $D${bindir}/afm-system-daemon
112 }
113 FILES_${PN} += " ${systemd_units_root} "
114
115 PACKAGES =+ "${PN}-binding ${PN}-binding-dbg"
116 FILES_${PN}-binding = " ${afb_binding_dir}/afm-main-binding.so "
117 FILES_${PN}-binding-dbg = " ${afb_binding_dir}/.debug/afm-main-binding.so "
118
119 PACKAGES =+ "${PN}-tools ${PN}-tools-dbg"
120 FILES_${PN}-tools = "${bindir}/wgtpkg-*"
121 FILES_${PN}-tools-dbg = "${bindir}/.debug/wgtpkg-*"