1DESCRIPTION = "Blueman is a GTK+ Bluetooth Manager"
2LICENSE = "GPL-3.0-only"
3LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
4
5DEPENDS = "gtk+3 glib-2.0 bluez5 python3-pygobject python3-cython-native"
6
7inherit meson gettext systemd gsettings pkgconfig python3native gtk-icon-cache useradd features_check
8
9REQUIRED_DISTRO_FEATURES = "gobject-introspection-data"
10
11SRC_URI = " \
12    git://github.com/blueman-project/blueman.git;protocol=https;branch=2-3-stable \
13    file://0001-Search-for-cython3.patch \
14    file://0002-fix-fail-to-enable-bluetooth.patch \
15    file://0001-meson-add-pythoninstalldir-option.patch \
16"
17S = "${WORKDIR}/git"
18SRCREV = "c85e7afb8d6547d4c35b7b639124de8e999c3650"
19
20EXTRA_OEMESON = "-Druntime_deps_check=false -Dpythoninstalldir=${@noprefix('PYTHON_SITEPACKAGES_DIR', d)}"
21
22SYSTEMD_SERVICE:${PN} = "${BPN}-mechanism.service"
23SYSTEMD_AUTO_ENABLE:${PN} = "disable"
24
25RRECOMMENDS:${PN} += "adwaita-icon-theme"
26RDEPENDS:${PN} += " \
27    python3-core \
28    python3-ctypes \
29    python3-dbus \
30    python3-pygobject \
31    python3-terminal \
32    python3-fcntl \
33    packagegroup-tools-bluetooth \
34"
35
36PACKAGECONFIG ??= " \
37    ${@bb.utils.filter('DISTRO_FEATURES', 'polkit pulseaudio ', d)} \
38    thunar \
39"
40PACKAGECONFIG[thunar] = "-Dthunar-sendto=true,-Dthunar-sendto=false"
41PACKAGECONFIG[pulseaudio] = "-Dpulseaudio=true,-Dpulseaudio=false"
42PACKAGECONFIG[polkit] = "-Dpolicykit=true,-Dpolicykit=false"
43
44FILES:${PN} += " \
45    ${datadir} \
46    ${systemd_user_unitdir} \
47    ${PYTHON_SITEPACKAGES_DIR} \
48"
49
50# In code, path to python is a variable that is replaced with path to native version of it
51# during the configure stage, e.g ../recipe-sysroot-native/usr/bin/python3-native/python3.
52# Replace it with #!/usr/bin/env python3
53do_install:append() {
54    sed -i "1s/.*/#!\/usr\/bin\/env python3/" ${D}${prefix}/libexec/blueman-rfcomm-watcher \
55                                              ${D}${prefix}/libexec/blueman-mechanism \
56                                              ${D}${bindir}/blueman-adapters \
57                                              ${D}${bindir}/blueman-applet \
58                                              ${D}${bindir}/blueman-manager \
59                                              ${D}${bindir}/blueman-sendto \
60                                              ${D}${bindir}/blueman-services \
61                                              ${D}${bindir}/blueman-tray
62}
63
64do_install:append() {
65    install -d ${D}${datadir}/polkit-1/rules.d
66    cat >${D}${datadir}/polkit-1/rules.d/51-blueman.rules <<EOF
67/* Allow users in wheel group to use blueman feature requiring root without authentication */
68polkit.addRule(function(action, subject) {
69    if ((action.id == "org.blueman.network.setup" ||
70         action.id == "org.blueman.dhcp.client" ||
71         action.id == "org.blueman.rfkill.setstate" ||
72         action.id == "org.blueman.pppd.pppconnect") &&
73        subject.isInGroup("wheel")) {
74
75        return polkit.Result.YES;
76    }
77});
78EOF
79}
80
81USERADD_PACKAGES = "${PN}"
82USERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir ${sysconfdir}/polkit-1 --shell /bin/nologin polkitd"
83
84do_install:append() {
85        # Fix up permissions on polkit rules.d to work with rpm4 constraints
86        chmod 700 ${D}/${datadir}/polkit-1/rules.d
87        chown polkitd:root ${D}/${datadir}/polkit-1/rules.d
88}
89