使用portsnap更新ports tree

来源:百度文库 编辑:神马文学网 时间:2024/04/20 05:35:20

使用portsnap更新ports tree

基础知识 2009-08-17 13:31:50 阅读262 评论0  字号:大中小 订阅

 声明!本文属于原创文章。欢迎转载,但务必保持原文完整,保留作者名,并注明出处。
作者:星外天空
原文地址:http://vsbsd.blog.163.com

portsnap是专门用于安装与更新ports tree的工具,这个工具用法很简单,通常是使用以下命令:

portsnap  fetch 

portsnap  extract

portsnap  update

portsnap fetch 连接到默认portsnap更新服务器,通过安全验证后把经压缩的ports tree快照文件下载到/var/db/portsnap目录中。这个过程只是下载文件,并没有对ports tree进行更新。

portsnap extract  把下载的快照文件全数解压释放到/usr/ports中,如果/usr/ports文件已经存在,将被全部覆盖掉,并删除多余文件。例如,你在某个port目录中建立一个apple.txt文件,这个文件将被删掉。放在/usr/ports这个目录中的文件或目录却不会删掉,原因可能因为这不会影响ports快照的释放!如果/usr/ports不存在,那么这将可以看作是安装ports tree。安装后,可以直接使用。

portsnap update 将已下载的快照与/usr/ports中的文件进行对比检查,如果发现/var/db/portsnap中的文件比/usr/ports中的文件新,就将新的部分更新到/usr/ports中。

 

通常第一次运行portsnap 的命令是:

portsnap fetch extract 

下载快照文件并释放到/usr/ports目录中。

而在以后只须要运行:
portsnap fetch update

这里的 fetch 会检查上一次下载的快照文件,看看网络服务器上的最新快照是否比本地快照有所更新,如果是一样的,就会提示:
Latest snapshot on server matches what we already have.
No updates needed.
提示本地已经存在最新的快照,并不用下载更新。如果服务器上的快照有所更新,那么只会从服务器上下载须要更新的部分,如补丁之类的。并不会将整个快照下载到本地。所以速度上会比第一次快非常非常多。

至于update参数跟fetch参数差不多,它首先检查上一次下载的快照文件是否比ports tree中的文件新,如果一样,那么就会提示:Ports tree is already up to date. ,那就不须要更新。 如果本地快照比ports tree的文件要新,那么update仅仅只会把本地快照中须要更新的东西复制到ports tree中,而不是全数覆盖。

 

portsnap的配置文件

 它的配置文件是/etc/portsnap,有一个例子文件在/etc/share/examples/etc/portsnap。如果/etc/中不存放此文件,就把例子文件复制过来吧。现在我们来看看这个文件

---------------------------------------------------------------------------------------------------------------------------------

#这是工作目录,将下载的快照文件存放到这里
# WORKDIR=/var/db/portsnap  

#这是释放与更新的目标目录
# PORTSDIR=/usr/ports

#从哪里下载快照文件
SERVERNAME=portsnap.FreeBSD.org

#这是密匙,一般情况下千万不要修改,因为这关系到ports快照的安全KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330


我不知以下这些是什么东西,但这些东西一般不会用到。

# REFUSE arabic chinese french german hebrew hungarian japanese
# REFUSE korean polish portuguese russian ukrainian vietnamese

# List of INDEX files to build and the DESCRIBE file to use for each
INDEX INDEX-5 DESCRIBE.5
INDEX INDEX-6 DESCRIBE.6
INDEX INDEX-7 DESCRIBE.7
 

---------------------------------------------------------------------------------------------------------------------------------

这个配置文件一般情况下,仅仅只要修改SERVERNAME这个参数,把它修改为中国大陆 或 中国台湾的服务器,这样会加快它的下载速度。

 

portsnap的man翻译

-------------------------------------------------------------------------------

PORTSNAP(8)       FreeBSD System Manager's Manual       PORTSNAP(8)

 

NAME(名字)

     portsnap -- fetch and extract compressed snapshots of the ports tree

     portsnap --取得 和 提取经压缩的ports tree快照

 

SYNOPSIS

     portsnap [-I] [-d workdir] [-f conffile] [-k KEY] [-l descfile]

          [-p portsdir] [-s server] command ... [path]

 

