3 # buildbff.sh: Create AIX SMIT-installable OpenSSH packages
5 # Author: Darren Tucker (dtucker at zip dot com dot au)
6 # This file is placed in the public domain and comes with absolutely
9 # Based originally on Ben Lindstrom's buildpkg.sh for Solaris
15 PATH=$PATH:`pwd` # set path for external tools
18 ## Extract common info requires for the 'info' part of the package.
19 VERSION=`tail -1 ../../version.h | sed -e 's/.*_\([0-9]\)/\1/g' | sed 's/\"$//'`
20 BFFVERSION=`echo $VERSION | sed 's/p/./g'`
22 echo "Building BFF for $PKGNAME $VERSION (package version $BFFVERSION)"
25 # Clean build directory and package file
28 rm -f $PKGNAME-$VERSION.bff
30 if [ ! -f ../../Makefile ]
32 echo "Top-level Makefile not found (did you run ./configure?)"
36 ## Start by faking root install
37 echo "Faking root install..."
39 FAKE_ROOT=$START/$PKGDIR
41 make install-nokeys DESTDIR=$FAKE_ROOT
44 # Fill in some details, like prefix and sysconfdir
45 # the eval also expands variables like sysconfdir=${prefix}/etc
46 # provided they are eval'ed in the correct order
48 for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir mansubdir sysconfdir piddir
50 eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2`
53 # Rename config files; postinstall script will copy them if necessary
54 for cfgfile in ssh_config sshd_config ssh_prng_cmds
56 mv $FAKE_ROOT/$sysconfdir/$cfgfile $FAKE_ROOT/$sysconfdir/$cfgfile.default
60 # Generate lpp control files.
61 # working dir is $FAKE_ROOT but files are generated in contrib/aix
62 # and moved into place just before creation of .bff
65 echo Generating LPP control files
66 find . ! -name . -print >../openssh.al
67 inventory.sh >../openssh.inventory
68 cp ../../../LICENCE ../openssh.copyright
71 # Create postinstall script
73 cat <<EOF >>../openssh.post_i
76 # Create configs from defaults if necessary
77 for cfgfile in ssh_config sshd_config ssh_prng_cmds
79 if [ ! -f $sysconfdir/\$cfgfile ]
81 echo "Creating \$cfgfile from default"
82 cp $sysconfdir/\$cfgfile.default $sysconfdir/\$cfgfile
84 echo "\$cfgfile already exists."
88 # Generate keys unless they already exist
89 if [ -f "$sysconfdir/ssh_host_key" ] ; then
90 echo "$sysconfdir/ssh_host_key already exists, skipping."
92 $bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N ""
94 if [ -f $sysconfdir/ssh_host_dsa_key ] ; then
95 echo "$sysconfdir/ssh_host_dsa_key already exists, skipping."
97 $bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N ""
99 if [ -f $sysconfdir/ssh_host_rsa_key ] ; then
100 echo "$sysconfdir/ssh_host_rsa_key already exists, skipping."
102 $bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N ""
105 # Add to system startup if required
106 if grep $sbindir/sshd /etc/rc.tcpip >/dev/null
108 echo "sshd found in rc.tcpip, not adding."
111 echo "echo Starting sshd" >>/etc/rc.tcpip
112 echo "$sbindir/sshd" >>/etc/rc.tcpip
117 # Create liblpp.a and move control files into it
119 echo Creating liblpp.a
122 for i in al copyright inventory post_i
124 ar -r liblpp.a openssh.$i
132 # This will end up looking something like:
134 # OpenSSH 3.0.2.1 1 N U en_US OpenSSH 3.0.2p1 Portable for AIX
137 # /usr/local/bin 8073
139 # /usr/local/libexec 185
140 # /usr/local/man/man1 145
141 # /usr/local/man/man8 83
142 # /usr/local/sbin 2105
146 echo Creating lpp_name
147 cat <<EOF >../lpp_name
149 $PKGNAME $BFFVERSION 1 N U en_US OpenSSH $VERSION Portable for AIX
154 for i in $bindir $sysconfdir $libexecdir $mandir/man1 $mandir/man8 $sbindir $datadir
156 # get size in 512 byte blocks
157 size=`du $FAKE_ROOT/$i | awk '{print $1}'`
158 echo "$i $size" >>../lpp_name
161 echo '%' >>../lpp_name
162 echo ']' >>../lpp_name
163 echo '}' >>../lpp_name
166 # Move pieces into place
168 mkdir -p usr/lpp/openssh
169 mv ../liblpp.a usr/lpp/openssh
173 # Now invoke backup to create .bff file
174 # note: lpp_name needs to be the first file do we generate the
175 # file list on the fly and feed it to backup using -i
177 echo Creating $PKGNAME-$VERSION.bff with backup...
180 find . ! -name lpp_name -a ! -name . -print
181 ) | backup -i -q -f ../$PKGNAME-$VERSION.bff $filelist