summaryrefslogtreecommitdiff
path: root/contrib/solaris/build-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/solaris/build-pkg')
-rwxr-xr-xcontrib/solaris/build-pkg207
1 files changed, 207 insertions, 0 deletions
diff --git a/contrib/solaris/build-pkg b/contrib/solaris/build-pkg
new file mode 100755
index 000000000..5f2e3addd
--- /dev/null
+++ b/contrib/solaris/build-pkg
@@ -0,0 +1,207 @@
1#!/bin/sh
2
3# OpenSSH solaris build script and supporting data files
4# Copyright (c) 2000 Rip Loomis and
5# Science Applications International Corporation (SAIC)
6# (http://www.cist-east.saic.com). All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16# 3. The name of the author may not be used to endorse or promote products
17# derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30# Obviously, without all the hard work of the OpenBSD OpenSSH developers
31# and the OpenSSH Portability Team, these scripts would be pointless...
32# so thanks again folks!
33#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
34
35#### Known issues
36# These methods are generally based on a "default" compilation of
37# OpenSSH on Solaris--so the more things that you change from the default,
38# the greater the chance that something in the script won't be able to
39# handle the changes. In general, though, most things should be determined
40# from your compile environment--the architecture, SSH version, and
41# other related data should all get picked up by this script. The script
42# and data files were last updated to match OpenSSH 2.1.1p4.
43#
44# All building and packaging is done under a temporary directory that is
45# itself created under the contrib/solaris directory--so there shouldn't
46# be any special security issues (or need for root access during the
47# packaging process). The temporary directory is defined below as
48# ${BUILDDIR}.
49#
50# The permissions on the installed files are based on how we prefer to
51# do things here--so nothing is installed SetUID to root.
52#
53# The post-install script makes a good-faith attempt to install a
54# functional configuration on your system. I would be interested in hearing
55# of any failure modes that are found, as I tried to compensate for all
56# the ones that showed up here when we started replacing all the
57# different installed versions of SSH.
58
59#### Body of the script (finally!)
60# We expect to be building the solaris package under the contrib/solaris
61# directory--but the build-package script might be run with a relative
62# path by a user in the main SSH directory...so we try to handle this
63# case. Note that this is still a quick and dirty solution, not robust.
64
65if [ -f sshd.c ]; then
66 cd contrib/solaris >/dev/null
67fi
68
69# Locations of standard binaries
70UNAME=/usr/bin/uname
71SED=/usr/bin/sed
72PWD=/usr/bin/pwd
73CUT=/usr/bin/cut
74STRIP=/usr/ccs/bin/strip
75PKGMK=/usr/bin/pkgmk
76PKGTRANS=/usr/bin/pkgtrans
77GREP=/usr/bin/grep
78DATE=/usr/bin/date
79
80CURRDIR=`${PWD}`
81BUILDDIR=${CURRDIR}/build-SSH-package
82# If you really want to name the package "ssh" then go ahead, but the
83# Sun convention is that the first 2-4 characters are supposed to be
84# uppercase representing the company or organization that produced the
85# software, and the next 3-5 characters are supposed to be lowercase
86# identifying the specific software. The best package names I could
87# come up with were "OBSDssh" or "OPENssh", given those constraints.
88PKGNAME="OPENssh"
89# PSTAMP is a standard setting in the 'pkginfo' file that helps to identify
90# the time and location that the packaging was done.
91PSTAMP="`${UNAME} -n`-`${DATE} +%Y-%m-%d-%H%M`"
92# The several lines below are designed to pull the relevant information
93# out of the Makefile. It may be simpler to hard-code this if you have
94# made changes and these lines don't find them.
95prefix=`${GREP} "^prefix=" ../../Makefile | ${CUT} -d = -f 2`
96execprefix=`${GREP} "^execprefix=" ../../Makefile | ${CUT} -d = -f 2`
97INSTROOT=${prefix:=/usr/local}
98ETCDIR=`${GREP} "^ETCDIR=" ../../Makefile | ${CUT} -d = -f 2`
99PIDDIR=`${GREP} "^piddir=" ../../Makefile | ${CUT} -d = -f 2`
100
101if [ ! -f ../../sshd ]; then
102 echo "Unable to locate sshd binary where I expected, and can't continue."
103 echo "Verify that the SSH configure/make has been completed, and that"
104 echo " this script is being run from within the SSH source tree."
105 exit 1
106fi
107
108
109VERSION=`${GREP} "SSH_VERSION" ../../version.h | ${CUT} -f 2 | sed -e 's/"//g' -e 's/OpenSSH_//g'`
110# Extra shenanigans to compensate for Sun marketeer tricks with Solaris
111# version numbering...
112OSMINOR=`${UNAME} -r | ${CUT} -f 2 -d .`
113if [ $OSMINOR -gt 6 ]; then
114 OSVERSION=$OSMINOR
115else
116 OSVERSION=`${UNAME} -r | ${SED} 's/5/2/'`
117fi
118ARCH=`$UNAME -p`
119SHORTINSTROOT=""
120if [ "$INSTROOT" = "/usr/local" ]; then
121 SHORTINSTROOT="-local"
122else
123 if [ "$INSTROOT" = "/opt" ]; then
124 SHORTINSTROOT="-opt"
125 fi
126fi
127
128DESTFILE="${PKGNAME}-${VERSION}-sol${OSVERSION}-${ARCH}${SHORTINSTROOT}"
129
130echo "Building Solaris package of OpenSSH ${VERSION} in\n\t${BUILDDIR}."
131echo "Binaries were compiled for Solaris ${OSVERSION} (${ARCH})"
132echo "The installable package will be named ${DESTFILE}."
133echo "When installed, the package will be located under ${INSTROOT}."
134echo ""
135
136echo "Cleaning up old build files..."
137rm -rf $BUILDDIR
138mkdir $BUILDDIR
139cd $BUILDDIR
140
141echo "Setting up build directories..."
142mkdir -p ${BUILDDIR}/man/man1
143# Need manpages for sshd_config(5) and ssh_config(5), but we don't yet have.
144#mkdir -p ${BUILDDIR}/man/man5
145mkdir -p ${BUILDDIR}/man/man8
146mkdir -p ${BUILDDIR}/etc
147mkdir -p ${BUILDDIR}/bin
148mkdir -p ${BUILDDIR}/sbin
149
150echo "Populating build directories..."
151cp -p ../../../sshd sbin
152cp -p ../../../ssh-keygen bin
153cp -p ../../../ssh bin
154cp -p ../../../ssh-add bin
155cp -p ../../../ssh-agent bin
156cp -p ../../../scp bin
157cp -p ../../../scp.1 man/man1/scp.1
158cp -p ../../../ssh-add.1 man/man1/ssh-add.1
159cp -p ../../../ssh-agent.1 man/man1/ssh-agent.1
160cp -p ../../../ssh-keygen.1 man/man1/ssh-keygen.1
161cp -p ../../../ssh.1 man/man1/ssh.1
162cp -p ../../../sshd.8 man/man8/sshd.8
163cp -p ../../../sshd_config.out etc/sshd_config.default
164cp -p ../../../ssh_config.out etc/ssh_config.default
165cp -p ../../../ssh_prng_cmds etc/ssh_prng_cmds.default
166
167# One of the annoying things about the Solaris packaging process is that
168# there's no simple way to prototype on the fly--so make sure you edit
169# the prototype file if you add/subtract files from the mix.
170cp -p ../prototype .
171cp -p ../preremove .
172
173echo "Creating compile-dependent files from their prototypes"
174$SED -e "s/%%PKGNAME%%/${PKGNAME}/g" -e "s|%%BASEDIR%%|${INSTROOT}|g" -e "s/%%VERSION%%/${VERSION}/g" -e "s/%%ARCH%%/${ARCH}/g" -e "s/%%OSVERSION%%/${OSVERSION}/g" <../pkginfo.in >./pkginfo
175$SED -e "s/%%PKGNAME%%/${PKGNAME}/g" -e "s/%%OSMINOR%%/${OSMINOR}/g" -e "s/%%OSVERSION%%/${OSVERSION}/g" <../checkinstall.in >./checkinstall
176$SED -e "s|%%PIDDIR%%|${PIDDIR}|g" <../postinstall.in >./postinstall
177$SED -e "s|%%PIDDIR%%|${PIDDIR}|g" <../sshd-initscript.in > etc/sshd-initscript
178
179echo "Stripping binaries"
180${STRIP} bin/ssh
181${STRIP} bin/ssh-add
182${STRIP} bin/ssh-agent
183${STRIP} bin/ssh-keygen
184${STRIP} sbin/sshd
185${STRIP} bin/scp
186
187echo ""
188echo "Building Package"
189
190cd ${BUILDDIR}
191$PKGMK -o -r . -p ${PSTAMP} -d ${BUILDDIR}
192
193if [ $? -gt 0 ]; then
194 echo "Error performing pkgmk--cannot continue."
195 exit 1
196fi
197
198echo ""
199echo "Translating Package Tree into Installable Image"
200$PKGTRANS -s ${BUILDDIR} ${BUILDDIR}/${DESTFILE} OPENssh
201
202if [ $? -gt 0 ]; then
203 echo "Error performing pkgtrans--cannot continue."
204 exit 1
205fi
206
207echo "Done. Package is in ${BUILDDIR}/${DESTFILE} !"