]> andersk Git - gssapi-openssh.git/blob - openssh/contrib/aix/buildbff.sh
merged trunk with OpenSSH 3.2.2p1 from vendor branch (OPENSSH_PORTABLE_DIST)
[gssapi-openssh.git] / openssh / contrib / aix / buildbff.sh
1 #!/bin/sh
2 #
3 # buildbff.sh: Create AIX SMIT-installable OpenSSH packages
4 #
5 # Author: Darren Tucker (dtucker at zip dot com dot au)
6 # This file is placed in the public domain and comes with absolutely
7 # no warranty.
8
9 # Based originally on Ben Lindstrom's buildpkg.sh for Solaris
10 #
11
12 umask 022
13 PKGNAME=openssh
14 PKGDIR=package
15
16 PATH=`pwd`:$PATH                # set path for external tools
17 export PATH
18
19 # Clean build directory 
20 rm -rf $PKGDIR
21 mkdir $PKGDIR
22
23 if [ ! -f ../../Makefile ]
24 then
25         echo "Top-level Makefile not found (did you run ./configure?)"
26         exit 1
27 fi
28
29 ## Start by faking root install 
30 echo "Faking root install..."
31 START=`pwd`
32 FAKE_ROOT=$START/$PKGDIR
33 cd ../.. 
34 make install-nokeys DESTDIR=$FAKE_ROOT
35
36 if [ $? -gt 0 ]
37 then
38         echo "Fake root install failed, stopping."
39         exit 1
40 fi
41
42 #
43 # Extract common info requires for the 'info' part of the package.
44 #       AIX requires 4-part version numbers
45 #
46 VERSION=`./ssh -V 2>&1 | sed -e 's/,.*//' | cut -f 2 -d _`
47 MAJOR=`echo $VERSION | cut -f 1 -d p | cut -f 1 -d .`
48 MINOR=`echo $VERSION | cut -f 1 -d p | cut -f 2 -d .`
49 PATCH=`echo $VERSION | cut -f 1 -d p | cut -f 3 -d .`
50 PORTABLE=`echo $VERSION | cut -f 2 -d p`
51 if [ "$PATCH" = "" ]
52 then
53         PATCH=0
54 fi
55 BFFVERSION=`printf "%d.%d.%d.%d" $MAJOR $MINOR $PATCH $PORTABLE`
56
57 echo "Building BFF for $PKGNAME $VERSION (package version $BFFVERSION)"
58
59 #
60 # Fill in some details, like prefix and sysconfdir
61 #       the eval also expands variables like sysconfdir=${prefix}/etc
62 #       provided they are eval'ed in the correct order
63 #
64 for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir mansubdir sysconfdir piddir
65 do
66         eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2`
67 done
68
69 # Rename config files; postinstall script will copy them if necessary
70 for cfgfile in ssh_config sshd_config ssh_prng_cmds
71 do
72         mv $FAKE_ROOT/$sysconfdir/$cfgfile $FAKE_ROOT/$sysconfdir/$cfgfile.default
73 done
74
75 #
76 # Generate lpp control files.
77 #       working dir is $FAKE_ROOT but files are generated in contrib/aix
78 #       and moved into place just before creation of .bff
79 #
80 cd $FAKE_ROOT
81 echo Generating LPP control files
82 find . ! -name . -print >../openssh.al
83 inventory.sh >../openssh.inventory
84 cp ../../../LICENCE ../openssh.copyright
85
86 #
87 # Create postinstall script
88 #
89 cat <<EOF >>../openssh.post_i
90 #!/bin/sh
91
92 # Create configs from defaults if necessary
93 for cfgfile in ssh_config sshd_config ssh_prng_cmds
94 do
95         if [ ! -f $sysconfdir/\$cfgfile ]
96         then
97                 echo "Creating \$cfgfile from default"
98                 cp $sysconfdir/\$cfgfile.default $sysconfdir/\$cfgfile
99         else
100                 echo "\$cfgfile already exists."
101         fi
102 done
103
104 # Generate keys unless they already exist
105 if [ -f "$sysconfdir/ssh_host_key" ] ; then
106         echo "$sysconfdir/ssh_host_key already exists, skipping."
107 else
108         $bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N ""
109 fi
110 if [ -f $sysconfdir/ssh_host_dsa_key ] ; then
111         echo "$sysconfdir/ssh_host_dsa_key already exists, skipping."
112 else
113         $bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N ""
114 fi
115 if [ -f $sysconfdir/ssh_host_rsa_key ] ; then
116         echo "$sysconfdir/ssh_host_rsa_key already exists, skipping."
117 else 
118         $bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N ""
119 fi
120
121 # Add to system startup if required
122 if grep $sbindir/sshd /etc/rc.tcpip >/dev/null
123 then
124         echo "sshd found in rc.tcpip, not adding."
125 else
126         echo >>/etc/rc.tcpip
127         echo "echo Starting sshd" >>/etc/rc.tcpip
128         echo "$sbindir/sshd" >>/etc/rc.tcpip
129 fi
130 EOF
131
132 #
133 # Create liblpp.a and move control files into it
134 #
135 echo Creating liblpp.a
136 (
137         cd ..
138         for i in al copyright inventory post_i
139         do
140                 ar -r liblpp.a openssh.$i
141                 rm openssh.$i
142         done
143 )
144
145 #
146 # Create lpp_name
147 #
148 # This will end up looking something like:
149 # 4 R I OpenSSH {
150 # OpenSSH 3.0.2.1 1 N U en_US OpenSSH 3.0.2p1 Portable for AIX
151 # [
152 # %
153 # /usr/local/bin 8073
154 # /usr/local/etc 189
155 # /usr/local/libexec 185
156 # /usr/local/man/man1 145
157 # /usr/local/man/man8 83
158 # /usr/local/sbin 2105
159 # /usr/local/share 3
160 # %
161 # ]
162 echo Creating lpp_name
163 cat <<EOF >../lpp_name
164 4 R I $PKGNAME {
165 $PKGNAME $BFFVERSION 1 N U en_US OpenSSH $VERSION Portable for AIX
166 [
167 %
168 EOF
169
170 for i in $bindir $sysconfdir $libexecdir $mandir/man1 $mandir/man8 $sbindir $datadir
171 do
172         # get size in 512 byte blocks
173         size=`du $FAKE_ROOT/$i | awk '{print $1}'`
174         echo "$i $size" >>../lpp_name
175 done
176
177 echo '%' >>../lpp_name
178 echo ']' >>../lpp_name
179 echo '}' >>../lpp_name
180
181 #
182 # Move pieces into place
183 #
184 mkdir -p usr/lpp/openssh
185 mv ../liblpp.a usr/lpp/openssh
186 mv ../lpp_name .
187
188 #
189 # Now invoke backup to create .bff file
190 #       note: lpp_name needs to be the first file do we generate the
191 #       file list on the fly and feed it to backup using -i
192 #
193 echo Creating $PKGNAME-$VERSION.bff with backup...
194 rm -f $PKGNAME-$VERSION.bff
195 (
196         echo "./lpp_name"
197         find . ! -name lpp_name -a ! -name . -print 
198 ) | backup  -i -q -f ../$PKGNAME-$VERSION.bff $filelist
199
200 cd ..
201
202 rm -rf $PKGDIR
203 echo $0: done.
204
This page took 0.054359 seconds and 5 git commands to generate.