In this post I will build a AIX package in BFF format with the standard AIX tool mkinstallp.

tool installation

To create your own packages you need the mkinstallp command.

It’s available in bos.adt.insttools.

# 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

I create a dedicated directory for the build of my vopt_manager package.

mkdir -p ~/build/vopt/manager

package mkinstallp use a main file named template to build the package. Below is the template file I will use for my package.

Package Name: vopt_manager
Package VRMF: 1.0.0.0
Update: N
Fileset
  Fileset Name: vopt_manager.rte
  Fileset VRMF: 1.0.0.0
  Fileset Description: manage creation and deletion of virtual optical devices
  Bosboot required: N
  License agreement acceptance required: N
  Include license files in this package: N
  Requisites:
  USRFiles
     /usr/local/bin/vopt_manager
     /usr/local/vopt_manager/lib/Net/OpenSSH.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ConnectionCache.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/Constants.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ModuleLoader.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/OSTracer.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/SSH.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/Chain.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSCmd.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSWin.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/POSIX.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/csh.pm
     /usr/local/vopt_manager/lib/Data/Dumper/Simple.pm
  EOUSRFiles
  USRLIBLPPFiles
  EOUSRLIBLPPFiles
  ROOT Part: N
  ROOTFiles
  EOROOTFiles
EOFileset

VRMF means Version, Release, Maintenance level, Fix. It’s what is used for package numbering.

The files listed in the USRFiles section are the files which will be included in the package. You need to put them under your build directory. For example, /usr/local/bin/vopt_manager will be installed in /build/vopt_manager/usr/local/bin/vopt_manager.

ROOTFiles are files which cannot be shared between machines. It’s mostly for diskless AIX systems. I never saw this kind of installation.

build

Building the package itself is pretty simple. You specify the directory containing your package files and the template file you will use to built it.

# mkinstallp -d /build/vopt_manager -T /build/vopt_manager/template
Using /build/vopt_manager as the base package directory.
Cannot find /build/vopt_manager/.info. Attempting to create.
Using /build/vopt_manager/.info to store package control files.
Cleaning intermediate files from /build/vopt_manager/.info.

Using /build/vopt_manager/template as the template file.
vopt_manager 1.0.0.0 I
processing vopt_manager.rte
creating ./.info/liblpp.a
creating ./tmp/vopt_manager.1.0.0.0.bff

Package installation

You obtain a standard AIX package in the tmp directory. You install it like any standard AIX package.

# cd ./tmp
# inutoc .
# installp -acXgd . vopt_manager.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
  -----------------
  vopt_manager.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:
        vopt_manager.rte 1.0.0.0

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

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

Installation Summary
--------------------
Name                        Level           Part        Event       Result
-------------------------------------------------------------------------------
vopt_manager.rte            1.0.0.0         USR         APPLY       SUCCESS

You can see your package content with lslpp :

# lslpp -f vopt_manager.rte
  Fileset               File
  ----------------------------------------------------------------------------
Path: /usr/lib/objrepos
  vopt_manager.rte 1.0.0.0
    /usr/local/vopt_manager/lib/Net/OpenSSH/OSTracer.pm
    /usr/local/vopt_manager/lib/Data/Dumper/Simple.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSWin.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/Chain.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ConnectionCache.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ModuleLoader.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/Constants.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/csh.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/POSIX.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/SSH.pm
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSCmd.pm
    /usr/local/bin/vopt_manager
    /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter.pm

rebuilding your package

Before rebuilding your package you need to remove the .info and tmp folders :

rm -rf tmp .info

pre and post installation scripts

The package I created here is pretty simple. But often you will want to run scripts during the package installation and removal.

Again it’s pretyeasy to do.

First we will create test scripts in our build directory :

 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

Here the new template file :

Package Name: vopt_manager
Package VRMF: 1.0.0.0
Update: N
Fileset
  Fileset Name: vopt_manager.rte
  Fileset VRMF: 1.0.0.0
  Fileset Description: manage creation and deletion of virtual optical devices
  Bosboot required: N
  License agreement acceptance required: N
  Include license files in this package: N
  Requisites:
  USRFiles
     /usr/local/bin/vopt_manager
     /usr/local/vopt_manager/lib/Net/OpenSSH.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ConnectionCache.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/Constants.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ModuleLoader.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/OSTracer.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/SSH.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/Chain.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSCmd.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/MSWin.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/POSIX.pm
     /usr/local/vopt_manager/lib/Net/OpenSSH/ShellQuoter/csh.pm
     /usr/local/vopt_manager/lib/Data/Dumper/Simple.pm
  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

The interesting section is :

  USRLIBLPPFiles
     Pre-installation Script: /tmp/pre_install.sh
     Post-installation Script: /tmp/post_install.sh
     Pre-deinstall Script: /tmp/pre_removal.sh
  EOUSRLIBLPPFiles

A important thing here is you are giving the full path for the scripts. it’s not mandatory for them to be part of your build package directory.

So now when installing the package you will see the messages from my test scripts :

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

installp:  APPLYING software for:
        vopt_manager.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
-------------------------------------------------------------------------------
vopt_manager.rte            1.0.0.0         USR         APPLY       SUCCESS

During package removal :

# installp -u vopt_manager.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
  -----------------
  vopt_manager.rte 1.0.0.0                    # manage creation and deletion...