From 8033fcf4a6845c6d0f36632c5683ad778f9c84fb Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Mon, 7 Oct 2024 18:55:13 -0700 Subject: [PATCH] Fix brew style docs --- Library/Homebrew/cask/cask.rb | 2 +- Library/Homebrew/extend/os/mac/keg.rb | 16 ++++++++++++++++ Library/Homebrew/keg.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 475e0478fd6ce..a939c4512a847 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -117,7 +117,7 @@ def refresh @dsl.language_eval end - DSL::DSL_METHODS.each do |method_name| + ::Cask::DSL::DSL_METHODS.each do |method_name| define_method(method_name) { |&block| @dsl.send(method_name, &block) } end diff --git a/Library/Homebrew/extend/os/mac/keg.rb b/Library/Homebrew/extend/os/mac/keg.rb index aae4eb6ad3552..e4c58603631ec 100644 --- a/Library/Homebrew/extend/os/mac/keg.rb +++ b/Library/Homebrew/extend/os/mac/keg.rb @@ -3,6 +3,22 @@ require "system_command" +class Keg + # TODO: re-implement these as functions, so that we aren't modifying constants: + GENERIC_KEG_LINK_DIRECTORIES = (remove_const :KEG_LINK_DIRECTORIES).freeze + KEG_LINK_DIRECTORIES = (GENERIC_KEG_LINK_DIRECTORIES + ["Frameworks"]).freeze + GENERIC_MUST_EXIST_SUBDIRECTORIES = (remove_const :MUST_EXIST_SUBDIRECTORIES).freeze + MUST_EXIST_SUBDIRECTORIES = ( + GENERIC_MUST_EXIST_SUBDIRECTORIES + + [HOMEBREW_PREFIX/"Frameworks"] + ).sort.uniq.freeze + GENERIC_MUST_BE_WRITABLE_DIRECTORIES = (remove_const :MUST_BE_WRITABLE_DIRECTORIES).freeze + MUST_BE_WRITABLE_DIRECTORIES = ( + GENERIC_MUST_BE_WRITABLE_DIRECTORIES + + [HOMEBREW_PREFIX/"Frameworks"] + ).sort.uniq.freeze +end + module OS module Mac module Keg diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 0b0f67d2564cd..7d1a332a30290 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -78,6 +78,32 @@ def to_s # Locale-specific directories have the form `language[_territory][.codeset][@modifier]` LOCALEDIR_RX = %r{(locale|man)/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?} INFOFILE_RX = %r{info/([^.].*?\.info(\.gz)?|dir)$} + KEG_LINK_DIRECTORIES = %w[ + bin etc include lib sbin share var + ].freeze + MUST_EXIST_SUBDIRECTORIES = ( + KEG_LINK_DIRECTORIES - %w[var] + %w[ + opt + var/homebrew/linked + ] + ).map { |dir| HOMEBREW_PREFIX/dir }.sort.uniq.freeze + MUST_BE_WRITABLE_DIRECTORIES = ( + %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 } + MUST_EXIST_SUBDIRECTORIES + [ + HOMEBREW_CACHE, + HOMEBREW_CELLAR, + HOMEBREW_LOCKS, + HOMEBREW_LOGS, + HOMEBREW_REPOSITORY, + Language::Python.homebrew_site_packages, + ] + ).sort.uniq.freeze # These paths relative to the keg's share directory should always be real # directories in the prefix, never symlinks.