基礎知識 2009-08-17 13:31:50 閱讀262 評論0 字號:大中小 訂閱
聲明!本文屬于原創(chuàng )文章。歡迎轉載,但務(wù)必保持原文完整,保留作者名,并注明出處。
作者:星外天空
原文地址:http://vsbsd.blog.163.com
portsnap是專(zhuān)門(mén)用于安裝與更新ports tree的工具,這個(gè)工具用法很簡(jiǎn)單,通常是使用以下命令:
portsnap fetch
portsnap extract
portsnap update
portsnap fetch 連接到默認portsnap更新服務(wù)器,通過(guò)安全驗證后把經(jīng)壓縮的ports tree快照文件下載到/var/db/portsnap目錄中。這個(gè)過(guò)程只是下載文件,并沒(méi)有對ports tree進(jìn)行更新。
portsnap extract 把下載的快照文件全數解壓釋放到/usr/ports中,如果/usr/ports文件已經(jīng)存在,將被全部覆蓋掉,并刪除多余文件。例如,你在某個(gè)port目錄中建立一個(gè)apple.txt文件,這個(gè)文件將被刪掉。放在/usr/ports這個(gè)目錄中的文件或目錄卻不會(huì )刪掉,原因可能因為這不會(huì )影響ports快照的釋放!如果/usr/ports不存在,那么這將可以看作是安裝ports tree。安裝后,可以直接使用。
portsnap update 將已下載的快照與/usr/ports中的文件進(jìn)行對比檢查,如果發(fā)現/var/db/portsnap中的文件比/usr/ports中的文件新,就將新的部分更新到/usr/ports中。
通常第一次運行portsnap 的命令是:
portsnap fetch extract
下載快照文件并釋放到/usr/ports目錄中。
而在以后只須要運行:
portsnap fetch update
這里的 fetch 會(huì )檢查上一次下載的快照文件,看看網(wǎng)絡(luò )服務(wù)器上的最新快照是否比本地快照有所更新,如果是一樣的,就會(huì )提示:
Latest snapshot on server matches what we already have.
No updates needed.
提示本地已經(jīng)存在最新的快照,并不用下載更新。如果服務(wù)器上的快照有所更新,那么只會(huì )從服務(wù)器上下載須要更新的部分,如補丁之類(lèi)的。并不會(huì )將整個(gè)快照下載到本地。所以速度上會(huì )比第一次快非常非常多。
至于update參數跟fetch參數差不多,它首先檢查上一次下載的快照文件是否比ports tree中的文件新,如果一樣,那么就會(huì )提示:Ports tree is already up to date. ,那就不須要更新。 如果本地快照比ports tree的文件要新,那么update僅僅只會(huì )把本地快照中須要更新的東西復制到ports tree中,而不是全數覆蓋。
portsnap的配置文件
它的配置文件是/etc/portsnap,有一個(gè)例子文件在/etc/share/examples/etc/portsnap。如果/etc/中不存放此文件,就把例子文件復制過(guò)來(lái)吧?,F在我們來(lái)看看這個(gè)文件
---------------------------------------------------------------------------------------------------------------------------------
#這是工作目錄,將下載的快照文件存放到這里
# WORKDIR=/var/db/portsnap
#這是釋放與更新的目標目錄
# PORTSDIR=/usr/ports
#從哪里下載快照文件
SERVERNAME=portsnap.FreeBSD.org
#這是密匙,一般情況下千萬(wàn)不要修改,因為這關(guān)系到ports快照的安全KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3aede40c98633216c330
我不知以下這些是什么東西,但這些東西一般不會(huì )用到。
# 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
---------------------------------------------------------------------------------------------------------------------------------
這個(gè)配置文件一般情況下,僅僅只要修改SERVERNAME這個(gè)參數,把它修改為中國大陸 或 中國臺灣的服務(wù)器,這樣會(huì )加快它的下載速度。
portsnap的man翻譯
-------------------------------------------------------------------------------
PORTSNAP(8) FreeBSD System Manager's Manual PORTSNAP(8)
NAME(名字)
portsnap -- fetch and extract compressed snapshots of the ports tree
portsnap --取得 和 提取經(jīng)壓縮的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工具是用于取得和更新經(jīng)壓縮的ports tree快照,提取和更新一個(gè)未壓縮的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.)
要求一個(gè)哈希值為SHA256的公共密匙。(默認:在配置文件中讀到這個(gè)值)
-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.
將指定的本地配置文件合并到正在創(chuàng )建中的INDEX文件。這個(gè)描述文件可以在每個(gè)本地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.)
當提取或更新一個(gè)未經(jīng)壓縮的快照時(shí),就是對portsdir目錄進(jìn)行操作。(默認:/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或服務(wù)器沲抓取文件。(默認:portsnap.FreeBSD.org,或配置文件給出的)
path For extract command on
tree starting with path. (e.g. portsnap extract
sysutils/port would extract sysutils/portsman, sysu-
tils/portsnap, sysutils/portupgrade, etc.)
只適用于extract命令,只對ports tree開(kāi)始時(shí)的路徑進(jìn)行操作(例如:portsnap extract sysutils/port 將提取
sysutils/portsman,sysutils/portsnap,sysutils/portupgrade,etc.)
COMMANDS(命令)
The command can be any on
fetch Fetch a compressed snapshot of the ports tree, or update the
existing snapshot. This command should on
actively; for non-interactive use, you should use the cron
command.
下載一個(gè)經(jīng)壓縮的ports tree快照,或更新現有的快照。這個(gè)命令僅僅用于交互式。
對于不是交互式的,你可以使用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.
靜止一個(gè)從1-3600的隨機秒數,然后執行,前提是fetch命令已經(jīng)指定。
顧名思義,這個(gè)命令是為了從cron(8)運行而設計的;這個(gè)隨機延時(shí)服務(wù)盡
可能減少大量機器同一時(shí)間下載更新。
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.
提取一個(gè)ports tree,替換掉現有的文件和目錄。注意:在文件或目錄釋放的地方若被占用著(zhù),那么將會(huì )把所有點(diǎn)著(zhù)東西都刪掉。尤其是,任何改變都會(huì )使本地到ports tree(例如,添加新補?。?huì )安靜地刪除。
On
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).
首先,你只要運行這個(gè)命令去初始化你的portsnap-維護ports樹(shù)。如果你重頭開(kāi)始清理,完全不更改樹(shù),或你希望提取樹(shù)的指定部分(使用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.
更新一個(gè)ports tree提取使用extract命令。在使用fetch或cron命令下載更新之后,你必須運行這個(gè)命令以給你的ports tree應用這些修改
TIPS(忠告)
+o If your clock is set to local time, adding the line
如果你的時(shí)鐘是設置為本地時(shí)間,請加上這等
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來(lái)講,是一個(gè)讓你保持ports tree最新的好方法,且可以快速地提到/usr/ports。如果你的時(shí)鐘是設置為UTC的,請選擇一個(gè)除3AM之外的時(shí)間,避免過(guò)于使快照服務(wù)主機負載過(guò)重。
+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.
如果你經(jīng)常在運行cron計劃同時(shí)安裝或更新port的話(huà),從cron運行portsnap更新是一個(gè)壞主意,當你使用portsnap更新或移除正在用于構建port的文件時(shí),最終可能搞得一團糟。然而,使用portsnap -I也許安全,配合portversion(1)一起用,檢查已安裝的軟件過(guò)時(shí)軟件。
+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更新大量機器,你不妨創(chuàng )建一個(gè)HTTP代理。portsnap使用fetch(1)下載更新,設置HTTP_PROXY環(huán)境變量可以從給定的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.
一個(gè)不能避免的操作部分,一臺機器運行著(zhù)portsnap導致它的公有IP地址和文件列表,它給服務(wù)器獲取可用更新。
利用這些,它可能使用較長(cháng)時(shí)間確認一部機器,確定它已經(jīng)更新了,并且確認是FreeBSD ports tree的哪一部分。
Statistical da
be published, but on
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 <cperciva@FreeBSD.org>
FreeBSD September 15, 2008 FreeBSD
-------------------------------------------------------------------------------
這是我自己翻譯的,要知道我并不是英語(yǔ)專(zhuān)業(yè),有些地方翻譯得非常不好,這也沒(méi)辦法
我已經(jīng)盡力了
。希望各位看到不對的地方給給予補充與修正。portsnap比起cvsup/csup感覺(jué)使用起來(lái)爽很多,而且它具體密匙驗證功能,對ports tree的安全更有保障。
聯(lián)系客服