A.3. 使用 Subversion

A.3.1. 簡介

As of July 2012, FreeBSD uses Subversion as the only version control system for storing all of FreeBSD's source code, documentation, and the Ports Collection.

注意:

Subversion is generally a developer tool. Users may prefer to use freebsd-update (節 23.2, “FreeBSD 更新”) to update the FreeBSD base system, and portsnap (節 4.5, “使用 Port 套件集”) to update the FreeBSD Ports Collection.

This section demonstrates how to install Subversion on a FreeBSD system and use it to create a local copy of a FreeBSD repository. Additional information on the use of Subversion is included.

A.3.2. 根 SSL 憑證

Installing security/ca_root_nss allows Subversion to verify the identity of HTTPS repository servers. The root SSL certificates can be installed from a port:

# cd /usr/ports/security/ca_root_nss
# make install clean

or as a package:

# pkg install ca_root_nss

A.3.3. Svnlite

A lightweight version of Subversion is already installed on FreeBSD as svnlite. The port or package version of Subversion is only needed if the Python or Perl API is needed, or if a later version of Subversion is desired.

The only difference from normal Subversion use is that the command name is svnlite.

A.3.4. 安裝

If svnlite is unavailable or the full version of Subversion is needed, then it must be installed.

Subversion can be installed from the Ports Collection:

# cd /usr/ports/devel/subversion
# make install clean

Subversion can also be installed as a package:

# pkg install subversion

A.3.5. 執行 Subversion

To fetch a clean copy of the sources into a local directory, use svn. The files in this directory are called a local working copy.

警告:

Move or delete an existing destination directory before using checkout for the first time.

Checkout over an existing non-svn directory can cause conflicts between the existing files and those brought in from the repository.

Subversion uses URLs to designate a repository, taking the form of protocol://hostname/path. The first component of the path is the FreeBSD repository to access. There are three different repositories, base for the FreeBSD base system source code, ports for the Ports Collection, and doc for documentation. For example, the URL https://svn.FreeBSD.org/ports/head/ specifies the main branch of the ports repository, using the https protocol.

A checkout from a given repository is performed with a command like this:

# svn checkout https://svn.FreeBSD.org/repository/branch lwcdir

where:

  • repository is one of the Project repositories: base, ports, or doc.

  • branch depends on the repository used. ports and doc are mostly updated in the head branch, while base maintains the latest version of -CURRENT under head and the respective latest versions of the -STABLE branches under stable/9 (9.x) and stable/10 (10.x).

  • lwcdir is the target directory where the contents of the specified branch should be placed. This is usually /usr/ports for ports, /usr/src for base, and /usr/doc for doc.

This example checks out the Ports Collection from the FreeBSD repository using the HTTPS protocol, placing the local working copy in /usr/ports. If /usr/ports is already present but was not created by svn, remember to rename or delete it before the checkout.

# svn checkout https://svn.FreeBSD.org/ports/head /usr/ports

Because the initial checkout must download the full branch of the remote repository, it can take a while. Please be patient.

After the initial checkout, the local working copy can be updated by running:

# svn update lwcdir

To update /usr/ports created in the example above, use:

# svn update /usr/ports

The update is much quicker than a checkout, only transferring files that have changed.

An alternate way of updating the local working copy after checkout is provided by the Makefile in the /usr/ports, /usr/src, and /usr/doc directories. Set SVN_UPDATE and use the update target. For example, to update /usr/src:

# cd /usr/src
# make update SVN_UPDATE=yes

A.3.6. Subversion 鏡像站

The FreeBSD Subversion repository is:

svn.FreeBSD.org

This is a publicly accessible mirror network that uses GeoDNS to select an appropriate back end server. To view the FreeBSD Subversion repositories through a browser, use https://svnweb.FreeBSD.org/.

注意:

The FreeBSD Subversion mirrors previously used self-signed SSL certificates documented in this chapter. As of July 14, 2015, all mirrors now use an official SSL certificate that will be recognized by Subversion if the security/ca_root_nss port is installed. The legacy self-signed certificates and server names are still available but are deprecated and no longer supported.

For those without the security/ca_root_nss port installed, the SHA1 and SHA256 fingerprints are:

HashFingerprint
SHA1E9:37:73:80:B5:32:1B:93:92:94:98:17:59:F0:FA:A2:5F:1E:DE:B9
SHA256D5:27:1C:B6:55:E6:A8:7D:48:D5:0C:F0:DA:9D:51:60:D7:42:6A:F2:05:F1:8A:47:BE:78:A1:3A:72:06:92:60

HTTPS is the preferred protocol, providing protection against another computer pretending to be the FreeBSD mirror (commonly known as a man in the middle attack) or otherwise trying to send bad content to the end user.

If https cannot be used due to firewall or other problems, svn is the next choice, with slightly faster transfers. When neither can be used, use http.

For those still using deprecated server names, the SHA1 and SHA256 fingerprints will be one of:

HashFingerprint
Legacy-SHA11C:BD:85:95:11:9F:EB:75:A5:4B:C8:A3:FE:08:E4:02:73:06:1E:61
Legacy-SHA1F6:44:AA:B9:03:89:0E:3E:8C:4D:4D:14:F0:27:E6:C7:C1:8B:17:C5
Legacy-SHA25647:35:A9:09:A3:AB:FA:20:33:36:43:C5:1A:D6:E6:FB:EB:C0:C0:83:37:D4:46:9C:A0:AB:89:7F:C2:9C:4C:A3
Legacy-SHA25648:3C:84:DB:7C:27:1B:FA:D5:0B:A0:D7:E0:4C:79:AA:A3:8E:A3:FA:84:E6:32:34:7D:EB:30:E6:11:01:CF:BE

Seeing one of these legacy certificate fingerprints means it is likely that a deprecated server name is being used.

A.3.7. 取得更多資訊

For other information about using Subversion, please see the Subversion Book, titled Version Control with Subversion, or the Subversion Documentation.

本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/

若有 FreeBSD 方面疑問,請先閱讀 FreeBSD 相關文件,如不能解決的話,再洽詢 <questions@FreeBSD.org>。

關於本文件的問題,請洽詢 <doc@FreeBSD.org>。