Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
ef9c49c5
Unverified
Commit
ef9c49c5
authored
3 years ago
by
Sean Molenaar
Committed by
Sean Molenaar
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
service: ensure environment variables are prefixed in command
parent
1bdfacdd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/caveats.rb
+1
-1
1 addition, 1 deletion
Library/Homebrew/caveats.rb
Library/Homebrew/service.rb
+12
-2
12 additions, 2 deletions
Library/Homebrew/service.rb
Library/Homebrew/test/service_spec.rb
+37
-2
37 additions, 2 deletions
Library/Homebrew/test/service_spec.rb
with
50 additions
and
5 deletions
Library/Homebrew/caveats.rb
+
1
−
1
View file @
ef9c49c5
...
...
@@ -155,7 +155,7 @@ class Caveats
return
if
!
f
.
plist_manual
&&
!
f
.
service?
command
=
if
f
.
service?
f
.
service
.
command
.
join
(
" "
)
f
.
service
.
manual_
command
else
f
.
plist_manual
end
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/service.rb
+
12
−
2
View file @
ef9c49c5
...
...
@@ -172,6 +172,16 @@ module Homebrew
@run
.
map
(
&
:to_s
)
end
sig
{
returns
(
String
)
}
def
manual_command
instance_eval
(
&
@service_block
)
vars
=
@environment_variables
.
except
(
:PATH
)
.
map
{
|
k
,
v
|
"
#{
k
}
=
\"
#{
v
}
\"
"
}
out
=
vars
+
command
out
.
join
(
" "
)
end
# Returns a `String` plist.
# @return [String]
sig
{
returns
(
String
)
}
...
...
@@ -217,8 +227,8 @@ module Homebrew
options
<<
"StandardOutput=append:
#{
@log_path
}
"
if
@log_path
.
present?
options
<<
"StandardError=append:
#{
@error_log_path
}
"
if
@error_log_path
.
present?
if
@environment_variables
.
present?
list
=
@environment_variables
.
map
{
|
k
,
v
|
"
#{
k
}
=
#{
v
}
"
}
.
join
(
"&"
)
options
<<
"Environment=
\"
#{
list
}
\"
"
list
=
@environment_variables
.
map
{
|
k
,
v
|
"
#{
k
}
=
#{
v
}
"
}
.
each
{
|
value
|
options
<<
"Environment=
\"
#{
value
}
\"
"
}
end
unit
+
options
.
join
(
"
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/service_spec.rb
+
37
−
2
View file @
ef9c49c5
...
...
@@ -32,12 +32,44 @@ describe Homebrew::Service do
end
end
describe
"#manual_command"
do
it
"returns valid manual_command"
do
f
.
class
.
service
do
run
"
#{
HOMEBREW_PREFIX
}
/bin/beanstalkd"
run_type
:immediate
environment_variables
PATH
:
std_service_path_env
,
ETC_DIR
:
etc
/
"beanstalkd"
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
working_dir
var
keep_alive
true
end
path
=
f
.
service
.
manual_command
expect
(
path
).
to
eq
(
"ETC_DIR=
\"
#{
HOMEBREW_PREFIX
}
/etc/beanstalkd
\"
#{
HOMEBREW_PREFIX
}
/bin/beanstalkd"
)
end
it
"returns valid manual_command without variables"
do
f
.
class
.
service
do
run
opt_bin
/
"beanstalkd"
run_type
:immediate
environment_variables
PATH
:
std_service_path_env
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
working_dir
var
keep_alive
true
end
path
=
f
.
service
.
manual_command
expect
(
path
).
to
eq
(
"
#{
HOMEBREW_PREFIX
}
/opt/formula_name/bin/beanstalkd"
)
end
end
describe
"#to_plist"
do
it
"returns valid plist"
do
f
.
class
.
service
do
run
[
opt_bin
/
"beanstalkd"
,
"test"
]
run_type
:immediate
environment_variables
PATH
:
std_service_path_env
environment_variables
PATH
:
std_service_path_env
,
FOO
:
"BAR"
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
input_path
var
/
"in/beanstalkd"
...
...
@@ -56,6 +88,8 @@ describe Homebrew::Service do
<dict>
\t
<key>EnvironmentVariables</key>
\t
<dict>
\t\t
<key>FOO</key>
\t\t
<string>BAR</string>
\t\t
<key>PATH</key>
\t\t
<string>
#{
HOMEBREW_PREFIX
}
/bin:
#{
HOMEBREW_PREFIX
}
/sbin:/usr/bin:/bin:/usr/sbin:/sbin</string>
\t
</dict>
...
...
@@ -122,7 +156,7 @@ describe Homebrew::Service do
f
.
class
.
service
do
run
[
opt_bin
/
"beanstalkd"
,
"test"
]
run_type
:immediate
environment_variables
PATH
:
std_service_path_env
environment_variables
PATH
:
std_service_path_env
,
FOO
:
"BAR"
error_log_path
var
/
"log/beanstalkd.error.log"
log_path
var
/
"log/beanstalkd.log"
input_path
var
/
"in/beanstalkd"
...
...
@@ -150,6 +184,7 @@ describe Homebrew::Service do
StandardOutput=append:
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.log
StandardError=append:
#{
HOMEBREW_PREFIX
}
/var/log/beanstalkd.error.log
Environment=
\"
PATH=
#{
std_path
}
\"
Environment=
\"
FOO=BAR
\"
EOS
expect
(
unit
).
to
eq
(
unit_expect
.
strip
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment