[contrib/solaris/buildpkg.sh, contrib/solaris/README] Updated to

build on all platforms that support SVR4 style package tools. Now runs
from build dir. Parts are based on patches from Antonio Navarro, and
Darren Tucker.
This commit is contained in:
Tim Rice 2002-03-11 20:55:53 -08:00
parent 4a10d2e90b
commit 29bdd2c9bc
3 changed files with 262 additions and 45 deletions

View File

@ -1,3 +1,9 @@
20020311
- (tim) [contrib/solaris/buildpkg.sh, contrib/solaris/README] Updated to
build on all platforms that support SVR4 style package tools. Now runs
from build dir. Parts are based on patches from Antonio Navarro, and
Darren Tucker.
20020308 20020308
- (djm) Revert bits of Markus' OpenSSL compat patch which was - (djm) Revert bits of Markus' OpenSSL compat patch which was
accidentally committed. accidentally committed.
@ -7828,4 +7834,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1920 2002/03/11 11:53:29 djm Exp $ $Id: ChangeLog,v 1.1921 2002/03/12 04:55:53 tim Exp $

View File

@ -1,6 +1,7 @@
The following is a new package build script for Solaris. This is being The following is a new package build script for Solaris. This is being
introduced into OpenSSH 3.0 and above in hopes of simplifying the build introduced into OpenSSH 3.0 and above in hopes of simplifying the build
process. process. As of 3.1p2 the script should work on all platforms that have
SVR4 style package tools.
The build process is called a 'dummy install'.. Which means the software does The build process is called a 'dummy install'.. Which means the software does
a "make install-nokeys DESTDIR=[fakeroot]". This way all manpages should a "make install-nokeys DESTDIR=[fakeroot]". This way all manpages should
@ -11,7 +12,8 @@ Directions:
1. make -F Makefile.in distprep (Only if you are getting from the CVS tree) 1. make -F Makefile.in distprep (Only if you are getting from the CVS tree)
2. ./configure --with-pam [..any other options you want..] 2. ./configure --with-pam [..any other options you want..]
3. cd contrib/solaris; ./buildpkg.sh 3. look at the top of contrib/solaris/buildpkg.sh for the configurable options.
4. ./contrib/solaris/buildpkg.sh
If all goes well you should have a solaris package ready to be installed. If all goes well you should have a solaris package ready to be installed.
@ -20,9 +22,3 @@ openssh-unix-dev@mindrot.org and I will try to assist you as best as I can.
- Ben Lindstrom - Ben Lindstrom
TODO:
- Expand to cover all sysvr4 family of OSes
- Clean things up a bit more.
- Detect if sshd is running and refuse to start.
- SHOULD check for existing sshd_config nor ssh_config (does not currently).
[Post install script? Ugh.. Nasty]

View File

@ -1,52 +1,139 @@
#!/bin/sh #!/bin/sh
# #
# Fake Root Solaris Build System - Prototype # Fake Root Solaris/SVR4/SVR5 Build System - Prototype
# #
# The following code has been provide under Public Domain License. I really # The following code has been provide under Public Domain License. I really
# don't care what you use it for. Just as long as you don't complain to me # don't care what you use it for. Just as long as you don't complain to me
# nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org) # nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org)
# #
umask 022 umask 022
#
# Options for building the package
# You can create a config.local with your customized options
#
# uncommenting TEST_DIR and using configure--prefix=/var/tmp and
# PKGNAME=tOpenSSH should allow testing a package without interfering
# with a real OpenSSH package on a system.
#TEST_DIR=/var/tmp # leave commented out for production build
PKGNAME=OpenSSH PKGNAME=OpenSSH
SYSVINIT_NAME=opensshd
MAKE=${MAKE:="make"}
# uncomment these next two as needed
#PERMIT_ROOT_LOGIN=no
#X11_FORWARDING=yes
# list of system directories we do NOT want to change owner/group/perms
# when installing our package
SYSTEM_DIR="/etc \
/etc/init.d \
/etc/rcS.d \
/etc/rc0.d \
/etc/rc1.d \
/etc/rc2.d \
/opt \
/opt/bin \
/usr \
/usr/bin \
/usr/lib \
/usr/sbin \
/usr/share \
/usr/share/man \
/usr/share/man/man1 \
/usr/share/man/man8 \
/usr/local \
/usr/local/bin \
/usr/local/etc \
/usr/local/libexec \
/usr/local/man \
/usr/local/man/man1 \
/usr/local/man/man8 \
/usr/local/sbin \
/usr/local/share \
/var \
/var/run \
/var/tmp \
/tmp"
## Extract common info requires for the 'info' part of the package. # We may need to buiild as root so we make sure PATH is set up
VERSION=`tail -1 ../../version.h | sed -e 's/.*_\([0-9]\)/\1/g' | sed 's/\"$//'` # only set the path if it's not set already
ARCH=`uname -p` [ -d /usr/local/bin ] && {
echo $PATH | grep ":/usr/local/bin" > /dev/null 2>&1
[ $? -ne 0 ] && PATH=$PATH:/usr/local/bin
}
[ -d /usr/ccs/bin ] && {
echo $PATH | grep ":/usr/ccs/bin" > /dev/null 2>&1
[ $? -ne 0 ] && PATH=$PATH:/usr/ccs/bin
}
export PATH
#
[ -f Makefile ] || {
echo "Please run this script from your build directory"
exit 1
}
# we will look for config.local to override the above options
[ -s ./config.local ] && . ./config.local
## Start by faking root install ## Start by faking root install
echo "Faking root install..." echo "Faking root install..."
START=`pwd` START=`pwd`
OPENSSHD_IN=`dirname $0`/opensshd.in
FAKE_ROOT=$START/package FAKE_ROOT=$START/package
[ -d $FAKE_ROOT ] && rm -fr $FAKE_ROOT
mkdir $FAKE_ROOT mkdir $FAKE_ROOT
cd ../.. ${MAKE} install-nokeys DESTDIR=$FAKE_ROOT
make install-nokeys DESTDIR=$FAKE_ROOT if [ $? -gt 0 ]
then
echo "Fake root install failed, stopping."
exit 1
fi
## Fill in some details, like prefix and sysconfdir ## Fill in some details, like prefix and sysconfdir
ETCDIR=`grep "^sysconfdir=" Makefile | sed 's/sysconfdir=//'` for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir
PREFIX=`grep "^prefix=" Makefile | cut -d = -f 2` do
PIDDIR=`grep "^piddir=" Makefile | cut -d = -f 2` eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2`
cd $FAKE_ROOT done
## Extract common info requires for the 'info' part of the package.
VERSION=`./ssh -V 2>&1 | sed -e 's/,.*//'`
UNAME_S=`uname -s`
case ${UNAME_S} in
SunOS) UNAME_S=Solaris
ARCH=`uname -p`
RCS_D=yes
DEF_MSG="(default: n)"
;;
*) ARCH=`uname -m` ;;
esac
## Setup our run level stuff while we are at it. ## Setup our run level stuff while we are at it.
mkdir -p $FAKE_ROOT/etc/init.d mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.d
mkdir -p $FAKE_ROOT/etc/rcS.d
mkdir -p $FAKE_ROOT/etc/rc0.d
mkdir -p $FAKE_ROOT/etc/rc1.d
mkdir -p $FAKE_ROOT/etc/rc2.d
## setup our initscript correctly ## setup our initscript correctly
sed -e "s#%%configDir%%#$ETCDIR#g" \ sed -e "s#%%configDir%%#${sysconfdir}#g" \
-e "s#%%openSSHDir%%#$PREFIX#g" \ -e "s#%%openSSHDir%%#$prefix#g" \
-e "s#%%pidDir%%#$PIDDIR#g" \ -e "s#%%pidDir%%#${piddir}#g" \
../opensshd.in > $FAKE_ROOT/etc/init.d/opensshd ${OPENSSHD_IN} > $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}
chmod 711 $FAKE_ROOT/etc/init.d/opensshd chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}
ln -s ../init.d/opensshd $FAKE_ROOT/etc/rcS.d/K30opensshd [ "${PERMIT_ROOT_LOGIN}" = no ] && \
ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc0.d/K30opensshd perl -p -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" \
ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc1.d/K30opensshd $FAKE_ROOT/${sysconfdir}/sshd_config
ln -s ../init.d/opensshd $FAKE_ROOT/etc/rc2.d/S98opensshd [ "${X11_FORWARDING}" = yes ] && \
perl -p -i -e "s/#X11Forwarding no/X11Forwarding yes/" \
$FAKE_ROOT/${sysconfdir}/sshd_config
# fix PrintMotd
perl -p -i -e "s/#PrintMotd yes/PrintMotd no/" \
$FAKE_ROOT/${sysconfdir}/sshd_config
# We don't want to overwrite config files on multiple installs
mv $FAKE_ROOT/${sysconfdir}/ssh_config $FAKE_ROOT/${sysconfdir}/ssh_config.default
mv $FAKE_ROOT/${sysconfdir}/sshd_config $FAKE_ROOT/${sysconfdir}/sshd_config.default
[ -f $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds ] && \
mv $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds.default
cd $FAKE_ROOT
## Ok, this is outright wrong, but it will work. I'm tired of pkgmk ## Ok, this is outright wrong, but it will work. I'm tired of pkgmk
## whining. ## whining.
@ -58,28 +145,156 @@ done
echo "Building pkginfo file..." echo "Building pkginfo file..."
cat > pkginfo << _EOF cat > pkginfo << _EOF
PKG=$PKGNAME PKG=$PKGNAME
NAME=OpenSSH Portable for Solaris NAME="OpenSSH Portable for ${UNAME_S}"
DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh." DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh."
VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html" VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html"
BASEDIR=$FAKE_ROOT
ARCH=$ARCH ARCH=$ARCH
VERSION=$VERSION VERSION=$VERSION
CATEGORY=Security CATEGORY="Security,application"
BASEDIR=/ BASEDIR=/
CLASSES="none"
_EOF _EOF
## Build preinstall file
echo "Building preinstall file..."
cat > preinstall << _EOF
#! /sbin/sh
#
[ "\${PRE_INS_STOP}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop
exit 0
_EOF
## Build postinstall file
echo "Building postinstall file..."
cat > postinstall << _EOF
#! /sbin/sh
#
[ -f ${sysconfdir}/ssh_config ] || \\
cp -p ${sysconfdir}/ssh_config.default ${sysconfdir}/ssh_config
[ -f ${sysconfdir}/sshd_config ] || \\
cp -p ${sysconfdir}/sshd_config.default ${sysconfdir}/sshd_config
[ -f ${sysconfdir}/ssh_prng_cmds.default ] && {
[ -f ${sysconfdir}/ssh_prng_cmds ] || \\
cp -p ${sysconfdir}/ssh_prng_cmds.default ${sysconfdir}/ssh_prng_cmds
}
# make rc?.d dirs only if we are doing a test install
[ -n "${TEST_DIR}" ] && {
[ "$RCS_D" = yes ] && mkdir -p ${TEST_DIR}/etc/rcS.d
mkdir -p ${TEST_DIR}/etc/rc0.d
mkdir -p ${TEST_DIR}/etc/rc1.d
mkdir -p ${TEST_DIR}/etc/rc2.d
}
if [ "\${USE_SYM_LINKS}" = yes ]
then
[ "$RCS_D" = yes ] && \
installf ${PKGNAME} $TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
installf ${PKGNAME} $TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
installf ${PKGNAME} $TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
installf ${PKGNAME} $TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
else
[ "$RCS_D" = yes ] && \
installf ${PKGNAME} $TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
installf ${PKGNAME} $TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
installf ${PKGNAME} $TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
installf ${PKGNAME} $TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME}=$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
fi
installf -f ${PKGNAME}
[ "\${POST_INS_START}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} start
exit 0
_EOF
## Build preremove file
echo "Building preremove file..."
cat > preremove << _EOF
#! /sbin/sh
#
${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop
exit 0
_EOF
## Build request file
echo "Building request file..."
cat > request << _EOF
trap 'exit 3' 15
USE_SYM_LINKS=no
PRE_INS_STOP=no
POST_INS_START=no
# Use symbolic links?
ans=\`ckyorn -d n \
-p "Do you want symbolic links for the start/stop scripts? ${DEF_MSG}"\` || exit \$?
case \$ans in
[y,Y]*) USE_SYM_LINKS=yes ;;
esac
# determine if should restart the daemon
if [ -s ${piddir}/sshd.pid -a -f ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} ]
then
ans=\`ckyorn -d n \
-p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$?
case \$ans in
[y,Y]*) PRE_INS_STOP=yes
POST_INS_START=yes
;;
esac
else
# determine if we should start sshd
ans=\`ckyorn -d n \
-p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$?
case \$ans in
[y,Y]*) POST_INS_START=yes ;;
esac
fi
# make parameters available to installation service,
# and so to any other packaging scripts
cat >\$1 <<!
USE_SYM_LINKS='\$USE_SYM_LINKS'
PRE_INS_STOP='\$PRE_INS_STOP'
POST_INS_START='\$POST_INS_START'
!
exit 0
_EOF
## Build space file
echo "Building space file..."
cat > space << _EOF
# extra space required by start/stop links added by installf in postinstall
$TEST_DIR/etc/rc0.d/K30${SYSVINIT_NAME} 0 1
$TEST_DIR/etc/rc1.d/K30${SYSVINIT_NAME} 0 1
$TEST_DIR/etc/rc2.d/S98${SYSVINIT_NAME} 0 1
_EOF
[ "$RCS_D" = yes ] && \
echo "$TEST_DIR/etc/rcS.d/K30${SYSVINIT_NAME} 0 1" >> space
## Next Build our prototype ## Next Build our prototype
echo "Building prototype file..." echo "Building prototype file..."
find . | egrep -v "prototype|pkginfo" | sort | pkgproto $PROTO_ARGS | \ cat >mk-proto.awk << _EOF
awk ' BEGIN { print "i pkginfo"; print "i preinstall"; \\
BEGIN { print "i pkginfo" } print "i postinstall"; print "i preremove"; \\
{ $5="root"; $6="sys"; } print "i request"; print "i space"; \\
{ print; }' > prototype split("$SYSTEM_DIR",sys_files); }
{
for (dir in sys_files) { if ( \$3 != sys_files[dir] )
{ \$5="root"; \$6="sys"; }
else
{ \$4="?"; \$5="?"; \$6="?"; break;}
} }
{ print; }
_EOF
find . | egrep -v "prototype|pkginfo|mk-proto.awk" | sort | \
pkgproto $PROTO_ARGS | nawk -f mk-proto.awk > prototype
## Step back a directory and now build the package. ## Step back a directory and now build the package.
echo "Building package.." echo "Building package.."
cd .. cd ..
pkgmk -d . -f $FAKE_ROOT/prototype -o pkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -o
echo | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$UNAME_S-$ARCH-$VERSION.pkg
rm -rf $FAKE_ROOT rm -rf $FAKE_ROOT
echo | pkgtrans -os . $PKGNAME-$ARCH-$VERSION.pkg
rm -rf $PKGNAME