Eigene AIX installp-Pakete bauen (Teil 1)

In diesem Blog-Beitrag soll gezeigt werden, wie man unter AIX selber installp Pakete bauen kann. Die Benutzung des Kommandos mkinstallp wird dabei an einem einfachen Beispiel demonstriert. Komplexere Pakete werden in einem späteren Artikel behandelt.

Es ist relativ einfach unter AIX installp-Pakete zu bauen. Benötigt wird dazu das Kommando /usr/sbin/mkinstallp. Sollte das Kommando nicht installiert sein, muß das Paket bos.adt.insttools nachinstalliert werden. Zum Bau von Paketen werden root-Rechte benötigt.

Zunächst legen wir an beliebiger Stelle ein Verzeichnis an, in dem das Paket gebaut werden soll:

# mkdir pwrcmps.installp.example
#

Das Paket soll ein kleines Shell-Skript enthalten:

# cat <<EOF >hello
#! /bin/ksh
print "hello world"
EOF
# chmod a+x hello
#

Das Skript soll später unter /usr/local/bin installiert werden. Zu installierende Files müssen relativ zum Build-Directory (bei uns pwrcmps.installp.example) an der selben Stelle stehen, wie später relativ zum root-Directory. Wir legen daher die notwendige Directory Struktur an und kopieren das Skript hello an die entsprechende Stelle:

# mkdir –p pwrcmps.installp.example/usr/local/bin
# cp hello pwrcmps.installp.example/usr/local/bin
#

Wir wechseln in das Build-Directory und starten das Kommando mkinstallp zum Bauen des Paketes:

# cd pwrcmps.installp.example
# mkinstallp
Using /export/src/installp/pwrcmps.installp.example as the base package directory.
Cannot find /export/src/installp/pwrcmps.installp.example/.info. Attempting to create.
Using /export/src/installp/pwrcmps.installp.example/.info to store package control files.
Cleaning intermediate files from /export/src/installp/pwrcmps.installp.example/.info.

************************************************************
|            Beginning interactive package input           |
|   * - required; () - example value; [] - default value   |
************************************************************

* Package Name (xyz.net) []: pwrcmps.installp
* Package VRMF (1.0.0.0) []: 1.0.0.0
Update (Y/N) [N]:
Number of filesets in pwrcmps.installp (1) [1]:

Gathering info for new fileset (1 remaining)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Fileset Name (pwrcmps.installp.rte) []: pwrcmps.installp.example
* Fileset VRMF (1.0.0.0) []: 1.0.0.0
* Fileset Description (some text) []: Example Fileset
Do you want to include a copyright file for this fileset? (Y/N) [N]:
Entering information for the USER part liblpp files
Do you want to include an installp pre_i/u script for this fileset? (Y/N) [N]:
Do you want to include an installp post_i/u script for this fileset? (Y/N) [N]:
Do you want to include a pre-deinstall Script for this fileset? (Y/N) [N]:
Do you want to include an installp pre_rm script for this fileset? (Y/N) [N]:
Do you want to include an installp config script for this fileset? (Y/N) [N]:
Would you like to create ROOT part? (Y/N) [N]:
Bosboot required (Y/N) [N]:
License agreement acceptance required (Y/N) [N]:
Include license files for pwrcmps.installp.example in this package (Y/N) [N]:
Do you want to specify Requisites using a file for this fileset? (Y/N) [N]:
Number of Requisites for pwrcmps.installp.example (1) [0]:
Number of filesystems requiring additional space for pwrcmps.installp.example [0]:

You should include any directories that you are creating in the file count.
(ie: For /usr/proj/myFile, enter 2; 1 for /usr/proj and 1 for /usr/proj/myFile)
Number of USR part files in pwrcmps.installp.example (1) [0]: 1
* 1 of 1. Directory or File Path (/usr/proj/myFile) []: /usr/local/bin/hello
Do you want to make this fileset relocatable? (Y/N) [N]:
Do you want to include an override inventory file for this fileset? (Y/N) [N]:
Do you want to add WPAR attributes to your fileset? (Y/N) [N]:


Using /export/src/installp/pwrcmps.installp.example/.info/pwrcmps.installp.template as the template file.
pwrcmps.installp 1.0.0.0 I
processing pwrcmps.installp.example
creating ./.info/liblpp.a
creating ./tmp/pwrcmps.installp.1.0.0.0.bff
#

Das fertige Endprodukt findet man im Unterverzeichnis tmp:

# ls –l tmp
total 8
-rw-r--r--    1 root     system         2560 Sep 25 09:49 pwrcmps.installp.1.0.0.0.bff
#

