phiral.net
Home

To create the package, we need to know where the master copy of the scripts 
that make up the package are located and we need to create a work directory
to use while we actually create the package. We will create them under the
directory /export/master/fakepkg with the same directory structure they will
have when they are installed.

Create the work directory, and the reloc directory.

root@solaris {/} cd /export
root@solaris {/export} mkdir -p pkgdir/work
root@solaris {/export} cd pkgdir/work
root@solaris {/export/pkgdir/work} mkdir reloc
root@solaris {/export/pkgdir/work} ls -l
total 2
drwxr-xr-x   2 root     root         512 Sep 29 19:06 reloc
root@solaris {/export/pkgdir/work}

Create the pkginfo file in the work directory.

root@solaris {/export/pkgdir/work} cat pkginfo
PKG=TELWutils
NAME=Fake package
ARCH=sparc
VERSION=1.0.0.0
MAXINST=2
CATEGORY=application
DESC=Fake package so I remember hwo to create packages
VENDOR=phiral.net
HOTLINE=please call rtfm
EMAIL=lhall@domain.com
CLASSES=none
BASEDIR=/usr/local/fakepkg
root@solaris {/export/pkgdir/work}

The pkgmap file will be done in stages using some Solaris utils.

First make the directories we want, then put some files in there
just so we have something to install.

root@solaris {/export/master/fakepkg} mkdir bin lib logs
root@solaris {/export/master/fakepkg} cd bin
root@solaris {/export/master/fakepkg/bin} cat > hello.c << EOF
> main(){
>    write(1, "Hello, World!\n", 14);
>    exit(0);
> }
> EOF
root@solaris {/export/master/fakepkg/bin} cat > goodbye.c << EOF
> main(){
>    write(1, "Goodbye, World!\n", 16);
>    exit(0);
> }
> EOF
root@solaris {/export/master/fakepkg/bin} gcc -gstabs hello.c -o hello
root@solaris {/export/master/fakepkg/bin} gcc -gstabs goodbye.c -o goodbye
root@solaris {/export/master/fakepkg/bin} rm hello.c goodbye.c
root@solaris {/export/master/fakepkg/bin} ./hello
Hello, World!
root@solaris {/export/master/fakepkg/bin} ./goodbye
Goodbye, World!
root@solaris {/export/master/fakepkg/bin}

So its a simple package, looks like:

root@solaris {/export/master/fakepkg} ls -R .
.:
bin   lib   logs

./bin:
goodbye  hello

./lib:

./logs:

root@solaris {/export/master/fakepkg}

Copy it all over.

root@solaris {/export/master/fakepkg} find .|cpio -pvd /export/pkgdir/work/reloc/
/export/pkgdir/work/reloc/.
/export/pkgdir/work/reloc/bin
/export/pkgdir/work/reloc/bin/hello
/export/pkgdir/work/reloc/bin/goodbye
/export/pkgdir/work/reloc/lib
/export/pkgdir/work/reloc/logs
32 blocks
root@solaris {/export/master/fakepkg}

Create the prototype file, which is an interim file to help create the pkgmap file.

root@solaris {/export/master/fakepkg} cd /export/pkgdir/work/
root@solaris {/export/pkgdir/work} ls
pkginfo  reloc
root@solaris {/export/pkgdir/work} pkgproto reloc=. >prototype
root@solaris {/export/pkgdir/work} cat prototype
d none bin 0755 root root
f none bin/hello=reloc/bin/hello 0755 root root
f none bin/goodbye=reloc/bin/goodbye 0755 root root
d none lib 0755 root root
d none logs 0755 root root
root@solaris {/export/pkgdir/work}

Add the line "i pkginfo=./pkginfo" to the file, and run pkgmk which will use 
the prototype file and the other files from the work directory to create the 
intial version of the package.

root@solaris {/export/pkgdir/work} echo "i pkginfo=./pkginfo" >> prototype
root@solaris {/export/pkgdir/work} cat prototype
d none bin 0755 root root
f none bin/hello=reloc/bin/hello 0755 root root
f none bin/goodbye=reloc/bin/goodbye 0755 root root
d none lib 0755 root root
d none logs 0755 root root
i pkginfo=./pkginfo
root@solaris {/export/pkgdir/work} pkgmk -d /export/pkgdir/ -f prototype
## Building pkgmap from package prototype file.
## Processing pkginfo file.
WARNING: parameter <PSTAMP> set to "solaris20050929191716"
## Attempting to volumize 5 entries in pkgmap.
part  1 -- 40 blocks, 8 entries
## Packaging one part.
/export/pkgdir/TELWutils/pkgmap
/export/pkgdir/TELWutils/pkginfo
/export/pkgdir/TELWutils/reloc/bin/goodbye
/export/pkgdir/TELWutils/reloc/bin/hello
## Validating control scripts.
## Packaging complete.
root@solaris {/export/pkgdir/work}

This created the basic package in /export/pkgdir/TELWutils, pkgmk looked into
the pkginfo file and created the directory with the same name as the package(PKG=).
The warning message is because we did not create a PSTAMP entry in the pkginfo file,
so pkgmk created one for us.

root@solaris {/export/pkgdir/work} cd ..
root@solaris {/export/pkgdir} ls
TELWutils  work
root@solaris {/export/pkgdir} rm -rf work/
root@solaris {/export/pkgdir} cd TELWutils/
root@solaris {/export/pkgdir/TELWutils} ls -l
total 6
-rw-r--r--   1 root     root         285 Sep 29 19:17 pkginfo
-rw-r--r--   1 root     root         239 Sep 29 19:17 pkgmap
drwxr-xr-x   3 root     root         512 Sep 29 19:17 reloc
root@solaris {/export/pkgdir/TELWutils} cat pkgmap
: 1 40
1 d none bin 0755 root root
1 f none bin/goodbye 0755 root root 7060 30303 1128035621
1 f none bin/hello 0755 root root 7044 28372 1128035621
1 d none lib 0755 root root
1 d none logs 0755 root root
1 i pkginfo 285 23503 1128035836

Create the install directory with the copyright file in it.

root@solaris {/export/pkgdir/TELWutils} mkdir install
root@solaris {/export/pkgdir/TELWutils} cd install/
root@solaris {/export/pkgdir/TELWutils/install} echo "This would be some lame copyright." > copyright
root@solaris {/export/pkgdir/TELWutils/install} ls
copyright

Almost done, but now we have to add this file and its checksum to pkgmap.

root@solaris {/export/pkgdir/TELWutils/install} sum *
3214 1 copyright
root@solaris {/export/pkgdir/TELWutils/install} cksum *
3337672447      35      copyright
root@solaris {/export/pkgdir/TELWutils/install} echo "1 i copyright 35 3214 3337672447" >> ../pkgmap

Create our package.

root@solaris {/export/pkgdir} pkgtrans . /export/pkgdir/tele.pkg TELWutils
Transferring <TELWutils> package instance

Magic times our package is created.

root@solaris {/export/pkgdir} ls -la
total 40
drwxr-xr-x   3 root     root         512 Sep 29 19:25 .
drwxr-xr-x   5 root     sys          512 Sep 29 19:08 ..
drwxr-xr-x   4 root     root         512 Sep 29 19:21 TELWutils
-rw-r--r--   1 root     root       17408 Sep 29 19:25 tele.pkg

root@solaris {/export/pkgdir}