1517393d9SAndrew GeisslerDESCRIPTION = "Blueman is a GTK+ Bluetooth Manager"
2517393d9SAndrew GeisslerLICENSE = "GPL-3.0-only"
3517393d9SAndrew GeisslerLIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
4517393d9SAndrew Geissler
5517393d9SAndrew GeisslerDEPENDS = "gtk+3 glib-2.0 bluez5 python3-pygobject python3-cython-native"
6517393d9SAndrew Geissler
7*864cc43bSPatrick Williamsinherit meson gettext systemd gsettings pkgconfig python3native gtk-icon-cache useradd
8517393d9SAndrew Geissler
9517393d9SAndrew GeisslerSRC_URI = " \
10517393d9SAndrew Geissler    git://github.com/blueman-project/blueman.git;protocol=https;branch=2-3-stable \
11517393d9SAndrew Geissler    file://0001-Search-for-cython3.patch \
12517393d9SAndrew Geissler    file://0002-fix-fail-to-enable-bluetooth.patch \
13517393d9SAndrew Geissler    file://0001-meson-add-pythoninstalldir-option.patch \
14517393d9SAndrew Geissler"
15517393d9SAndrew GeisslerS = "${WORKDIR}/git"
16517393d9SAndrew GeisslerSRCREV = "c85e7afb8d6547d4c35b7b639124de8e999c3650"
17517393d9SAndrew Geissler
18517393d9SAndrew GeisslerEXTRA_OEMESON = "-Druntime_deps_check=false -Dpythoninstalldir=${@noprefix('PYTHON_SITEPACKAGES_DIR', d)}"
19517393d9SAndrew Geissler
20517393d9SAndrew GeisslerSYSTEMD_SERVICE:${PN} = "${BPN}-mechanism.service"
21517393d9SAndrew GeisslerSYSTEMD_AUTO_ENABLE:${PN} = "disable"
22517393d9SAndrew Geissler
23517393d9SAndrew GeisslerRRECOMMENDS:${PN} += "adwaita-icon-theme"
24517393d9SAndrew GeisslerRDEPENDS:${PN} += " \
25517393d9SAndrew Geissler    python3-core \
26*864cc43bSPatrick Williams    python3-ctypes \
27517393d9SAndrew Geissler    python3-dbus \
28517393d9SAndrew Geissler    python3-pygobject \
29517393d9SAndrew Geissler    python3-terminal \
30517393d9SAndrew Geissler    python3-fcntl \
31517393d9SAndrew Geissler    packagegroup-tools-bluetooth \
32517393d9SAndrew Geissler"
33517393d9SAndrew Geissler
34517393d9SAndrew GeisslerPACKAGECONFIG ??= " \
35517393d9SAndrew Geissler    ${@bb.utils.filter('DISTRO_FEATURES', 'polkit pulseaudio ', d)} \
36517393d9SAndrew Geissler    thunar \
37517393d9SAndrew Geissler"
38517393d9SAndrew GeisslerPACKAGECONFIG[thunar] = "-Dthunar-sendto=true,-Dthunar-sendto=false"
39517393d9SAndrew GeisslerPACKAGECONFIG[pulseaudio] = "-Dpulseaudio=true,-Dpulseaudio=false"
40517393d9SAndrew GeisslerPACKAGECONFIG[polkit] = "-Dpolicykit=true,-Dpolicykit=false"
41517393d9SAndrew Geissler
42517393d9SAndrew GeisslerFILES:${PN} += " \
43517393d9SAndrew Geissler    ${datadir} \
44517393d9SAndrew Geissler    ${systemd_user_unitdir} \
45517393d9SAndrew Geissler    ${PYTHON_SITEPACKAGES_DIR} \
46517393d9SAndrew Geissler"
47517393d9SAndrew Geissler
48517393d9SAndrew Geissler# In code, path to python is a variable that is replaced with path to native version of it
49517393d9SAndrew Geissler# during the configure stage, e.g ../recipe-sysroot-native/usr/bin/python3-native/python3.
50517393d9SAndrew Geissler# Replace it with #!/usr/bin/env python3
51517393d9SAndrew Geisslerdo_install:append() {
52517393d9SAndrew Geissler    sed -i "1s/.*/#!\/usr\/bin\/env python3/" ${D}${prefix}/libexec/blueman-rfcomm-watcher \
53517393d9SAndrew Geissler                                              ${D}${prefix}/libexec/blueman-mechanism \
54517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-adapters \
55517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-applet \
56517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-manager \
57517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-sendto \
58517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-services \
59517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-tray
60517393d9SAndrew Geissler}
61517393d9SAndrew Geissler
62*864cc43bSPatrick Williamsdo_install:append() {
63*864cc43bSPatrick Williams    install -d ${D}${datadir}/polkit-1/rules.d
64*864cc43bSPatrick Williams    cat >${D}${datadir}/polkit-1/rules.d/51-blueman.rules <<EOF
65*864cc43bSPatrick Williams/* Allow users in wheel group to use blueman feature requiring root without authentication */
66*864cc43bSPatrick Williamspolkit.addRule(function(action, subject) {
67*864cc43bSPatrick Williams    if ((action.id == "org.blueman.network.setup" ||
68*864cc43bSPatrick Williams         action.id == "org.blueman.dhcp.client" ||
69*864cc43bSPatrick Williams         action.id == "org.blueman.rfkill.setstate" ||
70*864cc43bSPatrick Williams         action.id == "org.blueman.pppd.pppconnect") &&
71*864cc43bSPatrick Williams        subject.isInGroup("wheel")) {
72*864cc43bSPatrick Williams
73*864cc43bSPatrick Williams        return polkit.Result.YES;
74*864cc43bSPatrick Williams    }
75*864cc43bSPatrick Williams});
76*864cc43bSPatrick WilliamsEOF
77*864cc43bSPatrick Williams}
78*864cc43bSPatrick Williams
79*864cc43bSPatrick WilliamsUSERADD_PACKAGES = "${PN}"
80*864cc43bSPatrick WilliamsUSERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir ${sysconfdir}/polkit-1 --shell /bin/nologin polkitd"
81*864cc43bSPatrick Williams
82*864cc43bSPatrick Williamsdo_install:append() {
83*864cc43bSPatrick Williams        # Fix up permissions on polkit rules.d to work with rpm4 constraints
84*864cc43bSPatrick Williams        chmod 700 ${D}/${datadir}/polkit-1/rules.d
85*864cc43bSPatrick Williams        chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
86*864cc43bSPatrick Williams}
87