ProFTPD pakage for opensolaris

In opensolaris there is no proftpd package, so I decide to build it and to make a pkg

First, you must decide how many packages you will need and what will be their names

the distributables names have the form:
<$PKG>-<$VERSION>--<$ARCH>-local[.tgz]



where local means that the package is installable on /opt or /usr/local
According to the solaris filesystem (man filesystem), add-on software could install files only on:
/opt/
/etc/opt/
/var/opt/
/var/svc/manifest
/var/tmp
/usr/local is not an SVR4 approved directory: /usr is availble only for Solaris bundled software; exceptionally, /usr/local could be a softlink to /opt/local
the usernames are limited to 8 characters.


In opensolaris the pkg have the name format XXXyyy, where XXX is the name of the of company and tge yyy is the name of the software.For example, SUNWpostgr-83-libs

So, let's start work on the proftpd pkg file.

Setup the directory structure in your home directory somethinglike this: ~/pkg/build/$PKG/{ControlFiles,Objects}

- $PKG is TSTproftpd

Copy the proftpd files structure in Objects directory

#pwd
#/root/pkg/build/TSTproftpd/Objects
root@freya:~/pkg/build/TSTproftpd/Objects# ls
_EXTRAS FAKE_ROOT


- FAKE_ROOT

-- contain the TSTproftpd directory (here are the files of the proftpd server).This will have a structure bin include lib libexec sbin share usr var.You will notice no etc directory (etc of proftpd will be located in /etc/opt/TSTSproftpd

-- in FAKE_ROOT/etc/opt/TSTproftpd are the conf files, proftpd.conf, proftpd.key/pem etc.

-- in FAKE_ROOT/var/opt/TSTproftpd directory will contain the pid file and the delay file

FAKE_ROOT is the proftpd directory structure after the install of the pkg file.


- _EXTRAS

Here we have the smf method file, sysV init script and the xml manifest file


#~/pkg/build/TSTproftpd/Objects/_EXTRAS# pwd
/root/pkg/build/TSTproftpd/Objects/_EXTRAS
#~/pkg/build/TSTproftpd/Objects/_EXTRAS# ls
etc TSTproftpd var



The structure of the _EXTRAS dir:

#~/pkg/build/TSTproftpd/Objects/_EXTRAS# ls -R
.:
etc TSTproftpd var

./etc:
init.d

./etc/init.d:
proftpd

./TSTproftpd:
lib

./TSTproftpd/lib:
svc

./TSTproftpd/lib/svc:
method

./TSTproftpd/lib/svc/method:
proftpd

./var:
opt svc

./var/opt:
TSTproftpd

./var/opt/TSTproftpd:
proftpd

./var/opt/TSTproftpd/proftpd:
proftpd.delay

./var/svc:
manifest

./var/svc/manifest:
network

./var/svc/manifest/network:
proftpd.xml



The second and the most and difficult step is to create the ControlFiles directory and the files from it.


create ControlFiles/copyright
(optional) create ControlFiles/space
(optional) create ControlFiles/compver
(optional) create ControlFiles/depend
(optional) create ControlFiles/checkinstall script
(optional) create ControlFiles/{preinstall, postinstall, preremove, postremove} procedure scripts
(optional) create ControlFiles/{i., r.} class action scripts
(optional) create ControlFiles/request user interaction script


#:~/pkg/build/TSTproftpd/ControlFiles# pwd
/root/pkg/build/TSTproftpd/ControlFiles
#:~/pkg/build/TSTproftpd/ControlFiles# ls
checkinstall compver copyright depend i.init i.smf pkginfo postinstall preremove prototype space


- pkginfo -


PKG=TSTproftpd
NAME=ProFTPD server and utilities
ARCH=i386
VERSION=1.3.2
CATEGORY=daemon
DESC=Professional grade GPL-licensed FTP server software; see www.proftpd.org
BASEDIR=/opt
CLASSES=none


- checkinstall -


# proftpd - checkinstall script
#
trap `exit 3` 15

# Assign Solaris release class to install release specific files
smf=no
if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ] ; then smf=yes ; fi
if [ $smf = yes ]; then
CLASSES='none smf'
else
CLASSES='none init'
fi
# Make env variables available to other packaging scripts
cat >$1 <CLASSES='$CLASSES'
!
exit 0


- compver -


1.3.1, 2009.02.01
1.2.2
1.0.1


- copyright -


#Copyright (c) 1999 company_name
#All Rights Reserved.
#THIS PACKAGE CONTAINS UNPUBLISHED PROPRIETARY SOURCE CODE OF
#company_name.
#The copyright notice above does not evidence any
#actual or intended publication of such source code


