forked from pachyderm/homebrew-tap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-formula.sh
executable file
·65 lines (55 loc) · 2.27 KB
/
update-formula.sh
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
#!/bin/bash
# Full URL looks like this:
# https://github.com/pachyderm/pachyderm/releases/download/v1.0.1-dirty/pachctl_v1.0.1-dirty_darwin_amd64.zip
GITHUB_HOSTING_ROOT=https://github.com/pachyderm/pachyderm/releases/download
MACINTEL_BINARY_SUFFIX=_darwin_amd64.zip
MACARM_BINARY_SUFFIX=_darwin_arm64.zip
FORMULA=pachctl.rb.template
# e.g. convert from 1.3.4 -> 1.3
MAJOR_MINOR=`echo $VERSION | cut -f -2 -d "."`
# e.g. convert from 1.3 -> 13
MAJOR_MINOR_SQUASHED=`echo $MAJOR_MINOR | sed 's/\.//g'`
# run the old script for anything prior to 2.3.x
if [[ $MAJOR_MINOR_SQUASHED -lt 23 ]]; then
./update-formula-old.sh
exit 0
fi
cp $FORMULA pachctl@$MAJOR_MINOR.rb
FORMULA="pachctl@$MAJOR_MINOR.rb"
# Linux doesn't allow a space after the -i flag in sed. OSX needs it.
AMDURL=$GITHUB_HOSTING_ROOT"/v"$VERSION"/pachctl_"$VERSION$MACINTEL_BINARY_SUFFIX
ARMURL=$GITHUB_HOSTING_ROOT"/v"$VERSION"/pachctl_"$VERSION$MACARM_BINARY_SUFFIX
# Put the file in place
### replace binary URL
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e "s|AMDURLPH|${AMDURL}|g" $FORMULA
sed -i '' -e "s|ARMURLPH|${ARMURL}|g" $FORMULA
else
sed -i'' -e "s|AMDURLPH|${AMDURL}|g" $FORMULA
sed -i'' -e "s|ARMURLPH|${ARMURL}|g" $FORMULA
fi
### get binary and update SHA
echo "download: $AMDURL"
curl -L -o intelbin "$AMDURL"
echo "download: $ARMURL"
curl -L -o armbin "$ARMURL"
# Need sha256sum ... install on mac via: 'brew install coreutils'
# And then do 'ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum'
which sha256sum
sha256sum intelbin | cut -f 1 -d " " > INTELSHA
sha256sum armbin | cut -f 1 -d " " > ARMSHA
if [[ "$OSTYPE" == "darwin"* ]]; then
cat INTELSHA | xargs -I NEWSHA sed -i '' -e "s|AMDSHAPH|NEWSHA|g" $FORMULA
cat ARMSHA | xargs -I NEWSHA sed -i '' -e "s|ARMSHAPH|NEWSHA|g" $FORMULA
else
cat INTELSHA | xargs -I NEWSHA sed -i'' -e "s|AMDSHAPH|NEWSHA|g" $FORMULA
cat ARMSHA | xargs -I NEWSHA sed -i'' -e "s|ARMSHAPH|NEWSHA|g" $FORMULA
fi
### update version
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/version ".*"/version "v'"$VERSION"'"/g' $FORMULA
sed -i '' 's/class Pachctl/class PachctlAT'"$MAJOR_MINOR_SQUASHED"'/g' $FORMULA
else
sed -i'' 's/version ".*"/version "v'"$VERSION"'"/g' $FORMULA
sed -i'' 's/class Pachctl/class PachctlAT'"$MAJOR_MINOR_SQUASHED"'/g' $FORMULA
fi