Beim Erzeugen des Paketes haben wir der Einfachheit wegen immer die Default-Werte bestätigt. Als Produkt-Namen haben wir pwrcmps.installp angegeben, und als Fileset-Namen pwrcmps.installp.example, jeweils mit der Version 1.0.0.0. Alle Dateien und Verzeichnisse des Pakets müssen explizit mit absolutem Pfad aufgelistet werden! Das kann bei einigen hundert Pfaden etwas unpraktikabel werden, lässt sich aber durch eigene Skripte vereinfachen und automatisieren.

Wir installieren das neu generierte Paket einmal, und überprüfen ob unser Shell-Skript auch installiert wird:

# installp -ad tmp/pwrcmps.installp.1.0.0.0.bff all
+-----------------------------------------------------------------------------+
                    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
  -----------------
  pwrcmps.installp.example 1.0.0.0            # Example Fileset

  << 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:
        pwrcmps.installp.example 1.0.0.0

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

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

Installation Summary
--------------------
Name                        Level           Part        Event       Result
-------------------------------------------------------------------------------
pwrcmps.installp.example    1.0.0.0         USR         APPLY       SUCCESS   
# which hello
/usr/local/bin/hello
# hello
hello world
#

Wir erweitern jetzt unser Skript und lassen die Meldung „hello world, how are you“ ausgeben.

# vi usr/local/bin/hello
…
print "hello world, how are you"
#

Das Paket soll nun neu gebaut werden, allerdings wollen wir die Version auf 1.1.0.0 erhöhen. Natürlich könnten wir das Kommando mkinstallp wieder interaktiv starten und alle notwendigen Informationen erneut eingeben, das ist aber sehr aufwändig und auch nicht notwendig. Das Kommando mkinstallp unterstützt die Angabe eines Template-Files mit allen notwendigen Informationen. Beim Bau der ersten Version unseres Paketes wurde ein solches Template-File unter .info/pwrcmps.installp.template generiert. Wir kopieren dieses Template-File direkt in das Buildroot-Directory und benennen es dabei um in template:

# cp .info/pwrcmps.installp.template template
# cat template
Package Name: pwrcmps.installp
Package VRMF: 1.0.0.0
Update: N
Fileset
  Fileset Name: pwrcmps.installp.example
  Fileset VRMF: 1.0.0.0
  Fileset Description: Example Fileset
  USRLIBLPPFiles
  EOUSRLIBLPPFiles
  Bosboot required: N
  License agreement acceptance required: N
  Include license files in this package: N
  Requisites:
  USRFiles
    /usr/local/bin/hello
  EOUSRFiles
  ROOT Part: N
  ROOTFiles
  EOROOTFiles
  Relocatable: N
EOFileset
#

Das Template-File enthält die von uns interaktiv gemachten Angaben. Wir ändern in diesem Template-File die Versions-Nummer von 1.0.0.0 auf 1.1.0.0:

# vi template
…
Package VRMF: 1.1.0.0
…
  Fileset VRMF: 1.1.0.0
…
#

Wir versuchen nun die Version 1.1.0.0 zu bauen, indem wir mkinstallp mit der Option –T (für Template) und dem Template-File template starten:

# mkinstallp -T template
Using /export/src/installp/pwrcmps.installp.example as the base package directory.
Using /export/src/installp/pwrcmps.installp.example/.info to store package control files.
Cleaning intermediate files from /export/src/installp/pwrcmps.installp.example/.info.
0503-844 mkinstallp: Cannot overwrite existing
        /export/src/installp/pwrcmps.installp.example/.info/pwrcmps.installp.template file.
#

Es kommt eine Fehlermeldung, das Template-File unter .info kann nicht überschrieben werden. Das .info-Verzeichnis wird beim Build-Prozess immer wieder neu angelegt und kann daher einfach gelöscht werden, bevor der nächste Build-Prozeß gestartet wird:

# rm -rf .info
# mkinstallp -T template
Using /export/src/installp/pwrcmps.installp.example as the base package directory.
Cannot find /export/src/installp/pwrcmps.installp.example/.info. Attempting to create.
Using /export/src/installp/pwrcmps.installp.example/.info to store package control files.
Cleaning intermediate files from /export/src/installp/pwrcmps.installp.example/.info.

Using template as the template file.
0503-880 mkinstallp: This file /usr/local/bin/hello
        already exists as a system file.
pwrcmps.installp 1.1.0.0 I
processing pwrcmps.installp.example
creating ./.info/liblpp.a
creating ./tmp/pwrcmps.installp.1.1.0.0.bff
#

Die neue Version des Paketes ist wie gehabt unter tmp zu finden:

# ls -l tmp
total 16
-rw-r--r--    1 root     system         2560 Sep 25 10:08 pwrcmps.installp.1.0.0.0.bff
-rw-r--r--    1 root     system         2560 Sep 25 10:35 pwrcmps.installp.1.1.0.0.bff
#

Auf diese Weise lassen sich leicht Änderungen vornehmen und dann anschließend paketieren.