- depend -


P SUNWpostgr-83-libs PostgreSQL client libraries



!!!! my proftpd server is using pgsql for storing users and quota.

- i.init -


# proftpd - i.init script
#
# Copy the SysV specific files to the base directory.
# These are:
# /etc/init.d/proftpd
# /etc/rc0.d/K10proftpd=/etc/init.d/proftpd
# /etc/rc1.d/K10proftpd=/etc/init.d/proftpd
# /etc/rc2.d/K10proftpd=/etc/init.d/proftpd
# /etc/rc3.d/S70proftpd=/etc/init.d/proftpd
#
while read src dest; do
/usr/bin/cp $src $dest || exit 2
echo $dest
done
exit 0




- i.smf -


# proftpd - i.smf script
#
# Copy the SMF specific files to the base directory.
# The files specific to SMF are:
# TSTproftpd/lib/svc
# TSTproftpd/lib/svc/method
# TSTproftpd/lib/svc/method/proftpd
# /var/svc
# /var/svc/manifest
# /var/svc/manifest/network
# /var/svc/manifest/network/proftpd.xml
#
while read src dest; do
/usr/bin/cp $src $dest || exit 2
echo $dest
done
exit 0


- postinstall -


# proftpd - postinstall script
# 2009/04/23 - add SMF capabilities
#

# Set variable smf depending on the availability of SMF binaries
smf=no
if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ]; then
smf=yes
fi
# If needed, configure SMF
if [ $smf = yes ]; then
# registering with SMF
/usr/sbin/svccfg import /var/svc/manifest/network/proftpd.xml >/dev/null 2>&1
echo "ProFTPD is using SMF; the FMRI is:"
echo " svc:/network/proftpd"
# disable the service, by default
/usr/sbin/svcadm disable -s network/proftpd
echo "The service is disabled by default!"
else
echo "ProFTPD is using the SysVinit style"
fi
exit 0


- preremove -


# proftpd - preremove script
# 2009/04/23 - add SMF functionality
#
# Set variable smf depending on the availability of SMF binaries
smf=no
if [ -f /usr/sbin/svccfg -a -f /usr/sbin/svcadm ]; then
smf=yes
fi
if [ $smf = yes ]; then
# disable the service
echo "Disabling the service (if running)"
/usr/sbin/svcadm disable -s network/proftpd >/dev/null 2>&1
# remove the service hook from SMF
echo "Unregistering the SMF service"
/usr/sbin/svccfg delete network/proftpd >/dev/null 2>&1
fi
exit 0


- space -

#empty file, nothing here

Finaly the prototype file must be created, this is the difficult part ;)

# cd ~/pkg/build/TSTproftpd
# pkgproto Objects/ > ControlFiles/prototype

This will create a file, containing the pkg structure.Anyway, some modifications must be done.

i pkginfo
i copyright
i compver
i depend
i space
i checkinstall
i i.smf
i i.init
i postinstall
i preremove

edit the paths for the relocatable objects
add the {e, v, x} entries
modify the (user, group) owner for the entries
modify the file permissions for the entries
(optional) add the classes entries, other than 'none'
build the package:

The file should be like this:


