| 
									
										
										
										
											2023-04-04 22:13:58 -07:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							|  |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(CLI::Parser) } | 
					
						
							| 
									
										
										
										
											2019-01-30 21:33:03 +00:00
										 |  |  |   def vendor_gems_args | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  |         Install and commit Homebrew's vendored gems. | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 04:12:33 +01:00
										 |  |  |       comma_array "--update", | 
					
						
							| 
									
										
										
										
											2023-02-10 23:15:40 -05:00
										 |  |  |                   description: "Update the specified list of vendored gems to the latest version." | 
					
						
							| 
									
										
										
										
											2022-10-08 18:39:47 +01:00
										 |  |  |       switch      "--no-commit", | 
					
						
							|  |  |  |                   description: "Do not generate a new commit upon completion." | 
					
						
							| 
									
										
										
										
											2023-04-24 10:32:10 +01:00
										 |  |  |       switch     "--non-bundler-gems", | 
					
						
							|  |  |  |                  description: "Update vendored gems that aren't using Bundler.", | 
					
						
							|  |  |  |                  hidden:      true | 
					
						
							| 
									
										
										
										
											2020-11-19 09:22:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-10 14:26:40 -05:00
										 |  |  |       named_args :none | 
					
						
							| 
									
										
										
										
											2019-01-30 21:33:03 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 04:12:33 +01:00
										 |  |  |   sig { void } | 
					
						
							| 
									
										
										
										
											2019-01-30 21:33:03 +00:00
										 |  |  |   def vendor_gems | 
					
						
							| 
									
										
										
										
											2020-11-19 09:22:01 +01:00
										 |  |  |     args = vendor_gems_args.parse | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 15:08:21 +00:00
										 |  |  |     Homebrew.install_bundler! | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-10 16:53:59 +01:00
										 |  |  |     ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":") | 
					
						
							| 
									
										
										
										
											2021-05-12 16:07:47 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-24 13:24:31 +00:00
										 |  |  |     # System Ruby does not pick up the correct SDK by default. | 
					
						
							|  |  |  |     ENV["SDKROOT"] = MacOS.sdk_path if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-05 08:26:38 +00:00
										 |  |  |     ohai "cd #{HOMEBREW_LIBRARY_PATH}" | 
					
						
							| 
									
										
										
										
											2019-02-21 15:41:42 +00:00
										 |  |  |     HOMEBREW_LIBRARY_PATH.cd do | 
					
						
							| 
									
										
										
										
											2020-11-21 04:12:33 +01:00
										 |  |  |       if args.update | 
					
						
							| 
									
										
										
										
											2020-11-19 09:22:01 +01:00
										 |  |  |         ohai "bundle update" | 
					
						
							| 
									
										
										
										
											2020-11-21 04:12:33 +01:00
										 |  |  |         safe_system "bundle", "update", *args.update | 
					
						
							| 
									
										
										
										
											2020-11-19 09:22:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 18:39:47 +01:00
										 |  |  |         unless args.no_commit? | 
					
						
							|  |  |  |           ohai "git add Gemfile.lock" | 
					
						
							|  |  |  |           system "git", "add", "Gemfile.lock" | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2020-11-19 09:22:01 +01:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  |       ohai "bundle install --standalone" | 
					
						
							| 
									
										
										
										
											2021-06-07 14:51:07 +01:00
										 |  |  |       safe_system "bundle", "install", "--standalone" | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-11 12:39:06 +00:00
										 |  |  |       ohai "bundle pristine" | 
					
						
							|  |  |  |       safe_system "bundle", "pristine" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-24 10:32:10 +01:00
										 |  |  |       if args.non_bundler_gems? | 
					
						
							|  |  |  |         %w[
 | 
					
						
							|  |  |  |           mechanize | 
					
						
							|  |  |  |         ].each do |gem| | 
					
						
							|  |  |  |           ohai "gem install #{gem}" | 
					
						
							|  |  |  |           safe_system "gem", "install", "mechanize", "--install-dir", "vendor", | 
					
						
							|  |  |  |                       "--no-document", "--no-wrappers", "--ignore-dependencies", "--force" | 
					
						
							|  |  |  |           (HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do | 
					
						
							|  |  |  |             if (source = Pathname.glob("#{gem}-*/").first) | 
					
						
							|  |  |  |               FileUtils.ln_sf source, gem | 
					
						
							|  |  |  |             end | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 18:39:47 +01:00
										 |  |  |       unless args.no_commit? | 
					
						
							| 
									
										
										
										
											2023-04-24 10:32:10 +01:00
										 |  |  |         ohai "git add vendor" | 
					
						
							|  |  |  |         system "git", "add", "vendor" | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 18:39:47 +01:00
										 |  |  |         Utils::Git.set_name_email! | 
					
						
							|  |  |  |         Utils::Git.setup_gpg! | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-08 18:39:47 +01:00
										 |  |  |         ohai "git commit" | 
					
						
							|  |  |  |         system "git", "commit", "--message", "brew vendor-gems: commit updates." | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-12-21 20:09:08 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |