Module: OS::Linux::Diagnostic::Checks Private

Extended by:
T::Helpers
Included in:
Homebrew::Diagnostic::Checks
Defined in:
extend/os/linux/diagnostic.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#check_gcc_dependent_linkageObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'extend/os/linux/diagnostic.rb', line 133

def check_gcc_dependent_linkage
  gcc_dependents = ::Formula.installed.select do |formula|
    next false unless formula.tap&.core_tap?

    # FIXME: This includes formulae that have no runtime dependency on GCC.
    formula.recursive_dependencies.map(&:name).include? "gcc"
  rescue TapFormulaUnavailableError
    false
  end
  return if gcc_dependents.empty?

  badly_linked = gcc_dependents.select do |dependent|
    keg = Keg.new(dependent.prefix)
    keg.binary_executable_or_library_files.any? do |binary|
      paths = binary.rpaths
      versioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/\d+$}) }
      unversioned_linkage = paths.any? { |path| path.match?(%r{lib/gcc/current$}) }

      versioned_linkage && !unversioned_linkage
    end
  end
  return if badly_linked.empty?

  inject_file_list badly_linked, <<~EOS
    Formulae which link to GCC through a versioned path were found. These formulae
    are prone to breaking when GCC is updated. You should `brew reinstall` these formulae:
  EOS
end

#check_glibc_minimum_versionObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



86
87
88
89
90
91
92
93
94
95
96
97
# File 'extend/os/linux/diagnostic.rb', line 86

def check_glibc_minimum_version
  return unless OS::Linux::Glibc.below_minimum_version?

  <<~EOS
    Your system glibc #{OS::Linux::Glibc.system_version} is too old.
    We only support glibc #{OS::Linux::Glibc.minimum_version} or later.
    #{please_create_pull_requests}
    We recommend updating to a newer version via your distribution's
    package manager, upgrading your distribution to the latest version,
    or changing distributions.
  EOS
end

#check_kernel_minimum_versionObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'extend/os/linux/diagnostic.rb', line 99

def check_kernel_minimum_version
  return unless OS::Linux::Kernel.below_minimum_version?

  <<~EOS
    Your Linux kernel #{OS.kernel_version} is too old.
    We only support kernel #{OS::Linux::Kernel.minimum_version} or later.
    You will be unable to use binary packages (bottles).
    #{please_create_pull_requests}
    We recommend updating to a newer version via your distribution's
    package manager, upgrading your distribution to the latest version,
    or changing distributions.
  EOS
end

#check_linuxbrew_bottle_domainObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



123
124
125
126
127
128
129
130
131
# File 'extend/os/linux/diagnostic.rb', line 123

def check_linuxbrew_bottle_domain
  return unless Homebrew::EnvConfig.bottle_domain.include?("linuxbrew")

  <<~EOS
    Your HOMEBREW_BOTTLE_DOMAIN still contains "linuxbrew".
    You must unset it (or adjust it to not contain linuxbrew
    e.g. by using homebrew instead).
  EOS
end

#check_linuxbrew_coreObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



113
114
115
116
117
118
119
120
121
# File 'extend/os/linux/diagnostic.rb', line 113

def check_linuxbrew_core
  return unless Homebrew::EnvConfig.no_install_from_api?
  return unless CoreTap.instance.linuxbrew_core?

  <<~EOS
    Your Linux core repository is still linuxbrew-core.
    You must `brew update` to update to homebrew-core.
  EOS
end

#check_supported_architectureObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



76
77
78
79
80
81
82
83
84
# File 'extend/os/linux/diagnostic.rb', line 76

def check_supported_architecture
  return if Hardware::CPU.arch == :x86_64

  <<~EOS
    Your CPU architecture (#{Hardware::CPU.arch}) is not supported. We only support
    x86_64 CPU architectures. You will be unable to use binary packages (bottles).
    #{please_create_pull_requests}
  EOS
end

#check_tmpdir_executableObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'extend/os/linux/diagnostic.rb', line 47

def check_tmpdir_executable
  f = Tempfile.new(%w[homebrew_check_tmpdir_executable .sh], HOMEBREW_TEMP)
  f.write "#!/bin/sh\n"
  f.chmod 0700
  f.close
  return if system T.must(f.path)

  <<~EOS
    The directory #{HOMEBREW_TEMP} does not permit executing
    programs. It is likely mounted as "noexec". Please set HOMEBREW_TEMP
    in your #{Utils::Shell.profile} to a different directory, for example:
      export HOMEBREW_TEMP=~/tmp
      echo 'export HOMEBREW_TEMP=~/tmp' >> #{Utils::Shell.profile}
  EOS
ensure
  f&.unlink
end

#check_tmpdir_sticky_bitObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'extend/os/linux/diagnostic.rb', line 34

def check_tmpdir_sticky_bit
  message = generic_check_tmpdir_sticky_bit
  return if message.nil?

  message + <<~EOS
    If you don't have administrative privileges on this machine,
    create a directory and set the HOMEBREW_TEMP environment variable,
    for example:
      install -d -m 1755 ~/tmp
      #{Utils::Shell.set_variable_in_profile("HOMEBREW_TEMP", "~/tmp")}
  EOS
end

#check_umask_not_zeroObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



65
66
67
68
69
70
71
72
73
74
# File 'extend/os/linux/diagnostic.rb', line 65

def check_umask_not_zero
  return unless File.umask.zero?

  <<~EOS
    umask is currently set to 000. Directories created by Homebrew cannot
    be world-writable. This issue can be resolved by adding "umask 002" to
    your #{Utils::Shell.profile}:
      echo 'umask 002' >> #{Utils::Shell.profile}
  EOS
end

#fatal_preinstall_checksObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



18
19
20
21
22
23
24
# File 'extend/os/linux/diagnostic.rb', line 18

def fatal_preinstall_checks
  %w[
    check_access_directories
    check_linuxbrew_core
    check_linuxbrew_bottle_domain
  ].freeze
end

#supported_configuration_checksObject

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



26
27
28
29
30
31
32
# File 'extend/os/linux/diagnostic.rb', line 26

def supported_configuration_checks
  %w[
    check_glibc_minimum_version
    check_kernel_minimum_version
    check_supported_architecture
  ].freeze
end