百度空间 | 百度首页 
               
 
查看文章
 
Using portsnap instead of portupgrade
2008-11-19 15:12

Introducing portsnap

Portsnap is another tool for updating the ports tree. On FreeBSD 6.0 and more recent versions, portsnap is contained in the FreeBSD base system, so you don't need to install it. Portsnap is a system for securely downloading and updating a compressed snapshot of the FreeBSD ports tree, and using this compressed snapshot to extract or update an uncompressed copy of the ports tree.

Historically, most people have used cvsup to keep their ports tree up to date. While cvsup works fine, the protocol uses no encryption. While cvsup is very efficient for updating a tree which has been significantly changed (eg, by a month or more of commits), it transmits a list of all the files in the tree, which makes it quite inefficient if only a few files have changed. Portsnap avoids these problems by operating over HTTP (using FreeBSD's fetch utility and a new experimental pipelined HTTP client), signing the snapshots using OpenSSL, and using more sophisticated delta compression to distribute the snapshots.

Portsnap characteristics

Approximately once an hour, a snapshot of the ports tree is generated, repackaged, and cryptographically signed. The resulting files are then distributed via HTTP. Like cvsup, portsnap uses a pull model of updating. The packaged and signed ports trees are placed on a web server which waits passively for clients to request files. Users must either run portsnap manually to download updates or set up a cron job to download updates automatically on a regular basis. In addition to operating entirely over HTTP, portsnap can use under a tenth of the bandwidth required by cvsup if a copy of the ports tree is being updated every few days.

For technical reasons, portsnap does not update the “live” ports tree in /usr/ports/ directly. Instead, it works via a compressed copy of the ports tree stored in /var/db/portsnap/ by default. This compressed copy is then used to update the live ports tree. For a complete guide, check out Using Portsnap in the FreeBSD Handbook.

Portsnap configuration

Portsnap's operation is controlled by the /etc/portsnap.conf configuration file. For most users, the default configuration file will suffice. There are currently 3 mirrors which can be used with portsnap. If you edit your /etc/portsnap.conf file to include SERVERNAME=us.portsnap.FreeBSD.org, then portsnap will try the two US mirrors before trying the European mirror. Similarly, SERVERNAME=eu.portsnap.FreeBSD.org will cause it to try the European mirror first. Either way, portsnap will only fail if none of the three mirrors are available.

To avoid overloading the portsnap servers, portsnap fetch will not run from a cron job. Instead, a special portsnap cron command exists, which waits for a random duration up to 3600 seconds before fetching updates. It is strongly recommended that portsnap update not be run from a cron job, since it is liable to cause major problems if it happens to run at the same time as a port is being built or installed. However, it is safe to update the ports' INDEX files, and this can be done by passing the -I flag to portsnap. Obviously, if portsnap -I update is run from cron, then it will be necessary to run portsnap update without the -I flag at a later time in order to update the rest of the tree.

Adding the following line to /etc/crontab will cause portsnap to update its compressed snapshot and the INDEX files in /usr/ports/, and will send an email if any installed ports are out of date:

0 3 * * * root portsnap -I cron update && pkg_version -vIL=

Using portsnap

When portsnap is run for the first time, it will need to download a compressed snapshot of the entire ports tree into the directory /var/db/portsnap/. This is approximately a 41 MB download.

# portsnap fetch

Note:
This will pull in the latest snapshot from the SERVERNAME defined in /etc/portsnap.conf, and place the files in /var/db/portsnap

Once a snapshot finishes downloading, run the following:

# portsnap extract

Note:
This will extract the compressed snapshot into /usr/ports. This is necessary even if a ports tree has already been created in that directory (e.g., by using CVSup), since it establishes a baseline from which portsnap can determine which parts of the ports tree need to be updated later.

Warning:
Please note that when extracting a copy of the FreeBSD ports tree, portsnap will remove existing files. If you have any local changes (eg, extra patches which you've added into a port's files/ directory) then you'll have to put those back after updating the ports tree with portsnap.

Once the extraction process completes, the typical processes can be used to build applications (e.g., make or portupdate). The portsnap manual page mentions that the extract command should only be used to initialize a portsnap-managed ports tree, and subsequent updates should use the portsnap update option.

Then after that first time you simply use:

# portsnap update

Note:
This is much faster than portsnap extract because it avoids extracting directories which haven't changed.

http://www.joomlawebserver.com/freebsd/host-installation/34.-using-portsnap-instead-of-portupgrade.html


类别:Freebsd | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu