author | Wuzzy <Wuzzy2@mail.ru> |
Fri, 09 Feb 2018 14:33:00 +0100 | |
changeset 12940 | 39b7b3ed619e |
parent 11587 | cf83d9cb5590 |
permissions | -rw-r--r-- |
11587
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
1 |
#!/bin/bash |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
2 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
3 |
# Downloads and install a .dmg from a URL |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
4 |
# |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
5 |
# Usage |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
6 |
# $ dmg_pkg_install [url] |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
7 |
# |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
8 |
# Adopted from https://gist.github.com/afgomez/4172338 |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
9 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
10 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
11 |
if [[ $# -lt 1 ]]; then |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
12 |
echo "Usage: dmg_pkg_install [url]" |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
13 |
exit 1 |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
14 |
fi |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
15 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
16 |
url=$* |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
17 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
18 |
# Generate a random file name |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
19 |
tmp_file=/tmp/`openssl rand -base64 10 | tr -dc '[:alnum:]'`.dmg |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
20 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
21 |
# Download file |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
22 |
echo "Downloading $url..." |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
23 |
curl -# -L -o $tmp_file $url |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
24 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
25 |
echo "Mounting image..." |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
26 |
volume=`hdiutil mount $tmp_file | tail -n1 | perl -nle '/(\/Volumes\/[^ ]+)/; print $1'` |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
27 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
28 |
# Locate .pkg |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
29 |
app_pkg=`find $volume/. -name *.pkg -maxdepth 1 -print0` |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
30 |
echo "Install pkg..." |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
31 |
installer -pkg $app_pkg -target / |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
32 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
33 |
# Unmount volume, delete temporal file |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
34 |
echo "Cleaning up..." |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
35 |
hdiutil unmount $volume -quiet |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
36 |
rm $tmp_file |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
37 |
|
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
38 |
echo "Done!" |
cf83d9cb5590
- Enable CI builds with travis for hw iOS
antonc27 <antonc27@mail.ru>
parents:
diff
changeset
|
39 |
exit 0 |