软件包开发的最后一步是安装软件包以测试所发布的软件包是否已正确打包。
要在不需要 root 特权的情况下测试安装,需要为测试用户指定 Software Installation(软件安装)配置文件。使用 usermod 命令的 -P 选项可为测试用户指定 Software Installation(软件安装)配置文件。
以下 pkg set-publisher 命令会将 my-repository 系统信息库中的所有发布者添加到在该映像中配置的发布者列表:
$ pkg publisher PUBLISHER TYPE STATUS P LOCATION solaris origin online F http://pkg.oracle.com/solaris/release/ $ pkg set-publisher -p my-repository pkg set-publisher: Added publisher(s): mypublisher $ pkg publisher PUBLISHER TYPE STATUS P LOCATION solaris origin online F http://pkg.oracle.com/solaris/release/ mypublisher origin online F file:///home/username/my-repository/
使用 -nv 选项和 pkg install 命令可查看安装命令将执行的操作,而不对映像进行任何更改。以下命令实际上安装软件包:
$ pkg install mypkg Packages to install: 1 Create boot environment: No Create backup boot environment: No Services to change: 1 DOWNLOAD PKGS FILES XFER (MB) SPEED Completed 1/1 3/3 0.0/0.0 787k/s PHASE ITEMS Installing new actions 16/16 Updating package state database Done Updating image state Done Creating fast lookup database Done Reading search index Done Updating search index 1/1
检查交付到系统上的软件:
$ find /opt/mysoftware /opt/mysoftware /opt/mysoftware/bin /opt/mysoftware/bin/mycmd /opt/mysoftware/lib /opt/mysoftware/lib/mylib.so.1 /opt/mysoftware/man /opt/mysoftware/man/man1 /opt/mysoftware/man/man1/mycmd.1 /opt/mysoftware/man/man-index /opt/mysoftware/man/man-index/term.dic /opt/mysoftware/man/man-index/term.req /opt/mysoftware/man/man-index/term.pos /opt/mysoftware/man/man-index/term.exp /opt/mysoftware/man/man-index/term.doc /opt/mysoftware/man/man-index/.index-cache /opt/mysoftware/man/man-index/term.idx
执行器重新启动 man-index 服务后,除了二进制文件和手册页,系统还会生成手册页索引。
pkg info 命令显示添加到软件包的元数据:
$ pkg info mypkg Name: mypkg Summary: This is an example package Description: This is a full description of all the interesting attributes of this example package. Category: Applications/Accessories State: Installed Publisher: mypublisher Version: 1.0 Build Release: 5.11 Branch: 0 Packaging Date: July 20, 2013 00:54:52 AM Size: 12.95 kB FMRI: pkg://mypublisher/mypkg@1.0,5.11-0:20130720T005452Z
查询通过 mypkg 交付的文件时,pkg search 命令将返回命中:
$ pkg search -l mycmd INDEX ACTION VALUE PACKAGE basename file opt/mysoftware/bin/mycmd pkg:/mypkg@1.0-0