Skip to content

Instantly share code, notes, and snippets.

@GuanshanLiu
Created July 22, 2012 07:49
Show Gist options
  • Save GuanshanLiu/3158813 to your computer and use it in GitHub Desktop.
Save GuanshanLiu/3158813 to your computer and use it in GitHub Desktop.
Downloads Mac OS X, iOS released source code from http://www.opensource.apple.com/
#!/bin/sh
# applesource.sh
# Downloads Mac OS X, iOS released source code from http://www.opensource.apple.com/
#
# Created by Guanshan Liu on 22/07/2012.
#
if [ $# != 2 ]
then
echo "Usage: $0 <osx|ios> <version>"
exit 1
fi
if [ $1 == 'osx' ]
then
version="mac-os-x-`echo $2 | tr -d "."`"
else
version="ios-`echo $2 | tr -d "."`"
fi
homepage="http://www.opensource.apple.com"
URL="${homepage}/release/${version}/"
sources="./${version}"
mkdir -p ${sources}
curl -s ${URL} | \
sed -n 's/<a href="\(.*.tar.gz\)">/\1/p' | \
while read line; do
tarball=".${line}"
curl --create-dirs -o ${tarball} "${homepage}${line}"
tar xfz "${tarball}" -C ${sources}
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment