欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

自己生成AIX bff打包安装文件

程序员文章站 2024-01-31 08:39:31
...

复杂度3/5
机密度4/5

最后更新2021/04/28

AIX提供了生成打包文件的命令:mkinstallp,需要安装bos.adt.insttools fileset
查看fileset是否已经安装:

#lslpp -L bos.adt.insttools
  Fileset                      Level  State  Type  Description (Uninstaller)
  ----------------------------------------------------------------------------
  bos.adt.insttools         7.1.3.15    C     F    Tool to Create installp Packages
  • 准备
    先要准备一个安装目录:
#mkdir -p ~/build/mypackage

把安装包需要的文件放到对应的目录和子目录下:

~/build/mypackage/usr/local/bin/my_execution
~/build/mypackage/usr/local/filepackage/my_files
~/build/mypackage/usr/local/filepackage/lib/my_libs

mkinstallp命令使用一个template文件控制如何生成安装文件,下面是一个最简单模板文件的例子:

#cat ~/build/mypackage/template
Package Name: my_package
Package VRMF: 1.0.0.0
Update: N
Fileset
  Fileset Name: mypackage.rte
  Fileset VRMF: 1.0.0.0
  Fileset Description: bff packaging process template
  Bosboot required: N
  License agreement acceptance required: N
  Include license files in this package: N
  Requisites:
  USRFiles
     /usr/local/bin/my_execution
     /usr/local/filepackage/my_files
     /usr/local/filepackage/lib/my_libs
  EOUSRFiles
  USRLIBLPPFiles
  EOUSRLIBLPPFiles
  ROOT Part: N
  ROOTFiles
  EOROOTFiles
EOFileset

VRMF 表示此fileset对应的版本号Version, 发布号Release, 维护级别Maintenance level, 补丁级别Fix

模板文件中的USRFiles段说明在安装包中有哪些文件,以及安装的目标位置;

ROOTFiles表示不同机器之间不能共享的文件,仅仅用于AIX无盘工作站使用,目前已经没有什么用处,通常都是N;

  • 生成包
    生成命令非常简单:
# mkinstallp -d ~/build/mypackage -T ~/build/mypackage/template
Using ~/build/mypackage as the base package directory.
Cannot find ~/build/mypackage/.info. Attempting to create.
Using ~/build/mypackage/.info to store package control files.
Cleaning intermediate files from ~/build/mypackage/.info.

Using ~/build/mypackage/template as the template file.
vopt_manager 1.0.0.0 I
processing mypackage.rte
creating ./.info/liblpp.a
creating ./tmp/mypackage.1.0.0.0.bff
  • 安装
    安装刚生成的安装包
 # cd ./tmp
 # inutoc .
 # installp -acXgd . mypackage.rte
+-----------------------------------------------------------------------------+
                    Pre-installation Verification...
+-----------------------------------------------------------------------------+
Verifying selections...done
Verifying requisites...done
Results...

SUCCESSES

  Filesets listed in this section passed pre-installation verification
  and will be installed.

  Selected Filesets
  -----------------
  mypackage.rte 1.0.0.0                    # manage creation and deletion...

  << End of Success Section >>

+-----------------------------------------------------------------------------+
                   BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done

FILESET STATISTICS

    1  Selected to be installed, of which:
        1  Passed pre-installation verification
  ----
    1  Total to be installed

+-----------------------------------------------------------------------------+
                         Installing Software...
+-----------------------------------------------------------------------------+

installp:  APPLYING software for:
        mypackage.rte 1.0.0.0

Finished processing all filesets.  (Total time:  0 secs).

+-----------------------------------------------------------------------------+
                                Summaries:
+-----------------------------------------------------------------------------+

Installation Summary

Name Level Part Event Result

mypackage.rte            1.0.0.0         USR         APPLY       SUCCESS

You can see your package content with lslpp :

 # lslpp -f mypackage.rte

  Fileset               File
  ----------------------------------------------------------------------------
Path: /usr/lib/objrepos
  mypackage.rte 1.0.0.0
     /usr/local/bin/my_execution
     /usr/local/filepackage/my_files
     /usr/local/filepackage/lib/my_libs

如果重新build,要先把.info和tmp子目录删掉:

#rm -rf tmp .info
  • 更进一步
    前面只完成了最基础的打包过程,如果想在安装之前、之后做一些额外动作怎么办?还有pre/post script可以帮助实现这个目标。

生成相应的脚本:

 echo 'echo PRE INSTALL' > /tmp/pre_install.sh
 echo 'echo POST INSTALL' > /tmp/post_install.sh
 echo 'echo PRE REMOVAL' > /tmp/pre_removal.sh
 chmod u+x /tmp/pre_install.sh /tmp/post_install.sh /tmp/pre_removal.sh

修改模板文件:

#cat ~/build/mypackage/template
Package Name: mypackage
Package VRMF: 1.0.0.0
Update: N
Fileset
  Fileset Name: mypackage.rte
  Fileset VRMF: 1.0.0.0
  Fileset Description: bff packaging process template
  Bosboot required: N
  License agreement acceptance required: N
  Include license files in this package: N
  Requisites:
  USRFiles
     /usr/local/bin/my_execution
     /usr/local/filepackage/my_files
     /usr/local/filepackage/lib/my_libs
  EOUSRFiles
  USRLIBLPPFiles
     Pre-installation Script: /tmp/pre_install.sh
     Post-installation Script: /tmp/post_install.sh
     Pre-deinstall Script: /tmp/pre_removal.sh
  EOUSRLIBLPPFiles
  ROOT Part: N
  ROOTFiles
  EOROOTFiles
EOFileset

现在我们把这些脚本放到了绝对目录/tmp中,其实也可以放到build目录下,但脚本编写一定要注意在build目录下的时候,真正执行时的所在目录其实是刨除build父目录之后的位置。下面是安装时的屏显:

+-----------------------------------------------------------------------------+
                         Installing Software...
+-----------------------------------------------------------------------------+

installp:  APPLYING software for:
        mypackage.rte 1.0.0.0

PRE INSTALL
POST INSTALL
Finished processing all filesets.  (Total time:  0 secs).

+-----------------------------------------------------------------------------+
                                Summaries:
+-----------------------------------------------------------------------------+

Installation Summary
 -------------------- 
 Name Level Part Event Result

mypackage.rte            1.0.0.0         USR         APPLY       SUCCESS

删除:

 #installp -u mypackage.rte
+-----------------------------------------------------------------------------+
                    Pre-deinstall Verification...
+-----------------------------------------------------------------------------+
Verifying selections...PRE REMOVAL
done
Verifying requisites...done
Results...

SUCCESSES
---------
  Filesets listed in this section passed pre-deinstall verification
  and will be removed.

  Selected Filesets
  -----------------
mypackage.rte 1.0.0.0                    # manage creation and deletion...
相关标签: aix 操作系统