摘要

   portsnap [-I] [-d  工作路径] [-f  配置文件] [-k KEY] [-l descfile]

          [-p ports目录路径] [-s server] command ... [路径]

 

 

DESCRIPTION (描述)

     The portsnap tool is used to fetch and update compressed snapshots of the

     FreeBSD ports tree, and extract and update an uncompressed ports tree.

     portsnap工具是用于取得和更新经压缩的ports tree快照,提取和更新一个未压缩的ports tree

 

OPTIONS(选项)

     The following options are supported:

    支持以下选项:

 

     -d workdir   Store working files (e.g. downloaded updates) in workdir.

         (default: /var/db/portsnap, or as given in the configuration

         file.)

                 存放工作文件(比如:下载更新的文件)到workdir目录

        (默认是:/var/db/portsnap,或者在配置文件中给出的)

 

     -f conffile  Read the configuration from conffile.  (default: /etc/portsnap.conf)

             从配置文件读取配置(默认是:/etc/portsnap.conf)

      

     -I      For the update command, update INDEX files, but not the rest of the ports tree.

         这是更新命令,更新INDEX文件,但不更新其它的ports tree

 

     -k KEY     Expect a public key with given SHA256 hash.  (default: read  value from configuration file.)

         要求一个哈希值为SHA256的公共密匙。(默认:在配置文件中读到这个值)

   

 

     -l descfile  Merge the specified local describes file into the INDEX files being built.  The descfile should be generated by running make describe in each of the local port directories.

           将指定的本地配置文件合并到正在创建中的INDEX文件。这个描述文件可以在每个本地port目录使用make describe命令生成

          

      

 

     -p portsdir  When extracting or updating an uncompressed snapshot, oper-

         ate on the directory portsdir.  (default: /usr/ports/, or as

         given in the configuration file.)

           当提取或更新一个未经压缩的快照时,就是对portsdir目录进行操作。(默认:/usr/ports/,或配置文件出给的)

 

     -s server      Fetch files from the specified server or server pool.

         (default: portsnap.FreeBSD.org , or as given in the configu-

         ration file.)

           从指定的server或服务器沲抓取文件。(默认:portsnap.FreeBSD.org,或配置文件给出的)

          

 

     path    For extract command only, operate only on parts of the ports

         tree starting with path.  (e.g. portsnap extract

         sysutils/port would extract sysutils/portsman, sysu-

         tils/portsnap, sysutils/portupgrade, etc.)

       只适用于extract命令,只对ports tree开始时的路径进行操作(例如:portsnap extract sysutils/port 将提取

       sysutils/portsman,sysutils/portsnap,sysutils/portupgrade,etc.)

 

COMMANDS(命令)

     The command can be any one of the following:

   

     fetch   Fetch a compressed snapshot of the ports tree, or update the

         existing snapshot.  This command should only be used inter-

         actively; for non-interactive use, you should use the cron

         command.

       下载一个经压缩的ports tree快照,或更新现有的快照。这个命令仅仅用于交互式。

       对于不是交互式的,你可以使用cron命令

 

     cron    Sleep a random amount of time between 1 and 3600 seconds,

         then operate as if the fetch command was specified.  As the

         name suggests, this command is designed for running from

         cron(8); the random delay serves to minimize the probability

         that a large number of machines will simultaneously attempt

         to fetch updates.

           静止一个从1-3600的随机秒数,然后执行,前提是fetch命令已经指定。

           顾名思义,这个命令是为了从cron(8)运行而设计的;这个随机延时服务尽

           可能减少大量机器同一时间下载更新。

      

 

     extract    Extract a ports tree, replacing existing files and directories. NOTE: This will remove anything occupying the location where files or directories are being extracted; in particular, any changes made locally to the ports tree (for

         example, adding new patches) will be silently obliterated.

           提取一个ports tree,替换掉现有的文件和目录。注意:在文件或目录释放的地方若被占用着,那么将会把所有点着东西都删掉。尤其是,任何改变都会使本地到ports tree(例如,添加新补丁)将会安静地删除。

 

         Only run this command to initialize your portsnap-maintained

         ports tree for the first time, if you wish to start over

         with a clean, completely unmodified tree, or if you wish to

         extract a specific part of the tree (using the path option).

       首先,你只要运行这个命令去初始化你的portsnap-维护ports树。如果你重头开始清理,完全不更改树,或你希望提取树的指定部分(使用path选项吧)

 

     update     Update a ports tree extracted using the extract command.

         You must run this command to apply changes to your ports

         tree after downloading updates via the fetch or cron com-

         mands.  Again, note that in the parts of the ports tree

         which are being updated, any local changes or additions will

         be removed.

       更新一个ports tree提取使用extract命令。在使用fetch或cron命令下载更新之后,你必须运行这个命令以给你的ports tree应用这些修改

 

