mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
brew: improve Docker detection.
Needed for Ubuntu 22.04.
This commit is contained in:
parent
0334658633
commit
e58d7d3456
@ -120,8 +120,9 @@ begin
|
|||||||
# Unset HOMEBREW_HELP to avoid confusing the tap
|
# Unset HOMEBREW_HELP to avoid confusing the tap
|
||||||
with_env HOMEBREW_HELP: nil do
|
with_env HOMEBREW_HELP: nil do
|
||||||
tap_commands = []
|
tap_commands = []
|
||||||
cgroup = Utils.popen_read("cat", "/proc/1/cgroup")
|
if File.exist?("/.dockerenv") ||
|
||||||
if %w[azpl_job actions_job docker garden kubepods].none? { |container| cgroup.include?(container) }
|
((cgroup = Utils.popen_read("cat", "/proc/1/cgroup").presence) &&
|
||||||
|
%w[azpl_job actions_job docker garden kubepods].none? { |type| cgroup.include?(type) })
|
||||||
brew_uid = HOMEBREW_BREW_FILE.stat.uid
|
brew_uid = HOMEBREW_BREW_FILE.stat.uid
|
||||||
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] if Process.uid.zero? && !brew_uid.zero?
|
tap_commands += %W[/usr/bin/sudo -u ##{brew_uid}] if Process.uid.zero? && !brew_uid.zero?
|
||||||
end
|
end
|
||||||
|
@ -197,6 +197,7 @@ check-run-command-as-root() {
|
|||||||
[[ "$(id -u)" == 0 ]] || return
|
[[ "$(id -u)" == 0 ]] || return
|
||||||
|
|
||||||
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
# Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there)
|
||||||
|
[[ -f /.dockerenv ]] && return
|
||||||
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
[[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return
|
||||||
|
|
||||||
# Homebrew Services may need `sudo` for system-wide daemons.
|
# Homebrew Services may need `sudo` for system-wide daemons.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user