i pkginfo
i copyright
i compver
i depend
i space
i checkinstall
i i.smf
i i.init
i postinstall
i preremove
d none /etc/opt/TSTproftpd 0755 root root
f none /etc/opt/TSTproftpd/proftpd.conf 0440 root bin
f none /etc/opt/TSTproftpd/proftpd.key.pem 0444 root bin
f none /etc/opt/TSTproftpd/proftpd.conf.orig 0444 root bin
f none /etc/opt/TSTproftpd/proftpd.cert.pem 0444 root bin
d none TSTproftpd 0755 root root
d none TSTproftpd/share 0555 root bin
d none TSTproftpd/share/locale 0555 root bin
d none TSTproftpd/share/man 0555 root bin
d none TSTproftpd/share/man/man5 0555 root bin
f none TSTproftpd/share/man/man5/xferlog.5 0444 root bin
d none TSTproftpd/share/man/man8 0555 root bin
f none TSTproftpd/share/man/man8/ftpshut.8 0444 root bin
f none TSTproftpd/share/man/man8/proftpd.8 0444 root bin
f none TSTproftpd/share/man/man8/ftpdctl.8 0444 root bin
d none TSTproftpd/share/man/man1 0555 root bin
f none TSTproftpd/share/man/man1/ftpwho.1 0444 root bin
f none TSTproftpd/share/man/man1/ftpcount.1 0444 root bin
f none TSTproftpd/share/man/man1/ftptop.1 0444 root bin
d none TSTproftpd/lib 0555 root bin
d none TSTproftpd/lib/pkgconfig 0555 root bin
f none TSTproftpd/lib/pkgconfig/proftpd.pc 0444 root bin
d none TSTproftpd/lib/proftpd 0555 root bin
d none TSTproftpd/include 0555 root bin
d none TSTproftpd/include/proftpd 0555 root bin
f none TSTproftpd/include/proftpd/response.h 0444 root bin
f none TSTproftpd/include/proftpd/compat.h 0444 root bin
f none TSTproftpd/include/proftpd/regexp.h 0444 root bin
f none TSTproftpd/include/proftpd/timers.h 0444 root bin
f none TSTproftpd/include/proftpd/conf.h 0444 root bin
f none TSTproftpd/include/proftpd/str.h 0444 root bin
f none TSTproftpd/include/proftpd/help.h 0444 root bin
f none TSTproftpd/include/proftpd/modules.h 0444 root bin
f none TSTproftpd/include/proftpd/netio.h 0444 root bin
f none TSTproftpd/include/proftpd/sets.h 0444 root bin
f none TSTproftpd/include/proftpd/config.h 0444 root bin
f none TSTproftpd/include/proftpd/default_paths.h 0444 root bin
f none TSTproftpd/include/proftpd/ctrls.h 0444 root bin
f none TSTproftpd/include/proftpd/trace.h 0444 root bin
f none TSTproftpd/include/proftpd/child.h 0444 root bin
f none TSTproftpd/include/proftpd/xferlog.h 0444 root bin
f none TSTproftpd/include/proftpd/throttle.h 0444 root bin
f none TSTproftpd/include/proftpd/bindings.h 0444 root bin
f none TSTproftpd/include/proftpd/event.h 0444 root bin
f none TSTproftpd/include/proftpd/proftpd.h 0444 root bin
f none TSTproftpd/include/proftpd/display.h 0444 root bin
f none TSTproftpd/include/proftpd/ftp.h 0444 root bin
f none TSTproftpd/include/proftpd/log.h 0444 root bin
f none TSTproftpd/include/proftpd/fsio.h 0444 root bin
f none TSTproftpd/include/proftpd/mkhome.h 0444 root bin
f none TSTproftpd/include/proftpd/mod_ctrls.h 0444 root bin
f none TSTproftpd/include/proftpd/pr-syslog.h 0444 root bin
f none TSTproftpd/include/proftpd/env.h 0444 root bin
f none TSTproftpd/include/proftpd/data.h 0444 root bin
f none TSTproftpd/include/proftpd/var.h 0444 root bin
f none TSTproftpd/include/proftpd/class.h 0444 root bin
f none TSTproftpd/include/proftpd/options.h 0444 root bin
f none TSTproftpd/include/proftpd/version.h 0444 root bin
f none TSTproftpd/include/proftpd/mod_sql.h 0444 root bin
f none TSTproftpd/include/proftpd/glibc-glob.h 0444 root bin
f none TSTproftpd/include/proftpd/netaddr.h 0444 root bin
f none TSTproftpd/include/proftpd/netacl.h 0444 root bin
f none TSTproftpd/include/proftpd/mod_quotatab.h 0444 root bin
f none TSTproftpd/include/proftpd/expr.h 0444 root bin
f none TSTproftpd/include/proftpd/scoreboard.h 0444 root bin
f none TSTproftpd/include/proftpd/inet.h 0444 root bin
f none TSTproftpd/include/proftpd/parser.h 0444 root bin
f none TSTproftpd/include/proftpd/libsupp.h 0444 root bin
f none TSTproftpd/include/proftpd/buildstamp.h 0444 root bin
f none TSTproftpd/include/proftpd/encode.h 0444 root bin
f none TSTproftpd/include/proftpd/dirtree.h 0444 root bin
f none TSTproftpd/include/proftpd/table.h 0444 root bin
f none TSTproftpd/include/proftpd/auth.h 0444 root bin
f none TSTproftpd/include/proftpd/support.h 0444 root bin
f none TSTproftpd/include/proftpd/pool.h 0444 root bin
f none TSTproftpd/include/proftpd/pidfile.h 0444 root bin
d none TSTproftpd/bin 0555 root bin
f none TSTproftpd/bin/ftptop 0555 root bin
f none TSTproftpd/bin/prxs 0555 root bin
f none TSTproftpd/bin/ftpdctl 0555 root bin
f none TSTproftpd/bin/ftpcount 0555 root bin
f none TSTproftpd/bin/ftpwho 0555 root bin
d none TSTproftpd/usr 0755 root sys
d none TSTproftpd/usr/proftpd-1.3.2 0755 root sys
d none TSTproftpd/usr/proftpd-1.3.2/include 0755 root sys
d none TSTproftpd/usr/proftpd-1.3.2/include/proftpd 0755 root sys
f none TSTproftpd/usr/proftpd-1.3.2/include/proftpd/privs.h 0444 root bin
f none TSTproftpd/usr/proftpd-1.3.2/include/proftpd/proctitle.h 0444 root bin
f none TSTproftpd/usr/proftpd-1.3.2/include/proftpd/feat.h 0444 root bin
d none TSTproftpd/sbin 0555 root bin
f none TSTproftpd/sbin/proftpd 0555 root bin
s none TSTproftpd/sbin/in.proftpd=proftpd
f none TSTproftpd/sbin/ftpshut 0555 root bin
d none TSTproftpd/libexec 0555 root bin
f none TSTproftpd/libexec/mod_sql.so 0555 root bin
f none TSTproftpd/libexec/mod_sql_postgres.a 0644 root root
f none TSTproftpd/libexec/mod_quotatab.a 0444 root bin
f none TSTproftpd/libexec/mod_sql_postgres.so 0755 root root
f none TSTproftpd/libexec/mod_quotatab.la 0555 root bin
f none TSTproftpd/libexec/mod_quotatab.so 0555 root bin
f none TSTproftpd/libexec/mod_sql_postgres.la 0644 root root
f none TSTproftpd/libexec/mod_quotatab_file.a 0444 root bin
f none TSTproftpd/libexec/mod_sql.la 0555 root bin
f none TSTproftpd/libexec/mod_sql.a 0444 root bin
f none TSTproftpd/libexec/mod_quotatab_file.so 0555 root bin
f none TSTproftpd/libexec/mod_quotatab_sql.so 0555 root bin
f none TSTproftpd/libexec/mod_quotatab_file.la 0555 root bin
f none TSTproftpd/libexec/mod_quotatab_sql.a 0444 root bin
f none TSTproftpd/libexec/mod_quotatab_sql.la 0555 root bin
d none TSTproftpd/var 0555 root bin
d none TSTproftpd/var/proftpd 0555 root bin
#d none /var/opt 0755 root root
d none /var/opt/TSTproftpd 0755 root root
d none /var/opt/TSTproftpd/proftpd 0755 root root
v none /var/opt/TSTproftpd/proftpd/proftpd.delay 0644 root bin