TIPS(忠告)

     +o    If your clock is set to local time, adding the line

       如果你的时钟是设置为本地时间,请加上这等

 

           0 3 * * * root /usr/sbin/portsnap cron

 

     to /etc/crontab is a good way to make sure you always have an up-to-

     date snapshot of the ports tree available which can quickly be

     extracted into /usr/ports.  If your clock is set to UTC, please pick

     a random time other than 3AM, to avoid overly imposing an uneven load

     on the server(s) hosting the snapshots.

    对于/etc/crontab来讲,是一个让你保持ports tree最新的好方法,且可以快速地提到/usr/ports。如果你的时钟是设置为UTC的,请选择一个除3AM之外的时间,避免过于使快照服务主机负载过重。

 

     +o    Running portsnap update from cron(8) is a bad idea -- if you are ever

     installing or updating a port at the time the cron job runs, you will

     probably end up in a mess when portsnap updates or removes files

     which are being used by the port build.  However, running portsnap -I

     update is probably safe, and can be used together with portversion(1)

     to identify installed software which is out of date.

     如果你经常在运行cron计划同时安装或更新port的话,从cron运行portsnap更新是一个坏主意,当你使用portsnap更新或移除正在用于构建port的文件时,最终可能搞得一团糟。然而,使用portsnap -I也许安全,配合portversion(1)一起用,检查已安装的软件过时软件。

 

     +o    If you wish to use portsnap to keep a large number of machines up to

     date, you may wish to set up a caching HTTP proxy.  Since portsnap

     uses fetch(1) to download updates, setting the HTTP_PROXY environment

     variable will direct it to fetch updates from the given proxy.  This

     is much more efficient than mirroring the files on the portsnap

     server, since the vast majority of files are not needed by any par-

     ticular client.

       如果你希望使用portsnap更新大量机器,你不妨创建一个HTTP代理。portsnap使用fetch(1)下载更新,设置HTTP_PROXY环境变量可以从给定的HTTP代理直接下载更新。

 

PRIVACY NOTICE(隐私声明)

     As an unavoidable part of its operation, a machine running portsnap will

     make its public IP address and the list of files it fetches available to

     the server from which it fetches updates.   Using these it may be possible

     to recognize a machine over an extended period of time, determine when it

     is updated, and identify which portions of the FreeBSD ports tree, if

     any, are being ignored using "REFUSE" directives in portsnap.conf.  In

     addition, the FreeBSD release level is transmitted to the server.

    一个不能避免的操作部分,一台机器运行着portsnap导致它的公有IP地址和文件列表,它给服务器获取可用更新。

    利用这些,它可能使用较长时间确认一部机器,确定它已经更新了,并且确认是FreeBSD ports tree的哪一部分。

 

     Statistical data generated from information collected in this manner may

     be published, but only in aggregate and after anonymizing the individual

     systems.

 

FILES(档案文件)

     /etc/portsnap.conf  Default location of the portsnap configuration file.

               portsnap配置文件的默认存放位置

 

     /var/db/portsnap    Default location where compressed snapshots are stored.

              压缩快照存放默认位置

 

     /usr/ports    Default location where the ports tree is extracted.

              提取出快照的默认位置。

 

SEE ALSO(也要看看)

     fetch(1), sha256(1), fetch(3), portsnap.conf(5)

 

AUTHORS

     Colin Percival

 

FreeBSD             September 15, 2008           FreeBSD

-------------------------------------------------------------------------------

这是我自己翻译的,要知道我并不是英语专业,有些地方翻译得非常不好,这也没办法

我已经尽力了。希望各位看到不对的地方给给予补充与修正。portsnap比起cvsup/csup感觉使用起来爽很多,而且它具体密匙验证功能,对ports tree的安全更有保障。