File:  [NetBSD Developer Wiki] / wikisrc / guide / fetch.mdwn
Revision 1.3: download - view: text, annotated - select for diffs
Tue Mar 5 23:33:53 2013 UTC (5 years, 7 months ago) by jdf
Branches: MAIN
CVS tags: HEAD
Cosmetics (mainly removing trailing whitespaces).

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

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb