http://www.zzlan.cn/blog/?action=show&id=6
port:原意,港口
   转意,输出

计算机科学中的本意:
1)端口 (计算机系统中用于输入输出的某个端点的抽象概念)
2)移植(多指跨平台之间的代码转换和适应性修改)
<不幸的是这个词我国的大多数计算机教科书和文档都翻译错了,很多就直译为
端口>

    在BSD系统中,特指FreeBSD/NetBSD/OpenBSD的一类特殊的软件维护系
统和方式,就是Ports软件集合;在系统中的存在方式为/usr/ports目录,里面有若干分类目录,每个目录包含若干软件的维护结构,由make命令来负责
下载/更新/安装 本地系统中的ports软件(在联网状态下),所以系统中ports就是一组软件的配置文件和Makefile,更广义的,是包含这些软件的当前 ports源代码。(ports是世界上最伟大的软件工程之一,整个源码树系统由全世界成千上万的自由软件开发者维护)

    相对这个得一个概念,是packages Collection,packages就是每个ports对应的本地化二进制版本,可以直接用pkg_add命令安装,或者其他的pkg系列命令进行管理。

    ports也可以直接编译成packages,只要进入某个ports的目录,执行make package就可以制作当前软件ports版本对应的packages.

相关命令:
ports:
==============================================
下载/编译: make
安装 : make install
打包 : make package
升级 :详见cvsup
查询 : cd /usr/ports && make search key="关键字"

packages:
==============================================
安装: pkg_add
删除: pkg_delete
查询: pkg_info
.................
安装应用软件:The Ports collection
本文件操作于:FreeBSD 4.4-RELEASE
--------------------------------------------------------------------------------

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 ftp://freebsd.csie.nctu.edu.tw/pub/CVSup/cvsupfile-ports
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 -acCv

备注:执行 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不同,害我装了之后找好久才找到。



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

版本冲突时
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


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

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 install
make install clean
make install clean distclean

Tags: freebsd, ports