Summary
This is a practical description showing how to use Sun Solaris
Application Packaging. The sample files and the explanations gives all developers the
possibility to easy take-off with Application Packaging and to adopt the samples to
theirs own needs. The chosen package and file names are specified either by Sun or
Akadia.
Every developer has to prepare and maintain its own installation
scripts for the initial and further releases. Application changes may require changes in
installation scripts and the set of to be installed files. Thus Application Packaging is
an ongoing task for every developer.
The explanations reflect the actual level of knowledge we have about
Application Packaging and may be improved and extended by everybody during implementation
where we gather more experience. Comments are always welcome.
Scope
These explanations are based on a sample DEMO package and help
to quickly start with Application Packing. It is not a full description and does not
cover all required aspects. For details see Sun's Application Packaging Developer's
Guide
Application software is delivered in units called packages. A package
is a collection of files and directories required for a software product, and is usually
designed and built by the application developer after completing the development of the
application code. A software product needs to be built into one or more packages so that
it can easily be transferred to a distribution medium, be mass produced, and installed by
administrators.
Required Steps
Check out and prepare your application run-time files in a directory.
Files must already be compiled. Creating a package does not include automated activities
at the time of package creation but at the time of package installation. We can only
specify a set of files to be packaged. This is an important difference. Packaging deals
with installation activities on the target system like copying files, changing
permissions or executing specific installation tasks. Of course, you may build shell
scripts which do compilation steps for you prior building a package.
Along with your application files you need some packaging files
controlling the package creation and installation process. Most of these files are
static, can be written once and afterwards used by all your releases and shipments. The
only non-static one is called prototype.
After you can make a package using the command: pkgmk
To ship your package to a tape or tar file you may use:
pkgtrans
Package Files
The sample package is called SCPdemo. All application files are in
a sub-directory called SCPdemo too. Files controlling the packaging process stay on top of
our structure:
-rw-r--r-- 1 steiner
dba 404 Aug 21 15:20 checkinstall
-rw-r--r-- 1 steiner
dba 174 Aug 21 11:01 copyright
-rw-r--r-- 1 steiner
dba 591 Aug 21 15:24 i.sql
-rw-r--r-- 1 steiner
dba 145 Aug 21 15:26 pkginfo
-rw-r--r-- 1 steiner
dba 485 Aug 21 14:09 prototype
-rw-r--r-- 1 steiner
dba 564 Aug 21 15:25 r.sql
-rwxr-xr-x 1 steiner
dba 718 Aug 21 15:24 request
drwxr-xr-x 8 steiner
dba 512 Aug 21 10:44
SCPdemo
./SCPdemo:
drwxr-xr-x 2 steiner
dba 512 Aug 21 10:39 bin
drwxr-xr-x 2 steiner
dba 512 Aug 21 10:44 ctl
drwxr-xr-x 2 steiner
dba 512 Aug 21 10:46 doc
drwxr-xr-x 2 steiner
dba 512 Aug 21 10:37 java
drwxr-xr-x 2 steiner
dba 512 Aug 21 14:06 plsql
drwxr-xr-x 2 steiner
dba 512 Aug 21 10:44 sql
./SCPdemo/bin:
-rw-r--r-- 1 steiner
dba 24 Aug 10 14:15
sample.ksh
./SCPdemo/ctl:
-rw-r--r-- 1 steiner
dba 792 Aug 21 10:44 hlr.ctl
./SCPdemo/doc:
-rw-r--r-- 1 steiner dba 225792 Aug
21 10:46 DEMO_APPDES.doc
./SCPdemo/java:
-rw-r--r-- 1 steiner
dba 460 Aug 21 10:37 Sample.class
-rw-r--r-- 1 steiner
dba 222 Aug 21 10:37 Sample.java
./SCPdemo/plsql:
./SCPdemo/sql:
-rw-r--r-- 1 steiner
dba 199 Aug 9 16:46
create.sql
-rw-r--r-- 1 steiner
dba 197 Aug 10 13:20 drop.sql
Package installation must be done by super-user root. Usually
root does not have the environment set in a way we could use it for our application. For
instance during installation we like to connect to a database, but we cannot access it
due to missing settings.
There will be cases in which the classes concept cannot be used and a
simple installation script is required. Such a installation script can be executed after
package installation by any suitable user.
Static Packaging Files
These are the static files required to control the package
installation. The names are fix and cannot be changed. See sample files for content.
General information about the package like name, vendor etc:
Holds a copyright message displayed during installation.
Asks for information form the administrator installing the package.
Different examples are implemented:
Checks the environment, no user interaction allowed here. For user
interaction use the request script:
Class file to install SQL files:
Class file to remove SQL files:
Prototype File
At the begin of the prototype file we list all the static control files
we may like to include in the package. Afterwards a list of all application files follow.
This is the reason why the prototype file cannot be static. If we change the application
the required files may change too.
We can generate the prototype file like this (\n is the newline
character):
$ echo "i pkginfo\ni copyright\ni request\ni checkinstall\ni
i.sql\ni r.sql" > prototype
$ pkgproto ./SCPdemo >> prototype
For our purposes the prototype file is not yet correct. We may like to
change the following:
$ sed '/.java/d' prototype > prototype.tmp $ sed
'/.ksh/s/0[0-7][0-7][0-7]/0755/' prototype.tmp >
prototype $ sed 's/steiner dba/root other/' prototype >
prototype.tmp $ sed '/.sql/s/none/sql/' prototype.tmp > prototype $
rm *.tmp
Here a sample how the prototype file can look like:
i pkginfo
i copyright
i request
i checkinstall
i i.sql
i r.sql
d none SCPdemo 0755 root other
d none SCPdemo/bin 0755 root other
f none SCPdemo/bin/sample.ksh 0755 root other
d none SCPdemo/ctl 0755 root other
f none SCPdemo/ctl/hlr.ctl 0644 root other
d none SCPdemo/doc 0755 root other
f none SCPdemo/doc/DEMO_APPDES.doc 0644 root other
d sql SCPdemo/plsql 0755 root other
d sql SCPdemo/sql 0755 root other
f sql SCPdemo/sql/create.sql 0644 root other
f sql SCPdemo/sql/drop.sql 0644 root other
Make
Now we are ready to create the package. As <package
directory> pass the absolute path to the static package files. Additionally we
pass the version name and a production stamp. In this sample the production stamp
includes the date of shipment creation and the tag or label the sources have been frozen
in a source management system.
The created package is stored by default in /var/spool/pkg
$ pkgmk -o -b /export/home/scpdemo -v "release 1.0"
-p "21 Aug 2001, rel-1-0-20010821"
## Building pkgmap from package prototype file.
## Processing pkginfo file.
## Attempting to volumize 11 entries in pkgmap.
part 1 -- 504 blocks, 19 entries
## Packaging one part.
/var/spool/pkg/SCPdemo/pkgmap
/var/spool/pkg/SCPdemo/pkginfo
/var/spool/pkg/SCPdemo/reloc/SCPdemo/bin/sample.ksh
/var/spool/pkg/SCPdemo/reloc/SCPdemo/ctl/hlr.ctl
/var/spool/pkg/SCPdemo/reloc/SCPdemo/doc/DEMO_APPDES.doc
/var/spool/pkg/SCPdemo/reloc/SCPdemo/sql/create.sql
/var/spool/pkg/SCPdemo/reloc/SCPdemo/sql/drop.sql
/var/spool/pkg/SCPdemo/install/checkinstall
/var/spool/pkg/SCPdemo/install/copyright
/var/spool/pkg/SCPdemo/install/i.sql
/var/spool/pkg/SCPdemo/install/r.sql
/var/spool/pkg/SCPdemo/install/request
## Validating control scripts.
## Packaging complete.
All the following installation and de-installation operations must
be performed as super-user: root.
Add
To test your package you need neither a shipment nor a tar file. You
can directly install it on the same machine you created it. The temporary default
directory /var/spool/pkg will be used to get the files from.
$ su - # pkgadd SCPdemo
Processing package instance <SCPdemo> from
</var/spool/pkg>
Sample package for AKADIA DEMO installation
(sparc) release 1.0
Copyright (c) 2001 Akadia Ltd All Rights Reserved
This product is protected by copyright and distributed under
licenses restricting copying, distribution and
decompilation.
Starting script "request" with parameter
"/tmp/installd7aam2/respe7aam2"
Press any key to start installation, C to cancel:
Enter installation directory (Press Return key for
"/usr/local"):
## Executing checkinstall script.
Starting script "checkinstall" with parameter
"/tmp/installd7aam2/respe7aam2"
The selected base directory </usr/local> must exist
before installation is attempted.
Do you want this directory created now [y,n,?,q] y
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.
This package contains scripts which will be executed
with super-user permission during the process of
installing this package.
Do you want to continue with the installation of
<SCPdemo> [y,n,?] y
Installing Sample package for AKADIA DEMO installation
as <SCPdemo>
## Installing part 1 of 1.
/usr/local/SCPdemo/bin/sample.ksh
/usr/local/SCPdemo/ctl/hlr.ctl
/usr/local/SCPdemo/doc/DEMO_APPDES.doc
[ verifying class <none> ]
Starting script "i.sql" for package SCPdemo with
parameter "ENDOFCLASS"
cp /var/spool/pkg/SCPdemo/reloc/SCPdemo/sql/create.sql
/usr/local/SCPdemo/sql/create.sql
Lists /usr/local/SCPdemo/sql/create.sql...
PROMPT
============================================================
PROMPT This is a SQL script installing objects in a database
PROMPT
============================================================
EXIT;
cp /var/spool/pkg/SCPdemo/reloc/SCPdemo/sql/drop.sql
/usr/local/SCPdemo/sql/drop.sql
Lists /usr/local/SCPdemo/sql/drop.sql...
PROMPT
==========================================================
PROMPT This is a SQL script dropping objects in a database
PROMPT
==========================================================
EXIT;
[ verifying class <sql> ]
Installation of <SCPdemo> was successful.
Don't forget that you have to test not only the package installation
but also the package removal.
Remove
You may remove a package like this:
# pkgrm SCPdemo
The following package is currently installed:
SCPdemo Sample package for AKADIA DEMO installation
(sparc) release 1.0
Do you want to remove this package? y
## Removing installed package instance <SCPdemo>
This package contains scripts which will be executed with
super-user permission during the process of removing this
package.
Do you want to continue with the removal of this
package [y,n,?,q] y
## Verifying package dependencies.
## Processing package information.
## Removing pathnames in class <sql>
Starting script "r.sql" for package SCPdemo with
parameter ""
Lists /usr/local/SCPdemo/sql/drop.sql...
PROMPT
============================================================
PROMPT This is a SQL script dropping objects in a database
PROMPT
============================================================
EXIT;
rm /usr/local/SCPdemo/sql/drop.sql
Lists /usr/local/SCPdemo/sql/create.sql...
PROMPT
===========================================================
PROMPT This is a SQL script installing objects in a database
PROMPT
============================================================
EXIT;
rm /usr/local/SCPdemo/sql/create.sql
## Removing pathnames in class <none>
/usr/local/SCPdemo/doc/DEMO_APPDES.doc
/usr/local/SCPdemo/doc
/usr/local/SCPdemo/ctl/hlr.ctl
/usr/local/SCPdemo/ctl
/usr/local/SCPdemo/bin/sample.ksh
/usr/local/SCPdemo/bin
/usr/local/SCPdemo
## Updating system information.
Removal of <SCPdemo> was successful.
If the removal fails due to incorrect files, correct the files and
install the package again. Afterwards you can try to remove it again.
There are a couple of commands that may be used for package
verification and to retrieve information from installed packages. Play around with them
and see Solaris' man pages for pademoeters and descriptions.
# pkgchk -v SCPdemo
/usr/local/SCPdemo
/usr/local/SCPdemo/bin
/usr/local/SCPdemo/bin/sample.ksh
/usr/local/SCPdemo/ctl
/usr/local/SCPdemo/ctl/hlr.ctl
/usr/local/SCPdemo/doc
/usr/local/SCPdemo/doc/DEMO_APPDES.doc
/usr/local/SCPdemo/plsql
/usr/local/SCPdemo/sql
/usr/local/SCPdemo/sql/create.sql
/usr/local/SCPdemo/sql/drop.sql
# pkginfo -l SCPdemo
PKGINST: SCPdemo
NAME: Sample package for AKADIA DEMO
installation
CATEGORY: application
ARCH: sparc
VERSION: release 1.0
BASEDIR: /usr/local
VENDOR: Akadia Ltd
PSTAMP: 21 Aug 2001, rel-1-0-20010821
INSTDATE: Aug 25 2001 13:45
STATUS: completely installed
FILES: 11 installed pathnames
6 directories
1 executables
446
blocks used (approx)
# pkginfo -x SCPdemo
SCPdemo Sample package for AKADIA DEMO installation
(sparc) release 1.0
# pkgparam -v SCPdemo
CLASSES='none sql'
BASEDIR='/usr/local'
TZ='MET'
PATH='/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin'
OAMBASE='/usr/sadm/sysadm'
VERSION='release 1.0'
PSTAMP='21 Aug 2001, rel-1-0-20010821'
PKG='SCPdemo'
NAME='Sample package for AKADIA DEMO installation'
ARCH='sparc'
CATEGORY='application'
VENDOR='Akadia Ltd'
PKGINST='SCPdemo'
PKGSAV='/var/sadm/pkg/SCPdemo/save'
INSTDATE='Aug 25 2001 13:45'
Transfer
Before creating a tar file you must transfer your package form the
temporary default location to a tape or into a shipment directory. We don't need to be
super-user to do this. In the shipment directory you my create a tar file. As <
shipment directory> pass the absolute path to your directory.
$ pkgtrans -o /var/spool/pkg /export/home/scpdemo SCPdemo
Transferring <SCPdemo> package instance
$ cd /export/home/scpdemo
$ tar -cvf SCPdemo_1_0.tar ./*
$ gzip SCPdemo_1_0.tar
Installation
For the following installation we must be again super-user.
After generating the tar file we can use it for installation. In this
sample we move it to a temporary directory and unpack it:
# mv SCPdemo_1_0.tar.gz ../tmp # cd /tmp
# gunzip SCPdemo_1_0.tar.gz
# tar -xvf SCPdemo_1_0.tar
Package installation from the current working directory (/tmp)
# pkgadd -d . SCPdemo
Install New Package
To install a newer version without removing an older one, chose
different package names, e.g. SCPdemo10, SCPdemo11 etc. It is not possible to have more
than one version from the same package installed within the same or even different
directories at the same time.
Remove older package version before installing a new one with the
same name. By default the package installer does not allow overwriting an older
version. It does only allow to overwrite the same version again to fix damaged
installations.
To install a package with the same name but with a newer version, the
configuration file for administration purposes must be appropriate. The default file is
/var/sadm/install/admin/default and should be copied prior modification:
mail=
instance=unique
partial=ask
runlevel=ask
idepend=ask
rdepend=ask
space=ask
setuid=ask
conflict=ask
action=ask
basedir=default
The parameter "instance" must be set to "ask":
instance=ask
Pass the new configuration file, e.g. admin while adding the
new package:
# cd /export/home/scpdemo # pkgadd -a admin
SCPdemo
Overwrite Existing Package
The package installer informs if a package with the same name and
version is installed again. If the user decides to continue, missing files are added
and existing ones are overwritten. This can be used to fix a corrupt installation.
Technically this could be used to patch an installation with modified
files too. However, nobody can recognise the installed patch after installation.
As mentioned before, the package installer informs if a package with
the same version is installed again. If the user decides to continue, missing files are
added and existing ones are overwritten.
We introduce a variable called PATCH to make the difference visible.
With the use of a PATCH variable we can later identify which patch is installed.
$ pkgmk -o -b /export/home/scpdemo -v "release
1.0" -p "21 Aug 2001, rel-1-0-1-20010821"
PATCH="patch 1.0.1"
After installation we can get the version and patch:
$ pkgparam -v SCPdemo
CLASSES='none sql'
BASEDIR='/usr/local'
TZ='MET'
PATH='/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin'
OAMBASE='/usr/sadm/sysadm'
VERSION='release 1.0'
PSTAMP='21 Aug 2001, rel-1-0-1-20010821'
PKG='SCPdemo'
NAME='Sample package for AKADIA DEMO installation'
ARCH='sparc'
CATEGORY='application'
VENDOR='Akadia Ltd'
PATCH='patch 1.0.1'
PKGINST='SCPdemo'
PKGSAV='/var/sadm/pkg/SCPdemo/save'
INSTDATE='Aug 25 2001 14:18'
Download the Demo
Examples as tar.gz
|