[Index] [About]  
Author Simes
Created:  2005-11-18
Last changed:  2005-11-18
[Root]  [Prev] [Idx] [Next] http://www.bpfh.net/computing/software/pkg-tools/example/openssh.html 

Building openssh

Building the OpenSSH package is a relatively complex job. The following details how it can be done.

It should be noted that this example was prepared using


Building OpenSSH

Actually building OpenSSH is simple; I just used the following:

+-------------

% ./configure
% make

+-------------

The above does assume that you want OpenSSH installed in its default location and that you have various supporting systems like OpenSSL installed in their default locations; i.e. under the /usr/local tree.


Initial packaging

Once the actual software is ready we can start the work required to package it for installation. In doing this we will run build-pkg twice and make changes to the package in between runs.

To create the initial package we run the following:

+-------------

% build-pkg make install-nokeys

+-------------

After we answer a number of questions about the package, this builds a package and places it in the directory InstallPackage. We ignore this package; we only ran build-pkg so that the InstallPackage/build directory would be populated with the OpenSSH installation.


Package control scripts

The first thing we do is prepare a number of package control scripts and files. These include the following which are placed in the InstallPackage directory.

depend - place a dependancy on other packages

This is a simple file (see depend(4) for details) which lists any packages, patches, etc the package may depend on or conflicts with. In this case it contains:

+-------------

P OpenSSL SSL access libraries
P PRNGD Pseudo Random Number Generator Daemon
I SUNWsshu Sun supplied SSH daemon
I SUNWsshdu Sun supplied SSH daemon

+-------------

The "P" refers to a package which is a pre-condition of installation; i.e the packages OpenSSL and PRNGD have to exist for the package to be installed. By using this you also ensure that if someone tries to remove one of the packages this package depends on they will get a warning to that effect.

The "I" refers to a package which conflicts with the package; i.e. that package should not be installed for the successful addition of the package. In this case we have the package installation fail if the Sun provided SSH daemon is present on the system; this is the case if you are running Solaris 9.

A copy of this file is available here: depend.

postinstall - Script run after package installation

This script is run after package installation and will do the following tasks:

A copy of this script is available here: postinstall.

preremove - Script run before package removal

This script is run before a package is removed from the system via pkgrm. The only action this script performs is to stop the sshd if it is running by running:

/usr/local/startup/openssh stop

A copy of this script is available here: preremove.

postremove - Script run after package removal

This script is run after a package has been removed from the system via pkgrm. This script performs the following actions:

Note that this script does not remove the host keys for the machine or the configuration files held under /usr/local/etc. This is mainly due to the way I deal with upgrading software. First I pkgrm the old version and then pkgadd the new version. As a result I'll often want to leave the configuration files for the package in place.

A copy of this script is available here: postremove.


Work within InstallPackage/build

The following is work done within the InstallPackage/build tree which is where the OpenSSH installation has been placed. By manipulating the contents of this tree and running build-pkg again you can easily effect the contents of the package.

The following assumes that you are in the openssh-3.4p1 directory and that you have a suitable startup/shutdown script for Solaris called openssh.rc in this directory.

A copy of this script is available here: openssh.rc.

The work done is as follows:

The code to do this is as follows. You will need to run the following commands as the root user. The command prompt (i.e. a #) which would normally be prepended to the below has been removed to aid in cut&paste operations.

+-------------

umask 022
(cd InstallPackage/build/usr/local/etc ; mv sshd_config sshd_config.sample)
(cd InstallPackage/build/usr/local/etc ; mv ssh_config ssh_config.sample)
chown root:sys InstallPackage/build/var/empty
chmod 0755 InstallPackage/build/var/empty
mkdir InstallPackage/build/usr/local/startup
cp openssh.rc InstallPackage/build/usr/local/startup/openssh
chmod 755 InstallPackage/build/usr/local/startup/openssh
mkdir -p InstallPackage/build/etc/rc0.d
mkdir -p InstallPackage/build/etc/rc3.d
ln -s /usr/local/startup/openssh InstallPackage/build/etc/rc0.d/K01openssh
ln -s /usr/local/startup/openssh InstallPackage/build/etc/rc3.d/S20openssh

+-------------


Final package creation

The final package is ready for creation; this can be done by running the following command:

+-------------

build-pkg

+-------------

And the OpenSSH package will be available in the directory InstallPackage.

[Root]  [Prev] [Idx] [Next] http://www.bpfh.net/computing/software/pkg-tools/example/openssh.html 
 [Index] [About] Powered by WML
Author Simes
Created:  2005-11-18
Last changed:  2005-11-18
 
More by the same author Comments? EMail webmaster@bpfh.net
 
© Simes