1: **Contents**
2:
3: [[!toc levels=3]]
4:
5: # Obtaining the sources
6:
7: To read the NetBSD sources from your local disk or to build the system or parts
8: of it, you need to download the NetBSD sources. This chapter explains how to get
9: the NetBSD source using a number of different ways, although the preferred one
10: is to get the tarballs and then update via
11: [[!template id=man name="cvs" section="1"]].
12:
13: ## Preparing directories
14:
15: Kernel and userland sources are usually placed in `/usr/src`. This directory is
16: not present by default in the NetBSD installation and you will need to create it
17: first. As it is in a system directory, you will need root access to create the
18: directory and make sure your normal user account can write to it. For
19: demonstration purposes, it is assumed that the non-root login is `carlo`.
20: Please replace it with a valid login name on your system:
21:
22: $ su
23: Password:
24: # mkdir /usr/src
25: # chown <carlo> /usr/src
26:
27: Also, if you want X11R6 sources, you can prepare `/usr/xsrc`:
28:
29: # mkdir /usr/xsrc
30: # chown <carlo> /usr/xsrc
31:
32: *Note*: Please note that for the subsequent steps, root access is neither needed
33: nor recommended, so this preparation step should be done first. All CVS
34: operations can (and should) be done as normal user and you don't need root
35: privileges any more:
36:
37: # exit
38: $
39:
40: ## Terminology
41:
42: **Before starting to fetch or download the required files, you may want to know
43: the definitions of *Formal releases*, *Maintenance branches* and other related
44: terms**. That information is available under the [NetBSD release glossary and
45: graphs](http://www.NetBSD.org/releases/release-map.html).
46:
47: ## Downloading tarballs
48:
49: It is sometimes faster to download a tarball and then continue updating with
50: [[!template id=man name="cvs" section="1"]]. You can
51: download tarballs (see
52: [[!template id=man name="tar" section="1"]]) from
53: ftp.NetBSD.org (or any other mirror) for a number of releases or branches.
54:
55: The only drawback is that the tarballs are updated less often. Normally, every
56: three days.
57:
58: Also, please note that these tarballs include the `CVS` directories, so you can
59: download them and then update your source tree using
60: [[!template id=man name="cvs" section="1"]], as
61: explained in the CVS section.
62:
63: ### Downloading sources for a NetBSD release
64:
65: The tarball files for the sources of a specific release are available under
66: `/pub/NetBSD/NetBSD-<RELEASE-NUMBER>/source/sets/`
67: on ftp.NetBSD.org (or a mirror), where `<RELEASE-NUMBER>` is the release you
68: want to fetch (for example, `4.0`).
69:
70: To fetch the sources of a NetBSD release using tarballs, simply do:
71:
72: $ ftp -i ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-4.0/source/sets/
73: Trying 2001:4f8:4:7:2e0:81ff:fe21:6563...
74: Connected to ftp.NetBSD.org.
75: 220 ftp.NetBSD.org FTP server (NetBSD-ftpd 20070809) ready.
76: 331 Guest login ok, type your name as password.
77: [...]
78: 250 CWD command successful.
79: 250 CWD command successful.
80: 250 CWD command successful.
81: ftp> mget *.tgz
82: local: gnusrc.tgz remote: gnusrc.tgz
83: 229 Entering Extended Passive Mode (|||58302|)
84: 150 Opening BINARY mode data connection for 'gnusrc.tgz' (79233899 bytes).
85: [...]
86: ftp> quit
87: 221-
88: Data traffic for this session was 232797304 bytes in 5 files.
89: Total traffic for this session was 232803039 bytes in 6 transfers.
90: 221 Thank you for using the FTP service on ftp.NetBSD.org.
91:
92: You should now have 5 files:
93:
94: $ ls *.tgz
95: gnusrc.tgz sharesrc.tgz src.tgz syssrc.tgz xsrc.tgz
96:
97: You now must extract them all:
98:
99: $ foreach file (*.tgz)
100: ? tar -xzf $file -C /usr/src
101: ? end
102:
103: ### Downloading sources for a NetBSD stable branch
104:
105: $ ftp -i ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-release-4-0/tar_files/src/
106: Trying 2001:4f8:4:7:2e0:81ff:fe21:6563...
107: Connected to ftp.NetBSD.org.
108: 220 ftp.NetBSD.org FTP server (NetBSD-ftpd 20070809) ready.
109: 331 Guest login ok, type your name as password.
110: [...]
111: 250 CWD command successful.
112: 250 CWD command successful.
113: 250 CWD command successful.
114: 250 CWD command successful.
115: ftp> mget *.tar.gz
116: local: bin.tar.gz remote: bin.tar.gz
117: 229 Entering Extended Passive Mode (|||56011|)
118: 150 Opening BINARY mode data connection for 'bin.tar.gz' (914202 bytes).
119: [...]
120: ftp> quit
121: 221-
122: Data traffic for this session was 149221420 bytes in 22 files.
123: Total traffic for this session was 149231539 bytes in 23 transfers.
124: 221 Thank you for using the FTP service on ftp.NetBSD.org.
125:
126: You should now have 22 files:
127:
128: $ ls *.tar.gz
129: bin.tar.gz doc.tar.gz libexec.tar.gz tools.tar.gz
130: config.tar.gz etc.tar.gz regress.tar.gz top-level.tar.gz
131: contrib.tar.gz games.tar.gz rescue.tar.gz usr.bin.tar.gz
132: crypto.tar.gz gnu.tar.gz sbin.tar.gz usr.sbin.tar.gz
133: dist.tar.gz include.tar.gz share.tar.gz
134: distrib.tar.gz lib.tar.gz sys.tar.gz
135:
136: You now must extract them all:
137:
138: $ foreach file (*.tar.gz)
139: ? tar -xzf $file -C /usr/src
140: ? end
141:
142: ### Downloading sources for a NetBSD-current development branch
143:
144: To download the NetBSD-current tarballs, located under
145: `/pub/NetBSD/NetBSD-current/tar_files/src`, just follow the same steps as in the
146: previous section, but now on a different directory.
147:
148: You may also want to fetch the X11 source, available under:
149: `/pub/NetBSD/NetBSD-current/tar_files/xsrc`.
150:
151: ## Fetching by CVS
152:
153: CVS (Concurrent Versions System) can be used to fetch the NetBSD source tree or
154: to keep the NetBSD source tree up to date with respect to changes made to the
155: NetBSD sources. There are three trees maintained for which you can use
156: [[!template id=man name="cvs" section="1"]] to obtain
157: them or keep them up to date:
158:
159: The list of currently maintained branches is available under
160: [`src/doc/BRANCHES`](http://cvsweb.NetBSD.org/bsdweb.cgi/src/doc/BRANCHES?rev=HEAD&content-type=text/x-cvsweb-markup)
161: (see the *Status* entry on *Release branches* section).
162:
163: Before you can do an initial (full) checkout of the NetBSD sources via
164: *anonymous CVS*, you first have to set some environment variables. For the
165: C-Shell, type:
166:
167: $ setenv CVS_RSH ssh
168: $ setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot
169:
170: Or, the same for the bourne shell:
171:
172: $ export CVS_RSH="ssh"
173: $ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
174:
175: We will also use the `-P` option in the examples below since it is used to prune
176: empty directories.
177:
178: ### Fetching a NetBSD release
179:
180: A release is a set of particular versions of source files, and once released
181: does not change over time.
182:
183: To get the NetBSD (kernel and userland) sources from a specific release, run the
184: following command after the preparations done above:
185:
186: $ cd /usr
187: $ cvs checkout -r <BRANCH> -P src
188:
189: Where `<BRANCH>` is the release branch to be checked out, for example,
190: `netbsd-3-1-RELEASE` or `netbsd-4-0-RELEASE`. If you want to fetch a different
191: patchlevel, you would use `netbsd-3-0-1-RELEASE` or `netbsd-3-0-2-RELEASE`.
192:
193: For example, in order to fetch `netbsd-4-0-RELEASE` you would use:
194:
195: $ cvs checkout -r netbsd-4-0-RELEASE -P src
196:
197: To fetch the X11R6 source, just `checkout` the `xsrc` module. For example:
198:
199: $ cvs checkout -r netbsd-4-0-RELEASE -P xsrc
200:
201: ### Fetching a NetBSD stable branch
202:
203: NetBSD stable branches are also called *Maintenance branches*. Please consult
204: the [[Terminology|guide/fetch#term]].
205:
206: If you want to follow a stable branch, just pass the branch name to the
207: [[!template id=man name="cvs" section="1"]] `-r`
208: option.
209:
210: For example, if you want to fetch the most recent version of `netbsd-4`, you
211: just need to use that tag:
212:
213: $ cd /usr
214: $ cvs checkout -r netbsd-4 -P src
215:
216: And for the `xsrc` module:
217:
218: $ cvs checkout -r netbsd-4 -P xsrc
219:
220: If you have checked out sources from a stable branch in `/usr/src` and want to
221: update them to get the latest security-fixes and bug-fixes, run:
222:
223: $ cd /usr/src
224: $ cvs update -Pd
225:
226: The same applies to the `xsrc` module, but in that case you will have to change
227: your working directory to `/usr/xsrc` first.
228:
229: *Caution!* Be sure to take care in selecting the correct and desired branch tag
230: so you don't accidentally *downgrade* your source tree.
231:
232: ### Fetching the NetBSD-current development branch
233:
234: To obtain the NetBSD-current source just omit `-r` *`<BRANCH>`* and replace it
235: by `-A`:
236:
237: $ cd /usr
238: $ cvs checkout -A -P src
239:
240: The `xsrc` is also available:
241:
242: $ cd /usr
243: $ cvs checkout -A -P xsrc
244:
245: To update your NetBSD-current source tree, add the `-A` flag:
246:
247: $ cd /usr/src
248: $ cvs update -A -Pd
249:
250: ### Saving some cvs options
251:
252: If you find yourself typing some options to cvs over and over again, you can as
253: well put them into a file `.cvsrc` in your home directory. It is useful for just
254: typing `cvs update` on a directory with a branch checked out to update it
255: (adding `-A` would revert the branch to the -current branch, which is not what
256: one usually wants!), For unified diffs, transfers should be compressed and `cvs
257: update` should be mostly quiet:
258:
259: **Example `.cvsrc`**:
260:
261: #update -dPA
262: update -dP
263: rdiff -u
264: diff -u
265: cvs -q
266:
267: ## Sources on CD (ISO)
268:
269: If you prefer to download (and maybe burn) a CD-ROM image with the NetBSD
270: source, just fetch `sourcecd-<RELEASE-NUMBER>.iso` from ftp.NetBSD.org or any
271: other mirror.
272:
273: The `sourcecd-<RELEASE-NUMBER>.iso` file is located under
274: `/pub/NetBSD/iso/<RELEASE>`, where `<RELEASE>` is a release of NetBSD,
275: for example, `5.1`:
276:
277: ftp://ftp.NetBSD.org/pub/NetBSD/iso/5.1/sourcecd-5.1.iso
278:
279: The next step is to burn the ISO image or mount it with the help of
280: [[!template id=man name="vnconfig" section="8"]].
281: Please see [[Using removable media|guide/rmmedia]], as it explains in detail how
282: to do it.
283:
284: Assuming you have mounted the CD under `/mnt`, `/mnt/source/sets` should have
285: everything you need to extract:
286:
287: $ ls /mnt/source/sets
288: BSDSUM MD5 gnusrc.tgz src.tgz xsrc.tgz
289: CKSUM SYSVSUM sharesrc.tgz syssrc.tgz
290:
291: All tarballs should be extracted to the root file system (`/`). The following
292: command will do it:
293:
294: $ foreach file (*.tgz)
295: ? tar -xzf $file -C /
296: ? end
297:
298: After that, you should have `/usr/src` and `/usr/xsrc` populated with the NetBSD
299: sources.
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb