Created
July 22, 2012 07:49
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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