Convert to new override syntax
[AGL/meta-agl.git] / meta-app-framework / recipes-core / af-main / af-main_git.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 sed m4"
14 DEPENDS:class-native = "openssl libxml2 xmlsec1 libzip json-c"
15 RDEPENDS:${PN}:class-target += "af-binder-tools nss-localuser cynagoauth"
16
17 PACKAGE_WRITE_DEPS:append:with-lsm-smack = " smack-native libcap-native"
18
19 EXTRA_OECMAKE:append:class-native  = "\
20         -DUSE_LIBZIP=1 \
21         -DUSE_SIMULATION=1 \
22         -DUSE_SDK=1 \
23         -DAGLVERSION=${AGLVERSION} \
24         -Dafm_name=${afm_name} \
25         -Dafm_confdir=${afm_confdir} \
26         -Dafm_datadir=${afm_datadir} \
27 "
28
29 EXTRA_OECMAKE:append:class-target = "\
30         -DUSE_LIBZIP=1 \
31         -DUSE_SIMULATION=0 \
32         -DUSE_SDK=0 \
33         -DAGLVERSION=${AGLVERSION} \
34         -Dafm_name=${afm_name} \
35         -Dafm_confdir=${afm_confdir} \
36         -Dafm_datadir=${afm_datadir} \
37         -Dsystemd_units_root=${systemd_units_root} \
38         -DUNITDIR_USER=${systemd_user_unitdir} \
39         -DUNITDIR_SYSTEM=${systemd_system_unitdir} \
40 "
41
42 # ------------------------ WARNING WARNING WARNNING ---------------------------
43 #
44 # ATM (FF.rc2), forcing all apps to be signed is an issue when building without
45 # agl-devel feature. A workaround is to define ALLOW_NO_SIGNATURE=ON for all
46 # builds but this must be removed later. See SPEC-1614 for more details.
47 #
48 # A variable AGL_FORBID_UNSIGNED_APPS is introduced to enable/disable this 
49 # workaround in local.conf and allow transition to signed apps:
50 # * forbid unsigned apps by setting: AGL_FORBID_UNSIGNED_APPS="1"
51 # * [DEFAULT] allow unsigned apps: do nothing (or set: AGL_FORBID_UNSIGNED_APPS="0")
52 AGL_FORBID_UNSIGNED_APPS ?= "0"
53 #
54 # WORKAROUND:
55 EXTRA_OECMAKE:append:agl-devel = " -DAGL_DEVEL=1"
56 EXTRA_OECMAKE:append = " ${@bb.utils.contains('AGL_FORBID_UNSIGNED_APPS','1','','-DALLOW_NO_SIGNATURE=ON', d)}"
57 #
58 # Correct version (IMPORTANT TODO: to be restored later):
59 #EXTRA_OECMAKE:append:agl-devel = " -DAGL_DEVEL=1 -DALLOW_NO_SIGNATURE=ON"
60 #
61 # ------------------------ WARNING WARNING WARNNING ---------------------------
62
63
64 USERADD_PACKAGES = "${PN}"
65 USERADD_PARAM:${PN} = "--system --gid ${afm_name} --home-dir ${afm_datadir} ${afm_name}"
66 GROUPADD_PARAM:${PN} = "--system ${afm_name}"
67
68 RDEPENDS:${PN}:append:with-lsm-smack = " smack bash"
69 DEPENDS:append:with-lsm-smack = " smack-native"
70
71 do_install:append:class-target() {
72     install -d ${D}${bindir}
73     install -d -m 0775 ${D}${systemd_units_root}/system
74     install -d -m 0775 "${D}${systemd_units_root}/system/multi-user.target.wants"
75     install -d -m 0775 "${D}${systemd_units_root}/system/afm-user-session@.target.wants"
76     install -d -m 0775 ${D}${systemd_units_root}/user
77     install -d -m 0775 ${D}${systemd_units_root}/user/default.target.wants
78     install -d -m 0775 ${D}${systemd_units_root}/user/sockets.target.wants
79     install -d ${D}${afm_datadir}/applications
80     install -d ${D}${afm_datadir}/icons
81     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
82         install -d -m 0755 ${D}${systemd_system_unitdir}/multi-user.target.wants
83         install -d -m 0755 ${D}${systemd_system_unitdir}/sockets.target.wants
84         ln -sf ../afm-system-setup.service ${D}${systemd_system_unitdir}/multi-user.target.wants/afm-system-setup.service
85         ln -sf ../afm-system-daemon.service ${D}${systemd_system_unitdir}/multi-user.target.wants/afm-system-daemon.service
86         ln -sf ../afm-system-daemon.socket ${D}${systemd_system_unitdir}/sockets.target.wants/afm-system-daemon.socket
87     fi
88 }
89
90 pkg_postinst_ontarget:${PN}() {
91     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
92         chgrp ${afm_name} $D${systemd_units_root}/system
93         chgrp ${afm_name} $D${systemd_units_root}/system/afm-user-session@.target.wants
94         chgrp ${afm_name} $D${systemd_units_root}/user/default.target.wants
95         chgrp ${afm_name} $D${systemd_units_root}/user/sockets.target.wants
96     fi
97     chown ${afm_name}:${afm_name} $D${afm_datadir}
98     chown ${afm_name}:${afm_name} $D${afm_datadir}/applications
99     chown ${afm_name}:${afm_name} $D${afm_datadir}/icons
100 }
101
102 pkg_postinst_ontarget:${PN}:append:with-lsm-smack() {
103     if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
104         chsmack -a 'System::Shared' -t $D${systemd_units_root}/system
105         chsmack -a 'System::Shared' -t $D${systemd_units_root}/system/afm-user-session@.target.wants
106         chsmack -a 'System::Shared' -t $D${systemd_units_root}/user/default.target.wants
107         chsmack -a 'System::Shared' -t $D${systemd_units_root}/user/sockets.target.wants
108     fi
109     chsmack -a 'System::Shared' -t $D${afm_datadir}
110     chsmack -a 'System::Shared' -t $D${afm_datadir}/applications
111     chsmack -a 'System::Shared' -t $D${afm_datadir}/icons
112 }
113 FILES:${PN} += "${systemd_units_root}/* ${systemd_system_unitdir} ${systemd_user_unitdir}"
114 FILES:${PN}:append:agl-sign-wgts = " ${datadir}/afm"
115
116 PACKAGES =+ "${PN}-binding ${PN}-binding-dbg"
117 FILES:${PN}-binding = " ${afb_binding_dir}/afm-main-binding.so "
118 FILES:${PN}-binding-dbg = " ${afb_binding_dir}/.debug/afm-main-binding.so "
119
120 PACKAGES =+ "${PN}-tools ${PN}-tools-dbg"
121 FILES:${PN}-tools = "${bindir}/wgtpkg-*"
122 FILES:${PN}-tools-dbg = "${bindir}/.debug/wgtpkg-*"