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. poj 3070 Fibonacci 矩阵快速幂

    Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. F ...

  2. hdu 2254(矩阵)

    题意:指定v1,v2,要求计算出在t1,t2天内从v1->v2的走法 思路:可以知道由矩阵求,即将其建图A,求矩阵A^t1 + ...... + A^t2.   A^n后,/*A.xmap[v1 ...

  3. 勤拂拭软件系列教程 - java web开发

    勤拂拭软件工作室持续推出Java Web开发系列教程与案例,供广大朋友分享交流技术经验,帮助喜欢java的朋友们学习进步: 1. 勤拂拭软件 java web 开发教程(1) - 开发环境搭建 勤拂拭 ...

  4. LAN、WAN、WLAN、WiFi之间的区别

    感觉这几个概念让人傻傻分不清,下面以最常见的路由器来解释这几个概念. LAN   1 LAN,全称Local Area Network,中文名叫做局域网. 顾名思义,LAN是指在某一区域内由多台计算机 ...

  5. C++多态实现原理

    C++的多态性用一句话概括就是:在基类的函数前加上virtual关键字,在派生类中重写该函数,运行时将会根据对象的实际类型来调用相应的函数.如果对象类型是派生类,就调用派生类的函数:如果对象类型是基类 ...

  6. POJ-2299 Ultra-QuickSort---树状数组求逆序对+离散化

    题目链接: https://vjudge.net/problem/POJ-2299 题目大意: 本题要求对于给定的无序数组,求出经过最少多少次相邻元素的交换之后,可以使数组从小到大有序. 两个数(a, ...

  7. 好久没用IJ写Java 之 《求输入的一个数中包含奇数、偶数、零的个数》

    /** *Created by xuzili at 22:12 on 2018/4/4 */ // 以上注释使用了IntelliJ Idea的File-Settings-Editor-Live Tem ...

  8. 使用PHP脚本远程部署git项目

    准备工作: 1.coding.net创建私有项目 2.安装了Web服务 Git服务的服务器 服务器端: 1.nginx.php-fpm统一用www用户 www 目录,这个可以通过修改配置文件实现. [ ...

  9. redux 最简例子

    方便初学redux的同学学习,这里是最简单的redux例子 1 import React, {Component, PropTypes} from 'react' 2 import ReactDOM ...

  10. 关于一些基础的Java问题的解答(二)

    6. Hashcode的作用 官方对于hashCode的解释如下: Whenever it is invoked on the same object more than once during an ...