diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-05-20 16:16:39 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-05-20 16:16:39 -0400 |
commit | 27554072ccc744d561cc9c27a15c3cccba954145 (patch) | |
tree | bbbc8f2016d4092c7853e8756ad8dc2d7384a222 | |
parent | ff53761db422fcf79398bd72c63342cb2c79f206 (diff) | |
download | apple_cmds-27554072ccc744d561cc9c27a15c3cccba954145.tar.gz apple_cmds-27554072ccc744d561cc9c27a15c3cccba954145.tar.zst apple_cmds-27554072ccc744d561cc9c27a15c3cccba954145.zip |
download.sh: Make way better
-rwxr-xr-x | download.sh | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/download.sh b/download.sh index 3c3d0cc..54b86a8 100755 --- a/download.sh +++ b/download.sh @@ -1,5 +1,14 @@ #!/bin/sh -TEMP=$(mktemp -d) -wget -q -P${TEMP} https://opensource.apple.com/tarballs/${1}/${1}-${2}.tar.gz -tar xf ${TEMP}/${1}-${2}.tar.gz -C ${1} --strip-components=1 -echo "${2}" > ${1}/.apple_version +version="$(basename $(curl -s https://opensource.apple.com/tarballs/${1}/ | \ + pup 'table tbody tr td a:not([href="./../"]) text{}' -c | \ + sort -V | tail -n 1) .tar.gz | \ + rev | cut -d- -f 1 | rev)" +if [ "$( echo -e "${version}\n$(cat ${1}/.apple_version)" | sort -V | tail -n 1)" = "$(cat ${1}/.apple_version)" ]; then + echo "${1} - $(cat ${1}/.apple_version)" +else + echo "${1} - $(cat ${1}/.apple_version) -> ${version}" + TEMP=$(mktemp -d) + wget -q -P${TEMP} https://opensource.apple.com/tarballs/${1}/${1}-${version}.tar.gz + tar xf ${TEMP}/${1}-${2}.tar.gz -C ${1} --strip-components=1 + echo "${version}" > ${1}/.apple_version +fi |