5bcfdf9d5e08717cc1c9f82e0d6de607fafd0c77
[AGL/meta-agl.git] / meta-app-framework / recipes-core / af-main / af-main_1.0.bb
1 # NOTE: using libcap-native and setcap in install doesn't work
2 # NOTE: there is no SYSTEMD_USER_SERVICE_...
3 # NOTE: maybe setting afm_name to agl-framework is cleaner but has implications
4 # NOTE: there is a hack of security for using groups and dbus (to be checked)
5 # NOTE: using ZIP programs creates directories with mode 777 (very bad)
6
7 inherit cmake pkgconfig useradd systemd
8
9 SUMMARY = "AGL Framework Main part"
10 DESCRIPTION = "\
11 This is a core framework component for managing \
12 applications, widgets, and components. \
13 "
14
15 HOMEPAGE = "https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/app-framework-main"
16 LICENSE = "Apache-2.0"
17 LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
18
19 SRC_URI_git = "git://gerrit.automotivelinux.org/gerrit/src/app-framework-main;protocol=https;branch=master"
20 SRC_URI_files = ""
21 SRC_URI = "${SRC_URI_git} \
22            ${SRC_URI_files} \
23           "
24
25 SRCREV = "81df68c04dc5e32d5d6d06bc20a7030afdf45f59"
26
27 SECTION = "base"
28
29 S = "${WORKDIR}/git"
30
31 DEPENDS = "openssl libxml2 xmlsec1 systemd libzip json-c security-manager libcap-native af-binder"
32
33 afm_name    = "afm"
34 afm_confdir = "${sysconfdir}/${afm_name}"
35 afm_datadir = "${datadir}/${afm_name}"
36 afb_binding_dir = "${libdir}/afb"
37
38 EXTRA_OECMAKE = "\
39         -DUSE_LIBZIP=1 \
40         -DUSE_SIMULATION=0 \
41         -Dafm_name=${afm_name} \
42         -Dafm_confdir=${afm_confdir} \
43         -Dafm_datadir=${afm_datadir} \
44         -DUNITDIR_USER=${systemd_user_unitdir} \
45         -DUNITDIR_SYSTEM=${systemd_system_unitdir} \
46 "
47
48 USERADD_PACKAGES = "${PN}"
49 USERADD_PARAM_${PN} = "-g ${afm_name} -d ${afm_datadir} -r ${afm_name}"
50 GROUPADD_PARAM_${PN} = "-r ${afm_name}"
51
52 SYSTEMD_SERVICE_${PN} = "afm-system-daemon.service"
53 SYSTEMD_AUTO_ENABLE = "enable"
54
55 FILES_${PN} += "\
56         ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${systemd_user_unitdir}/afm-user-daemon.service', '', d)} \
57 "
58
59 RDEPENDS_${PN}_append_smack = " smack-userspace"
60 DEPENDS_append_smack = " smack-userspace-native"
61
62 # short hack here
63 SRC_URI += " file://Hack-to-allow-the-debugging.patch"
64
65 do_install_append() {
66     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
67         mkdir -p ${D}${sysconfdir}/systemd/user/default.target.wants
68         ln -sf ${systemd_user_unitdir}/afm-user-daemon.service ${D}${sysconfdir}/systemd/user/default.target.wants
69     fi
70 }
71
72 pkg_postinst_${PN}() {
73     mkdir -p $D${afm_datadir}/applications $D${afm_datadir}/icons
74     setcap cap_mac_override,cap_dac_override=ie $D${bindir}/afm-system-daemon
75     setcap cap_mac_override,cap_mac_admin,cap_setgid=ie $D${bindir}/afm-user-daemon
76 }
77
78 pkg_postinst_${PN}_smack() {
79     mkdir -p $D${afm_datadir}/applications $D${afm_datadir}/icons
80     chown ${afm_name}:${afm_name} $D${afm_datadir} $D${afm_datadir}/applications $D${afm_datadir}/icons
81     chsmack -a 'System::Shared' -t $D${afm_datadir} $D${afm_datadir}/applications $D${afm_datadir}/icons
82     setcap cap_mac_override,cap_dac_override=ie $D${bindir}/afm-system-daemon
83     setcap cap_mac_override,cap_mac_admin,cap_setgid=ie $D${bindir}/afm-user-daemon
84 }
85
86 PACKAGES =+ "${PN}-binding ${PN}-binding-dbg"
87 FILES_${PN}-binding = " ${afb_binding_dir}/afm-main-binding.so "
88 FILES_${PN}-binding-dbg = " ${afb_binding_dir}/.debug/afm-main-binding.so "
89
90 PACKAGES =+ "${PN}-tools ${PN}-tools-dbg"
91 FILES_${PN}-tools = "${bindir}/wgtpkg-*"
92 FILES_${PN}-tools-dbg = "${bindir}/.debug/wgtpkg-*"
93
94 BBCLASSEXTEND = "native nativesdk"
95