Tuesday, April 21, 2009

Create Solaris Package

Creating a Solaris package organizes the required software/packages. This greatly decreases the time needed to add software to a host.

Creation of the software

To package any software you need to know which files are to be included in the package which is easy if you created the software. Since in our application this will generally be the case, it will be covered by this blog.

1. Complete the following step, replacing "YOUR_DIR" with the directory that contains the software that you want to install:


% cd /YOUR_DIR
% find . -print sed 's/^\.//g' > /tmp/files



2. Create a prototype file to uses with your package. This file contains a table of contents suitable to be used by the package creation tool.


% cat /tmp/files l pkgproto > /tmp/Prototype



This will take the /tmp/files file and with each entry it will look at the file and it's attributes and then create a /tmp/Prototype file with the following in it:


d none /dir1 0755 actraadm actra
f none /script1.sh 0755 actraadm actra
f none /dir1/readme 0644 actraadm actra



The character in for of the line depicts which type of item is being created.

'i' means it's an informational or control file for the package subsystem.
'd' means the file in question is a directory.
'f' means the file is a regular file.

After manually reviewing the /tmp/Prototype file you may notice the permissions are not to your liking. The Prototype file can be edited by hand to change the owner, group or file permissions.

3. Add an entry to the Prototype file for the "pkginfo" file. This file contains a lot of the details about the package including who made it and how to install it. Add the following line to the TOP of the Prototype file.


i pkginfo


If you want a checkinstall, preinstall, postinstall or postremove script to run on installation of the package simply include them at the top of the prototype file after the pkginfo line. Make sure to prefix the line with the

'i'

A checkinstall is a script that is run at install time, by the user "nobody". With it you can check for dependancies and problems and if needed, exit the pkgadd gracefully.

preinstall is run as root when the package is being installed An abort here will require the user to pkgrm the half installed package. You are asked by pkgadd if you want to run this script.

postinstall is a script that runs after the rest of the package has been installed, as the root user. With it you can do tasks like startup the software you just installed.

postremove is a script that runs after the package has been removed from the system as root. It can be used for additional clean up steps which may need to be run after the package is removed.

To add them to the Prototype file put in a line like:


i postinstall
i postremove

Finally our Prototype file looks like:


i pkginfo
i postinstall
d none /dir1 0755 actraadm actra
f none
/script1.sh 0755 actraadm actra
f none /dir1/readme 0644 actraadm actra


See the prototype man page for further information on this file (man -s 4 prototype).

4. Create a pkginfo file in the /YOUR_DIR directory. The pkginfo file tells pkgmk what you actually want the package to be called. Here is an example of a pkginfo file, see the pkginfo man page for more details (man -s 4 pkginfo):


PKG="MIKESPKG"
NAME="Mikes test package"
VERSION="1.0"
ARCH="sparc"
CLASSES="none"
CATEGORY="utility"
VENDOR="WPS"
PSTAMP="4thOct2002"
EMAIL="support@yourdomain.com"
BASEDIR="/YOUR_DIR"

5. Create the package.


% pkgmk -o -r /YOUR_DIR -d /tmp

The above command means make the package, overwrite any previous attempts (-o), use '/YOUR_DIR' as the root directory for locating the files (-r) and build the package in the /tmp directory (-d)

The output produced was:


## Processing pkginfo file.
## Attempting to volumize 5 entries in pkgmap.
part 1 -- 990 blocks, 6 entries
## Packaging one part.
/tmp/pkginfo
/tmp/postinstall
/tmp/dir1
/tmp/script1.sh
/tmp/dir1/readme
## Packaging complete.

This command created a directory in /tmp called MIKESPKG. Inside that directory were two files called pkgmap and pkginfo. This is your completed package.

6. To allow easy storage and transportation of this package all you need to do is run the pkgtrans command to make a single archive of the package.


%pkgtrans -s /tmp/ /tmp/MIKESPKG.pkg

This command searches the /tmp for packages (-s) and any packages which you decided to include will be added to the file /tmp/MIKESPKG.pkg.

Readers who read this page, also read:




Bookmark and Share My Zimbio http://www.wikio.com

0 comments: