2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-04-27 20:27:42 +01:00
|
|
|
require "bintray"
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2018-04-10 18:37:15 +05:30
|
|
|
|
2016-05-20 11:00:51 +01:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2018-07-30 18:25:38 +05:30
|
|
|
def mirror_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
2018-09-28 21:39:52 +05:30
|
|
|
usage_banner <<~EOS
|
2019-01-30 21:33:03 +00:00
|
|
|
`mirror` <formula>
|
2018-10-02 19:54:22 +05:30
|
|
|
|
2020-04-18 12:13:43 -04:00
|
|
|
Reupload the stable URL of a formula to Bintray for use as a mirror.
|
2018-09-28 21:39:52 +05:30
|
|
|
EOS
|
2020-04-27 20:27:42 +01:00
|
|
|
flag "--bintray-org=",
|
|
|
|
description: "Upload to the specified Bintray organisation (default: homebrew)."
|
2020-06-20 21:55:49 +10:00
|
|
|
flag "--bintray-repo=",
|
|
|
|
description: "Upload to the specified Bintray repository (default: mirror)."
|
|
|
|
switch "--no-publish",
|
|
|
|
description: "Upload to Bintray, but don't publish."
|
2018-04-01 16:47:30 +05:30
|
|
|
switch :verbose
|
2018-10-08 22:49:03 -04:00
|
|
|
switch :debug
|
2019-01-30 21:33:03 +00:00
|
|
|
hide_from_man_page!
|
2020-03-04 17:28:24 +00:00
|
|
|
min_named :formula
|
2018-04-01 16:47:30 +05:30
|
|
|
end
|
2018-07-30 18:25:38 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def mirror
|
|
|
|
mirror_args.parse
|
2018-04-01 16:47:30 +05:30
|
|
|
|
2020-04-27 20:27:42 +01:00
|
|
|
bintray_org = args.bintray_org || "homebrew"
|
2020-06-20 21:55:49 +10:00
|
|
|
bintray_repo = args.bintray_repo || "mirror"
|
2020-04-27 20:27:42 +01:00
|
|
|
|
|
|
|
bintray = Bintray.new(org: bintray_org)
|
2016-05-20 11:00:51 +01:00
|
|
|
|
2020-06-08 17:48:28 +02:00
|
|
|
args.formulae.each do |formula|
|
2020-06-20 21:55:49 +10:00
|
|
|
mirror_url = bintray.mirror_formula(formula, repo: bintray_repo, publish_package: !args.no_publish?)
|
2020-06-08 17:48:28 +02:00
|
|
|
ohai "Mirrored #{formula.full_name} to #{mirror_url}!"
|
2016-05-20 11:00:51 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|