Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
st2/get-pants.sh at master · StackStorm/st2 · 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 }}
StackStorm
st2
Repository navigation
Code
Issues
556
(556)
Pull requests
49
(49)
Discussions
Actions
Wiki
Security and quality
2
(2)
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
st2
/
get-pants.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
221 lines (179 loc) · 4.81 KB
master
Breadcrumbs
st2
/
get-pants.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
221 lines (179 loc) · 4.81 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!
/usr/bin/env bash
#
Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
#
Licensed under the Apache License, Version 2.0 (see LICENSE).
set
-euo pipefail
COLOR_RED=
"
\x1b[31m
"
COLOR_GREEN=
"
\x1b[32m
"
COLOR_YELLOW=
"
\x1b[33m
"
COLOR_RESET=
"
\x1b[0m
"
function
log()
{
echo
-e
"
$@
"
1>&2
}
function
die()
{
((
$#
>
0
))
&&
log
"
${COLOR_RED}
$*
${COLOR_RESET}
"
exit
1
}
function
green()
{
((
$#
>
0
))
&&
log
"
${COLOR_GREEN}
$*
${COLOR_RESET}
"
}
function
warn()
{
((
$#
>
0
))
&&
log
"
${COLOR_YELLOW}
$*
${COLOR_RESET}
"
}
function
check_cmd()
{
local
cmd=
"
$1
"
command
-v
"
$cmd
"
>
/dev/null
||
die
"
This script requires the
${cmd}
binary to be on the PATH.
"
}
help_url=
"
https://www.pantsbuild.org/docs/getting-help
"
_GC=()
function
gc()
{
if
((
$#
>
0
))
;
then
check_cmd rm
_GC+=(
"
$@
"
)
else
rm -rf
"
${_GC[@]}
"
fi
}
trap
gc EXIT
check_cmd uname
function
calculate_os()
{
local
os
os=
"
$(
uname -s
)
"
if
[[
"
${os}
"
=~
[Ll]inux ]]
;
then
echo
linux
elif
[[
"
${os}
"
=~
[Dd]arwin ]]
;
then
echo
macos
elif
[[
"
${os}
"
=~
[Ww]in
|
[Mm][Ii][Nn][Gg] ]]
;
then
#
Powershell reports something like: Windows_NT
#
Git bash reports something like: MINGW64_NT-10.0-22621
echo
windows
else
die
"
Pants is not supported on this operating system (
${os}
). Please reach out to us at
${help_url}
for help.
"
fi
}
OS=
"
$(
calculate_os
)
"
check_cmd basename
if
[[
"
${OS}
"
==
"
windows
"
]]
;
then
check_cmd pwsh
else
check_cmd curl
fi
function
fetch()
{
local
url=
"
$1
"
local
dest_dir=
"
$2
"
local
dest
dest=
"
${dest_dir}
/
$(
basename
"
${url}
"
)
"
if
[[
"
${OS}
"
==
"
windows
"
]]
;
then
pwsh -c
"
Invoke-WebRequest -OutFile
$dest
-Uri
$url
"
else
curl --proto
'
=https
'
--tlsv1.2 -sSfL -o
"
${dest}
"
"
${url}
"
fi
}
if
[[
"
${OS}
"
==
"
macos
"
]]
;
then
check_cmd shasum
else
check_cmd sha256sum
fi
function
sha256()
{
if
[[
"
${OS}
"
==
"
macos
"
]]
;
then
shasum --algorithm 256
"
$@
"
else
sha256sum
"
$@
"
fi
}
check_cmd mktemp
function
install_from_url()
{
local
url=
"
$1
"
local
dest=
"
$2
"
local
workdir
workdir=
"
$(
mktemp -d
)
"
gc
"
${workdir}
"
fetch
"
${url}
.sha256
"
"
${workdir}
"
fetch
"
${url}
"
"
${workdir}
"
(
cd
"
${workdir}
"
sha256 -c --status ./
*
.sha256
||
die
"
Download from
${url}
did not match the fingerprint at
${url}
.sha256
"
)
rm
"
${workdir}
/
"
*
.sha256
if
[[
"
${OS}
"
==
"
macos
"
]]
;
then
mkdir -p
"
$(
dirname
"
${dest}
"
)
"
install -m 755
"
${workdir}
/
"
*
"
${dest}
"
else
install -D -m 755
"
${workdir}
/
"
*
"
${dest}
"
fi
}
function
calculate_arch()
{
local
arch
arch=
"
$(
uname -m
)
"
if
[[
"
${arch}
"
=~
x86[_-]64 ]]
;
then
echo
x86_64
elif
[[
"
${arch}
"
=~
arm64
|
aarch64 ]]
;
then
echo
aarch64
else
die
"
Pants is not supported for this chip architecture (
${arch}
). Please reach out to us at
${help_url}
for help.
"
fi
}
check_cmd cat
function
usage()
{
cat
<<
EOF
Usage:
$0
Installs the pants launcher binary.
You only need to run this once on a machine when you do not have "pants"
available to run yet.
The pants binary takes care of managing and running the underlying
Pants version configured in "pants.toml" in the surrounding Pants-using
project.
Once installed, if you want to update your "pants" launcher binary, use
"SCIE_BOOT=update pants" to get the latest release or
"SCIE_BOOT=update pants --help" to learn more options.
-h | --help: Print this help message.
-d | --bin-dir:
The directory to install the scie-pants binary in, "~/.local/bin" by default.
-b | --base-name:
The name to use for the scie-pants binary, "pants" by default.
-V | --version:
The version of the scie-pants binary to install, the latest version by default.
The available versions can be seen at:
https://github.com/pantsbuild/scie-pants/releases
EOF
}
bin_dir=
"
${HOME}
/.local/bin
"
base_name=
"
pants
"
version=
"
latest/download
"
while
((
$#
>
0
))
;
do
case
"
$1
"
in
--help | -h)
usage
exit
0
;;
--bin-dir | -d)
bin_dir=
"
$2
"
shift
;;
--base-name | -b)
base_name=
"
$2
"
shift
;;
--version | -V)
version=
"
download/v
$2
"
shift
;;
*
)
usage
die
"
Unexpected argument
$1
\n
"
;;
esac
shift
done
ARCH=
"
$(
calculate_arch
)
"
URL=
"
https://github.com/pantsbuild/scie-pants/releases/
${version}
/scie-pants-
${OS}
-
${ARCH}
"
dest=
"
${bin_dir}
/
${base_name}
"
log
"
Downloading and installing the pants launcher ...
"
install_from_url
"
${URL}
"
"
${dest}
"
green
"
Installed the pants launcher from
${URL}
to
${dest}
"
if
!
command
-v
"
${base_name}
"
>
/dev/null
;
then
warn
"
${dest}
is not on the PATH.
"
log
"
You'll either need to invoke
${dest}
explicitly or else add
${bin_dir}
to your shell's PATH.
"
fi
green
"
\nRunning
\`
pants
\`
in a Pants-enabled repo will use the version of Pants configured for that repo.
"
green
"
In a repo not yet Pants-enabled, it will prompt you to set up Pants for that repo.
"
You can’t perform that action at this time.