tools/dmg_pkg_install.sh
author nemo
Thu, 03 Mar 2016 16:36:05 -0500
changeset 11589 c453620cc6d6
parent 11587 cf83d9cb5590
permissions -rw-r--r--
Break up the hog/object collision. Currently is $7F, allowing 128 overlapping objects accurately. Breaking it up into 15 for hogs, 7 for other objects. I'm thinking the overall accuracy should be just fine as far as people noticing even with a ton of overlapping hogs, and this way we can tell the difference between a hog and "something else". For experiment and rope-breaking purposes, make rope pass through hogs.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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