From bfr7kq6 Thu Oct 26 17:32:17 1995
Return-Path: 
Received: by is000913.BELL-ATL.COM (4.1/SMI-4.1)
	id AA23589; Thu, 26 Oct 95 17:32:14 EDT
From: bfr7kq6 (Boss)
Message-Id: <9510262132.AA23589@is000913.BELL-ATL.COM>
Subject: Re: package under Solaris2.X
To: simdro@sisca.qc.ca
Date: Thu, 26 Oct 1995 17:32:12 -0400 (EDT)
In-Reply-To: <199510261258.IAA21864@Sisca.qc.ca> from "Simon-Bernard Drolet" at Oct 26, 95 08:58:54 am
X-Mailer: ELM [version 2.4 PL23]
Content-Type: text
Content-Length: 7953      
Status: RO

> I would like to know what are the different step to create
> a package under Solaris 2.X. We would like to use it
> to install and distribute our products.
> 
> Is there a software somewhere that can help us achieve this
> goal ?
> 
> I will summarize.

I don't know of any automated tools to make packages...its a
pretty manual process.  To distribute, we use rdist from a 
main repository server to our client servers...rdist is 
capable of running through cron and is capable of running
install scripts at the remote site...we rdist a package of
a script and a datastream package, then execute the distributed
script, which basically says "pkgadd -d ./"
or something...fast and easy.

How to make a package?  Its not easy...

First thing for you to do is read through the Solaris 2.x manual
"Developers Guide to Application Packaging."  This is the Solaris
doc that explains all the different scripts associated with 
packaging.

I'll describe the files I typically use when making a package.
Best thing to do is, get a copy of someone's package creation
scripts and substitute for your stuff....else you'll go crazy
trying to do everything from scratch.  I'll include you copies of
information for packages we have internal; but i'd appreciate 
it if you did not broadcast these examples everywhere.

all these files i'll describe get put in a directory, and this
directory serves as the home for the packaging.  You can use
your home directory if you wish...since packages get created
with relative directory paths; you populate the absolute path
name when creating the prototype file...you'll see.

Lets say I wanted to package up the gzip utils for distribution...
# ls -l
total 454
   2 drwxr-xr-x   5 root     other        512 Oct  3 04:44 .
   2 drwxrwxrwx   8 bfr7kq6  osis        1024 Aug 11 16:11 ..
   2 drwxr-xr-x   4 root     other        512 Dec 29  1994 BAgzip
 416 -rw-r--r--   1 root     other     200761 Dec 29  1994 BAgzip.ds_1.2.4.BA1.0.Z
   2 -rwxr-xr-x   1 root     other         42 Dec 29  1994 copyright
   1 -rw-r--r--   1 root     other         11 Jan 21  1994 depend
   2 -rwxr-xr-x   1 root     other        736 Dec 29  1994 make_pkg
   2 -rwxr-xr-x   1 root     other        602 Dec 29  1994 make_proto
   2 drwxr-xr-x   3 root     other        512 Dec 29  1994 opt
   2 -rwxr-xr-x   1 root     other        237 Dec 29  1994 pkginfo
   8 -rwxr-xr-x   1 root     other       3658 Dec 29  1994 postinstall
   1 -rwxr-xr-x   1 root     other        466 Aug 10  1994 preinstall
   6 -rwxr-xr-x   1 root     other       2855 Dec 29  1994 prototype
   2 -rwxr-xr-x   1 root     other         32 Dec 29  1994 prototype.additions
   2 -rwxr-xr-x   1 root     other        872 Dec 29  1994 request
   2 drwxr-xr-x   3 root     other        512 Dec 29  1994 usr

