获得软件包信息
获得软件包信息的命令主要是pkginfo。pkgchk -v则可以用来获得软件包中的文件列表。如果要查看未安的装软件包的信息,需要用-d选项指定软件包所在的位置。查看系统上安装的软件包则不需要使用-d选项。
pkginfo命令不带任何参数显示当前系统安装的所有软件包的概要信息,包括分类、名称、描述。
-bash-3.00# pkginfo |more
system CADP160 Adaptec Ultra160 SCSI Host Adapter Driver
system HPFC Agilent Fibre Channel HBA Driver
ALE SUNW5xmft Traditional Chinese (BIG5) X Windows Platform minimum required Fonts Package
system SUNWGlib GLIB - Library of useful routines for C programming
system SUNWGtkr GTK - The GIMP Toolkit (Root)
system SUNWGtku GTK - The GIMP Toolkit (Usr)
GNOME2 SUNWPython The Python interpreter, libraries and utilities
system SUNWTk Tk - TCL GUI Toolkit
system SUNWa2psr a2ps - GNU Any to PostScript filter (root)
system SUNWa2psu a2ps - GNU Any to PostScript filter (user)
system SUNWaac Adaptec AdvanceRaid Controller SCSI HBA Driver
system SUNWad810 SUNW W1100z & W2100z Audio Drivers
system SUNWadmap System administration applications
system SUNWadmc System administration core libraries
system SUNWadmfr System & Network Administration Framework Configuration
system SUNWadmfw System & Network Administration Framework
system SUNWadmj Admin/Install Java Extension Libraries
system SUNWadmlib-sysid System and Network identification libraries
system SUNWadmr System & Network Administration Root
system SUNWadp Adaptec 29xx/39/xx/78xx Family of SCSI HBA
system SUNWadpu320 Adaptec Ultra320 Driver
......
pkginfo -l则列出软件包的详细信息:
-bash-3.00# pkginfo -d . -l SMCapch22
PKGINST: SMCapch22
NAME: apache
CATEGORY: application
ARCH: sparc
VERSION: 2.2.0
BASEDIR: /usr/local/apache2
VENDOR: The Apache Group
PSTAMP: Steve Christensen
EMAIL: steve@smc.vnet.net
STATUS: spooled
FILES: 2198 spooled pathnames
66 directories
72 executables
2 package information files
44173 blocks used (approx)
pkgchk命令用来检查软件包是否安装、软件包中的文件是否有所改动等信息。如果软件包成功安装并且没有任何文件改动过,该命令无任何输出,否则在标准错误上输出相关的信息。pkgchk不带任何参数则检查当前系统安装的所有软件包,并列出检查结果的概要信息,如果要详细信息可以用-l选项。如果要限定某个具体软件包,最后一个参数写上该软件包名称即可。如果只要检查某个软件包的某个文件可以用-p选项加上该文件的完全路径即可,如果不知道完全路径可以使用-P选项加文件的部分路径。例如:
-bash-3.00# pkgchk -p /etc/shadow
ERROR: /etc/shadow
modtime <01/22/05 07:46:05 AM> expected <02/13/06 01:36:36 PM> actual
file size <296> expected <373> actual
file cksum <20180> expected <26166> actual
检查/etc/shadow自安装以来是否发生变化。有输出说明有变化,没有输出则表示没有变化。
-bash-3.00# pkgchk -l -p /usr/bin/showrev
Pathname: /usr/bin/showrev
Type: regular file
Expected mode: 0755
Expected owner: root
Expected group: sys
Expected file size (bytes): 28148
Expected sum(1) of contents: 7605
Expected last modification: Jan 23 09:40:57 2005
Referenced by the following packages:
SUNWadmc
Current status: installed
列出/usr/bin/showrev文件在软件包中的属主、权限、所属软件包名称等信息。
-bash-3.00# pkgchk -l -P showrev
Pathname: /usr/bin/showrev
Type: regular file
Expected mode: 0755
Expected owner: root
Expected group: sys
Expected file size (bytes): 28148
Expected sum(1) of contents: 7605
Expected last modification: Jan 23 09:40:57 2005
Referenced by the following packages:
SUNWadmc
Current status: installed
Pathname: /usr/share/man/man1m/showrev.1m
Type: regular file
Expected mode: 0644
Expected owner: root
Expected group: root
Expected file size (bytes): 3744
Expected sum(1) of contents: 56811
Expected last modification: Oct 22 08:51:42 2005
Referenced by the following packages:
SUNWman
Current status: installed
列出含有showrev文件的软件包中该文件的相关信息。可见如果知道某个文件的完全路径名或部分路径名可以通过pkgchk -lp或pkgchk -lP命令查找出该文件所属的软件包。
pkgchk -v pkg_name用来列出指名称的软件包所包含的文件。下面的命令用分页显示列出软件包SMCapch22中所包含的文件列表:
-bash-3.00# ls -l
total 3002
-rw-r--r-- 1 root root 75782 Feb 25 20:56 1
drwxr-xr-x 3 root root 512 Feb 25 18:09 SMCapch22
drwxr-xr-x 5 root root 512 Feb 25 17:15 SUNWcsr
-rw-r--r-- 1 root root 1216512 Feb 25 17:09 SUNWcsr.pkg
-rw-r--r-- 1 root root 220672 Feb 25 17:59 zone.pkg
-bash-3.00# pkgchk -d . -v SMCapch22 2>&1 | more
bin/ab
bin/apachectl
bin/apxs
bin/checkgid
bin/dbmmanage
bin/envvars
bin/envvars-std
bin/htcacheclean
bin/htdbm
bin/htdigest
bin/htpasswd
bin/httpd
bin/httxt2dbm
bin/logresolve
bin/rotatelogs
build/config.nice
build/config_vars.mk
build/instdso.sh
build/library.mk
build/ltlib.mk
build/mkdir.sh
build/program.mk
--More--
要注意的是pkgchk命令只往标准错误输出文件列表,所以使用管道时需要重定向到标准输出。
安装软件包
安装软件包用pkgadd命令,该命令可以安装文件系统各式的软件包:
-bash-3.00# cd /cdrom/cdrom0/Solaris_10/ExtraValue/CoBundled/SunVTS_6.1/Packages
-bash-3.00# pkgadd -d . SUNWvts
Processing package instance <SUNWvts> from </cdrom/sol_10_106_x86/Solaris_10/Ext
raValue/CoBundled/SunVTS_6.1/Packages>
SunVTS Framework(i386) 6.1,REV=2005.11.10.13.29
Copyright 2004 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
## Executing checkinstall script.
Using </opt> as the package base directory.
## Processing package information.
## Processing system information.
## Verifying package dependencies.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
This package contains scripts which will be executed with super-user
permission during the process of installing this package.
Do you want to continue with the installation of <SUNWvts> [y,n,?] y
Installing SunVTS Framework as <SUNWvts>
## Installing part 1 of 1.
5254 blocks
Installation of <SUNWvts> was successful.
也可以安装数据流格式的本地软件包:
-bash-3.00# pkgadd -d cvs-bundle.pkg all
Processing package instance <SMCcvs> from </export/home/justin/pkg/cvs-bundle.pkg>
cvs(x86) 1.11.20
FSF
The selected base directory </usr/local> must exist before
installation is attempted.
Do you want this directory created now [y,n,?,q] y
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
Installing cvs as <SMCcvs>
## Installing part 1 of 1.
/usr/local/bin/cvs
/usr/local/bin/cvsbug
/usr/local/bin/rcs2log
......
/usr/local/man/man1/cvs.1
/usr/local/man/man5/cvs.5
/usr/local/man/man8/cvsbug.8
[ verifying class <none> ]
Installation of <SMCcvs> was successful.
Processing package instance <SMCgzip> from </export/home/justin/pkg/cvs-bundle.pkg>
gzip(intel) 1.3.5
Free Software Foundation
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
5 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
Installing gzip as <SMCgzip>
## Installing part 1 of 1.
/usr/local/bin/gzexe
/usr/local/bin/gzip
/usr/local/man/man1/gzip.1
......
[ verifying class <none> ]
/usr/local/bin/gunzip <linked pathname>
/usr/local/bin/zcat <linked pathname>
/usr/local/bin/zcmp <linked pathname>
/usr/local/bin/zegrep <linked pathname>
/usr/local/bin/zfgrep <linked pathname>
cvs(x86) 1.11.20
FSF
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
Installing cvs as <SMCcvs>
## Installing part 1 of 1.
/usr/local/bin/cvs
/usr/local/bin/cvsbug
......
[ verifying class <none> ]
gzip(intel) 1.3.5
Free Software Foundation
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
5 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
Installing gzip as <SMCgzip>
## Installing part 1 of 1.
/usr/local/bin/gzexe
/usr/local/bin/gzip
......
Installation of <SMCgzip> was successful.
要注意的是有些软件包有它所依赖的其它软件包,如果这些依赖没有安装,那么pkgadd将会报错。遇到这种情形应当首先安装依赖的软件包。此外,如果需要无人值守的情况下安装那些需要用户输入的软件包时,可以事先使用pkgask将设置记录到一个文件中,然后使用pkgadd的-r选项告诉pkgadd命令使用该文件的的用户输入。
删除软件包
删除软件包用pkgrm命令:
-bash-3.00# pkgrm SMCgzip
The following package is currently installed:
SMCgzip gzip
(intel) 1.3.5
Do you want to remove this package? [y,n,?,q] y
## Removing installed package instance <SMCgzip>
## Verifying package <SMCgzip> dependencies in global zone
## Processing package information.
## Removing pathnames in class <none>
/usr/local/man/man1 <shared pathname not removed>
/usr/local/man <shared pathname not removed>
/usr/local/info/gzip.info
/usr/local/info <shared pathname not removed>
/usr/local/doc <shared pathname not removed>
/usr/local/bin/zcat
/usr/local/bin/gzip
/usr/local/bin/gzexe
/usr/local/bin/gunzip
/usr/local/bin <shared pathname not removed>
## Updating system information.
Removal of <SMCgzip> was successful.
如果试图删除被其它软件包依赖的软件包,pkgrm命令会提出警告,并让用户选择是否继续,如果继续软件包会被强制删除。如:
-bash-3.00# pkgrm SUNWapchr
The following package is currently installed:
SUNWapchr Apache Web Server (root)
(i386) 11.10.0,REV=2005.01.08.01.09
Do you want to remove this package? [y,n,?,q] y
## Removing installed package instance <SUNWapchr>
## Verifying package <SUNWapchr> dependencies in global zone
WARNING:
The <SUNWapchu> package depends on the package
currently being removed.
WARNING:
The <SUNWapchd> package depends on the package
currently being removed.
WARNING:
The <SUNWserweb> package depends on the package
currently being removed.
Dependency checking failed.
Do you want to continue with the removal of this package [y,n,?,q]