diff options
Diffstat (limited to 'data/iphoneos-sdk/download-theos-sdk')
-rwxr-xr-x | data/iphoneos-sdk/download-theos-sdk | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/data/iphoneos-sdk/download-theos-sdk b/data/iphoneos-sdk/download-theos-sdk new file mode 100755 index 000000000..c17dd3143 --- /dev/null +++ b/data/iphoneos-sdk/download-theos-sdk @@ -0,0 +1,51 @@ +#!/bin/bash +# download-theos-sdk +# Provides a copy of the SDK through download. +# +# Report any issues to the maintainer of this package. + +url='https://github.com/theos/sdks/archive/master.zip' +_SDK='/usr/share/SDKs/iPhoneOS.sdk' +# FUNCTIONS +function die(){ + local msg="$@" + printf 'ERROR: %s\n' "${msg}" 1>&2 + exit 1 +} + +function _root() { + if sudo -n /bin/true &>/dev/null; then + cmd="sudo" + elif command -v crux &>/dev/null; then + cmd="crux" + else + die "Run this script as root." + fi + ${cmd} $(realpath ${BASH_SOURCE[0]}) + exit $? +} + +# START +# Check for the SDK. +if [[ -d ${_SDK}/usr/lib ]]; then + echo "Installed to ${_SDK}, nothing more to do." + exit 0 +fi + +[[ ${UID} != 0 ]] && _root +set -e +function error(){ + die "Something went wrong." +} +trap "error" ERR + +cd $(mktemp -d) +echo 'Please wait.' 1>&2 +/usr/bin/wget ${url} &>/dev/null || die "Failed to download ${url}" +/usr/bin/unzip ${url##**/} &>/dev/null || die "Failed to extract ${url##**/}" +SDK="$(for d in */*.sdk; do echo "${d}"; done | sort -rVtx | head -n1 )" +mkdir -p ${_SDK} +cp -rn ${SDK:-/nonexist}/* ${_SDK} + +echo "${SDK##**/} was installed to ${_SDK}" +exit 0 |