(BAgzip is the directory that pkgmk creates halfway during the 
package creation process.  The BAgzip.ds_1.2.4.BA1.0.Z is the
actual datastream file (the actual isntallable final file.  
make_pkg and make_proto are two scripts I use to help make
packages and prototype.additions i'll explain.  opt and usr
are the feed directories...they will point at an absolute
directory path later.  All others are standard pkg control 
files i'll explain).

copyright
Just a simple copyright statement: ours reads
Copyright 1995 Bell Atlantic Corporation

depend
the depend file tells the pkg utiltities what other packages
are required before installing your particular package:
example:
P BAbasenv

pkginfo
This has information about the package that gets put into the
/var/sadm/pkg/ directory once a package has been 
installed.  It serves as a good documentation source for 
users who have problems w/ the package.
example
PKG=BAgzip
NAME=Gnu-zip Utilities
VERSION=1.0
ARCH=SPARC_Sol_2.3
CATEGORY=application
CLASSES=none 
BASEDIR=/BA
DESC=Gnu-zip Utilities
VENDOR=OSIS
HOTLINE=Todd Boss (301) 989-6896
EMAIL=bfr7kq6@bell-atl.com
ISTATES=3
RSTATES=3
MAXINST=1

(the different variables are pretty self explanitory; istates means 
the run levels the machine has to be in to install the package (pkgadd)
and rstates similarly is the run levels required to remove the package
(pkgrm).  maxinst is the maximum number of times you can isntall the
package on one machine.

prototype
This is the file that the pkg utiltities use to know where the
files are that you want included in the distribution.  You generate
the prototype file with the pkgproto command.  I use a script to
automate it, because there are certain files that have to be added
to the prototype file by hand before it will successfully make a
package.  Hence the need for the prototype.additions file, which
contains for example:
i pkginfo
i depend
i request
i copyright
i preinstall
i postinstall


preinstall
postinstall
preremove
postremove
These are self-explanitory shell scripts designed to perform actions
before the files are laid down, after they are laid down, before
they are removed, and after they are removed.

i.
r.
You have the ability to assign files to "classes" and then perform
actions on just classes of files...we don't really use these much
because it just confuses the process, but the ability is there.  
I'd read about it if you wish.  There are also plenty of other
weird stuff you can do...im giving a pretty simple example fo stuff.

---
Steps to make the package:
-Get all the files into the relative directory structure that you
want them to go into...for example, if you are installing something
into /usr/local/bin then your relative directory is usr underneath
your working directory (as demonstrated with usr and opt above).
- Figure out all the stuff that you need to do before you would
install this package (get backup copies of files, edit configs, etc)
Do this in the shell script "preinstall"
- Figure out all the stuff that needs to occur once this package has
been isntalled (daemons started, files edited, crons created etc).
Automate all this in "postinstall"
- Create the pkginfo, request, depend, and copyright files.  Create 
a file called "prototype.additions" (note: this is not a standard
pkg file...just an easy way to keep track of the files pkgproto 
does not add to the generated prototype file).
Example prototype.additions file:
i pkginfo
i depend
i request
i copyright
i preinstall
i postinstall
- Make the prototype file: i run a script called make_proto that looks 
like this:
#!/bin/sh
rm -f prototype
cp prototype.additions prototype
pkgproto usr=/usr opt=/opt >> prototype
- make the package: i run another script called make_pkg...here it is:
#!/bin/sh
rm -rf BAgzip
rm BAgzip.ds_1.2.4.BA1.0*
pkgmk -r /home/bfr7kq6/gzip -d /home/bfr7kq6/gzip
pkgtrans -s /home/bfr7kq6/gzip /home/bfr7kq6/gzip/BAgzip.ds BAgzip
mv BAgzip.ds BAgzip.ds_1.2.4.BA1.0
compress -v BAgzip.ds_1.2.4.BA1.0

(I remove the old output directory BAgzip, then I remove the old 
datastream file, then i run pkgmk on my working directory
/home/bfr7kq6/gzip (this makes the BAgzip directory with all the
files in it ready to go), then i run pkgtrans from the working 
directory to the datastream file using the BAgzip package
instance, then I move the datastream file into our standard
naming scheme (pkgname.ds_.BA
and finally i compress the output of all this.

===

whew!  I think this is it.  Once you get the hang of this, you'll
love it.  It does take some getting used to though.

email me your summary, if anyone else sends you anything (or don't worry
about it if you are going to send it to the whole list).  I'm always
interested in learning more about packaging.

todd boss

-----
 ____    _     |  Todd Boss; Unix Systems Analyst| Todd.E.Boss@Bell-Atl.Com
| .  >  /.\    |  OSIS - Info Sys - Bell Atlantic| (301) 989-6896 (W)
| . <  /   \   |  13101 Columbia Pike, Rm. 209B  | (301) 236-8021/8274 (Fax)
|____><_/^\_>  |  Silver Spring, MD 20904        | (301) 629-4682 (Pager)