创建SOLARIS安装包(SRV4格式)

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 root
d none /usr/local/doc 0755 bin bin
d none /usr/local/doc/autoconf 0755 root bin
f none /usr/local/doc/autoconf/COPYING 0644 root bin
f none /usr/local/doc/autoconf/THANKS 0644 root bin

.........

 

如果需要,可修改该文件中的权限部分。

 

然后,你需要为pkginfo命令添加一个指针,告诉pkgmk命令你锁创建的包的细节。请在Prototype文件开头加上以下内容:

 

i pkginfo

 

 如果你想运行checkinstall, preinstall, postinstall脚本,也将他们加入到Prototype文件开头:

 

i preinstall
i postinstall
i 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="[email protected]"
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/sh
pkg=GNUbison
pkgfile=GNUbison.1.24.SPARC.Solaris.2.6.pkg.tgz
pkgmk -o -r / -d /tmp -f Prototype
echo "Setting file permissions in /tmp/${pkg} tree to 644."
find /tmp/${pkg} -type f -print | xargs chmod a+r
find /tmp/${pkg} -type f -print | xargs chmod u+w
echo "Setting directory permissions in /tmp/${pkg} tree to 755."
find /tmp/${pkg} -type d -print | xargs chmod 755
if [ -f /tmp/${pkg}/install/preinstall ]; then
    chmod 755 /tmp/${pkg}/install/preinstall
fi
if [ -f /tmp/${pkg}/install/postinstall ]; then
    chmod 755 /tmp/${pkg}/install/postinstall
fi
if [ -f /tmp/${pkg}/install/preremove ]; then
    chmod 755 /tmp/${pkg}/install/preremove
fi
if [ -f /tmp/${pkg}/install/postremove ]; then
    chmod 755 /tmp/${pkg}/install/postremove
fi
if [ -f /tmp/${pkg}/install/request ]; then
    chmod 755 /tmp/${pkg}/install/request
fi
if [ -f /tmp/${pkg}/install/checkinstall ]; then
    chmod 755 /tmp/${pkg}/install/checkinstall
fi
cd /tmp
echo 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 1
fi
# 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
# fi

exit 0

 

你可能感兴趣的:(erlang,Solaris,F#,prototype,脚本)