keg: further tweak directory constants.
- ensure that `HOMEBREW_CELLAR` is always created on `install`. - remove the need for a special `PRUNEABLE_DIRECTORIES` variable - reuse values from existing variables and get `uniq`s.
This commit is contained in:
parent
d4f8335f0a
commit
9a698d2130
@ -26,7 +26,7 @@ before_install:
|
||||
sudo chown -R "$USER" "$HOMEBREW_REPOSITORY";
|
||||
else
|
||||
LINUX="1";
|
||||
export PATH="$PWD/bin:$PATH";
|
||||
export PATH="$PWD/bin:/usr/bin:/bin";
|
||||
fi
|
||||
# umask 022 fixes Linux `brew tests` failures;
|
||||
- if [ "$LINUX" ]; then
|
||||
|
||||
@ -293,7 +293,6 @@ module Homebrew
|
||||
def rm_ds_store(dirs = nil)
|
||||
dirs ||= begin
|
||||
Keg::MUST_EXIST_DIRECTORIES + [
|
||||
HOMEBREW_CELLAR,
|
||||
HOMEBREW_PREFIX/"Caskroom",
|
||||
]
|
||||
end
|
||||
|
||||
@ -15,7 +15,7 @@ module Homebrew
|
||||
|
||||
dirs = []
|
||||
|
||||
Keg::PRUNEABLE_DIRECTORIES.each do |dir|
|
||||
Keg::MUST_EXIST_SUBDIRECTORIES.each do |dir|
|
||||
next unless dir.directory?
|
||||
|
||||
dir.find do |path|
|
||||
@ -32,8 +32,7 @@ module Homebrew
|
||||
path.unlink
|
||||
end
|
||||
end
|
||||
elsif path.directory? && !Keg::PRUNEABLE_DIRECTORIES.include?(path) &&
|
||||
!Keg::MUST_BE_WRITABLE_DIRECTORIES.include?(path)
|
||||
elsif path.directory? && !Keg::MUST_EXIST_SUBDIRECTORIES.include?(path)
|
||||
dirs << path
|
||||
end
|
||||
end
|
||||
|
||||
@ -276,7 +276,7 @@ module Homebrew
|
||||
def check_for_broken_symlinks
|
||||
broken_symlinks = []
|
||||
|
||||
Keg::PRUNEABLE_DIRECTORIES.each do |d|
|
||||
Keg::MUST_EXIST_SUBDIRECTORIES.each do |d|
|
||||
next unless d.directory?
|
||||
|
||||
d.find do |path|
|
||||
|
||||
@ -18,7 +18,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
def attempt_directory_creation
|
||||
Keg::MUST_BE_WRITABLE_DIRECTORIES.each do |dir|
|
||||
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
||||
begin
|
||||
FileUtils.mkdir_p(dir) unless dir.exist?
|
||||
rescue
|
||||
|
||||
@ -70,27 +70,27 @@ class Keg
|
||||
].freeze
|
||||
# TODO: remove when brew-test-bot no longer uses this
|
||||
TOP_LEVEL_DIRECTORIES = KEG_LINK_DIRECTORIES
|
||||
PRUNEABLE_DIRECTORIES = (
|
||||
KEG_LINK_DIRECTORIES - %w[var] + %w[var/homebrew/linked]
|
||||
).map { |dir| HOMEBREW_PREFIX/dir }
|
||||
MUST_EXIST_SUBDIRECTORIES = (
|
||||
KEG_LINK_DIRECTORIES - %w[var] + %w[
|
||||
opt
|
||||
var/homebrew/linked
|
||||
]
|
||||
).map { |dir| HOMEBREW_PREFIX/dir }.uniq.sort.freeze
|
||||
|
||||
# Keep relatively in sync with
|
||||
# https://github.com/Homebrew/install/blob/master/install
|
||||
MUST_EXIST_DIRECTORIES = (
|
||||
(KEG_LINK_DIRECTORIES + %w[
|
||||
opt
|
||||
]).map { |dir| HOMEBREW_PREFIX/dir }
|
||||
).freeze
|
||||
MUST_EXIST_DIRECTORIES = MUST_EXIST_SUBDIRECTORIES + [
|
||||
HOMEBREW_CELLAR,
|
||||
].uniq.sort.freeze
|
||||
MUST_BE_WRITABLE_DIRECTORIES = (
|
||||
(KEG_LINK_DIRECTORIES + %w[
|
||||
opt
|
||||
%w[
|
||||
etc/bash_completion.d lib/pkgconfig
|
||||
share/aclocal share/doc share/info share/locale share/man
|
||||
share/man/man1 share/man/man2 share/man/man3 share/man/man4
|
||||
share/man/man5 share/man/man6 share/man/man7 share/man/man8
|
||||
share/zsh share/zsh/site-functions
|
||||
var/log
|
||||
]).map { |dir| HOMEBREW_PREFIX/dir } + [
|
||||
].map { |dir| HOMEBREW_PREFIX/dir } + MUST_EXIST_SUBDIRECTORIES + [
|
||||
HOMEBREW_CACHE,
|
||||
HOMEBREW_CELLAR,
|
||||
HOMEBREW_LOCKS,
|
||||
@ -98,7 +98,7 @@ class Keg
|
||||
HOMEBREW_REPOSITORY,
|
||||
Language::Python.homebrew_site_packages,
|
||||
]
|
||||
).freeze
|
||||
).uniq.sort.freeze
|
||||
|
||||
# These paths relative to the keg's share directory should always be real
|
||||
# directories in the prefix, never symlinks.
|
||||
|
||||
@ -142,9 +142,10 @@ RSpec.configure do |config|
|
||||
|
||||
FileUtils.rm_rf [
|
||||
TEST_DIRECTORIES.map(&:children),
|
||||
*Keg::MUST_EXIST_DIRECTORIES,
|
||||
*Keg::MUST_EXIST_SUBDIRECTORIES,
|
||||
HOMEBREW_LINKED_KEGS,
|
||||
HOMEBREW_PINNED_KEGS,
|
||||
HOMEBREW_PREFIX/"var",
|
||||
HOMEBREW_PREFIX/"Caskroom",
|
||||
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-cask",
|
||||
HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bar",
|
||||
|
||||
@ -4,10 +4,10 @@ jobs:
|
||||
vmImage: xcode9-macos10.13
|
||||
steps:
|
||||
- bash: |
|
||||
HOMEBREW_REPOSITORY="$(brew --repo)";
|
||||
mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library";
|
||||
sudo rm -rf "$HOMEBREW_REPOSITORY";
|
||||
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY";
|
||||
HOMEBREW_REPOSITORY="$(brew --repo)"
|
||||
mv "$HOMEBREW_REPOSITORY/Library/Taps" "$PWD/Library"
|
||||
sudo rm -rf "$HOMEBREW_REPOSITORY"
|
||||
sudo ln -s "$PWD" "$HOMEBREW_REPOSITORY"
|
||||
brew update-reset Library/Taps/homebrew/homebrew-core
|
||||
brew test-bot --coverage
|
||||
displayName: Run brew test-bot
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user