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. 51 nod 1427 文明 (并查集 + 树的直径)

    1427 文明 题目来源: CodeForces 基准时间限制:1.5 秒 空间限制:131072 KB 分值: 160 难度:6级算法题   安德鲁在玩一个叫“文明”的游戏.大妈正在帮助他. 这个游 ...

  2. hdu 5274 树链剖分

    Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  3. SpringCloud学习之Ribbon

    一.负载均衡与Ribbon 负载均衡,在集群中是很常见的一个“名词”,顾名思义是根据一定的算法将请求分摊至对应的服务节点上,常见的算法有如下几种: 轮询法:所有请求被依次分发到每台应用服务器上,每台服 ...

  4. python中如何将生成等差数列和等比数列

    在python库numpy 中提供了函数linspace和logspace函数用于生产等差数列和等比数列.     1.linspace函数生成等差数列 def linspace(start, sto ...

  5. 开源小工具 - swagger API访问代码生成器(js/typescript)

    现在流行前后端分离,后端通常会使用swagger生成api文档,提供给前端的同事来调用,一般前端是查看这个文档,根据文档说明编写调用代码.其实,swagger已经提供了足够多的描述信息,我们可以基于s ...

  6. 使用Aes对称加密解密Web.Config数据库连接串

    现在很多公司开始为了保证数据库的安全性,通常会对Web.Config的数据库连接字符串进行加密.本文将介绍学习使用Aes加密解密数据库连接字符串.本文采用MySql数据库. AES概念简述 AES 是 ...

  7. koa2+webSocket 聊天室

    做了一个简单的的聊天室,用来看看 koa和 websocket的使用还是挺好的,已经放到gitHub. https://github.com/zhaowanhua/koa2WebSocket

  8. MySQL创建用户与授权(CentOS6.5)

    1.相关SQL语句 #创建用户与授权方法 ##本地访问 create user 'zend'@'localhost' IDENTIFIED BY '123456'; grant ALL privile ...

  9. Linux下SonarQube代码质量平台的安装和使用方法

    Sonar简介: Sonar是一个用于代码质量管理的开源平台,用于管理源代码的质量,可以从七个维度检测代码质量 通过插件形式,可以支持包括java,C#,C/C++,PL/SQL,Cobol,Java ...

  10. Struts中的找不到StringUtils异常

    今天在Struts2框架下使用JSON插件时,程序保存找不到类org/apache/commons/lang/xwork/StringUtils,我纳闷了,commons-lang-2.5.jar和c ...