安裝應用軟體:The Ports collection Ports安裝設定: 用Ports的方式安裝基本的應用軟體。而FreeBSD原則上會到各應用軟體的總站臺下載原始程式後才編譯、安裝,如此速度上會顯得很慢。因此,我們必須設定FreeBSD只需到交大資工系(或者是臺灣地區其他的mirror站)來抓取原始程式碼即可。

cp /etc/defaults/make.conf /etc/
vi /etc/make.conf

將: # Port master sites.
#
# If you want your port fetches to go somewhere else than the default
# (specified below) in case the distfile/patchfile was not found,
# uncomment this and change it to a location nearest you. (Don't
# remove the "/${DIST_SUBDIR}/" part.)
#
#MASTER_SITE_BACKUP?= \
# ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
#
# If you want your port fetches to check the above site first (before
# the MASTER_SITES specified in the port Makefiles), uncomment the
# line below. You can also change the right side to point to wherever
# you want.
#
#MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
#

改為: # Port master sites.
#
# If you want your port fetches to go somewhere else than the default
# (specified below) in case the distfile/patchfile was not found,
# uncomment this and change it to a location nearest you. (Don't
# remove the "/${DIST_SUBDIR}/" part.)
#

MASTER_SITE_BACKUP?= \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp10.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp3.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp11.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp12.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/

#
# If you want your port fetches to check the above site first (before
# the MASTER_SITES specified in the port Makefiles), uncomment the
# line below. You can also change the right side to point to wherever
# you want.
#
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
#

上述站台的排列原則是,哪一台的網路連線與您的網路環境最佳者,排在第一個。

抓檔案時,如果第一台抓不到,會依序向第二台詢問有沒有。如果都問完了,還是沒有,就會到國外的原始站台去抓。不過,這種情形應該很少見到。


開始用Ports安裝應用軟體: cd /usr/ports/net/cvsup-without-gui; make install clean
cd /usr/ports/sysutils/portupgrade ; make install clean
cd /usr/ports/ftp/wget ; make install clean
cd /usr/ports/security/sudo ; make install clean
cd /usr/ports/shells/bash2 ; make install clean
cd /usr/ports/ftp/ncftp3 ; make install clean
cd /usr/ports/mail/imap-uw ; make install clean
cd /usr/ports/mail/qpopper ; make install clean
cd /usr/ports/security/pidentd ; make install clean
cd /usr/ports/misc/gnuls ; make install clean 其中,cvsup-without-gui 與 portupgrade 是屬於系統更新( src 及 ports-tree )的工具軟體,建議您一定要裝。


查看安裝之後的結果: pkg_info
autoconf-2.13_1 Automatically configure source code on many Un*x platforms
bash-2.05 The GNU Bourne Again Shell
gettext-0.10.35 GNU gettext package
gettext-0.10.38 GNU gettext package
gmake-3.79.1 GNU version of 'make' utility
isc-dhcp3-3.0.r11 ISC Dynamic Host Configuration Protocol client and server code
libiconv-1.7_1 A character set conversion library
libtool-1.3.4_2 Generic shared library support script
m4-1.4 GNU's m4
ncftp3-3.0.3 ftp replacement with advanced user interface
pidentd-2.8.5 An RFC1413 identification server
qpopper-4.0.3_1 Berkeley POP 3 server (now maintained by Qualcomm)
wget-1.7_3 Retrieve files from the 'net via HTTP and FTP


大海撈針:搜尋某一ports cd /usr/ports
make search key="popper" | more cd /usr/ports
make search key="libiconv" | grep Path: | grep libiconv Port: qpopper-2.53_2
Path: /usr/ports/mail/popper
Info: Berkeley POP 3 server (now maintained by Qualcomm)
Maint: ache@freebsd.org
Index: mail
B-deps:
R-deps:

Port: qpopper-4.0.3_1
Path: /usr/ports/mail/qpopper
Info: Berkeley POP 3 server (now maintained by Qualcomm)
Maint: lioux@FreeBSD.org
Index: mail ipv6
B-deps: autoconf-2.13_1 m4-1.4
R-deps: Port:軟體名稱,Path:路徑,Info:訊息,Maint:維護者,Index:類型。

cd /usr/ports
make search key="libiconv" | grep Path: | grep libiconv


ports-tree的更新 cd /usr/ports

fetch
cvsup -g -L 2 cvsupfile-ports 我以HiNet-ADSL在FreeBSD 4.2-RELEASE上至NCTU更新ports,共花費了01:07:00。

而在苗栗縣網中,以FreeBSD 4.6-RELEASE至NCTU更新ports,只花費了00:05:00。

這個更新的內容預設值是全部的ports,所需耗費的時間相對就很長。您可以只選擇其中的一部份來更新即可,只要改cvsupfile-ports檔案最底下的那一行(ports-all)。 ports-base: /usr/ports/... misc files at the top of /usr/ports
ports-archivers: /usr/ports/archivers archiving tools
ports-audio: /usr/ports/audio sound support
ports-benchmarks: /usr/ports/benchmarks benchmarks
ports-cad: /usr/ports/cad CAD tools
ports-comms: /usr/ports/comms communication software
ports-databases: /usr/ports/databases databases
ports-devel: /usr/ports/devel development utilities
ports-editors: /usr/ports/editors editors
ports-emulators: /usr/ports/emulators emulators for other OSes
ports-games: /usr/ports/games games
ports-graphics: /usr/ports/graphics various graphics utilities
ports-japanese: /usr/ports/japanese Japanese software.
ports-lang: /usr/ports/lang programming languages
ports-mail: /usr/ports/mail mail software
ports-math: /usr/ports/math numerical computation software
ports-misc: /usr/ports/misc miscellaneous utilities
ports-net: /usr/ports/net networking software
ports-news: /usr/ports/news USENET news software
ports-plan9: /usr/ports/plan9 various programs from Plan9
ports-print: /usr/ports/print printing software
ports-russian: /usr/ports/russian Russian software
ports-security: /usr/ports/security ``security'' utilities, for better or for worse
ports-shells: /usr/ports/shells various UN*X shells
ports-sysutils: /usr/ports/sysutils system utilities
ports-www: /usr/ports/www software related to the world wide web
ports-x11: /usr/ports/x11 X11 software


