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