Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,12 @@ homebrew_casks:
previous = system_command "/usr/bin/plutil",
args: ["-convert", "json", "-o", "-", File.expand_path("~/Library/LaunchAgents/run.driga.service.plist")],
must_succeed: true
system_command "#{appdir}/Driga.app/Contents/MacOS/driga",
args: ["service", "install"],
env: JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}),
# system_command shell-escapes env: values yet runs no shell, so a
# value with a space would gain a literal backslash. /usr/bin/env
# takes these assignments verbatim.
environment = JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}).map { |name, value| "#{name}=#{value}" }
system_command "/usr/bin/env",
args: [*environment, "#{appdir}/Driga.app/Contents/MacOS/driga", "service", "install"],
must_succeed: true
end
end
Expand Down
5 changes: 3 additions & 2 deletions scripts/macos_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def appdir; "/Applications"; end
def postflight; yield; end
def system_command(name, **opts)
$calls << [name, opts]
Struct.new(:stdout).new('{"EnvironmentVariables":{"DRIGA_DATA_DIR":"/custom/data","PATH":"/custom/bin:/usr/bin"}}')
Struct.new(:stdout).new('{"EnvironmentVariables":{"DRIGA_DATA_DIR":"/Users/me/Library/Application Support/driga","PATH":"/custom/bin:/usr/bin"}}')
end
class File
def self.exist?(path)
Expand All @@ -264,7 +264,8 @@ end
check := `
if ENV["EXISTING_SERVICE"] == "true"
raise "plist not read" unless $calls.length == 2 && $calls[0] == ["/usr/bin/plutil", {args: ["-convert", "json", "-o", "-", File.expand_path("~/Library/LaunchAgents/run.driga.service.plist")], must_succeed: true}]
expected = ["/Applications/Driga.app/Contents/MacOS/driga", {args: ["service", "install"], env: {"DRIGA_DATA_DIR" => "/custom/data", "PATH" => "/custom/bin:/usr/bin"}, must_succeed: true}]
# env: would reach the service as "Application\\ Support"; /usr/bin/env args do not.
expected = ["/usr/bin/env", {args: ["DRIGA_DATA_DIR=/Users/me/Library/Application Support/driga", "PATH=/custom/bin:/usr/bin", "/Applications/Driga.app/Contents/MacOS/driga", "service", "install"], must_succeed: true}]
raise "environment or command changed: #{$calls}" unless $calls[1] == expected
else
raise "fresh install started service" unless $calls.empty?
Expand Down
7 changes: 4 additions & 3 deletions scripts/verify-release-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ if grep -Fq 'caskroom_path' "$cask"; then
exit 1
fi
if ! grep -Fq 'if File.exist?(File.expand_path("~/Library/LaunchAgents/run.driga.service.plist"))' "$cask" ||
! grep -Fq 'system_command "#{appdir}/Driga.app/Contents/MacOS/driga",' "$cask" ||
! grep -Fq 'args: ["service", "install"],' "$cask" ||
! grep -Fq 'env: JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}),' "$cask"; then
! grep -Fq 'environment = JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}).map { |name, value| "#{name}=#{value}" }' "$cask" ||
! grep -Fq 'system_command "/usr/bin/env",' "$cask" ||
! grep -Fq 'args: [*environment, "#{appdir}/Driga.app/Contents/MacOS/driga", "service", "install"],' "$cask" ||
grep -Fq 'env: JSON.parse' "$cask"; then
echo "Homebrew Cask is missing the existing-service upgrade repair." >&2
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions scripts/verify_release_dist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func releaseDistFixture(t *testing.T, version, tag string) (string, string) {
previous = system_command "/usr/bin/plutil",
args: ["-convert", "json", "-o", "-", File.expand_path("~/Library/LaunchAgents/run.driga.service.plist")],
must_succeed: true
system_command "#{appdir}/Driga.app/Contents/MacOS/driga",
args: ["service", "install"],
env: JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}),
environment = JSON.parse(previous.stdout).fetch("EnvironmentVariables", {}).map { |name, value| "#{name}=#{value}" }
system_command "/usr/bin/env",
args: [*environment, "#{appdir}/Driga.app/Contents/MacOS/driga", "service", "install"],
must_succeed: true
end
end
Expand Down
Loading