用 ports 安裝的軟體,遇有該軟體版本更新時如何處置? 請先做「ports-tree的更新」的動作,之後再分別執行下列三道指令:

portsdb -Uu

pkgdb -F

portupgrade -aWy

備註:執行 portsdb -Uu 時,會有令人覺得當機的味道。別耽心,耐心的稍等一下下就好。


portupgrade時,改變預設的編譯安裝選項 編輯 /usr/local/etc/pkgtools.conf

MAKE_ARGS = {
     'databases/mysql323-*' => 'WITH_CHARSET=big5',
     'databases/mysql323-*' => 'SKIP_INSTALL_DB=yes',
     'databases/phpmyadmin' => 'MYADMDIR?=www/data/phpMyAdmin',
     'www/apache13' => 'WITH_APACHE_SUEXEC=yes',
}

mysql 安裝時,預設不支援中文;而phpMyAdmin預設的安裝路徑則在www/data.default/phpMyAdmin,與apache不同,害我裝了之後找好久才找到。

這只是舉例,更詳細的安裝選項,請查看每個 PORTS 中的 Makefile 檔案。


版本衝突時 pkgdb -F

Duplicated origin: sysutils/portupgrade - portupgrade-20020706 portupgrade-20020805
Unregister any of them? [no] yes

Unregister portupgrade-20020706 keeping the installed files intact? [no] no


portupgrade 強制更新 (操作於 FreeBSD 4.6.2-RELEASE )

  • 未更新 PORTS-TREE 前,portupgrade 已安裝的版本:

    pkg_info | grep portupgrade
    portupgrade-20020429 Very powerful FreeBSD ports/packages upgrading tool and mor

  • 更新 PORTS-TREE 之後,PORTS 中 portupgrade 的版本:

    grep \PORTVERSION= /usr/ports/sysutils/portupgrade/Makefile

    PORTVERSION= 20020805

  • 執行 portupgrade 後,portupgrade 自己並未更新。
  • 強制以新的portupgrade取代舊的portupgrade-20020429

    portupgrade     -o    /usr/ports/sysutils/portupgrade     portupgrade-20020429

  • 再檢查一遍portupgrade 安裝的版本:

    pkg_info | grep portupgrade

    portupgrade-20020805 Very powerful FreeBSD ports/packages upgrading tool and mor


升級 perl 之後及 openwebmail 安裝使用的相關問題 有太多的程式和 perl 相關,剛開始的時候它們「都認識」系統中預設的 perl
有天,我使用 PORTS 中的 /usr/ports/lang/perl5.8 來升級 perl
升級完,也依照指示
use.perl port

之後卻發現,新版的 perl 好像「誰都不認識」
因此,如果原本的系統跑得好好的,卻突然啥事都不對勁,大概就是和 perl 的升級有關。

其實,只要使用 portupgrade 就可解決此一問題。

portupgrade -f perl-5.8.\* -m "ENABLE_SUIDPERL=yes"

rehash

use.perl port

portupgrade \
-m "-DFORCE_PKG_REGISTER" \
-rf perl-5.8.\* \
-x perl-5.8.\* \
-l /tmp/portupgrade.log

說明:

-f "perl-5.8.*"
強迫更新,就算版本號碼相同,也會將 perl 重新編譯一次。

-m "ENABLE_SUIDPERL=yes"
在 make 時送出 ENABLE_SUIDPERL=yes 的參數,這個參數值在配合 openwebmail 使用時特別需要,否則 openwebmail 會 error
ps. 此部份的參數與值,建議寫入 pkgtools.conf 中。若是,則可省略此參數。

-r "perl-5.8.*"
把相依於 perl-5.8 的軟體一起更新
到底有多少軟體相依於 perl 呢?天知道,我一點概念也沒有,就讓 portupgrade 幫我做吧!


FreshPorts http://freshports.org/

每一個ports都有專人負責,其更新也是非常迅速,這兒有第一手資料。


網路上的相關文件: http://freebsd.sinica.edu.tw/~statue/handbook/ports.html
http://freebsd.sinica.edu.tw/pipermail/freebsd-taiwan-doc/2001-April/000013.html
http://www.lsps.tp.edu.tw/~gsyan/freebsd2001/ports.html
http://ohaha.ks.edu.tw/ports.htm
http://ohaha.ks.edu.tw/portupgrade.htm
http://ohaha.ks.edu.tw/portexec.htm
http://www.study-area.net/freebsd/how_to_use_ports_package/how_to_use_ports.htm
http://freebsd.csie.nctu.edu.tw/handbook.big5/handbook197.html

其他:
  • make install : 安裝所選定的 Port
  • make deinstall : 移除已安裝的 Port
  • make reinstall : 移除之後再安裝一次
  • make clean : 安裝完畢後移除 make 資料夾下的檔案
  • make distclean : 移除安裝後的原始檔案,以節省磁碟空間
  • make all-depends-list
  • make install
  • make install clean
  • make install clean distclean

原文地址 http://freebsd.lab.mlc.edu.tw/ports.htm