Last active
August 29, 2015 13:58
-
-
Save tjluoma/9956533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the actual filename that will be installed once the app is installed | |
# note that the '.app' suffix _is_ included because we might be | |
# installing preference panes so we don't want to assume. | |
INSTALLED_NAME="VLC.app" | |
# this is the directory where the 'INSTALLED_NAME' program will go | |
# when it is installed. Could be anywhere as long as user can write to it | |
# such as "$HOME/Applications" or "$HOME/Library/PreferencePanes" | |
# or even something weird like '/var/mac/apps' if you have a truly | |
# odd configuration for some reason. | |
INSTALL_DIR="/Applications" | |
# DL_URL _must_ be compatible with `curl --location --remote-name` | |
# Also, it _must_ be _one line_ although I have put it on several | |
# lines for readability in this example. A user should be able to | |
# run `fgrep DL_URL=` on this file and get the full command | |
# necessary for getting the URL | |
DL_URL=$(curl -sL 'http://update.videolan.org/vlc/sparkle/vlc.xml' |\ | |
awk -F'"' '/http:\/\/.*\.dmg/{print $2}'|\ | |
tail -1) | |
# This is actually optional _IFF_ the end of DL_URL is the same | |
# as the filename. For example, this: | |
# http://www.omnigroup.com/download/latest/omnifocus | |
# when used with `curl --location --remote-name` is going to leave | |
# us with a file named 'omnifocus' which isn't what we want, so | |
# in that case we'd want to define | |
# FILENAME=omnifocus.dmg | |
# OTOH: | |
# http://www.omnigroup.com/ftp1/pub/software/MacOSX/10.6/OmniFocus-1.10.6.dmg | |
# would leave us with 'OmniFocus-1.10.6.dmg' | |
# which would work just fine, and in that case we would not need a | |
# FILENAME= line at all | |
# OPTIONAL IF: "$DL_URL:t" | |
# REQUIRED IF: not equal to "$DL_URL:t" | |
FILENAME="$DL_URL:t" | |
# Like DL_URL this should all be on one line. A user should be able to run | |
# `fgrep LATEST_VERSION=` on this file and get the full command. | |
# how do | |
LATEST_VERSION=$(curl -sL 'http://update.videolan.org/vlc/sparkle/vlc.xml' |\ | |
awk -F'"' '/sparkle:version/{print $2}'|\ | |
tail -1) | |
# If the app we are going to install is already installed, we need to know what | |
# to check the LATEST_VERSION against to see if the app is up to date | |
# This is usually CFBundleShortVersionString or CFBundleVersion | |
# The main script will check in | |
# $INSTALL_DIR/$INSTALLED_NAME/Contents/Info.plist | |
# (there's also a few other edge cases but those are the most common) | |
VERSION_TYPE="CFBundleVersion" | |
# need to know this for trying to resume partial downloads, checking | |
# download size, etc. | |
# Most servers support this, but some do not, so if this is not defined | |
# it will be assumed to be 'yes' but it's better to explicitly define it | |
# if possible | |
# OPTIONAL IF: answer is 'yes' | |
# REQUIRED IF: answer is 'no | |
DOES_SERVER_SUPPORT_HEAD="yes" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment