# SPDX-License-Identifier: MPL-2.0 """Connect the Sargo Bluetooth HAL to BlueZ; pairing stays user initiated.""" def prepare(root, write): import shutil from pathlib import Path shutil.copy2(Path(__file__).with_name('bluetooth-control.py'),root/'etc/tundra/bluetooth-control.py') write('etc/systemd/system/tundra-bluetooth.service', """[Unit] Description=Tundra Bluetooth pairing and discovery broker Requires=bluetooth.service After=bluetooth.service PartOf=bluetooth.service [Service] ExecStart=/usr/bin/python3 /etc/tundra/bluetooth-control.py RuntimeDirectory=tundra-bluetooth RuntimeDirectoryMode=0755 UMask=0077 Restart=on-failure RestartSec=3 NoNewPrivileges=yes ProtectSystem=strict ProtectHome=yes PrivateTmp=yes """) write('etc/dbus-1/system.d/tundra-bluetooth.conf', ''' ''') write('etc/bluetooth/main.conf', '[General]\nName=Vulpes OS\nDiscoverableTimeout=120\n[Policy]\nAutoEnable=false\n') write('etc/systemd/system/tundra-bluebinder.service', '''[Unit] Description=Sargo Bluetooth HAL bridge Requires=tundra-hal.service After=tundra-hal.service Before=bluetooth.service [Service] Type=notify ExecStartPre=/usr/bin/binder-wait android.hardware.bluetooth@1.0::IBluetoothHci/default ExecStart=/usr/sbin/bluebinder Restart=on-failure RestartSec=5 TimeoutStartSec=60 NoNewPrivileges=yes ProtectHome=yes ProtectSystem=strict PrivateTmp=yes ''') write('etc/systemd/system/bluetooth.service.d/tundra.conf', '''[Unit] Requires=tundra-bluebinder.service dbus.service After=tundra-bluebinder.service dbus.service ''') wants = root/'etc/systemd/system/tundra.target.wants' wants.mkdir(parents=True, exist_ok=True) (wants/'tundra-bluetooth.service').symlink_to('/etc/systemd/system/tundra-bluetooth.service') (wants/'bluetooth.service').symlink_to('/usr/lib/systemd/system/bluetooth.service')