Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • postmarketOS/bootmac
  • whynothugo/bootmac
  • a-wai/bootmac
3 results
Show changes
Commits on Source (2)
  • Arnaud Ferraris's avatar
    Add separate udev rules for systemd installs, rework service · 9ab9ff59
    Arnaud Ferraris authored
    On systemd-based systemd, running `bootmac` directly from the `udev`
    rules doesn't work very well for bluetooth. As previously noted, using
    a systemd service instead fixes those problems, although it requires
    finding an appropriate "reverse dependency" (such as e.g.
    `bluetooth.target`).
    
    Using unit activation from `udev` makes it easier, at it will be
    triggered once the interface exists. Moreover, in order to avoid
    creating service files for both wlan and bluetooth, we can make it a
    template and use the instance parameter as bootmac's main command-line
    argument.
    9ab9ff59
  • Arnaud Ferraris's avatar
    Add meson.build · 6c6d8451
    Arnaud Ferraris authored
    This can ease installation, while providing enough flexibility to cover
    both installation use-cases:
    * systemd installs, using the service file and specific udev rules
    * generics installs, using the basic udev rules only
    6c6d8451
[Unit]
Description=Set Bluetooth Mac Address
PartOf=bluetooth.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bootmac --bluetooth
[Install]
WantedBy=bluetooth.target
project(
'bootmac', 'c',
version: '0.6.0',
license : 'GPL-3.0-or-later',
)
prefix = get_option('prefix')
bindir = prefix / get_option('bindir')
libdir = prefix / get_option('libdir')
pkg = import('pkgconfig')
systemd = dependency('systemd', required : false)
# udev is only used to get the rules location, we can have a fallback
udev = dependency('udev', required : false)
if udev.found()
udev_rules_dir = udev.get_variable(pkgconfig : 'udevdir') / 'rules.d'
else
udev_rules_dir = libdir / 'udev' / 'rules.d'
endif
# By default, install the udev rules that execute bootmac directly
bt_udev_rules = 'bootmac-bluetooth.rules'
wifi_udev_rules = 'bootmac-wifi.rules'
if systemd.found()
# On systemd-based system, install a specific udev rule for bluetooth, using
# unit activation and a template service we can instantiate for either
# bluetooth or wifi
systemd_system_unit_dir = systemd.get_variable(
pkgconfig : 'systemdsystemunitdir',
pkgconfig_define: ['prefix', prefix]
)
install_data(
'systemd/bootmac@.service',
install_dir: systemd_system_unit_dir
)
bt_udev_rules = 'systemd/bootmac-bluetooth.rules'
endif
install_data(
bt_udev_rules,
wifi_udev_rules,
install_dir: udev_rules_dir,
rename: [
'90-bootmac-bluetooth.rules',
'90-bootmac-wifi.rules'
],
)
install_data(
'bootmac',
install_dir: bindir,
install_mode: 'rwxr-xr-x'
)
#
# Configure the MAC addresses of the Bluetooth interface when it appears.
# Copyright (c) Dylan Van Assche (2022)
# SPDX-License-Identifier: GPL-3.0-or-later
#
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="bootmac@bluetooth.service"
[Unit]
Description=Set %i MAC address
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bootmac --%i