博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

Aubrey Li

  aubrey.cublog.cn

关于作者
姓名:Aubrey.Li
职业:Solaris Kernel Dev
位置:Shanghai-ZiZhu
个性介绍:
|| << >> ||
我的分类


制作Solaris的软件包 (SVR4 package)
今天来说说如何制作Solaris的软件包,这里充分利用了blastwave的资源,我也因此成为blastwave的maintainer之一,呵呵

1. blastwave发布了一系列的脚本,使得制作solaris的软件包变得非常容易。在制造SVR4 package之前,首先安装blastwave maintainer scripts
#pkg-get install cswutils
2. 创建一个简单的例子
aubrey@Indiana:~/packages/build$ ls -l hellopkg-1.0/
total 2
-rw-r--r-- 1 aubrey staff  82 2008-04-27 16:00 hellopkg.c
-rw-r--r-- 1 aubrey staff 133 2008-04-27 16:01 Makefile
这里主要看看makefile文件
aubrey@Indiana:~/packages/build/hellopkg-1.0$ cat Makefile
all: hellopkg

hellopkg: hellopkg.c
    $(CC) -o hellopkg hellopkg.c

install:
    cp hellopkg $(DESTDIR)/opt/csw/bin

clean:
    rm hellopkg
3. 我们要创建两个文件
    1) copyright, 这个文件一般从软件的源码包里面copy得到
    2) pkginfo,这个文件包含的软件包的信息
aubrey@Indiana:~/packages# ls -l pkgs/hellopkg/
total 2
-rw-r--r-- 1 root root   0 2008-04-27 16:22 copyright
-rw-r--r-- 1 root root 220 2008-04-27 16:25 pkginfo
aubrey@Indiana:~/packages# cat pkgs/hellopkg/pkginfo
PKG=CSWhellopkg
NAME=hellopkg - SVR4 packaging example
VERSION=1.0
CATEGORY=application
VENDOR=http://aubrey.cublog.cn  packaged for CSW by Aubrey Li
HOTLINE=http://www.blastwave.org/bugtrack/
EMAIL=aubrey@blastwave.org
4. 生成prototype文件
aubrey@Indiana:~/packages/build/hellopkg-1.0# CC=gcc MAKE=make stagepkg
removing old staging area
creating staging area /export/home/aubrey/packages/build/hellopkg-1.0/cswstage
using make arguments of DESTDIR=/export/home/aubrey/packages/build/hellopkg-1.0/cswstage install
will use fakeroot to do install
make
DESTDIR=/export/home/aubrey/packages/build/hellopkg-1.0/cswstage install
/export/home/aubrey/packages/build/hellopkg-1.0/cswstage
fakeroot
cp hellopkg /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/opt/csw/bin

Checking for relocatable capability...

Stripping executables...
prototype file is now in /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/prototype
If you dont already have a prototype file, you should copy
/export/home/aubrey/packages/build/hellopkg-1.0/cswstage/prototype
to where you keep your pkginfo file, and edit it as appropriate. Next,
  cd ~/pkgs/[software]
You should then do EITHER
  createpkg -b /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/opt/csw
OR if you want to do things the hard way
  pkgmk -b /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/opt/csw \
        -f /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/prototype \
         BASEDIR=/opt/csw
  [and then all the other cleanup type stuff by hand]
aubrey@Indiana:~/packages/build/hellopkg-1.0#
5. 把prototype文件copy到pkgs目录下, 并去掉prototype文件里面的“i depend”这一行
aubrey@Indiana:~/packages# ls
build  pkgs
aubrey@Indiana:~/packages# cp build/hellopkg-1.0/cswstage/prototype pkgs/hellopkg/
6. 准备工作已经做好了,我们去pkgs/hellopkg下面生成SVR4的软件包,注意第4步的输出,已经告诉我们如何生成软件包了.
aubrey@Indiana:~/packages/pkgs/hellopkg# createpkg -b /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/opt/csw
i copyright
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: parameter <PSTAMP> set to "Indiana20080427163708"
WARNING: parameter <CLASSES> set to "none"
## Attempting to volumize 2 entries in pkgmap.
part  1 -- 19 blocks, 8 entries
## Packaging one part.
/var/spool/pkg/CSWhellopkg/pkgmap
/var/spool/pkg/CSWhellopkg/pkginfo
/var/spool/pkg/CSWhellopkg/reloc/bin/hellopkg
/var/spool/pkg/CSWhellopkg/install/copyright
## Validating control scripts.
## Packaging complete.
Transferring <CSWhellopkg> package instance
Conversion complete. Cleaning up in /var/spool/pkg

Running checkpkg on pkgfile
Examining hellopkg-1.0-SunOS5.11-i386-CSW.pkg
Looking for bad strings...
Extracting files for more detailed inspection...
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.000591384 s, 13.9 MB/s
CSWhellopkg/pkginfo
2 blocks
Info for pkg CSWhellopkg
software= 'hellopkg'
arch= 'i386'
desc='SVR4 packaging example'
pkgname='CSWhellopkg'
version='1.0'
maintainer name='Aubrey Li'
maint email='aubrey@blastwave.org'
hotline='http://www.blastwave.org/bugtrack/'
basedir='/opt/csw'

Extracing pkg for examination of files...
pkginfo
pkgmap
install
install/copyright
reloc
reloc/bin
reloc/bin/hellopkg
14 blocks
Checking uninstalled directory format package <CSWhellopkg> from </tmp/dissect.20161>
## Checking control scripts.
## Checking package objects.
## Checking is complete.
/usr/sbin/pkgchk passed.
libraries used are:
libc.so.1
cross-referencing with depend file (May take a while)

Checking relocation ability...
trivial check passed
packaging of files under /export/home/aubrey/packages/build/hellopkg-1.0/cswstage/opt/csw complete
gzipping pkgfile
aubrey@Indiana:~/packages/pkgs/hellopkg#
7. OK, 软件包已经做好了,来试试吧
aubrey@Indiana:~/packages/pkgs/hellopkg# ls
copyright  depend  hellopkg-1.0-SunOS5.11-i386-CSW.pkg    pkginfo  prototype
aubrey@Indiana:~/packages/pkgs/hellopkg# pkgadd -d hellopkg-1.0-SunOS5.11-i386-CSW.pkg

The following packages are available:
  1  CSWhellopkg     hellopkg - SVR4 packaging example
                     (i386) 1.0

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

Processing package instance <CSWhellopkg> from </export/home/aubrey/packages/pkgs/hellopkg/hellopkg-1.0-SunOS5.11-i386-CSW.pkg>

hellopkg - SVR4 packaging example(i386) 1.0
Using </opt/csw> as the package base directory.
## Processing package information.
## Processing system information.
   1 package pathname is already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing hellopkg - SVR4 packaging example as <CSWhellopkg>

## Installing part 1 of 1.
/opt/csw/bin/hellopkg
[ verifying class <none> ]

Installation of <CSWhellopkg> was successful.
aubrey@Indiana:~/packages/pkgs/hellopkg# /opt/csw/bin/hellopkg
hello SVR4 package


发表于: 2008-04-27,修改于: 2008-04-28 14:26,已浏览1163次,有评论0条 推荐 投诉


网友评论
 发表评论