summaryrefslogtreecommitdiff
path: root/data/iphoneos-sdk/download-theos-sdk
diff options
context:
space:
mode:
authorMCApollo <34170230+MCApollo@users.noreply.github.com>2019-04-24 20:58:12 -0500
committerMCApollo <34170230+MCApollo@users.noreply.github.com>2019-04-24 20:58:12 -0500
commita12a0f8a5ab9cce38d815e83474656bf504d96dc (patch)
tree4ddff6b7a27819c46577b2a172961393677e34e6 /data/iphoneos-sdk/download-theos-sdk
parent70c8b04b525b7ed4af0689ebf2b2ad540c95ec11 (diff)
Proposed package to replace iphoneos-sys.
Diffstat (limited to 'data/iphoneos-sdk/download-theos-sdk')
-rwxr-xr-xdata/iphoneos-sdk/download-theos-sdk51
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