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*e760df85SPatrick Williamsinherit meson gettext systemd gsettings pkgconfig python3native gtk-icon-cache useradd features_check
8*e760df85SPatrick Williams
9*e760df85SPatrick WilliamsREQUIRED_DISTRO_FEATURES = "gobject-introspection"
10517393d9SAndrew Geissler
11517393d9SAndrew GeisslerSRC_URI = " \
12517393d9SAndrew Geissler    git://github.com/blueman-project/blueman.git;protocol=https;branch=2-3-stable \
13517393d9SAndrew Geissler    file://0001-Search-for-cython3.patch \
14517393d9SAndrew Geissler    file://0002-fix-fail-to-enable-bluetooth.patch \
15517393d9SAndrew Geissler    file://0001-meson-add-pythoninstalldir-option.patch \
16517393d9SAndrew Geissler"
17517393d9SAndrew GeisslerS = "${WORKDIR}/git"
18517393d9SAndrew GeisslerSRCREV = "c85e7afb8d6547d4c35b7b639124de8e999c3650"
19517393d9SAndrew Geissler
20517393d9SAndrew GeisslerEXTRA_OEMESON = "-Druntime_deps_check=false -Dpythoninstalldir=${@noprefix('PYTHON_SITEPACKAGES_DIR', d)}"
21517393d9SAndrew Geissler
22517393d9SAndrew GeisslerSYSTEMD_SERVICE:${PN} = "${BPN}-mechanism.service"
23517393d9SAndrew GeisslerSYSTEMD_AUTO_ENABLE:${PN} = "disable"
24517393d9SAndrew Geissler
25517393d9SAndrew GeisslerRRECOMMENDS:${PN} += "adwaita-icon-theme"
26517393d9SAndrew GeisslerRDEPENDS:${PN} += " \
27517393d9SAndrew Geissler    python3-core \
28864cc43bSPatrick Williams    python3-ctypes \
29517393d9SAndrew Geissler    python3-dbus \
30517393d9SAndrew Geissler    python3-pygobject \
31517393d9SAndrew Geissler    python3-terminal \
32517393d9SAndrew Geissler    python3-fcntl \
33517393d9SAndrew Geissler    packagegroup-tools-bluetooth \
34517393d9SAndrew Geissler"
35517393d9SAndrew Geissler
36517393d9SAndrew GeisslerPACKAGECONFIG ??= " \
37517393d9SAndrew Geissler    ${@bb.utils.filter('DISTRO_FEATURES', 'polkit pulseaudio ', d)} \
38517393d9SAndrew Geissler    thunar \
39517393d9SAndrew Geissler"
40517393d9SAndrew GeisslerPACKAGECONFIG[thunar] = "-Dthunar-sendto=true,-Dthunar-sendto=false"
41517393d9SAndrew GeisslerPACKAGECONFIG[pulseaudio] = "-Dpulseaudio=true,-Dpulseaudio=false"
42517393d9SAndrew GeisslerPACKAGECONFIG[polkit] = "-Dpolicykit=true,-Dpolicykit=false"
43517393d9SAndrew Geissler
44517393d9SAndrew GeisslerFILES:${PN} += " \
45517393d9SAndrew Geissler    ${datadir} \
46517393d9SAndrew Geissler    ${systemd_user_unitdir} \
47517393d9SAndrew Geissler    ${PYTHON_SITEPACKAGES_DIR} \
48517393d9SAndrew Geissler"
49517393d9SAndrew Geissler
50517393d9SAndrew Geissler# In code, path to python is a variable that is replaced with path to native version of it
51517393d9SAndrew Geissler# during the configure stage, e.g ../recipe-sysroot-native/usr/bin/python3-native/python3.
52517393d9SAndrew Geissler# Replace it with #!/usr/bin/env python3
53517393d9SAndrew Geisslerdo_install:append() {
54517393d9SAndrew Geissler    sed -i "1s/.*/#!\/usr\/bin\/env python3/" ${D}${prefix}/libexec/blueman-rfcomm-watcher \
55517393d9SAndrew Geissler                                              ${D}${prefix}/libexec/blueman-mechanism \
56517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-adapters \
57517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-applet \
58517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-manager \
59517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-sendto \
60517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-services \
61517393d9SAndrew Geissler                                              ${D}${bindir}/blueman-tray
62517393d9SAndrew Geissler}
63517393d9SAndrew Geissler
64864cc43bSPatrick Williamsdo_install:append() {
65864cc43bSPatrick Williams    install -d ${D}${datadir}/polkit-1/rules.d
66864cc43bSPatrick Williams    cat >${D}${datadir}/polkit-1/rules.d/51-blueman.rules <<EOF
67864cc43bSPatrick Williams/* Allow users in wheel group to use blueman feature requiring root without authentication */
68864cc43bSPatrick Williamspolkit.addRule(function(action, subject) {
69864cc43bSPatrick Williams    if ((action.id == "org.blueman.network.setup" ||
70864cc43bSPatrick Williams         action.id == "org.blueman.dhcp.client" ||
71864cc43bSPatrick Williams         action.id == "org.blueman.rfkill.setstate" ||
72864cc43bSPatrick Williams         action.id == "org.blueman.pppd.pppconnect") &&
73864cc43bSPatrick Williams        subject.isInGroup("wheel")) {
74864cc43bSPatrick Williams
75864cc43bSPatrick Williams        return polkit.Result.YES;
76864cc43bSPatrick Williams    }
77864cc43bSPatrick Williams});
78864cc43bSPatrick WilliamsEOF
79864cc43bSPatrick Williams}
80864cc43bSPatrick Williams
81864cc43bSPatrick WilliamsUSERADD_PACKAGES = "${PN}"
82864cc43bSPatrick WilliamsUSERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir ${sysconfdir}/polkit-1 --shell /bin/nologin polkitd"
83864cc43bSPatrick Williams
84864cc43bSPatrick Williamsdo_install:append() {
85864cc43bSPatrick Williams        # Fix up permissions on polkit rules.d to work with rpm4 constraints
86864cc43bSPatrick Williams        chmod 700 ${D}/${datadir}/polkit-1/rules.d
87864cc43bSPatrick Williams        chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
88864cc43bSPatrick Williams}
89