├── .github └── workflows │ └── tests.yml ├── .gitignore ├── Casks ├── zulu11.rb └── zulu8.rb ├── Formula ├── elasticsearch@1.7.rb ├── elasticsearch@2.4.rb ├── hadoop@2.rb ├── hive@2.rb ├── kind.rb └── kustomize@3.1.rb ├── LICENSE.txt ├── README.md ├── cmd ├── brew-bootstrap-jenv-java ├── brew-bootstrap-nodenv-node ├── brew-bootstrap-rbenv-ruby ├── brew-macos-vscode-codespaces ├── brew-report-issue.rb ├── brew-setup-nginx-conf.rb ├── brew-upgrade-mysql └── brew-vendor-gem └── ruby-definitions ├── 1.9.3-p231-github ├── 1.9.3-p231-tcs-github ├── 2.0.0-github ├── 2.1.0-github ├── 2.1.1-github ├── 2.1.2-github ├── 2.1.4-github ├── 2.1.5-github ├── 2.1.6-github ├── 2.1.7-github └── 2.4-typedruby1 /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: brew test-bot 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | test-bot: 9 | runs-on: macos-latest 10 | steps: 11 | - name: Set up Homebrew 12 | id: set-up-homebrew 13 | uses: Homebrew/actions/setup-homebrew@master 14 | 15 | - name: Cache Homebrew Bundler RubyGems 16 | id: cache 17 | uses: actions/cache@v1 18 | with: 19 | path: ${{ steps.set-up-homebrew.outputs.gems-path }} 20 | key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} 21 | restore-keys: ${{ runner.os }}-rubygems- 22 | 23 | - name: Install Homebrew Bundler RubyGems 24 | if: steps.cache.outputs.cache-hit != 'true' 25 | run: brew install-bundler-gems 26 | 27 | - run: brew test-bot --only-cleanup-before 28 | 29 | - run: brew test-bot --only-setup 30 | 31 | - run: brew test-bot --only-tap-syntax 32 | 33 | - run: brew test-bot --only-formulae 34 | if: github.event_name == 'pull_request' 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .built 2 | -------------------------------------------------------------------------------- /Casks/zulu11.rb: -------------------------------------------------------------------------------- 1 | cask "zulu11" do 2 | version "11.2.3,11.0.1" 3 | sha256 "5e2364ae8e1f4d81b2253de3d52dee5701f8f7c31160fac2d23b4f1c371cff2b" 4 | 5 | url "https://cdn.azul.com/zulu/bin/zulu#{version.csv.first}-jdk#{version.csv.second}-macosx_x64.dmg", 6 | referer: "https://www.azul.com/downloads/zulu/zulu-mac/" 7 | name "Azul Zulu Java Standard Edition Development Kit" 8 | desc "OpenJDK distribution from Azul" 9 | homepage "https://www.azul.com/downloads/zulu/zulu-mac/" 10 | 11 | pkg "Double-Click to Install Zulu #{version.major}.pkg" 12 | 13 | postflight do 14 | system_command "/bin/mv", 15 | args: ["-f", "--", "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk", "/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk"], 16 | sudo: true 17 | system_command "/bin/ln", 18 | args: ["-nsf", "--", "/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk", "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk"], 19 | sudo: true 20 | system_command "/bin/ln", 21 | args: ["-nsf", "--", "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk/Contents/Home", "/Library/Java/Home"], 22 | sudo: true 23 | system_command "/usr/libexec/PlistBuddy", 24 | args: ["-c", "Add :JavaVM:JVMCapabilities: string JNI", "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk/Contents/Info.plist"], 25 | sudo: true 26 | end 27 | 28 | uninstall pkgutil: "com.azulsystems.zulu.#{version.major}", 29 | delete: [ 30 | "/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk", 31 | "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk", 32 | "/Library/Java/Home", 33 | ] 34 | end 35 | -------------------------------------------------------------------------------- /Casks/zulu8.rb: -------------------------------------------------------------------------------- 1 | cask "zulu8" do 2 | version "8.0.232,8.42.0.23-ca" 3 | sha256 "71f1a6e400325737b2a833f70b33ae09f95c63b793f931d84d8fd70d5687ff25" 4 | 5 | url "https://cdn.azul.com/zulu/bin/zulu#{version.csv.second}-jdk#{version.csv.first}-macosx_x64.dmg", 6 | referer: "https://www.azul.com/downloads/zulu/zulu-mac/" 7 | name "Azul Zulu Java 8 Standard Edition Development Kit" 8 | desc "OpenJDK distribution from Azul" 9 | homepage "https://www.azul.com/downloads/zulu/zulu-mac/" 10 | 11 | pkg "Double-Click to Install Zulu #{version.major}.pkg" 12 | 13 | uninstall pkgutil: "com.azulsystems.zulu.#{version.major}" 14 | end 15 | -------------------------------------------------------------------------------- /Formula/elasticsearch@1.7.rb: -------------------------------------------------------------------------------- 1 | class ElasticsearchAT17 < Formula 2 | desc "Distributed search & analytics engine" 3 | homepage "https://www.elastic.co/products/elasticsearch" 4 | url "https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.tar.gz" 5 | sha256 "78affc30353730ec245dad1f17de242a4ad12cf808eaa87dd878e1ca10ed77df" 6 | revision 1 7 | 8 | keg_only :versioned_formula 9 | 10 | depends_on "openjdk@8" 11 | 12 | def cluster_name 13 | "elasticsearch_#{ENV["USER"]}" 14 | end 15 | 16 | def install 17 | # Remove Windows files 18 | rm_f Dir["bin/*.bat"] 19 | rm_f Dir["bin/*.exe"] 20 | 21 | # Move libraries to `libexec` directory 22 | libexec.install Dir["lib/*.jar"] 23 | (libexec/"sigar").install Dir["lib/sigar/*.{jar,dylib}"] 24 | 25 | # Install everything else into package directory 26 | prefix.install Dir["*"] 27 | 28 | # Remove unnecessary files 29 | rm_f Dir["#{lib}/sigar/*"] 30 | 31 | # Set up Elasticsearch for local development: 32 | inreplace "#{prefix}/config/elasticsearch.yml" do |s| 33 | # 1. Give the cluster a unique name 34 | s.gsub!(/#\s*cluster\.name: elasticsearch/, "cluster.name: #{cluster_name}") 35 | 36 | # 2. Configure paths 37 | s.sub!(%r{#\s*path\.data: /path/to.+$}, "path.data: #{var}/elasticsearch/") 38 | s.sub!(%r{#\s*path\.logs: /path/to.+$}, "path.logs: #{var}/log/elasticsearch/") 39 | s.sub!(%r{#\s*path\.plugins: /path/to.+$}, "path.plugins: #{var}/lib/elasticsearch/plugins") 40 | 41 | # 3. Bind to loopback IP for laptops roaming different networks 42 | s.gsub!(/#\s*network\.host: [^\n]+/, "network.host: 127.0.0.1") 43 | end 44 | 45 | inreplace "#{bin}/elasticsearch.in.sh" do |s| 46 | # Configure ES_HOME 47 | s.sub!(%r{#!/bin/sh\n}, "#!/bin/sh\n\nES_HOME=#{prefix}") 48 | # Configure ES_CLASSPATH paths to use libexec instead of lib 49 | s.gsub!(%r{ES_HOME/lib/}, "ES_HOME/libexec/") 50 | end 51 | 52 | inreplace "#{bin}/plugin" do |s| 53 | # Add the proper ES_CLASSPATH configuration 54 | s.sub!(/SCRIPT="\$0"/, %Q(SCRIPT="$0"\nES_CLASSPATH=#{libexec})) 55 | # Replace paths to use libexec instead of lib 56 | s.gsub!(%r{\$ES_HOME/lib/}, "$ES_CLASSPATH/") 57 | end 58 | end 59 | 60 | def post_install 61 | # Make sure runtime directories exist 62 | (var/"elasticsearch/#{cluster_name}").mkpath 63 | (var/"log/elasticsearch").mkpath 64 | (var/"lib/elasticsearch/plugins").mkpath 65 | ln_s etc/"elasticsearch", prefix/"config" 66 | end 67 | 68 | def caveats 69 | <<~EOS 70 | Data: #{var}/elasticsearch/#{cluster_name}/ 71 | Logs: #{var}/log/elasticsearch/#{cluster_name}.log 72 | Plugins: #{var}/lib/elasticsearch/plugins/ 73 | Config: #{etc}/elasticsearch/ 74 | EOS 75 | end 76 | 77 | plist_options manual: "elasticsearch --config=#{HOMEBREW_PREFIX}/opt/elasticsearch@1.7/config/elasticsearch.yml" 78 | 79 | def plist 80 | <<~EOS 81 | 82 | 83 | 84 | 85 | KeepAlive 86 | 87 | Label 88 | #{plist_name} 89 | ProgramArguments 90 | 91 | #{opt_bin}/elasticsearch 92 | --config=#{prefix}/config/elasticsearch.yml 93 | 94 | EnvironmentVariables 95 | 96 | ES_JAVA_OPTS 97 | -Xss200000 98 | 99 | RunAtLoad 100 | 101 | WorkingDirectory 102 | #{var} 103 | StandardErrorPath 104 | #{var}/log/#{name}.log 105 | StandardOutPath 106 | #{var}/log/#{name}.log 107 | 108 | 109 | EOS 110 | end 111 | 112 | test do 113 | system "#{bin}/plugin", "--list" 114 | end 115 | end 116 | -------------------------------------------------------------------------------- /Formula/elasticsearch@2.4.rb: -------------------------------------------------------------------------------- 1 | class ElasticsearchAT24 < Formula 2 | desc "Distributed search & analytics engine" 3 | homepage "https://www.elastic.co/products/elasticsearch" 4 | url "https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz" 5 | sha256 "5f7e4bb792917bb7ffc2a5f612dfec87416d54563f795d6a70637befef4cfc6f" 6 | revision 1 7 | 8 | keg_only :versioned_formula 9 | 10 | depends_on "openjdk@8" 11 | 12 | def cluster_name 13 | "elasticsearch_#{ENV["USER"]}" 14 | end 15 | 16 | def install 17 | # Remove Windows files 18 | rm_f Dir["bin/*.bat"] 19 | rm_f Dir["bin/*.exe"] 20 | 21 | # Install everything else into package directory 22 | libexec.install "bin", "config", "lib", "modules" 23 | 24 | # Set up Elasticsearch for local development: 25 | inreplace "#{libexec}/config/elasticsearch.yml" do |s| 26 | # 1. Give the cluster a unique name 27 | s.gsub!(/#\s*cluster\.name: .*/, "cluster.name: #{cluster_name}") 28 | 29 | # 2. Configure paths 30 | s.sub!(%r{#\s*path\.data: /path/to.+$}, "path.data: #{var}/elasticsearch/") 31 | s.sub!(%r{#\s*path\.logs: /path/to.+$}, "path.logs: #{var}/log/elasticsearch/") 32 | end 33 | 34 | inreplace "#{libexec}/bin/elasticsearch.in.sh" do |s| 35 | # Configure ES_HOME 36 | s.sub!(%r{#!/bin/sh\n}, "#!/bin/sh\n\nES_HOME=#{libexec}") 37 | end 38 | 39 | inreplace "#{libexec}/bin/plugin" do |s| 40 | # Add the proper ES_CLASSPATH configuration 41 | s.sub!(/SCRIPT="\$0"/, %Q(SCRIPT="$0"\nES_CLASSPATH=#{libexec}/lib)) 42 | # Replace paths to use libexec instead of lib 43 | s.gsub!(%r{\$ES_HOME/lib/}, "$ES_CLASSPATH/") 44 | end 45 | 46 | # Move config files into etc 47 | (etc/"elasticsearch").install Dir[libexec/"config/*"] 48 | (etc/"elasticsearch/scripts").mkpath 49 | (libexec/"config").rmtree 50 | 51 | bin.install libexec/"bin/elasticsearch", 52 | libexec/"bin/plugin" 53 | bin.env_script_all_files(libexec/"bin", Language::Java.java_home_env("1.8")) 54 | end 55 | 56 | def post_install 57 | # Make sure runtime directories exist 58 | (var/"elasticsearch/#{cluster_name}").mkpath 59 | (var/"log/elasticsearch").mkpath 60 | ln_s etc/"elasticsearch", libexec/"config" unless (libexec/"config").exist? 61 | (libexec/"plugins").mkpath 62 | end 63 | 64 | def caveats 65 | <<~EOS 66 | Data: #{var}/elasticsearch/#{cluster_name}/ 67 | Logs: #{var}/log/elasticsearch/#{cluster_name}.log 68 | Plugins: #{libexec}/plugins/ 69 | Config: #{etc}/elasticsearch/ 70 | plugin script: #{libexec}/bin/plugin 71 | EOS 72 | end 73 | 74 | plist_options manual: "#{HOMEBREW_PREFIX}/opt/elasticsearch@2.4/bin/elasticsearch" 75 | 76 | def plist 77 | <<~EOS 78 | 79 | 80 | 81 | 82 | KeepAlive 83 | 84 | Label 85 | #{plist_name} 86 | ProgramArguments 87 | 88 | #{opt_bin}/elasticsearch 89 | 90 | EnvironmentVariables 91 | 92 | 93 | RunAtLoad 94 | 95 | WorkingDirectory 96 | #{var} 97 | StandardErrorPath 98 | #{var}/log/#{name}.log 99 | StandardOutPath 100 | #{var}/log/#{name}.log 101 | 102 | 103 | EOS 104 | end 105 | 106 | test do 107 | system "#{libexec}/bin/plugin", "list" 108 | pid = "#{testpath}/pid" 109 | begin 110 | mkdir testpath/"config" 111 | system "#{bin}/elasticsearch", "-d", "-p", pid, "--path.home", testpath 112 | sleep 10 113 | system "curl", "-XGET", "localhost:9200/" 114 | ensure 115 | Process.kill(9, File.read(pid).to_i) 116 | end 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /Formula/hadoop@2.rb: -------------------------------------------------------------------------------- 1 | class HadoopAT2 < Formula 2 | desc "Framework for distributed processing of large data sets" 3 | homepage "https://hadoop.apache.org/" 4 | url "https://www.apache.org/dyn/closer.lua?path=hadoop/common/hadoop-2.8.2/hadoop-2.8.2.tar.gz" 5 | mirror "https://archive.apache.org/dist/hadoop/common/hadoop-2.8.2/hadoop-2.8.2.tar.gz" 6 | sha256 "aea99c7ce8441749d81202bdea431f1024f17ee6e0efb3144226883207cc6292" 7 | 8 | depends_on "openjdk@8" 9 | 10 | def install 11 | rm_f Dir["bin/*.cmd", "sbin/*.cmd", "libexec/*.cmd", "etc/hadoop/*.cmd"] 12 | libexec.install %w[bin sbin libexec share etc] 13 | bin.write_exec_script Dir["#{libexec}/bin/*"] 14 | sbin.write_exec_script Dir["#{libexec}/sbin/*"] 15 | # But don't make rcc visible, it conflicts with Qt 16 | (bin/"rcc").unlink 17 | 18 | inreplace "#{libexec}/etc/hadoop/hadoop-env.sh", 19 | "export JAVA_HOME=${JAVA_HOME}", 20 | "export JAVA_HOME=\"$(/usr/libexec/java_home)\"" 21 | inreplace "#{libexec}/etc/hadoop/yarn-env.sh", 22 | "# export JAVA_HOME=/home/y/libexec/jdk1.6.0/", 23 | "export JAVA_HOME=\"$(/usr/libexec/java_home)\"" 24 | inreplace "#{libexec}/etc/hadoop/mapred-env.sh", 25 | "# export JAVA_HOME=/home/y/libexec/jdk1.6.0/", 26 | "export JAVA_HOME=\"$(/usr/libexec/java_home)\"" 27 | end 28 | 29 | def caveats 30 | <<~EOS 31 | In Hadoop's config file: 32 | #{libexec}/etc/hadoop/hadoop-env.sh, 33 | #{libexec}/etc/hadoop/mapred-env.sh and 34 | #{libexec}/etc/hadoop/yarn-env.sh 35 | $JAVA_HOME has been set to be the output of: 36 | /usr/libexec/java_home 37 | EOS 38 | end 39 | 40 | test do 41 | system bin/"hadoop", "fs", "-ls" 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /Formula/hive@2.rb: -------------------------------------------------------------------------------- 1 | class HiveAT2 < Formula 2 | desc "Hadoop-based data summarization, query, and analysis" 3 | homepage "https://hive.apache.org" 4 | url "https://downloads.apache.org/hive/hive-2.3.8/apache-hive-2.3.8-bin.tar.gz" 5 | mirror "https://archive.apache.org/dist/hive/hive-2.3.8/apache-hive-2.3.8-bin.tar.gz" 6 | sha256 "3746528298fb70938e30bfbb66f756d1810acafbe86ba84edef7bd3455589176" 7 | 8 | depends_on "hadoop@2" 9 | depends_on "openjdk@8" 10 | 11 | def install 12 | rm_f Dir["bin/*.cmd", "bin/ext/*.cmd", "bin/ext/util/*.cmd"] 13 | libexec.install %w[bin conf examples hcatalog lib scripts] 14 | 15 | Pathname.glob("#{libexec}/bin/*") do |file| 16 | next if file.directory? 17 | 18 | (bin/file.basename).write_env_script file, 19 | Language::Java.java_home_env("1.7+").merge(HIVE_HOME: libexec) 20 | end 21 | end 22 | 23 | def caveats 24 | <<~EOS 25 | Hadoop must be in your path for hive executable to work. 26 | If you want to use HCatalog with Pig, set $HCAT_HOME in your profile: 27 | export HCAT_HOME=#{opt_libexec}/hcatalog 28 | EOS 29 | end 30 | 31 | test do 32 | system bin/"schematool", "-initSchema", "-dbType", "derby" 33 | assert_match "Hive #{version}", shell_output("#{bin}/hive --version") 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /Formula/kind.rb: -------------------------------------------------------------------------------- 1 | class Kind < Formula 2 | desc "Kubernetes IN Docker - local clusters for testing Kubernetes" 3 | homepage "https://kind.sigs.k8s.io/" 4 | url "https://github.com/kubernetes-sigs/kind/archive/v0.3.0.tar.gz" 5 | sha256 "3d62392919bd93421acf61a17502f9dab8ec8d2a792b342b7a1abd749dbf81ef" 6 | 7 | depends_on "docker" => :build 8 | 9 | def install 10 | bin.mkpath 11 | system "make", "INSTALL_DIR=#{bin}", "install" 12 | end 13 | 14 | test do 15 | assert_equal "kind version v#{version}", shell_output("#{bin}/kind --version").chomp 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /Formula/kustomize@3.1.rb: -------------------------------------------------------------------------------- 1 | class KustomizeAT31 < Formula 2 | desc "Template-free customization of Kubernetes YAML manifests" 3 | homepage "https://github.com/kubernetes-sigs/kustomize" 4 | url "https://github.com/kubernetes-sigs/kustomize.git", 5 | tag: "v3.1.0", 6 | revision: "95f3303493fdea243ae83b767978092396169baf" 7 | 8 | depends_on "go" => :build 9 | 10 | def install 11 | ENV["GOPATH"] = buildpath 12 | ENV["CGO_ENABLED"] = "0" 13 | 14 | revision = Utils.safe_popen_read("git", "rev-parse", "HEAD").strip 15 | tag = Utils.safe_popen_read("git", "describe", "--tags").strip 16 | dir = buildpath/"src/sigs.k8s.io/kustomize" 17 | dir.install buildpath.children - [buildpath/".brew_home"] 18 | cd dir/"cmd/kustomize" do 19 | ldflags = %W[ 20 | -s -X sigs.k8s.io/kustomize/v3/pkg/commands/misc.kustomizeVersion=#{tag} 21 | -X sigs.k8s.io/kustomize/v3/pkg/commands/misc.gitCommit=#{revision} 22 | -X sigs.k8s.io/kustomize/v3/pkg/commands/misc.buildDate=#{Time.now.iso8601} 23 | ] 24 | system "go", "install", "-ldflags", ldflags.join(" ") 25 | bin.install buildpath/"bin/kustomize" => "kustomize@3.1" 26 | prefix.install_metafiles 27 | end 28 | end 29 | 30 | test do 31 | assert_match version.to_s, shell_output("#{bin}/kustomize@3.1 version") 32 | 33 | (testpath/"kustomization.yaml").write <<~EOS 34 | resources: 35 | - service.yaml 36 | patches: 37 | - patch.yaml 38 | EOS 39 | (testpath/"patch.yaml").write <<~EOS 40 | apiVersion: v1 41 | kind: Service 42 | metadata: 43 | name: brew-test 44 | spec: 45 | selector: 46 | app: foo 47 | EOS 48 | (testpath/"service.yaml").write <<~EOS 49 | apiVersion: v1 50 | kind: Service 51 | metadata: 52 | name: brew-test 53 | spec: 54 | type: LoadBalancer 55 | EOS 56 | output = shell_output("#{bin}/kustomize@3.1 build #{testpath}") 57 | assert_match(/type:\s+"?LoadBalancer"?/, output) 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2016 by GitHub 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Homebrew Bootstrap 2 | 3 | A series of helper scripts, casks and formulae to reduce duplication across `script/bootstrap`s. Scripts: 4 | 5 | - [`brew bootstrap-jenv-java`](cmd/brew-bootstrap-jenv-java): Installs Zulu JDK. 6 | - [`brew bootstrap-nodenv-node`](cmd/brew-bootstrap-nodenv-node): Installs Node and NPM. 7 | - [`brew bootstrap-rbenv-ruby`](cmd/brew-bootstrap-rbenv-ruby): Installs Ruby and Bundler. 8 | - [`brew macos-vscode-codespaces`](cmd/brew-macos-vscode-codespaces): Get Visual Studio Code ready for running with Codespaces. 9 | - [`brew report-issue`](cmd/brew-report-issue.rb): Creates and closes failure debugging issues on a project. 10 | - [`brew setup-nginx-conf`](cmd/brew-setup-nginx-conf.rb): Generates and installs a project `nginx` configuration using `erb`. 11 | - [`brew upgrade-mysql`](cmd/brew-upgrade-mysql): Upgrade `mysql` version used by GitHub production. 12 | - [`brew vendor-gem`](cmd/brew-vendor-gem): Build and cache a RubyGem for the given `git` repository 13 | - [`ruby-definitions/`](ruby-definitions): `ruby-build` definitions for GitHub Rubies (migrated from [boxen/puppet-ruby](https://github.com/boxen/puppet-ruby/tree/HEAD/files/definitions)). 14 | 15 | ## How do I install these scripts/casks/formulae? 16 | 17 | `brew install github/bootstrap/` 18 | 19 | Or `brew tap github/bootstrap` and then `brew install `. 20 | 21 | ## Status 22 | 23 | No longer in active development. 24 | 25 | ## License 26 | 27 | Homebrew Bootstrap is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License). 28 | The full license text is available in [LICENSE.txt](https://github.com/github/homebrew-bootstrap/blob/HEAD/LICENSE.txt). 29 | -------------------------------------------------------------------------------- /cmd/brew-bootstrap-jenv-java: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #: `Usage: brew bootstrap-jenv-java` [--debug] 3 | #: 4 | #: Installs Zulu JDK. 5 | set -e 6 | 7 | if [ "$1" = "--debug" ]; then 8 | shift 9 | PRINT_DEBUG="1" 10 | set -x 11 | fi 12 | 13 | warn() { echo "$@" >&2; } 14 | abort() { EXPECTED_EXIT="1"; warn "$@"; exit 1; } 15 | 16 | abort_for_sh() { 17 | abort 'Error: add `eval "$(jenv init -)"` to the end of your .bash_profile!' 18 | } 19 | 20 | abort_for_zsh() { 21 | abort 'Error: add `eval "$(jenv init -)"` to the end of your .zshrc!' 22 | } 23 | 24 | abort_for_fish() { 25 | abort 'Error: check the installation instructions at https://github.com/gcuisinier/jenv#gettings-started!' 26 | } 27 | 28 | abort_with_shell_setup_message() { 29 | case $(basename ${SHELL:-bash}) in 30 | sh|bash) 31 | abort_for_sh 32 | ;; 33 | zsh) 34 | abort_for_zsh 35 | ;; 36 | fish) 37 | abort_for_fish 38 | ;; 39 | # tcsh users are on their own 40 | *) 41 | abort 'Error: you must finish setting up jenv in your shell; check `jenv init` for instructions!' 42 | esac 43 | } 44 | 45 | abort_with_jenv_path_message() { 46 | abort "Error: the $(jenv root)/versions path does not exist. Please create it." 47 | } 48 | 49 | cleanup() { 50 | set +e 51 | if [ -n "$EXPECTED_EXIT" ]; then 52 | return 53 | fi 54 | warn "Error: $(basename $0) failed!" 55 | if [ -z "$PRINT_DEBUG" ]; then 56 | warn "For debugging output run:" 57 | warn " $0 --debug" 58 | warn "If you're stuck: file an issue with debugging output at:" 59 | warn " https://github.com/github/homebrew-bootstrap/issues/new" 60 | fi 61 | } 62 | trap "cleanup" EXIT 63 | 64 | BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 65 | 66 | if ! which jenv &>/dev/null; then 67 | abort "Error: you need to 'brew install jenv'!" 68 | fi 69 | 70 | if ! [[ -d "$(jenv root)/versions" ]]; then 71 | abort_with_jenv_path_message 72 | fi 73 | 74 | if ! jenv version-name &>/dev/null; then 75 | if ! [[ -z "$JENV_VERSION" ]]; then 76 | JAVA_REQUESTED="$JENV_VERSION" 77 | else 78 | JAVA_REQUESTED="$(jenv local)" 79 | fi 80 | 81 | if ! [[ "$JAVA_REQUESTED" =~ "." ]]; then 82 | warn "Error: requested Java version, \"$JAVA_REQUESTED\", is invalid." 83 | warn "hint: Java versions must contain a period." 84 | abort "hint: For example, instead of \"11\", use \"11.0\"." 85 | fi 86 | 87 | # Prior to Java 9, the major version is the second token, e.g. 1.8.0 88 | # From Java 9 on, the major version is the first token, e.g. 9.0.0 89 | if [[ "$(echo $JAVA_REQUESTED | awk -F. '{ print $1 }')" -ge 9 ]]; then 90 | cask_version="$(echo $JAVA_REQUESTED | awk -F. '{ print $1 }')" 91 | else 92 | cask_version="$(echo $JAVA_REQUESTED | awk -F. '{ print $2 }')" 93 | fi 94 | 95 | cask_shortname="zulu${cask_version}" 96 | if ! [[ -f "$BASE_PATH/Casks/${cask_shortname}.rb" ]]; then 97 | warn "Error: couldn't find a definition for ${cask_shortname}." 98 | warn "hint: This script only supports Zulu JVMs." 99 | warn "hint: For versions before Java 9, use the 1.x format, i.e. 1.8 or 1.8.0.181" 100 | warn "hint: For versions 9 and up, the major version comes first, i.e. 11.0 or 11.0.1" 101 | warn "hint: If the requested JVM still can't be found, you may not have requested a supported version." 102 | abort "hint: Leave off the leading \"openjdk-\" or \"openjdk64-\"." 103 | fi 104 | 105 | cask_name="github/bootstrap/${cask_shortname}" 106 | brew bundle --file=- <<-EOS 107 | tap "github/bootstrap" 108 | cask "$cask_name" 109 | EOS 110 | 111 | java_home=$(/usr/libexec/java_home -v $JAVA_REQUESTED) 112 | yes | jenv add $java_home 113 | fi 114 | 115 | if [ "$(jenv exec java -version 2>&1)" != "$(java -version 2>&1)" ]; then 116 | abort_with_shell_setup_message 117 | fi 118 | 119 | EXPECTED_EXIT="1" 120 | exit 0 121 | -------------------------------------------------------------------------------- /cmd/brew-bootstrap-nodenv-node: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #: `Usage: brew bootstrap-nodenv-node` [--debug] 3 | #: 4 | #: Installs Node and NPM. 5 | set -e 6 | 7 | if [ "$1" = "--debug" ]; then 8 | shift 9 | PRINT_DEBUG="1" 10 | set -x 11 | fi 12 | 13 | warn() { echo "$@" >&2; } 14 | abort() { EXPECTED_EXIT="1"; warn "$@"; exit 1; } 15 | 16 | abort_for_sh() { 17 | abort 'Error: add `eval "$(nodenv init -)"` to the end of your .bash_profile!' 18 | } 19 | 20 | abort_for_zsh() { 21 | abort 'Error: add `eval "$(nodenv init -)"` to the end of your .zshrc!' 22 | } 23 | 24 | abort_for_fish() { 25 | abort 'Error: add `status --is-interactive; and . (nodenv init -|psub)` to the end of your .config/fish/config.fish!' 26 | } 27 | 28 | abort_with_shell_setup_message() { 29 | case $(basename ${SHELL:-bash}) in 30 | sh|bash) 31 | abort_for_sh 32 | ;; 33 | zsh) 34 | abort_for_zsh 35 | ;; 36 | fish) 37 | abort_for_fish 38 | ;; 39 | # tcsh users are on their own 40 | *) 41 | abort 'Error: you must finish setting up nodenv in your shell; check `nodenv init` for instructions!' 42 | esac 43 | } 44 | 45 | cleanup() { 46 | set +e 47 | if [ -n "$EXPECTED_EXIT" ]; then 48 | return 49 | fi 50 | warn "Error: $(basename $0) failed!" 51 | if [ -z "$PRINT_DEBUG" ]; then 52 | warn "For debugging output run:" 53 | warn " $0 --debug" 54 | warn "If you're stuck: file an issue with debugging output at:" 55 | warn " https://github.com/github/homebrew-bootstrap/issues/new" 56 | fi 57 | } 58 | trap "cleanup" EXIT 59 | 60 | BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 61 | 62 | if ! which nodenv &>/dev/null; then 63 | abort "Error: you need to 'brew install nodenv'!" 64 | fi 65 | 66 | if ! nodenv version-name &>/dev/null; then 67 | NODE_REQUESTED="$(nodenv local)" 68 | NODE_DEFINITION="$(node-build --definitions | grep "^$NODE_REQUESTED$" || true)" 69 | 70 | if [ -z "$NODE_DEFINITION" ]; then 71 | abort "Error: cannot find Node $NODE_DEFINITION definition!" 72 | fi 73 | 74 | nodenv install "$NODE_DEFINITION" 75 | fi 76 | 77 | if [ "$(nodenv exec node --version)" != "$(node --version)" ]; then 78 | abort_with_shell_setup_message 79 | fi 80 | 81 | EXPECTED_EXIT="1" 82 | exit 0 83 | -------------------------------------------------------------------------------- /cmd/brew-bootstrap-rbenv-ruby: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #: `Usage: brew bootstrap-rbenv-ruby` [--debug] 3 | #: 4 | #: Installs Ruby and Bundler. 5 | set -e 6 | 7 | if [ "$1" = "--debug" ]; then 8 | shift 9 | PRINT_DEBUG="1" 10 | set -x 11 | fi 12 | 13 | warn() { echo "$@" >&2; } 14 | abort() { EXPECTED_EXIT="1"; warn "$@"; exit 1; } 15 | 16 | abort_for_sh() { 17 | abort 'Error: add `eval "$(rbenv init -)"` to the end of your .bash_profile!' 18 | } 19 | 20 | abort_for_zsh() { 21 | abort 'Error: add `eval "$(rbenv init -)"` to the end of your .zshrc!' 22 | } 23 | 24 | abort_for_fish() { 25 | abort 'Error: add `status --is-interactive; and . (rbenv init -|psub)` to the end of your .config/fish/config.fish!' 26 | } 27 | 28 | abort_with_shell_setup_message() { 29 | case $(basename ${SHELL:-bash}) in 30 | sh|bash) 31 | abort_for_sh 32 | ;; 33 | zsh) 34 | abort_for_zsh 35 | ;; 36 | fish) 37 | abort_for_fish 38 | ;; 39 | # tcsh users are on their own 40 | *) 41 | abort 'Error: you must finish setting up rbenv in your shell; check `rbenv init` for instructions!' 42 | esac 43 | } 44 | 45 | cleanup() { 46 | set +e 47 | if [ -n "$EXPECTED_EXIT" ]; then 48 | return 49 | fi 50 | warn "Error: $(basename $0) failed!" 51 | if [ -z "$PRINT_DEBUG" ]; then 52 | warn "For debugging output run:" 53 | warn " $0 --debug" 54 | warn "If you're stuck: file an issue with debugging output at:" 55 | warn " https://github.com/github/homebrew-bootstrap/issues/new" 56 | fi 57 | } 58 | trap "cleanup" EXIT 59 | 60 | BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" 61 | 62 | if ! which rbenv &>/dev/null; then 63 | abort "Error: you need to 'brew install rbenv'!" 64 | fi 65 | 66 | if ! rbenv version-name &>/dev/null; then 67 | if ! [[ -z "$RBENV_VERSION" ]]; then 68 | RUBY_REQUESTED="$RBENV_VERSION" 69 | else 70 | RUBY_REQUESTED="$(rbenv local)" 71 | fi 72 | RUBY_DEFINITION="$(ruby-build --definitions | grep "^$RUBY_REQUESTED$" || true)" 73 | 74 | if [ -z "$RUBY_DEFINITION" ]; then 75 | RUBY_DEFINITION="$BASE_PATH/ruby-definitions/$RUBY_REQUESTED" 76 | 77 | if ! [ -f "$RUBY_DEFINITION" ]; then 78 | warn "Error: cannot find Ruby $RUBY_REQUESTED definition in ruby-build or at:" 79 | abort "$RUBY_DEFINITION" 80 | fi 81 | fi 82 | 83 | # use workaround for necessary for some Ruby versions 84 | # https://github.com/ffi/ffi/issues/869#issuecomment-752123090 85 | if [ "$(uname -sm)" = "Darwin arm64" ]; then 86 | export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC 87 | fi 88 | rbenv install --skip-existing "$RUBY_DEFINITION" 89 | fi 90 | 91 | if [ "$(rbenv exec ruby --version)" != "$(ruby --version)" ]; then 92 | abort_with_shell_setup_message 93 | fi 94 | 95 | (rbenv which bundle &>/dev/null && bundle -v &>/dev/null) || { 96 | # Bundler 2 doesn't support Ruby 2.x or below, but 97 | # Rubygems won't automatically pick a compatible Bundler for us. Boo! 98 | if [[ "$RUBY_REQUESTED" < "2.3" ]]; then 99 | gem install bundler -v '<2' 100 | else 101 | gem install bundler 102 | fi 103 | 104 | rbenv rehash 105 | } 106 | 107 | EXPECTED_EXIT="1" 108 | exit 0 109 | -------------------------------------------------------------------------------- /cmd/brew-macos-vscode-codespaces: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #: `Usage: brew macos-vscode-codespaces` 3 | #: 4 | #: Get Visual Studio Code ready for running with Codespaces. 5 | 6 | set -eo pipefail 7 | 8 | if [ "$(uname -s)" != "Darwin" ]; then 9 | echo 'Error: brew macos-vscode-codespaces should only be run on macOS!' >&2 10 | exit 1 11 | fi 12 | 13 | # Check for Homebrew. 14 | if [ ! -x "$(command -v brew 2>/dev/null)" ]; then 15 | echo 'Error: Homebrew is not installed. Run https://strap.githubapp.com first.' >&2 16 | exit 1 17 | fi 18 | 19 | HOMEBREW_PREFIX="$(brew --prefix)" 20 | HOMEBREW_PREFIX="${HOMEBREW_PREFIX:-/usr/local}" 21 | 22 | # Link launchdns' configuration. 23 | if [ "$(readlink /etc/resolver)" != "${HOMEBREW_PREFIX}/etc/resolver" ] || 24 | [ ! -L "/etc/resolver" ]; then 25 | if ! sudo -n true >/dev/null; then 26 | echo "We need your user's password to link /etc/resolver with sudo:" 27 | /usr/bin/sudo -v 2>/dev/null 28 | fi 29 | echo "==> Linking ${HOMEBREW_PREFIX}/etc/resolver to /etc/resolver" 30 | sudo rm -rf /etc/resolver 31 | sudo ln -s "${HOMEBREW_PREFIX}/etc/resolver" /etc 32 | fi 33 | 34 | # Install launchdns and VS Code. 35 | brew bundle --quiet --file=- < [] 5 | #: 6 | #: Creates and closes failure debugging issues on a project. 7 | close = !ARGV.delete("--close").nil? 8 | user_repo = ARGV.shift 9 | message = ARGV.shift 10 | 11 | if user_repo.to_s.empty? || message.to_s.empty? 12 | abort "Usage: brew report-issue [--close] []" 13 | end 14 | 15 | unless close 16 | abort "Error: the issue/comment body should be piped over STDIN!" if $stdin.tty? 17 | body = $stdin.read 18 | end 19 | 20 | @strap_url = ENV.fetch("HOMEBREW_STRAP_URL", "https://strap.githubapp.com") 21 | 22 | if `git config credential.helper`.chomp.empty? 23 | abort <<~EOS 24 | Error: your Git HTTP(S) credential helper is not set! Set it by running Strap: 25 | #{@strap_url} 26 | EOS 27 | end 28 | 29 | def credential_helper(command, input) 30 | IO.popen({ "RUBYLIB" => nil, "RUBYOPT" => nil }, 31 | ["git", "credential", command.to_s], "w+") do |io| 32 | io.puts input 33 | io.close_write 34 | io.read 35 | end 36 | end 37 | 38 | @github_credentials = credential_helper :fill, "protocol=https\nhost=github.com" 39 | /username=(?.+)/ =~ @github_credentials 40 | /password=(?.+)/ =~ @github_credentials 41 | 42 | if github_username.to_s.empty? 43 | abort <<~EOS 44 | Error: your GitHub username is not set! Set it by running Strap: 45 | #{@strap_url} 46 | EOS 47 | end 48 | @github_username = `git config github.user`.chomp 49 | @github_username = github_username if @github_username.empty? 50 | @github_api_username = github_username 51 | 52 | if github_password.to_s.empty? 53 | abort <<~EOS 54 | Error: your GitHub password is not set! Set it by running Strap: 55 | #{@strap_url} 56 | EOS 57 | end 58 | @github_api_password = github_password 59 | 60 | credential_helper :approve, @github_credentials 61 | 62 | require "net/http" 63 | require "json" 64 | 65 | def http_request(type, url, body = nil) 66 | uri = URI url 67 | request = case type 68 | when :post 69 | post_request = Net::HTTP::Post.new uri 70 | post_request.body = body 71 | post_request 72 | when :get 73 | Net::HTTP::Get.new uri 74 | end 75 | return unless request 76 | 77 | request.basic_auth @github_api_username, @github_api_password 78 | Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http| 79 | http.request request 80 | end 81 | end 82 | 83 | def response_check(response, action) 84 | return if response.is_a? Net::HTTPSuccess 85 | 86 | # If there's bad credentials, erase them. 87 | credential_helper :reject, @github_credentials if response.code == "401" 88 | $stderr.puts "Error: failed to #{action}!" 89 | unless response.body.empty? 90 | failure = JSON.parse response.body 91 | $stderr.puts "--\n#{response.code}: #{failure["message"]}" 92 | end 93 | if response.code == "401" 94 | $stderr.puts <<~EOS 95 | Error: your GitHub username/access token are not correct! Fix by running Strap: 96 | #{@strap_url} 97 | EOS 98 | end 99 | exit 1 100 | end 101 | 102 | def create_issue(user_repo, title, body) 103 | new_issue_json = { title: title, body: body }.to_json 104 | issues_url = "https://api.github.com/repos/#{user_repo}/issues" 105 | response = http_request :post, issues_url, new_issue_json 106 | response_check response, "create issue (#{issues_url})" 107 | issue = JSON.parse response.body 108 | puts "Created issue: #{issue["html_url"]}" 109 | issue 110 | end 111 | 112 | def comment_issue(issue, comment_body, options = {}) 113 | comments_url = issue["comments_url"] 114 | issue_comment_json = { body: comment_body }.to_json 115 | response = http_request :post, comments_url, issue_comment_json 116 | response_check response, "create comment (#{comments_url})" 117 | puts "Commented on issue: #{issue["html_url"]}" if options[:notify] 118 | end 119 | 120 | def close_issue(issue) 121 | issue_url = issue["url"] 122 | close_issue_json = { state: "closed" }.to_json 123 | response = http_request :post, issue_url, close_issue_json 124 | response_check response, "close issue (#{issue_url})" 125 | end 126 | 127 | open_issues_url = \ 128 | "https://api.github.com/repos/#{user_repo}/issues?creator=#{@github_username}" 129 | response = http_request :get, open_issues_url 130 | response_check response, "get issues (#{open_issues_url})" 131 | 132 | open_issues = JSON.parse response.body 133 | 134 | if close 135 | open_issues.each do |issue| 136 | comment_body = "Succeeded at #{message}." 137 | comment_issue issue, comment_body 138 | close_issue issue 139 | end 140 | elsif open_issues.any? 141 | issue = open_issues.first 142 | comment_issue issue, body, notify: true 143 | else 144 | title = "#{message} failed for #{@github_username}" 145 | create_issue user_repo, title, body 146 | end 147 | -------------------------------------------------------------------------------- /cmd/brew-setup-nginx-conf.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | #: `Usage: brew setup-nginx-conf` [--root] [--extra-val=variable=value] 5 | #: 6 | #: 7 | #: Generates and installs a project `nginx` configuration using `erb`. 8 | require "erb" 9 | require "pathname" 10 | 11 | root_configuration = ARGV.delete "--root" 12 | http_port = 80 13 | https_port = 443 14 | 15 | name = ARGV.shift 16 | root = ARGV.shift || "." 17 | input = ARGV.shift || "config/dev/nginx.conf.erb" 18 | 19 | if !name || !root || !input 20 | abort "Usage: brew setup-nginx-conf [--root] [--extra-val=variable=value] " \ 21 | " " 22 | end 23 | 24 | abort "Error: #{input} is not a .erb file!" unless input.end_with? ".erb" 25 | 26 | root = File.expand_path root 27 | input = File.expand_path input 28 | 29 | # Find extra variables in the form of --extra-val=variable=value 30 | # Using a hash and ERB#result_with_hash would be nice, but it didn't 31 | # appear until Ruby 2.5. :/ 32 | variables = binding 33 | ARGV.delete_if do |argument| 34 | next unless argument.start_with? "--extra-val=" 35 | 36 | variable, value = argument.sub(/^--extra-val=/, "").split("=", 2) 37 | variables.local_variable_set(variable.to_sym, value) 38 | 39 | true 40 | end 41 | 42 | data = File.read input 43 | conf = ERB.new(data).result(variables) 44 | output = input.sub(/.erb$/, "") 45 | output.sub!(/.conf$/, ".root.conf") if root_configuration 46 | File.write output, conf 47 | 48 | exit if root_configuration 49 | 50 | /access_log (?.+);/ =~ conf 51 | if log 52 | log = Pathname(log) 53 | log.dirname.mkpath 54 | FileUtils.touch log unless log.exist? 55 | end 56 | 57 | exit unless RUBY_PLATFORM.include? "darwin" 58 | 59 | homebrew_prefix = RUBY_PLATFORM.include?("arm64") ? "/opt/homebrew" : "/usr/local" 60 | 61 | strap_url = ENV.fetch("HOMEBREW_STRAP_URL", "https://strap.githubapp.com") 62 | 63 | unless File.exist? "#{homebrew_prefix}/bin/brew" 64 | abort <<~EOS 65 | Error: Homebrew is not in #{homebrew_prefix}. Install it by running Strap: 66 | #{strap_url} 67 | EOS 68 | end 69 | 70 | brewfile = <<~EOS 71 | brew "launchdns", restart_service: true 72 | brew "nginx", restart_service: true 73 | EOS 74 | 75 | started_services = false 76 | unless system "echo '#{brewfile}' | brew bundle check --file=- >/dev/null" 77 | puts "Installing *.localhost dependencies:" 78 | unless system "echo '#{brewfile}' | brew bundle --file=-" 79 | abort "Error: install *.localhost dependencies with brew bundle!" 80 | end 81 | started_services = true 82 | end 83 | 84 | if `readlink /etc/resolver 2>/dev/null`.chomp != "#{homebrew_prefix}/etc/resolver" 85 | puts "Asking for your password to setup *.dev:" unless system "sudo -n true >/dev/null" 86 | system "sudo", "rm", "-rf", "/etc/resolver" 87 | unless system "sudo", "ln", "-sf", "#{homebrew_prefix}/etc/resolver", "/etc/resolver" 88 | abort "Error: failed to symlink #{homebrew_prefix}/etc/resolver to /etc/resolver!" 89 | end 90 | end 91 | 92 | if File.exist? "/etc/pf.anchors/dev.strap" 93 | puts "Asking for your password to uninstall pf:" unless system "sudo -n true >/dev/null" 94 | system "sudo", "rm", "/etc/pf.anchors/dev.strap" 95 | system "sudo grep -v 'dev.strap' /etc/pf.conf | sudo tee /etc/pf.conf" 96 | system "sudo launchctl unload /Library/LaunchDaemons/dev.strap.pf.plist 2>/dev/null" 97 | system "sudo launchctl load -w /Library/LaunchDaemons/dev.strap.pf.plist 2>/dev/null" 98 | system "sudo launchctl unload /Library/LaunchDaemons/dev.strap.pf.plist 2>/dev/null" 99 | system "sudo", "rm", "-f", "/Library/LaunchDaemons/dev.strap.pf.plist" 100 | end 101 | launch_socket_server_info = `brew services list | grep launch_socket_server | grep started`.chomp 102 | if launch_socket_server_info != "" 103 | puts "Asking for your password to stop launch_socket_server:" unless system "sudo -n true > /dev/null" 104 | command = "brew services stop launch_socket_server >/dev/null" 105 | run_by_user = launch_socket_server_info.include?("started #{ENV.fetch("USER", "(unknown user)")}") 106 | command = "sudo #{command}" unless run_by_user 107 | 108 | abort "Error: failed to stop launch_socket_server!" unless system command 109 | end 110 | 111 | server_base_path = "#{homebrew_prefix}/etc/nginx/servers" 112 | system "mkdir -p '#{server_base_path}'" 113 | server = File.join(server_base_path, name) 114 | unless system "ln -sf '#{File.absolute_path(output)}' '#{server}'" 115 | abort "Error: failed to symlink #{output} to #{server}!" 116 | end 117 | 118 | system "brew cleanup --prune-prefix >/dev/null" 119 | 120 | abort "Error: failed to (re)start nginx!" if !started_services && !(system "brew services restart nginx >/dev/null") 121 | -------------------------------------------------------------------------------- /cmd/brew-upgrade-mysql: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | #: `Usage: brew-upgrade-mysql` 4 | #: 5 | #: Upgrade `mysql` version used by GitHub production. 6 | #: 7 | #: Upgrades from `mysql` 5.6 to 5.7, upgrades 5.7 to latest patch release, verifies 8 | #: that `mysql_upgrade` has run to update all system schemas, updates `my.cnf` 9 | #: to match the `my.cnf` maintained in this script. 10 | 11 | set -e 12 | 13 | uninstall_old_mysql() { 14 | current_mysql=$(ls $(brew --cellar) | grep -E "^mysql(@\\d\\.\\d)?$") || true 15 | 16 | [[ -z "${current_mysql}" ]] && return 0 17 | [[ "${current_mysql}" == "mysql@${mysql_version}" ]] && return 0 18 | 19 | echo "Uninstalling ${current_mysql}..." 20 | brew services stop $current_mysql || true 21 | brew uninstall --force $current_mysql 22 | } 23 | 24 | upgrade_mysql() { 25 | if $mysql_dir/bin/mysql_upgrade -u root &>/dev/null; then 26 | restart_mysql=true 27 | fi 28 | } 29 | 30 | update_my_cnf() { 31 | CNF_PATH="$(brew --prefix)/etc/my.cnf" 32 | touch $CNF_PATH 33 | 34 | TMP_PATH="/tmp/my.cnf" 35 | rm -f "$TMP_PATH" 36 | 37 | cat > $TMP_PATH <<-EOM 38 | # For advice on how to change settings please see 39 | # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html 40 | 41 | [mysqld] 42 | 43 | innodb_strict_mode=OFF 44 | optimizer_switch='index_merge_intersection=OFF' 45 | query_cache_size=0 46 | sql_mode=NO_ENGINE_SUBSTITUTION 47 | table_open_cache=100 48 | gtid_mode=ON 49 | enforce_gtid_consistency=ON 50 | server_id=1 51 | log_bin=mysql-bin.log 52 | expire_logs_days=1 53 | EOM 54 | 55 | if ! diff -q "$CNF_PATH" "$TMP_PATH"; then 56 | echo "Backing up and replacing old my.cnf file" 57 | cp -vf "$CNF_PATH" "$CNF_PATH.github" 58 | mv -f "$TMP_PATH" "$CNF_PATH" 59 | restart_mysql=true 60 | fi 61 | } 62 | 63 | is_mysql_up() { 64 | $mysql_dir/bin/mysqladmin ping --silent -uroot &> /dev/null 65 | } 66 | 67 | mysql_restart() { 68 | echo -n "Restarting MySQL... " 69 | brew services restart mysql@${mysql_version} 70 | echo -n "done" 71 | 72 | echo -n "Waiting for MySQL to be available..." 73 | while ! is_mysql_up; do 74 | echo -n "." 75 | sleep 2 76 | done 77 | echo " done" 78 | } 79 | 80 | # -- 81 | mysql_version="5.7" 82 | mysql_dir=$(brew --prefix mysql@${mysql_version}) 83 | restart_mysql=false 84 | 85 | uninstall_old_mysql 86 | upgrade_mysql 87 | update_my_cnf 88 | 89 | if [ "$restart_mysql" = "true" ]; then 90 | mysql_restart 91 | fi 92 | echo "mysql@${mysql_version} is up-to-date." 93 | 94 | exit 0 95 | -------------------------------------------------------------------------------- /cmd/brew-vendor-gem: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #: `Usage: brew vendor-gem` [-r ] [-n ] 4 | #: 5 | #: Build a gem for the given git repository and stick it in vendor/cache. With -r, build 6 | #: the gem at the branch, tag, or SHA1 given. With no -r, build the default 7 | #: HEAD. 8 | #: 9 | #: This command is used in situations where you'd typically use a :git bundler 10 | #: source, but allows for caching in vendor. 11 | set -e 12 | [ $# -eq 0 ] && set -- --help 13 | 14 | # parse args 15 | rev=master 16 | while [ $# -gt 0 ]; do 17 | case "$1" in 18 | -r) 19 | rev=$2 20 | shift 2 21 | ;; 22 | -n) 23 | gem=$2 24 | shift 2 25 | ;; 26 | -h|--help) 27 | grep ^#: <"$0" |cut -c5- 28 | exit 29 | ;; 30 | *) 31 | url="$1" 32 | shift 33 | ;; 34 | esac 35 | done 36 | 37 | if [ -z "$url" ]; then 38 | echo "error: no git url given. see $0 --help for usage." 1>&2 39 | exit 1 40 | fi 41 | 42 | have_gemfile=$([ -f "Gemfile" ]; echo $?) 43 | 44 | repo=$(echo "$url" | sed 's@^\(https://github\.com.*\)\.git$@\1@') 45 | 46 | if [ -z "$gem" ]; then 47 | gem=$(basename "$url" .git) 48 | fi 49 | 50 | # in case people don't already have it in their PATH 51 | export PATH="$root/bin:$PATH" 52 | 53 | # clone the repo under tmp, clean up on exit 54 | echo "Cloning $url for gem build" 55 | mkdir -p "tmp/gems/$gem" 56 | 57 | # go in and build the gem using the HEAD version, clean up this tmp dir on exit 58 | echo "Building $gem" 59 | ( 60 | cd "tmp/gems/$gem" 61 | git init -q 62 | git fetch -q -fu "$url" "+refs/*:refs/*" 63 | git reset --hard HEAD 64 | git clean -df 65 | git checkout "$rev" 66 | git submodule update --init 67 | git --no-pager log -n 1 68 | 69 | gemspec=$(ls -1 *.gemspec | head -1) 70 | echo "Building $gemspec" 71 | 72 | gemname=$(basename "$gemspec" .gemspec) 73 | echo $gemname > vendor-gem-name 74 | 75 | # tag name + number of commits on top of tag + tree sha 76 | GEM_VERSION=$(git describe --tags 2>/dev/null | sed 's/-/./g' | sed 's/v//') 77 | 78 | # No tags 79 | if [ -z "${GEM_VERSION}" ] 80 | then 81 | gem_version=$(ruby -e "require 'rubygems'; spec=eval(File.read('$gemspec')); print spec.version.to_s") 82 | tree_sha=$(git show --quiet --format=format:%t $rev) 83 | GEM_VERSION="${gem_version}.g${tree_sha}" 84 | fi 85 | 86 | if [ -z "${GEM_VERSION}" ] 87 | then 88 | echo "couldn't determine the gem version from \"$gemspec\"" 89 | exit 1 90 | fi 91 | 92 | export GEM_VERSION 93 | 94 | # build a wrapping gemspec that adds the sha1 version to the gem version 95 | # unless the gemspec references the GEM_VERSION environment variable 96 | # in which case we assume this is handled explicitly in the gemspec itself 97 | if ! grep -q "GEM_VERSION" < $gemspec 98 | then 99 | cat <<-RUBY > vendor.gemspec 100 | require 'rubygems' 101 | spec = eval(File.read("$gemspec")) 102 | spec.version = "$GEM_VERSION" 103 | spec 104 | RUBY 105 | gem build vendor.gemspec 106 | else 107 | gem build $gemspec 108 | fi 109 | 110 | if [ $have_gemfile = 0 ]; then 111 | # Bump gem version in Gemfile (and deal with OS X sed differences) 112 | sed -i -e "s/^\([[:space:]]*\)gem ['\"]$gemname['\"],\( *\)['\"][^'\"]*['\"]/\\1gem \"$gemname\",\\2\"$GEM_VERSION\"/" ../../../Gemfile 113 | if [ `uname` = 'Darwin' ]; then 114 | rm -f "../../../Gemfile-e" 115 | fi 116 | fi 117 | ) 118 | [ $? -eq 0 ] || exit 1 119 | 120 | # get the gem name determined in the subprocess 121 | gemname=$(cat "tmp/gems/$gem/vendor-gem-name") 122 | 123 | # record old gem ref before deleting 124 | oldref=$(ls vendor/cache/$gemname-*.gem | grep -o -E -e "g[0-9a-f]{7}" | cut -c 2-) 125 | 126 | # remove any existing gems and add the newly built gem 127 | if [ -n "$gemname" ]; then 128 | git rm -f vendor/cache/$gemname*.gem 2>/dev/null || true 129 | cp tmp/gems/$gem/$gemname*.gem vendor/cache 130 | git add vendor/cache/$gemname* 131 | fi 132 | 133 | # get new gem ref 134 | newref=$(ls vendor/cache/$gemname-*.gem | grep -o -E -e "g[0-9a-f]{7}" | cut -c 2-) 135 | 136 | # write out compare url for review 137 | echo "$repo/compare/$oldref...$newref" 138 | 139 | if [ $have_gemfile = 0 ]; then 140 | bundle update --local $gemname 141 | git add Gemfile Gemfile.lock 142 | fi 143 | -------------------------------------------------------------------------------- /ruby-definitions/1.9.3-p231-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "ruby-1.9.3-p231-tcs-github-1.0.32" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-1.9.3-p231-tcs-github-1.0.32.tar.gz#49c440be308bb5a35419d79141bf3893" autoconf standard 3 | -------------------------------------------------------------------------------- /ruby-definitions/1.9.3-p231-tcs-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "ruby-1.9.3-p231-tcs-github" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-1.9.3-p231-tcs-github.tar.gz#e212d15ce3c807a432dd8020f8c6df9c" autoconf standard 3 | -------------------------------------------------------------------------------- /ruby-definitions/2.0.0-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2.0.0-github6" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-2.0.0-github6.tar.gz#63e06d012a10a66898def8afdba111ea" autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.0-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2.1.0-github1" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-2.1.0-github1.tar.gz#a8b528f2e0d5ecf55893002078014beb" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.1-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2.1.1-github1" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-2.1.1-github1.tar.gz#dd81268aaa87a7b200f40ad53ac47227" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.2-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2.1.2-github1" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-2.1.2-github1.tar.gz#3728f9ce8fc87aca1fef40d201358fa2" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.4-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#5fe00cda18ca5daeb43762b80c38e06e" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2.1.4-github1" "https://s3.amazonaws.com/boxen-downloads/ruby-build/ruby-2.1.4-github1.tar.gz#2e538443e5ce80da1d922153d1422439" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.5-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2_1_5_github1" "https://github.com/github/ruby/archive/v2_1_5_github1.tar.gz#003d09f172a16979c3eae7a91a46ee1db986d9c35f2d905f3c459d092f55fdf8" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.6-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2_1_6_github1" "https://github.com/github/ruby/archive/v2_1_6_github1.tar.gz#c874bb4aa16debc37e55f2b021f1970fb527be1053ce3a9a30a2a67848959b65" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.1.7-github: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2_1_7_github1" "https://github.com/github/ruby/archive/v2_1_7_github1.tar.gz#49fbdc6ee015b21f5b056ef847912ee8f0ae5afd9d1d2564e066e4679923a5e0" ldflags_dirs autoconf standard verify_openssl 4 | -------------------------------------------------------------------------------- /ruby-definitions/2.4-typedruby1: -------------------------------------------------------------------------------- 1 | install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz#7da6971b4bd08a986dd2a61353bc422362bd0edcc67d7ebaac68c95f74182749" --if needs_yaml 2 | install_package "openssl-1.0.2g" "https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33" mac_openssl --if has_broken_mac_openssl 3 | install_package "ruby-2_4_typedruby1" "https://github.com/github/ruby/archive/v2_4_typedruby1.tar.gz#c07d4f357123743467b9eb6809b597c28f7d315decddb31f682b20ca7c85d4f2" ldflags_dirs autoconf standard verify_openssl 4 | --------------------------------------------------------------------------------