Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/www/lifetype/class/data/Date.class.php on line 240
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/www/lifetype/class/locale/locale.class.php on line 505
六月
Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/www/lifetype/class/data/Date.class.php on line 240
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /usr/local/www/lifetype/class/locale/locale.class.php on line 505
22
Ports And Packages
Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/www/lifetype/class/cache/Cache_Lite/Lite.php on line 717
Deprecated: Function set_magic_quotes_runtime() is deprecated in /usr/local/www/lifetype/class/cache/Cache_Lite/Lite.php on line 727
FreeBSD 引用 (0)
來源:Tzeng, Yi-Feng (http://std1.mis.yzu.edu.tw/~s882617/FNP2/faq/ports_pkg.php)
如何只抓取 tarball?
如果只希望抓取 tarball 下來的話,僅需下 make fetch 即可。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make fetch
預設會將 joe 的 tarball 下載至 /usr/ports/distfiles/ 目錄下。
如何僅做到解開 tarball的步驟?
有時候習慣自己 patch/修正 原始碼的時候,很常用到這個功能。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make extract
會將 tarball解開至 /usr/ports/editors/joe/work/ 目錄下。
如何僅做到解開 tarball 並補上官方提供的 patch?
此方法與 2 有一些類似,不同於是先補上官方提供的 patch ,再行 patch 自己的修正。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make patch
會將 tarball解開至 /usr/ports/editors/joe/work/ 目錄下,並已經 patch 上官方提供的 patch。
如何安裝一個新的 port?
如果系統上未安裝此軟體,則可以選擇安裝一個新的 port。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make install
如此會在系統上安裝一個新的 joe 軟體。如果需要在安裝完成後,一併清除編輯時期所留下來的暫存目錄,則可參考 FAQ 8 的方法,一起使用,如:
cd /usr/ports/editors/joe/
make clean
如何安裝一個新的 port,並將打包(package)起來?
將安裝完成的軟體打包起來,有許多便利性:包括在叢集系統中,可供其它機器使用,或將未來此軟體出問題可重新利用此 package 重新快速安裝。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make package
如此會在系統上安裝一個新的 joe 軟體,並將此軟體打包(package)起來。package 預設會在 /usr/ports/editors/joe/ 目錄下,如果希望集中管理的話,建議做如下的步驟:
mkdir -p /usr/ports/packages/All/
以後打包的 packages 都會存放在此目錄下,並且系統會自動做分類,以方便管理。如果需要在安裝完成後,一併清除編輯 時期所留下來的暫存目錄,則可參考 FAQ 8 的方法,一起使用,如:
cd /usr/ports/editors/joe/
make package clean
如何打包一個 port,並將其所有相依的 ports 也打包起來?
因為 FAQ 5 只有對最終的 port 才進行打包,中間依賴的 ports 並沒有一起打包,這會出現一個常遇到 的問題,就是如果編輯一個 port 需要依賴其它的 ports,那麼必須將其它 ports 也一起打包,否則安裝 packages 會有相 依賴其它 ports 的 packages 的問題。
以 sysutils/portupgrade 為例的話,則:
cd /usr/ports/sysutils/portupgrade/
make DEPENDS_TARGET=package package
如此會在對所有 portupgrade 所相依賴的 ports 一併打包,也包括自己本身。
如何對一個已經安裝的 port 打包?
如果安裝好一個套軟,事前並未打包,事後想打包的話,則:
以 editors/joe 為例的話
cd /var/db/pkg/
pkg_create -b joe-{版本號}
會將已安裝的 port 打包起來,放在 /var/db/pkg/ 目錄下。
如何清理 ports 編輯期間所產生的暫存資料?
在編輯 port 的時候,會有編輯期間所需要的工作目錄(work),因此通常安裝好一個套件後,會清除此暫存目錄,以節省系 統磁碟空間。
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make clean
如何在安裝 ports 前查詢所需依賴/相關的套件?
在安裝 ports 前,可以查詢所需依賴/相關的套件。
以 mail/p5-Mail-SpamAssassin 為例的話,則:
cd /usr/ports/mail/p5-Mail-SpamAssassin/
make all-depends-list #顯示所有相關的套件
make pretty-print-build-depends-list #顯示編譯期間所需要的套件
make pretty-print-run-depends-list #顯示此套件要執行時所需要的套件
如何移除已安裝的 ports?
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make deinstall
或是使用 pkg_delete
cd /var/db/pkg/
pkg_delete joe-{version}
有時候套件之間的相依性會導致無法直接移除,如果要強制移除的話,則:
cd /var/db/pkg/
pkg_delete -f joe-{version}
但很有可能會導致其它的套件執行起來出現問題。
如何一併移除所相依的 ports?
以 sysutils/portupgrade 為例的話,則:
cd /usr/ports/sysutils/portupgrade/
make deinstall-depends
執行此步驟前,請注意是否會移除應該保護的套件。建議先參考 FAQ 9 的方法來檢查。
如何重新安裝已安裝過的 ports?
以 editors/joe 為例的話,則:
cd /usr/ports/editors/joe/
make reinstall
如何以關鍵字搜尋 ports?
如果要從全部的 ports collection 中找尋與關鍵字 "ldap" 有關的 ports,則:
cd /usr/ports/
make search key=ldap
如果只要從與 ftp 相關的 ports 下找尋與關鍵字 "ldap" 有關的 ports,則:
cd /usr/ports/ftp/
make search key=ldap
還有另一個用法,方法只是將 key 換成 name 。如果已經知道要搜尋 ports 的名稱,或只想找名稱相關的關鍵字 "ldap", 則:
cd /usr/ports/
make search name=ldap
如果只要從 ftp 相關的 ports 下找尋名稱與關鍵字 "ldap" 有關的 ports,則:
cd /usr/ports/ftp/
make search name=ldap
如何升級已安裝的 ports?
如果已經安裝好套件,事後欲升級的話,以 editors/joe 為例,則:
cd /usr/ports/editors/joe/
make deinstall
make install clean
或是
cd /usr/ports/editors/joe/
make reinstall
如何查詢目前系統安裝了哪些套件?
查詢目前系統已安裝的全部套件:
pkg_info
pkg_version -v
如何查詢目前系統有沒有安裝這個關鍵字的套件?
此方法類似 FAQ 14 :
pkg_info | grep
如何查詢某個檔案是屬於哪些套件?
如果想查詢 /usr/local/bin/joe 是屬於哪個套件的話,則:
pkg_info -W /usr/local/bin/joe
如果沒有回傳任何資訊的話,代表著這個檔案是由 FreeBSD 內建的。
如何查詢某個套件安裝了哪些檔案?
如果想查詢目前系統所安裝的 joe 包含了哪些檔案,則:
pkg_info -L /var/db/pkg/joe-{version}
如何安裝舊版的 ports?
有時候會因為相依性,或是新版有問題,而會想裝舊版本的套件。
這裡的方法是利用 CVS 的好處,回歸到以前舊版本存在的日子,以安裝舊版本的套件。
首先,若我們要回復到某一個套件的版本時,需要去查詢 FreeBSD ports CVS repository。
最常見的就是 Freshports 網站、 FreeBSD ports news group, 或是 FreeBSD ports cvsweb。
查到該套件版本所依存的日子後,就修改 CVS tag。一般預設 ports 的 CVS tag 會寫在 /usr/share/examples/cvsup/ports-supfile ,如要回朔到 2002/10/05 號的話,則:
# vi /usr/share/examples/cvsup/ports-supfile
******************************************
default date=2002.10.05.00.00.00 #將 date 改成當日
然後按照一般 CVSup 的時候一樣,執行 CVSup (make update),此時的 ports collections 就會回到當時的情形,那麼該套件 舊版本也會出現在 ports collections 中,只要安裝即可。
如果僅是想把某部份的 ports 回朔,則必須加上額外的資訊,如僅希望把 lang/perl5.8 回朔,而得知此屬於 lang 中的一支,則:
# vi /usr/share/examples/cvsup/ports-supfile
******************************************
#ports-all #將 ports-all 標示起來
ports-lang #加入這行
最後,執行 CVSup,並安裝即可。目前若希望單獨回朔單一的 ports,則比較麻煩。
如何更新 ports Mk?
Mk (/usr/ports/Mk/) 是編譯 ports 時所參考的設定,有時若發生 ports collections 太新,而導致 Mk 的內容不符,此時 就是應該更新 Mk 的時候了。
cd /usr/src/
make update
cd /usr/src/share/mk
make install
如何解決安裝 ports 時出現 sed -i 的錯誤?
因為 BSD style 的 sed ,也就是 BSD 本身自有的 sed ,與一些 ports 編譯期間所執行的 sed 不一致,所以會導致一些語 法錯誤。此時先安裝 sed_inplace (textproc/sed_inplace),然後再安裝原本無法安裝的 ports:
cd /usr/ports/???/???/
make -DUSE_REINPLACE install
如何列出所有可以升級的 ports?
ports collection 的更新速度很快,在每次更新 ports collections 後,往往會出現比目前現在安裝的套件還新的版本,可 以令系統自行整理並提供可升級套件的列表:
pkg_version -c
如何得知 ports system 對某個 ports 所提供的編譯參數?
所有的 ports collections 中所提供的編譯參數都會在對應的 Makefile 檔案內詳述,如 sysutils/portupgrade 的話,則 是位在 /usr/ports/sysutils/portupgrade/Makefile 檔案下。
可以對此檔案瀏覽以得知編譯時期可以下達的參數,如對 sysutils/portupgrade 有提供 NOPORTDOCS,則:
cd /usr/ports/sysutils/portupgrade/
make -DNOPORTDOCS install # make NOPORTDOCS=yes install 亦同
那麼安裝此 ports 時,會將 NOPORTDOCS 所對應的相關參數指定進去。
有時候設定較人性化的 ports 會在安裝前提供參數供選擇,但是其實大部份的 ports 都沒有提供,因此必須自行去搜尋可編 譯的參數,在此我提供的方式如下:
cd /usr/ports/sysutils/portupgrade/
grep defined Makefile
如此幾乎可以知道所有提供的可編譯參數,雖然有時會多出一些不相干的資料,不會這個確實是一個不錯可參考的方式。
如何手動加入編譯 ports 的參數?
在 FAQ 23 中的方法,是 ports collections 有提供的前提之下,有時候並不是所有該軟體所支援的參數 都會收納在 ports collections 中,因此有時候會需要手動加入編譯的參數。
如 ftp/pure-ftpd 中,如果不想把 inetd 的支援編入的選項,並沒有被 ports collections 所納入,因此必須手動加上這個 編譯參數,如下:
cd /usr/ports/ftp/pure-ftpd/
make CONFIGURE_ARGS+="--without-inetd" install
如何指定 ports 的安裝路徑?
預設 ports collecions 已安排安裝的路徑 (/usr/local/),如果不想將套件安裝在預設路徑的話,可以手動指定安裝路徑。 以 editors/joe 為例,則:
cd /usr/ports/editors/joe/
make PREFIX=/usr install
那麼 joe 就會將檔案對應在 /usr 目錄下,而不是預設的 /usr/local 目錄下。
安裝 ports 出現 FORCE_PKG_REGISTER 的錯誤訊息
請參考 Ohaha 的 FAQ。
安裝 ports 出現 Shared object libintl.so.X not found 的錯誤訊息
請參考 Ohaha 的 FAQ。
如何安裝 packages?
目前 FreeBSD 的 packages 是由 .tgz 所打包。如果想安裝一個 packages ,可使用 pkg_add,如安裝一個 joe 的 tgz:
pkg_add joe-{version}.tgz
如何遠端安裝 packages?
有兩種設定方式,首先是 PACKAGEROOT,如:
setenv PACKAGEROOT ftp://ftp.tw.freebsd.org #設定 PACKAGEROOT 為 ftp.tw.freebsd.org 站台
另一種方式是設定 PACKAGESITE,好處是若該站台的 packages 倉儲並不是符合官方的設定或你想自己指定一個路徑。
以 ftp.tw.freebsd.org i386 的 current pakcages 為例:
setenv PACKAGESITE ftp://ftp.tw.freebsd.org/pub/FreeBSD/ports/i386/packages-current/Latest/
兩種方式選擇其中一種皆可,接下來的步驟都一樣。
往後要安裝 packages 的時候,如 portupgrade 的話,則:
pkg_add -vr portupgrade
則系統會自動於 ftp.tw.freebsd.org 抓取所有與 portupgrade 相依的 packages 並安裝。
如何更新 INDEX 對照表?
4.x 的 INDEX 位於 /usr/ports/INDEX,5.x 位於 /usr/ports/INDEX-5。
INDEX 是對照 ports 所有相依等資訊的對照表,若長期未更新的話,會導致 ports 對照失敗。官方有定期更新 INDEX,如果 想自行更新的話,則:
cd /usr/ports/
make index
如何針對某些 ports 不做 CVSup?
若 ports 底下的某些分類完全用不到,則可以在 CVSup 時,不做更新,以節省網路頻寬與時間。
# vi /usr/sup/refuse
******************************************
ports/french
ports/german
ports/hebrew
ports/hungarian
ports/japanese
那麼則上述目錄下的檔案皆不會更新。
如果是想要某些單一的 ports 不做同步,例如想保留舊版不做同步,或新版出現問題時。
# vi /usr/sup/refuse
******************************************
ports/lang/perl5.8
那麼 ports/lang/perl5.8 這個 ports 不會做 CVSup 同步。
這些設定方法支援萬用字元。
# vi /usr/sup/refuse
******************************************
ports/lang/perl*
ports/po*
如何使用 CVSup 同步 ports collections?
請參考 gslin 的 用 CVSup 去更新你的 source tree 以及 ports tree。
安裝 ports 出現 port is outdated 的錯誤訊息
例如安裝 imap-uw 時,出現以下內容:
Your installation of the cclient port is outdated. Please delete it before continuing.
表示因為相對應,且已安裝好的 cclient 這個軟體過於老舊,建議先升級這個軟體再行安裝 imap-uw。因此只要先升級 cclient 後,再安裝即可。
# cd /usr/ports/mail/cclient/
# make reinstall 或 # make deinstall && make install
# cd /usr/ports/mail/imap-uw/
# make install
在FreeBSD6.2下更新了ports後,按照php5-gd,總是在編譯以前編譯xorg-libraries-7.2出錯,
其實編譯php5-gd不是必須要編譯xorg-libraries-7.2的。只需要打入下面的命令,就可以跳過xorg直接編譯。方便快捷,實用為上。哈哈。
#make WITHOUT_X11="YES" install
安裝 ports 出現 OpenSSL vulnerabilities 的錯誤訊息
在安裝有些套件時,如果有相依於 OpenSSL 時,且判斷系統目前的 OpenSSL 版本有漏洞問題時,會出現如下的訊息:
Dependency warning: used OpenSSL version contains known vulnerabilities
Please update or define either WITH_OPENSSL_BASE or WITH_OPENSSL_PORT
一般建議的解決方法有二種。
第一種:升級系統,再安裝該套件
升級系統可參考 FNP: upgrade core system 或 FNP: upgrade major system。
然後再安裝該套件,這訊息就不會出現了。
第二種:使該套件相依於 ports tree 中的 OpenSSL
這種方法會安裝 ports tree 中新版本的 OpenSSL,然後相依於此新版本的 OpenSSL,而不是系統本身內建的 OpenSSL。只要安裝套件時,加入 WITH_OPENSSL_PORT 的參數,即會安裝 ports tree 中的 OpenSSL,並且該套件也會相依於此。方法如下:
make -DWITH_OPENSSL_PORT install
這裡不建議用參數 WITH_OPENSSL_BASE,因為這表示安裝套件時,是相依於原本系統中可能有漏洞的 OpenSSL,這樣會導致安全性的問題。
http://www.tses.tcc.edu.tw/pc_class_room/ports_pkg.php (utf-8)