#
# the smf class files
#
d smf TSTproftpd/lib/svc 0755 root bin
d smf TSTproftpd/lib/svc/method 0755 root bin
f smf TSTproftpd/lib/svc/method/proftpd 0755 root bin
f smf /var/svc/manifest/network/proftpd.xml 0444 root sys

# the init class files
#
f init /etc/init.d/proftpd 0744 root sys
s init /etc/rc0.d/K10proftpd=/etc/init.d/proftpd
s init /etc/rc1.d/K10proftpd=/etc/init.d/proftpd
s init /etc/rc2.d/K10proftpd=/etc/init.d/proftpd
s init /etc/rc3.d/S70proftpd=/etc/init.d/proftpd



The proftpd will be installed in /opt/TSTproftpd directory.The conf file in /etc/opt/TSTproftpd directory, the svc method in /opt/TSTproftpd/lib/svc/method.The xml manifest will be in /var/svc/manifest/network.For more info about filesystem organization in opensolaris system, read man filesystem

Now it's time to build the pkg file.By default, the package in filesystem format will be generated on the 'spool' device: /var/spool/pkg/. For other destinations, see the '-d' option of pkgmk.

# pkgmk -o -f ControlFiles/prototype -r Objects/FAKE_ROOT,Objects/_EXTRAS


!!!! No errors are allowed. !!!!

# cd /var/spool/pkg

Translate the package to the datastream format, suitable for distribution:

# pkgtrans -s `pwd` /tmp/TSTproftpd.pkg

The following packages are available:
1 TSTproftpd ProFTPD server and utilities
(i386) 1.3.2

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:all
Transferring package instance


To install the TSTproftpd server, type # pkgadd -d TSTproftpd

By default, proftpd is disabled at start up

To enable it, type svcadmin enable network/TSTproftpd

The end :)


If you want to test the pkg file and to take a look at the ControlFiles take a look here:
http://idea-soft.sci-office.com/~dan/down/TSTproftpd/

More useful links:
http://www.sunfreeware.com/pkgadd.html
http://www.opencsw.org/standards/smf


Comments

Popular posts from this blog

Why sometimes oracle 10g XE sucks big time

Review of Yashica ML 50mm F2

NAT in opensolaris