Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
3b035970
Unverified
Commit
3b035970
authored
4 years ago
by
Dawid Dziurla
Browse files
Options
Downloads
Patches
Plain Diff
bintray: automatically run brew mirror if needed
parent
5a636365
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/bintray.rb
+32
-0
32 additions, 0 deletions
Library/Homebrew/bintray.rb
Library/Homebrew/dev-cmd/mirror.rb
+3
-28
3 additions, 28 deletions
Library/Homebrew/dev-cmd/mirror.rb
Library/Homebrew/dev-cmd/pr-pull.rb
+26
-4
26 additions, 4 deletions
Library/Homebrew/dev-cmd/pr-pull.rb
with
61 additions
and
32 deletions
Library/Homebrew/bintray.rb
+
32
−
0
View file @
3b035970
...
...
@@ -56,6 +56,38 @@ class Bintray
%w[homebrew linuxbrew]
.
include?
org
end
def
stable_mirrored?
(
url
)
headers
,
=
curl_output
(
"--connect-timeout"
,
"15"
,
"--location"
,
"--head"
,
url
)
status_code
=
headers
.
scan
(
%r{^HTTP/.* (
\d
+)}
).
last
.
first
status_code
.
start_with?
(
"2"
)
end
def
mirror_formula
(
formula
,
repo:
"mirror"
)
package
=
Utils
::
Bottles
::
Bintray
.
package
formula
.
name
create_package
(
repo:
repo
,
package:
package
)
unless
package_exists?
(
repo:
repo
,
package:
package
)
formula
.
downloader
.
fetch
version
=
ERB
::
Util
.
url_encode
(
formula
.
pkg_version
)
filename
=
ERB
::
Util
.
url_encode
(
formula
.
downloader
.
basename
)
destination_url
=
"https://dl.bintray.com/
#{
@bintray_org
}
/
#{
repo
}
/
#{
filename
}
"
odebug
"Uploading to
#{
destination_url
}
"
upload
(
formula
.
downloader
.
cached_location
,
repo:
repo
,
package:
package
,
version:
version
,
sha256:
formula
.
stable
.
checksum
,
remote_file:
filename
,
)
publish
(
repo:
repo
,
package:
package
,
version:
version
)
destination_url
end
def
create_package
(
repo
:,
package
:,
**
extra_data_args
)
url
=
"
#{
API_URL
}
/packages/
#{
@bintray_org
}
/
#{
repo
}
"
data
=
{
name:
package
,
public_download_numbers:
true
}
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/dev-cmd/mirror.rb
+
3
−
28
View file @
3b035970
...
...
@@ -26,37 +26,12 @@ module Homebrew
mirror_args
.
parse
bintray_org
=
args
.
bintray_org
||
"homebrew"
bintray_repo
=
"mirror"
bintray
=
Bintray
.
new
(
org:
bintray_org
)
args
.
formulae
.
each
do
|
f
|
bintray_package
=
Utils
::
Bottles
::
Bintray
.
package
f
.
name
unless
bintray
.
package_exists?
(
repo:
bintray_repo
,
package:
bintray_package
)
bintray
.
create_package
repo:
bintray_repo
,
package:
bintray_package
end
downloader
=
f
.
downloader
downloader
.
fetch
filename
=
ERB
::
Util
.
url_encode
(
downloader
.
basename
)
destination_url
=
"https://dl.bintray.com/
#{
bintray_org
}
/
#{
bintray_repo
}
/
#{
filename
}
"
ohai
"Uploading to
#{
destination_url
}
"
version
=
ERB
::
Util
.
url_encode
(
f
.
pkg_version
)
bintray
.
upload
(
downloader
.
cached_location
,
repo:
bintray_repo
,
package:
bintray_package
,
version:
version
,
sha256:
f
.
stable
.
checksum
,
remote_file:
filename
,
)
bintray
.
publish
(
repo:
bintray_repo
,
package:
bintray_package
,
version:
version
)
ohai
"Mirrored
#{
filename
}
!"
args
.
formulae
.
each
do
|
formula
|
mirror_url
=
bintray
.
mirror_formula
(
formula
)
ohai
"Mirrored
#{
formula
.
full_name
}
to
#{
mirror_url
}
!"
end
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/dev-cmd/pr-pull.rb
+
26
−
4
View file @
3b035970
...
...
@@ -204,18 +204,40 @@ module Homebrew
url
=
GitHub
.
get_artifact_url
(
user
,
repo
,
pr
,
workflow_id:
workflow
,
artifact_name:
artifact
)
download_artifact
(
url
,
dir
,
pr
)
json_files
=
Dir
[
"*.json"
]
if
Homebrew
.
args
.
dry_run?
puts
"brew bottle --merge --write
#{
Dir
[
"*.json"
]
.
join
" "
}
"
puts
"brew bottle --merge --write
#{
json_files
.
join
" "
}
"
else
quiet_system
"
#{
HOMEBREW_PREFIX
}
/bin/brew"
,
"bottle"
,
"--merge"
,
"--write"
,
*
Dir
[
"*.json"
]
quiet_system
"
#{
HOMEBREW_PREFIX
}
/bin/brew"
,
"bottle"
,
"--merge"
,
"--write"
,
*
json_files
end
next
if
args
.
no_upload?
if
Homebrew
.
args
.
dry_run?
puts
"Upload bottles described by these JSON files to Bintray:
\n
#{
Dir
[
"*.json"
]
.
join
(
"
\n
"
)
}
"
puts
"Upload bottles described by these JSON files to Bintray:
\n
#{
json_files
.
join
(
"
\n
"
)
}
"
else
bintray
.
upload_bottle_json
Dir
[
"*.json"
],
publish_package:
!
args
.
no_publish?
bintray
.
upload_bottle_json
json_files
,
publish_package:
!
args
.
no_publish?
end
bottles_hash
=
json_files
.
reduce
({})
do
|
hash
,
json_file
|
hash
.
deep_merge
(
JSON
.
parse
(
IO
.
read
(
json_file
)))
end
bottles_hash
.
each
do
|
formula_name
,
_
|
formula
=
Formula
[
formula_name
]
stable_urls
=
[
formula
.
stable
.
url
]
+
formula
.
stable
.
mirrors
stable_urls
.
grep
(
%r{^https://dl.bintray.com/homebrew/mirror/}
)
do
|
mirror_url
|
if
Homebrew
.
args
.
dry_run?
puts
"Mirror formulae sources described by these JSON files to Bintray:
\n
#{
json_files
.
join
(
"
\n
"
)
}
"
next
end
next
if
bintray
.
stable_mirrored?
(
mirror_url
)
mirror_url
=
bintray
.
mirror_formula
(
formula
)
ohai
"Mirrored
#{
formula
.
full_name
}
to
#{
mirror_url
}
!"
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment