While it is well known that Mac OS X contains open source code, how to access and download that source code is perhaps less well known. Apple publishes all its open source code on their Apple Open Source site. However, this site makes you download each program individually, without an obvious option to download an entire OS X release at once (i.e., all public sources for 10.6.1).

So I wrote the following bash script to automate the download procedure. It downloads the individual tarballs for each program, expands them locally, and then rolls everything up into one big tarball for local storage. Some caveats are that this script does not build the code, and that you are bound by a variety of licenses which are not included here (because no Apple code is included here).

#!/usr/bin/env bash
# --- applesource.bash --- downloads source code for an entire Apple release # Take input from command-line (use "10.5.8", "10.6.1", etc.)
version="mac-os-x-`echo $* | tr -d "."`" # URL:
homepage="http://www.opensource.apple.com"
URL="${homepage}/release/${version}/" # Announce beginning, and prepare a directory for the untarred sources
echo "Preparing to download..."
sources="./${version}-sources"
mkdir -p ${sources} # Process the webpage for the locations of the tarballs themselves
curl --silent ${URL} | sed -n 's/<a href="\(.*.tar.gz\)">/\1/p' | \
while read line; do # Find and announce the name of the next tarball to be downloaded
tarball=".${line}"
echo -e "\nDownloading `basename ${tarball}`..." # Download the tarball and keep Apple's original directory structure intact
curl --create-dirs --output ${tarball} "${homepage}${line}" # Untar into the "sources" directory (see line 13)
tar xfz "${tarball}" -C ${sources} done # Compress all sourcefiles into a single tarball for posterity
echo "Creating ${version}.tar.gz from all sources..."
tar cfvz "${version}.tar.gz" ${sources} # Explicitly show that everything finished.
echo "Done." # I like for my Mac to talk to me, although sometimes this can be creepy.
say "The source of ${version} is now ready."

Save the above somewhere on your path, make it executable (chmod a+x scriptname), and then run it with the version number you'd like to download: getsource 10.6.1, for instance. I am a bit shy about releasing my scripts, so please be gentle!

以上转自:http://hints.macworld.com/article.php?story=20091014194517371

另附:非常有用的参考网址:
tar包下载地址(全):www.opensource.apple.com/tarballs/
source在线查看(全):www.opensource.apple.com/source/
release发布包下载地址:
Mac OS X 10.6.2: www.opensource.apple.com/release/mac-os-x-1062/
Mac OS X 10.8:   www.opensource.apple.com/release/mac-os-x-108/

脚本下载地址:http://download.csdn.net/detail/duanyipeng/8831335

Download all Apple open source OS X files at once的更多相关文章

  1. English Conversations You Can Download for Free (Spoken English MP3/Audio Files)

    If you want to download free English conversations, you’ve come to the right place. This page introd ...

  2. How To Use XDOLoader to Manage, Download and Upload Files? (文档 ID 469585.1)

    Applies to: BI Publisher (formerly XML Publisher) - Version 5.6.3 to 5.6.3 [Release 5] Information  ...

  3. How To Use XDOLoader to Manage, Download and Upload Files? (DOC ID 469585.1)

    In this Document Goal Fix     Downloading Files   Uploading Files References Applies to: BI Publishe ...

  4. Install wget in Mac OS X Without Homebrew or MacPorts

    May 22, 2012 - 31 Comments The command line tool wget lets you retrieve a group of files from FTP an ...

  5. vmware 安装 Mac OS X 10.9 Mavericks

    This guide shows how to install fresh OS X 10.9 Mavericks on VMware workstation with Windows 7 or Wi ...

  6. 网络电话pjsip Getting Started: Building for Apple iPhone, iPad and iPod Touch

    Getting Started: Building for Apple iPhone, iPad and iPod Touch ¶ Getting Started Preparation Get th ...

  7. The Top 50 Proprietary Programs that Drive You Crazy — and Their Open Source Alternatives

    The Top 50 Proprietary Programs that Drive You Crazy — and Their Open Source Alternatives 01 / 22 / ...

  8. Mac OS X 背后的故事

    Mac OS X 背后的故事 作者: 王越  来源: <程序员>  发布时间: 2013-01-22 10:55  阅读: 25840 次  推荐: 49   原文链接   [收藏]   ...

  9. openbr on linuxmint13/ubuntu12.04/debian7 x64 facial recognition [Compile from source!!!]

    Openbr is a great project for facial detecting. System: linuxmint 13 x86_64 Face recognition,  motio ...

随机推荐

  1. ●BZOJ 3998 [TJOI2015]弦论

    题链: http://www.lydsy.com/JudgeOnline/problem.php?id=3998题解: 后缀自动机. 当T=0时, 由于在后缀自动机上沿着trans转移,每个串都是互不 ...

  2. VK Cup 2017 - Round 2

    FallDream打的AB都FFT了,只剩一个我打的C,没进前一百,之后看看马拉松复活赛有没机会呗. A. Voltage Keepsake 题目大意:n个东西,每个东西一开始有bi能源,每秒消耗ai ...

  3. *hdu 5536(字典树的运用)

    Input The first line of input contains an integer T indicating the total number of test cases. The f ...

  4. [BZOJ]1069 最大土地面积(SCOI2007)

    计算几何经典题,贴板子. Description 在某块平面土地上有N个点,你可以选择其中的任意四个点,将这片土地围起来,当然,你希望这四个点围成的多边形面积最大. Input 第1行一个正整数N,接 ...

  5. VS2012代码对齐快捷键

    1.选中想要对齐的代码 2.全选代码后按住Ctrl+K,Ctrl+F键,就可以了

  6. Redis开启远程登录连接

    Redis 安装详见 http://www.cnblogs.com/zendwang/p/6560628.html 当前安装测试版本:Redis 3.2.8 默认安装完毕Redis只能本机访问 [ro ...

  7. select动态绑定vue.js

    <select v-model="selected"> <option v-for="option in options" v-bind:va ...

  8. redis锁处理并发问题

    redis锁处理并发问题 redis锁处理高并发问题十分常见,使用的时候常见有几种错误,和对应的解决办法. set方式 setnx方式 setnx+getset方式 set方式 加锁:redis中se ...

  9. 使用RestTemplate访问restful服务时遇到的问题

    可以通过通过wireshark抓包,使用Postman发送请求 wireshark是非常流行的网络封包分析软件,功能十分强大.可以截取各种网络封包,显示网络封包的详细信息.使用wireshark的人必 ...

  10. 解决Error: ENOENT: no such file or directory, scandir 'D:\IdeaWork\code-front-jet\node_modules\.npminstall\node-sass\3.7.0\node-sass\vendor'

    在使用npm安装node-sass的时候,可能会出现如下的报错: Error: ENOENT: no such file or directory, scandir 'D:\IdeaWork\code ...