]> git.cameronkatri.com Git - apple_cmds.git/blob - download.sh
network_cmds: 606.140.3
[apple_cmds.git] / download.sh
1 #!/bin/sh
2 version="$(basename $(curl -s https://opensource.apple.com/tarballs/${1}/ | \
3 pup 'table tbody tr td a:not([href="./../"]) text{}' -c | \
4 sort -V | tail -n 1) .tar.gz | \
5 rev | cut -d- -f 1 | rev)"
6 if [ "$( echo -e "${version}\n$(cat ${1}/.apple_version)" | sort -V | tail -n 1)" = "$(cat ${1}/.apple_version)" ]; then
7 echo "${1} - $(cat ${1}/.apple_version)"
8 else
9 echo "${1} - $(cat ${1}/.apple_version) -> ${version}"
10 wget -q https://opensource.apple.com/tarballs/${1}/${1}-${version}.tar.gz
11 rm -rf ${1}
12 mkdir ${1}
13 tar xf ${1}-${version}.tar.gz -C ${1} --strip-components=1
14 echo "${version}" > ${1}/.apple_version
15 rm ${1}-${version}.tar.gz
16 fi