Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sim-use/scripts/verify-brew-install.sh at main · lycorp-jp/sim-use · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
lycorp-jp
sim-use
Repository navigation
Code
Issues
24
(24)
Pull requests
3
(3)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
sim-use
/
scripts
/
verify-brew-install.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
194 lines (176 loc) · 8.34 KB
main
Breadcrumbs
sim-use
/
scripts
/
verify-brew-install.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
194 lines (176 loc) · 8.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!
/usr/bin/env bash
#
Install the real generated formula under a separate name without linking it.
#
This checks Homebrew relocation as well as post_install signing. A notarized
#
binary must remain byte-identical to the archive after installation.
set
-euo pipefail
REPO_ROOT=
"
$(
cd
"
$(
dirname
"
${BASH_SOURCE[0]}
"
)
/..
"
&&
pwd
)
"
cd
"
$REPO_ROOT
"
#
Homebrew's test harness uses its own Ruby and CA configuration.
export
HOMEBREW_FORCE_BREWED_CA_CERTIFICATES=
"
${HOMEBREW_FORCE_BREWED_CA_CERTIFICATES
:-
1}
"
export
HOMEBREW_NO_AUTO_UPDATE=1
export
HOMEBREW_NO_INSTALL_CLEANUP=1
ARCHIVE=
"
"
VERSION=
"
"
DOWNLOAD_URL=
"
"
REQUIRE_DEVELOPER_ID=false
REQUIRE_SPCTL_ACCEPT=false
EXPECTED_TEAM_ID=
"
${SIM_USE_EXPECTED_TEAM_ID
:-
GFPYJQXRSN}
"
KEEP_ON_FAILURE=true
TAP_REF=
"
sim-use-release-test/dryrun
"
FORMULA_NAME=
"
sim-use-dryrun
"
TAP_CREATED=false
INSTALL_ATTEMPTED=false
usage
() {
cat
<<
'
EOF
'
Usage: scripts/verify-brew-install.sh --archive PATH --version VERSION [OPTIONS]
--archive PATH Existing release archive used as the reference.
--version VERSION Plain release version, without a leading v.
--download-url URL Have Homebrew fetch this URL instead of the local
archive. Its checksum must match --archive.
--require-developer-id Generate a notarized formula and verify its original
binary bytes, Developer ID signature and notary record.
--require-spctl-accept Also require a successful Gatekeeper assessment.
--cleanup-on-failure Remove this run's temporary tap and keg on failure.
Otherwise leave them available for inspection.
-h, --help Show this help.
The temporary formula is installed with --skip-link. The existing sim-use
installation and PATH links are not changed. Existing verification workspaces
are refused, not overwritten or removed.
EOF
}
log
() {
printf
'
\033[1;36m▶\033[0m %s\n
'
"
$*
"
;
}
warn
() {
printf
'
\033[1;33m⚠\033[0m %s\n
'
"
$*
"
>&2
;
}
ok
() {
printf
'
\033[1;32m✓\033[0m %s\n
'
"
$*
"
;
}
fail
() {
printf
'
\033[1;31m✗\033[0m %s\n
'
"
$*
"
>&2
;
exit
1
;
}
while
[[
$#
-gt
0 ]]
;
do
case
"
$1
"
in
--archive) ARCHIVE=
"
${2
:-
}
"
;
shift
2 ;;
--version) VERSION=
"
${2
:-
}
"
;
shift
2 ;;
--download-url) DOWNLOAD_URL=
"
${2
:-
}
"
;
shift
2 ;;
--require-developer-id) REQUIRE_DEVELOPER_ID=true
;
shift
;;
--require-spctl-accept) REQUIRE_SPCTL_ACCEPT=true
;
shift
;;
--cleanup-on-failure) KEEP_ON_FAILURE=false
;
shift
;;
-h|--help) usage
;
exit
0 ;;
*
) fail
"
Unknown argument:
$1
"
;;
esac
done
[[
-n
"
$ARCHIVE
"
&&
-n
"
$VERSION
"
]]
||
{ usage
>&2
;
fail
"
--archive and --version are required
"
;
}
[[
-f
"
$ARCHIVE
"
]]
||
fail
"
Archive not found:
$ARCHIVE
"
command
-v brew
>
/dev/null
||
fail
"
brew not on PATH
"
ARCHIVE=
"
$(
cd
"
$(
dirname
"
$ARCHIVE
"
)
"
&&
pwd
)
/
$(
basename
"
$ARCHIVE
"
)
"
TAP_DIR=
"
$(
brew --repository
)
/Library/Taps/sim-use-release-test/homebrew-dryrun
"
FORMULA_PATH=
"
$TAP_DIR
/Formula/
$FORMULA_NAME
.rb
"
INSTALLED_KEG=
"
$(
brew --cellar
)
/
$FORMULA_NAME
/
$VERSION
"
INSTALLED_BIN=
"
$INSTALLED_KEG
/libexec/sim-use
"
[[
!
-e
"
$TAP_DIR
"
]]
||
fail
"
Verification tap already exists:
$TAP_DIR
"
[[
-z
"
$(
brew list --versions
"
$FORMULA_NAME
"
2>
/dev/null
||
true
)
"
]] \
||
fail
"
Verification formula is already installed:
$FORMULA_NAME
"
SOURCE_DIR=
"
$(
mktemp -d
"
${TMPDIR
:-/
tmp}
/sim-use-verify-source.XXXXXX
"
)
"
#
Homebrew 6+ requires trust for local formulae. Keep that permission inside this
#
run rather than adding a permanent entry to the developer's trust database.
export
XDG_CONFIG_HOME=
"
$SOURCE_DIR
/config
"
cleanup
() {
local
rc=
$?
local
can_untap=true
if
[[
$rc
-ne
0
&&
"
$KEEP_ON_FAILURE
"
==
"
true
"
]]
;
then
warn
"
Verification failed; retaining this run's workspace for inspection.
"
warn
"
Reference files and isolated trust config:
$SOURCE_DIR
"
[[
"
$TAP_CREATED
"
!=
"
true
"
]]
||
warn
"
Tap:
$TAP_DIR
"
[[
"
$INSTALL_ATTEMPTED
"
!=
"
true
"
]]
||
warn
"
Keg:
$INSTALLED_KEG
"
exit
"
$rc
"
fi
if
[[
"
$INSTALL_ATTEMPTED
"
==
"
true
"
]]
;
then
brew uninstall --formula
"
$TAP_REF
/
$FORMULA_NAME
"
||
{ rc=1
;
can_untap=false
;
}
fi
if
[[
"
$TAP_CREATED
"
==
"
true
"
&&
"
$can_untap
"
==
"
true
"
]]
;
then
if
brew untap
"
$TAP_REF
"
;
then
[[
!
-d
"
$TAP_DIR
"
]]
||
rm -rf
"
$TAP_DIR
"
else
rc=1
fi
fi
rm -rf
"
$SOURCE_DIR
"
exit
"
$rc
"
}
trap
cleanup EXIT
tar -xzf
"
$ARCHIVE
"
-C
"
$SOURCE_DIR
"
sim-use SimUse_SimUse.bundle SimUse_AndroidBackend.bundle
SOURCE_APK=
"
$(
find
"
$SOURCE_DIR
/SimUse_AndroidBackend.bundle
"
-type f -name sim-use-device-bridge.apk
)
"
[[
-f
"
$SOURCE_APK
"
]]
||
fail
"
Archive must contain exactly one Android bridge APK
"
APK_PATH=
"
${SOURCE_APK
#
"
$SOURCE_DIR
/
"
}
"
INSTALLED_APK=
"
$INSTALLED_KEG
/libexec/
$APK_PATH
"
ARCHIVE_APK_SHA=
"
$(
shasum -a 256
"
$SOURCE_APK
"
|
awk
'
{print $1}
'
)
"
ARCHIVE_BINARY_SHA=
"
$(
shasum -a 256
"
$SOURCE_DIR
/sim-use
"
|
awk
'
{print $1}
'
)
"
ARCHIVE_SHA256=
"
$(
shasum -a 256
"
$ARCHIVE
"
|
awk
'
{print $1}
'
)
"
if
[[
-z
"
$DOWNLOAD_URL
"
]]
;
then
DOWNLOAD_URL=
"
$(
ruby -ruri -e
'
puts "file://" + URI::DEFAULT_PARSER.escape(ARGV.fetch(0))
'
"
$ARCHIVE
"
)
"
fi
mkdir -p
"
$TAP_DIR
/Formula
"
TAP_CREATED=true
FORMULA_FLAGS=(
--formula-class SimUseDryrun
--homepage https://github.com/lycorp-jp/sim-use
--version
"
$VERSION
"
--url
"
$DOWNLOAD_URL
"
--sha256
"
$ARCHIVE_SHA256
"
)
[[
"
$REQUIRE_DEVELOPER_ID
"
!=
"
true
"
]]
||
FORMULA_FLAGS+=(--notarized)
scripts/generate-homebrew-formula.sh
"
${FORMULA_FLAGS[@]}
"
>
"
$FORMULA_PATH
"
ruby -c
"
$FORMULA_PATH
"
(
cd
"
$TAP_DIR
"
git init --quiet
git add
"
Formula/
$FORMULA_NAME
.rb
"
git -c user.email=verify@local -c user.name=verify commit --quiet -m
"
sim-use-dryrun
$VERSION
"
)
if
brew
help
trust
>
/dev/null
2>&1
;
then
brew trust --formula
"
$TAP_REF
/
$FORMULA_NAME
"
fi
log
"
Installing
$TAP_REF
/
$FORMULA_NAME
without linking
"
INSTALL_ATTEMPTED=true
brew install --formula --skip-link
"
$TAP_REF
/
$FORMULA_NAME
"
[[
-x
"
$INSTALLED_BIN
"
]]
||
fail
"
Installed binary is missing:
$INSTALLED_BIN
"
[[
-f
"
$INSTALLED_APK
"
]]
||
fail
"
Installed APK is missing:
$INSTALLED_APK
"
[[
"
$(
shasum -a 256
"
$INSTALLED_APK
"
|
awk
'
{print $1}
'
)
"
==
"
$ARCHIVE_APK_SHA
"
]] \
||
fail
"
Installed APK differs from the archive
"
ok
"
Installed APK is byte-identical to the archive
"
for
bundle
in
SimUse_SimUse.bundle SimUse_AndroidBackend.bundle
;
do
diff -qr
"
$SOURCE_DIR
/
$bundle
"
"
$INSTALLED_KEG
/libexec/
$bundle
"
\
||
fail
"
Installed resource bundle differs from the archive:
$bundle
"
done
ok
"
Both resource bundles are unchanged
"
codesign --verify --deep --strict --all-architectures
"
$INSTALLED_BIN
"
SIG_INFO=
"
$(
codesign -dvv
"
$INSTALLED_BIN
"
2>&1
)
"
if
[[
"
$REQUIRE_DEVELOPER_ID
"
==
"
true
"
]]
;
then
[[
"
$(
shasum -a 256
"
$INSTALLED_BIN
"
|
awk
'
{print $1}
'
)
"
==
"
$ARCHIVE_BINARY_SHA
"
]] \
||
fail
"
Installed binary differs from the notarized archive
"
grep -q
"
^TeamIdentifier=
$EXPECTED_TEAM_ID
$
"
<<<
"
$SIG_INFO
"
\
||
fail
"
Installed binary lost the expected Developer ID team
"
grep -q
'
^Authority=Developer ID Application:
'
<<<
"
$SIG_INFO
"
\
||
fail
"
Installed binary lost its Developer ID certificate
"
codesign --verify --strict --all-architectures --check-notarization
"
$INSTALLED_BIN
"
ok
"
Developer ID signature, notarization and binary bytes preserved (
$EXPECTED_TEAM_ID
)
"
else
printf
'
%s\n
'
"
$SIG_INFO
"
|
grep -E
'
Signature|Identifier|Authority
'
||
true
fi
if
[[
"
$REQUIRE_SPCTL_ACCEPT
"
==
"
true
"
]]
;
then
spctl_out=
"
$(
spctl -a -vv
"
$INSTALLED_BIN
"
2>&1
||
true
)
"
#
A flat CLI can be valid without being an app. Newer macOS versions omit
#
spctl's origin line, so check the identity and notary record with codesign.
if
grep -q
'
the code is valid
'
<<<
"
$spctl_out
"
\
&&
grep -q
"
^TeamIdentifier=
$EXPECTED_TEAM_ID
$
"
<<<
"
$SIG_INFO
"
\
&&
grep -q
'
^Authority=Developer ID Application:
'
<<<
"
$SIG_INFO
"
;
then
codesign --verify --strict --all-architectures --check-notarization
"
$INSTALLED_BIN
"
ok
"
Gatekeeper confirms valid CLI code from
$EXPECTED_TEAM_ID
"
elif
grep -Eq
'
(^|: )accepted$
'
<<<
"
$spctl_out
"
;
then
ok
"
Gatekeeper accepted the binary
"
else
printf
'
%s\n
'
"
$spctl_out
"
>&2
fail
"
Gatekeeper did not confirm this binary; no ad-hoc fallback was attempted
"
fi
fi
"
$INSTALLED_BIN
"
--version
"
$INSTALLED_BIN
"
init --print
>
/dev/null
"
$INSTALLED_BIN
"
devices --no-physical-ios --json
>
/dev/null
#
--force permits testing an unlinked keg; it does not skip test assertions.
brew
test
--force
"
$TAP_REF
/
$FORMULA_NAME
"
ok
"
Homebrew installation preserves the expected release signature and resources
"
You can’t perform that action at this time.