六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 831|回复: 0

创建SOLARIS安装包(SRV4格式)

[复制链接]

升级  51.33%

37

主题

37

主题

37

主题

秀才

Rank: 2

积分
127
 楼主| 发表于 2013-2-7 13:18:55 | 显示全部楼层 |阅读模式
1.  环境
 
OS:  Solaris_10_x86_32bits,
Pkg:Erlang/OTP R13B03
source folder: /usr/local
 
 
2. 创建Prototype文件
 
# find /usr/local -print > /tmp/files
 
# cat /tmp/files | pkgproto > /tmp/Prototype
 
查看该文件内容如下:
 
d none /usr/local 0755 root rootd none /usr/local/doc 0755 bin bind none /usr/local/doc/autoconf 0755 root binf none /usr/local/doc/autoconf/COPYING 0644 root binf none /usr/local/doc/autoconf/THANKS 0644 root bin......... 
如果需要,可修改该文件中的权限部分。
 
然后,你需要为pkginfo命令添加一个指针,告诉pkgmk命令你锁创建的包的细节。请在Prototype文件开头加上以下内容:
 
i pkginfo 
 如果你想运行checkinstall, preinstall, postinstall脚本,也将他们加入到Prototype文件开头:
 
i preinstalli postinstalli checkinstall 
checkinstall由nobody用户执行,可检查软件包的依赖性、以及目录访问权限。pkgadd命令不会问你是否执行该脚本。
preinstall由root用户在安装过程中执行, 取消安装时用户需要执行pkgrm命令删除未完全安装的包,pkgadd命令会问你是否执行该脚本。
postinstall由root在安装结束后执行,执行一些善后工作,pkgadd命令会问你是否执行该脚本。
 
 
3. 创建pkginfo文件
 
主要用于命名,比如:
 
PKG="XMYerlang"NAME="Erlang/OTP-R13B03 Solaris 10 x86 32bits"VERSION="13.03"ARCH="x86"CLASSES="none"CATEGORY="utility"VENDOR="GNU"PSTAMP="1stSep09"EMAIL="xumingyong@gmail.com"ISTATES="S s 1 2 3"RSTATES="S s 1 2 3"BASEDIR="/" 
 
4. 创建包
 
# pkgmk -o -r / -d /tmp -f Prototype
This command means make the package, overwrite any previous attempts, use '/' as the root directory for locating the files, build the package in the /tmp directory and finally, take the list of files and attributes from the Prototype file.
 
这样,在/tmp目录下就创建了一个XMYerlang文件夹,其下包含pkgmap和pkginfo文件。pkgmap文件包含所有文件的路径、权限和校验和。pkginfo文件的内容和/tmp/pkginfo文件内容一样。/tmp/XMYerlang/root文件夹下包含真实部署系统文件树结构。
 
如果你包含了checkinstall脚本,则会被防止在一个install目录下。
 
# cd /tmp
# tar -cf - XMYerlang | gzip -9 -c > XMYerlang-13.03-sol10-x86-32bits.pkg.tar.gz
 
 
5. 解压缩包并安装
 
# gunzip -c XMYerlang-13.03-sol10-x86-32bits.pkg.tar.gz | tar -xf -
 
# pkgadd -d XMYerlang-13.03-sol10-x86-32bits.pkg.tar.gz
 
 
6. mkpkg文件
 
#!/bin/shpkg=GNUbisonpkgfile=GNUbison.1.24.SPARC.Solaris.2.6.pkg.tgzpkgmk -o -r / -d /tmp -f Prototypeecho "Setting file permissions in /tmp/${pkg} tree to 644."find /tmp/${pkg} -type f -print | xargs chmod a+rfind /tmp/${pkg} -type f -print | xargs chmod u+wecho "Setting directory permissions in /tmp/${pkg} tree to 755."find /tmp/${pkg} -type d -print | xargs chmod 755if [ -f /tmp/${pkg}/install/preinstall ]; then    chmod 755 /tmp/${pkg}/install/preinstallfiif [ -f /tmp/${pkg}/install/postinstall ]; then    chmod 755 /tmp/${pkg}/install/postinstallfiif [ -f /tmp/${pkg}/install/preremove ]; then    chmod 755 /tmp/${pkg}/install/preremovefiif [ -f /tmp/${pkg}/install/postremove ]; then    chmod 755 /tmp/${pkg}/install/postremovefiif [ -f /tmp/${pkg}/install/request ]; then    chmod 755 /tmp/${pkg}/install/requestfiif [ -f /tmp/${pkg}/install/checkinstall ]; then    chmod 755 /tmp/${pkg}/install/checkinstallficd /tmpecho Gzipping /tmp/$pkg into /tmp/$pkgfile.../usr/bin/tar -cf - $pkg | gzip -9c > /tmp/$pkgfile 
 
 
7. checkinstall文件
 
#!/bin/sh#expected_release="5.6"expected_platform="sparc"#release=`uname -r`platform=`uname -p`#if [ ${platform} != ${expected_platform} ]; then    echo "\n\n\n\tThis package must be installed on a ${expected_platform} architecture\n"    echo "\tAborting installation.\n\n\n"    exit 1fi# if [ ${release} != ${expected_release} ]; then#     echo "\n\n\n\tThis package must be installed on a ${expected_release} machine\n"#     echo "\tAborting installation.\n\n\n"#     exit 1# fiexit 0 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表