[client] Migrate macOS cask template to Homebrew install steps

Homebrew deprecated the postflight and uninstall_preflight cask stanzas
in favour of the declarative *_steps DSL, so every brew command that
evaluates netbirdio/tap now prints deprecation warnings. Once the
deprecation becomes a disable the generated cask stops loading and
netbird-ui can no longer be installed or upgraded through Homebrew.

The *_steps blocks take JSON-serialisable steps run in a sandbox rather
than arbitrary Ruby, so system_command is re-expressed as run/remove.
The two postflight blocks merge into one because a cask carries only a
single instance, preserving the original order. set_permissions moves
from a hardcoded /Applications to base: :appdir, matching what the
installer invocation already did. The launchctl fallbacks keep their
tolerant semantics through must_succeed: false, and remove is a no-op
when the plist is absent.
This commit is contained in:
Daniele Casciani
2026-09-08 21:01:43 +02:00
parent d2e62e358a
commit df3756151f
+9 -17
View File
@@ -17,25 +17,17 @@ cask "{{ $projectName }}" do
depends_on formula: "netbird"
postflight do
set_permissions "/Applications/Netbird UI.app/installer.sh", '0755'
set_permissions "/Applications/Netbird UI.app/uninstaller.sh", '0755'
postflight_steps do
set_permissions ["Netbird UI.app/installer.sh", "Netbird UI.app/uninstaller.sh"], "0755",
base: :appdir, recursive: false
run "Netbird UI.app/installer.sh", args: ["#{version}"], base: :appdir, sudo: true
end
postflight do
system_command "#{appdir}/Netbird UI.app/installer.sh",
args: ["#{version}"],
sudo: true
end
uninstall_preflight do
system_command "/bin/sh",
args: ["-c", <<~CMD],
launchctl bootout system/netbird 2>/dev/null || \
launchctl unload /Library/LaunchDaemons/netbird.plist 2>/dev/null || true
rm -f /Library/LaunchDaemons/netbird.plist
CMD
sudo: true
uninstall_preflight_steps do
run "/bin/launchctl", args: ["bootout", "system/netbird"], sudo: true, must_succeed: false
run "/bin/launchctl", args: ["unload", "/Library/LaunchDaemons/netbird.plist"],
sudo: true, must_succeed: false
remove "/Library/LaunchDaemons/netbird.plist", sudo: true
end
name "Netbird UI"