Ubuntu不仅是一个免费且开源的操作系统,而且其平台也是开放且透明的。每个组件的源码都可以获取到,也可以从源码自己编译软件包。下面就探讨一下在ubuntu下如何获取chromium源码,并编译Chromium Web Browser。
要从ubuntu的仓库下载源码并编译软件包,最方便的就是使用apt-build实用工具。在ubuntu的发布版本中,该实用工具并没有安装,您可以用如下命令安装:
1
| sudo apt-get install apt-build
|
接下来就可以使用如下命令下载并build chromium browser了:
1
| sudo apt-build install chromium-browser
|
因为我的ubuntu是64位系统(ubuntu 11.04 LTS 64bit),所以出现了如下错误:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
| E: There are problems and -y was used without --force-yes
E: Failed to process build dependencies
-----> Updating package lists <-----
Ign file: apt-build Release.gpg
Get:1 file: apt-build Release [107 B]
Ign file: apt-build/main TranslationIndex
Err file: apt-build/main i386 Packages
File not found
Ign file: apt-build/main Translation-en_US
Ign file: apt-build/main Translation-en
Get:2 https://mirrors.163.com precise-updates Release.gpg [198 B]
Get:3 https://mirrors.163.com precise Release.gpg [198 B]
Hit https://mirrors.163.com precise-updates Release
Hit https://mirrors.163.com precise Release
Hit https://mirrors.163.com precise-updates/restricted Sources
Get:4 https://dl.google.com stable Release.gpg [198 B]
Get:5 https://archive.ubuntu.com precise Release.gpg [198 B]
Hit https://mirrors.163.com precise-updates/main Sources
Hit https://mirrors.163.com precise-updates/universe Sources
Hit https://mirrors.163.com precise-updates/main amd64 Packages
Hit https://mirrors.163.com precise-updates/restricted amd64 Packages
Hit https://mirrors.163.com precise-updates/universe amd64 Packages
Get:6 https://ppa.launchpad.net precise Release.gpg [316 B]
Get:7 https://extras.ubuntu.com precise Release.gpg [72 B]
Hit https://mirrors.163.com precise-updates/main i386 Packages
Hit https://mirrors.163.com precise-updates/restricted i386 Packages
Hit https://mirrors.163.com precise-updates/universe i386 Packages
Hit https://mirrors.163.com precise-updates/main TranslationIndex
Hit https://mirrors.163.com precise-updates/restricted TranslationIndex
Hit https://mirrors.163.com precise-updates/universe TranslationIndex
Hit https://mirrors.163.com precise/universe amd64 Packages
Hit https://mirrors.163.com precise/universe i386 Packages
Hit https://dl.google.com stable Release
Hit https://mirrors.163.com precise/universe TranslationIndex
Hit https://mirrors.163.com precise-updates/main Translation-en
Hit https://mirrors.163.com precise-updates/restricted Translation-en
Hit https://mirrors.163.com precise-updates/universe Translation-en
Hit https://mirrors.163.com precise/universe Translation-en
Hit https://dl.google.com stable/main amd64 Packages
Hit https://archive.ubuntu.com precise Release
Hit https://dl.google.com stable/main i386 Packages
Hit https://ppa.launchpad.net precise Release
Ign https://dl.google.com stable/main TranslationIndex
Hit https://extras.ubuntu.com precise Release
Get:8 https://security.ubuntu.com precise-security Release.gpg [198 B]
Hit https://archive.ubuntu.com precise/main Sources
Get:9 https://cn.archive.ubuntu.com precise Release.gpg [198 B]
Hit https://ppa.launchpad.net precise/main Sources
Hit https://extras.ubuntu.com precise/main Sources
Hit https://security.ubuntu.com precise-security Release
Hit https://archive.ubuntu.com precise/restricted Sources
Hit https://ppa.launchpad.net precise/main amd64 Packages
Hit https://ppa.launchpad.net precise/main i386 Packages
Ign https://ppa.launchpad.net precise/main TranslationIndex
Hit https://extras.ubuntu.com precise/main amd64 Packages
Hit https://extras.ubuntu.com precise/main i386 Packages
Ign https://extras.ubuntu.com precise/main TranslationIndex
Hit https://security.ubuntu.com precise-security/restricted Sources
Hit https://security.ubuntu.com precise-security/main Sources
Hit https://security.ubuntu.com precise-security/universe Sources
Hit https://cn.archive.ubuntu.com precise Release
Hit https://security.ubuntu.com precise-security/main amd64 Packages
Hit https://security.ubuntu.com precise-security/restricted amd64 Packages
Hit https://security.ubuntu.com precise-security/universe amd64 Packages
Hit https://security.ubuntu.com precise-security/main i386 Packages
Hit https://security.ubuntu.com precise-security/restricted i386 Packages
Hit https://security.ubuntu.com precise-security/universe i386 Packages
Hit https://security.ubuntu.com precise-security/main TranslationIndex
Hit https://security.ubuntu.com precise-security/restricted TranslationIndex
Hit https://security.ubuntu.com precise-security/universe TranslationIndex
Ign https://dl.google.com stable/main Translation-en_US
Hit https://security.ubuntu.com precise-security/main Translation-en
Ign https://dl.google.com stable/main Translation-en
Hit https://cn.archive.ubuntu.com precise/main Sources
Hit https://security.ubuntu.com precise-security/restricted Translation-en
Hit https://cn.archive.ubuntu.com precise/restricted Sources
Hit https://cn.archive.ubuntu.com precise/main amd64 Packages
Hit https://security.ubuntu.com precise-security/universe Translation-en
Hit https://cn.archive.ubuntu.com precise/restricted amd64 Packages
Hit https://cn.archive.ubuntu.com precise/main i386 Packages
Hit https://cn.archive.ubuntu.com precise/restricted i386 Packages
Hit https://cn.archive.ubuntu.com precise/main TranslationIndex
Hit https://cn.archive.ubuntu.com precise/restricted TranslationIndex
Ign https://ppa.launchpad.net precise/main Translation-en_US
Hit https://cn.archive.ubuntu.com precise/main Translation-en
Ign https://extras.ubuntu.com precise/main Translation-en_US
Ign https://extras.ubuntu.com precise/main Translation-en
Hit https://cn.archive.ubuntu.com precise/restricted Translation-en
Ign https://ppa.launchpad.net precise/main Translation-en
Fetched 1,576 B in 10s (147 B/s)
W: Failed to fetch file:/var/cache/apt-build/repository/dists/apt-build/main/binary-i386/Packages File not found
|
从网上找到了答案,解决方法就是指定配置文件中的架构:修改/etc/apt/sources.list.d/apt-build.list文件,将其中的
1
| deb file:/var/cache/apt-build/repository apt-build main
|
替换为:
1
| deb [arch=amd64] file:/var/cache/apt-build/repository apt-build main
|
接下来就是下载源码,再经过漫长的build过程,生成并安装Chromium Web Browser。版本信息如下图:
下载的源码位于/var/cache/apt-build/build/下:
从上图中可以看到源码包的大小只有200多M,而我们从chromium开源项目下的源码通常有7、8个G,主要原因是这里下的源码是不带git和svn信息的,是纯粹的源代码。