]> andersk Git - openssh.git/blame - buildpkg.sh.in
- (tim) [configure.ac] Move CHECK_HEADERS test before platform specific
[openssh.git] / buildpkg.sh.in
CommitLineData
9cefe228 1#!/bin/sh
2#
3# Fake Root Solaris/SVR4/SVR5 Build System - Prototype
4#
5# The following code has been provide under Public Domain License. I really
6# don't care what you use it for. Just as long as you don't complain to me
7# nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org)
8#
9umask 022
10#
11# Options for building the package
12# You can create a openssh-config.local with your customized options
13#
14REMOVE_FAKE_ROOT_WHEN_DONE=yes
15#
16# uncommenting TEST_DIR and using
17# configure --prefix=/var/tmp --with-privsep-path=/var/tmp/empty
18# and
19# PKGNAME=tOpenSSH should allow testing a package without interfering
20# with a real OpenSSH package on a system. This is not needed on systems
21# that support the -R option to pkgadd.
22#TEST_DIR=/var/tmp # leave commented out for production build
23PKGNAME=OpenSSH
d386a795 24# revisions within the same version (REV=a)
25#REV=
9cefe228 26SYSVINIT_NAME=opensshd
27MAKE=${MAKE:="make"}
28SSHDUID=67 # Default privsep uid
29SSHDGID=67 # Default privsep gid
30# uncomment these next three as needed
31#PERMIT_ROOT_LOGIN=no
32#X11_FORWARDING=yes
33#USR_LOCAL_IS_SYMLINK=yes
34# System V init run levels
35SYSVINITSTART=S98
36SYSVINITSTOPT=K30
37# We will source these if they exist
103ff395 38POST_MAKE_INSTALL_FIXES=./pkg-post-make-install-fixes.sh
9cefe228 39POST_PROTOTYPE_EDITS=./pkg-post-prototype-edit.sh
40# We'll be one level deeper looking for these
41PKG_PREINSTALL_LOCAL=../pkg-preinstall.local
42PKG_POSTINSTALL_LOCAL=../pkg-postinstall.local
43PKG_PREREMOVE_LOCAL=../pkg-preremove.local
44PKG_POSTREMOVE_LOCAL=../pkg-postremove.local
45PKG_REQUEST_LOCAL=../pkg-request.local
46# end of sourced files
47#
ddd8c95b 48OPENSSHD=opensshd.init
29eadd7c 49OPENSSH_MANIFEST=openssh.xml
50OPENSSH_FMRI=svc:/site/openssh:default
9cefe228 51
52PATH_GROUPADD_PROG=@PATH_GROUPADD_PROG@
53PATH_USERADD_PROG=@PATH_USERADD_PROG@
54PATH_PASSWD_PROG=@PATH_PASSWD_PROG@
55#
56# list of system directories we do NOT want to change owner/group/perms
57# when installing our package
58SYSTEM_DIR="/etc \
59/etc/init.d \
60/etc/rcS.d \
61/etc/rc0.d \
62/etc/rc1.d \
63/etc/rc2.d \
64/etc/opt \
29eadd7c 65/lib \
66/lib/svc \
67/lib/svc/method \
68/lib/svc/method/site \
9cefe228 69/opt \
70/opt/bin \
71/usr \
72/usr/bin \
73/usr/lib \
74/usr/sbin \
75/usr/share \
76/usr/share/man \
77/usr/share/man/man1 \
78/usr/share/man/man8 \
79/usr/local \
80/usr/local/bin \
81/usr/local/etc \
82/usr/local/libexec \
83/usr/local/man \
84/usr/local/man/man1 \
85/usr/local/man/man8 \
86/usr/local/sbin \
87/usr/local/share \
88/var \
89/var/opt \
90/var/run \
29eadd7c 91/var/svc \
92/var/svc/manifest \
93/var/svc/manifest/site \
9cefe228 94/var/tmp \
95/tmp"
96
97# We may need to build as root so we make sure PATH is set up
98# only set the path if it's not set already
99[ -d /opt/bin ] && {
100 echo $PATH | grep ":/opt/bin" > /dev/null 2>&1
101 [ $? -ne 0 ] && PATH=$PATH:/opt/bin
102}
103[ -d /usr/local/bin ] && {
104 echo $PATH | grep ":/usr/local/bin" > /dev/null 2>&1
105 [ $? -ne 0 ] && PATH=$PATH:/usr/local/bin
106}
107[ -d /usr/ccs/bin ] && {
108 echo $PATH | grep ":/usr/ccs/bin" > /dev/null 2>&1
109 [ $? -ne 0 ] && PATH=$PATH:/usr/ccs/bin
110}
111export PATH
112#
113
114[ -f Makefile ] || {
115 echo "Please run this script from your build directory"
116 exit 1
117}
118
119# we will look for openssh-config.local to override the above options
120[ -s ./openssh-config.local ] && . ./openssh-config.local
121
122START=`pwd`
123FAKE_ROOT=$START/pkg
124
125## Fill in some details, like prefix and sysconfdir
126for confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir srcdir
127do
128 eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2`
129done
130
29eadd7c 131## Are we using Solaris' SMF?
132DO_SMF=0
133if egrep "^#define USE_SOLARIS_PROCESS_CONTRACTS" config.h > /dev/null 2>&1
134then
135 DO_SMF=1
136fi
9cefe228 137
138## Collect value of privsep user
139for confvar in SSH_PRIVSEP_USER
140do
141 eval $confvar=`awk '/#define[ \t]'$confvar'/{print $3}' config.h`
142done
143
144## Set privsep defaults if not defined
145if [ -z "$SSH_PRIVSEP_USER" ]
146then
147 SSH_PRIVSEP_USER=sshd
148fi
149
150## Extract common info requires for the 'info' part of the package.
151VERSION=`./ssh -V 2>&1 | sed -e 's/,.*//'`
152
153ARCH=`uname -m`
154DEF_MSG="\n"
155OS_VER=`uname -v`
156SCRIPT_SHELL=/sbin/sh
157UNAME_S=`uname -s`
158case ${UNAME_S} in
159 SunOS) UNAME_S=Solaris
160 ARCH=`uname -p`
161 RCS_D=yes
162 DEF_MSG="(default: n)"
163 ;;
164 SCO_SV) UNAME_S=OpenServer
165 OS_VER=`uname -X | grep Release | sed -e 's/^Rel.*3.2v//'`
166 SCRIPT_SHELL=/bin/sh
167 RC1_D=no
168 DEF_MSG="(default: n)"
169 ;;
170esac
171
172case `basename $0` in
173 buildpkg.sh)
174## Start by faking root install
175echo "Faking root install..."
176[ -d $FAKE_ROOT ] && rm -fr $FAKE_ROOT
177mkdir $FAKE_ROOT
178${MAKE} install-nokeys DESTDIR=$FAKE_ROOT
179if [ $? -gt 0 ]
180then
181 echo "Fake root install failed, stopping."
182 exit 1
183fi
184
185## Setup our run level stuff while we are at it.
29eadd7c 186if [ $DO_SMF -eq 1 ]
187then
188 # For Solaris' SMF, /lib/svc/method/site is the preferred place
189 # for start/stop scripts that aren't supplied with the OS, and
190 # similarly /var/svc/manifest/site for manifests.
191 mkdir -p $FAKE_ROOT${TEST_DIR}/lib/svc/method/site
192 mkdir -p $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site
193
194 cp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/lib/svc/method/site/${SYSVINIT_NAME}
195 chmod 744 $FAKE_ROOT${TEST_DIR}/lib/svc/method/site/${SYSVINIT_NAME}
196
197 cp ${OPENSSH_MANIFEST} $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site
198 chmod 644 $FAKE_ROOT${TEST_DIR}/var/svc/manifest/site/${OPENSSH_MANIFEST}
199else
200 mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.d
9cefe228 201
29eadd7c 202 cp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}
203 chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}
204fi
9cefe228 205
206[ "${PERMIT_ROOT_LOGIN}" = no ] && \
207 perl -p -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" \
208 $FAKE_ROOT/${sysconfdir}/sshd_config
209[ "${X11_FORWARDING}" = yes ] && \
210 perl -p -i -e "s/#X11Forwarding no/X11Forwarding yes/" \
211 $FAKE_ROOT/${sysconfdir}/sshd_config
212# fix PrintMotd
213perl -p -i -e "s/#PrintMotd yes/PrintMotd no/" \
214 $FAKE_ROOT/${sysconfdir}/sshd_config
215
216# We don't want to overwrite config files on multiple installs
217mv $FAKE_ROOT/${sysconfdir}/ssh_config $FAKE_ROOT/${sysconfdir}/ssh_config.default
218mv $FAKE_ROOT/${sysconfdir}/sshd_config $FAKE_ROOT/${sysconfdir}/sshd_config.default
219[ -f $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds ] && \
220mv $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds $FAKE_ROOT/${sysconfdir}/ssh_prng_cmds.default
221
222# local tweeks here
223[ -s "${POST_MAKE_INSTALL_FIXES}" ] && . ${POST_MAKE_INSTALL_FIXES}
224
225cd $FAKE_ROOT
226
227## Ok, this is outright wrong, but it will work. I'm tired of pkgmk
228## whining.
229for i in *; do
230 PROTO_ARGS="$PROTO_ARGS $i=/$i";
231done
232
233## Build info file
234echo "Building pkginfo file..."
235cat > pkginfo << _EOF
236PKG=$PKGNAME
237NAME="OpenSSH Portable for ${UNAME_S}"
238DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh."
239VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html"
240ARCH=$ARCH
d386a795 241VERSION=$VERSION$REV
9cefe228 242CATEGORY="Security,application"
243BASEDIR=/
244CLASSES="none"
245PSTAMP="${UNAME_S} ${OS_VER} ${ARCH} `date '+%d%b%Y %H:%M'`"
246_EOF
247
248## Build empty depend file that may get updated by $POST_PROTOTYPE_EDITS
249echo "Building depend file..."
250touch depend
251
252## Build space file
253echo "Building space file..."
29eadd7c 254if [ $DO_SMF -eq 1 ]
255then
256 # XXX Is this necessary? If not, remove space line from mk-proto.awk.
257 touch space
258else
259 cat > space << _EOF
260# extra space required by start/stop links added by installf
261# in postinstall
9cefe228 262$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1
263$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME} 0 1
264_EOF
29eadd7c 265 [ "$RC1_D" = no ] || \
266 echo "$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space
267 [ "$RCS_D" = yes ] && \
268 echo "$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space
269fi
9cefe228 270
271## Build preinstall file
272echo "Building preinstall file..."
273cat > preinstall << _EOF
274#! ${SCRIPT_SHELL}
275#
276_EOF
277
278# local preinstall changes here
279[ -s "${PKG_PREINSTALL_LOCAL}" ] && . ${PKG_PREINSTALL_LOCAL}
280
281cat >> preinstall << _EOF
282#
29eadd7c 283if [ "\${PRE_INS_STOP}" = "yes" ]
284then
285 if [ $DO_SMF -eq 1 ]
286 then
287 svcadm disable $OPENSSH_FMRI
288 else
289 ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop
290 fi
291fi
292
9cefe228 293exit 0
294_EOF
295
296## Build postinstall file
297echo "Building postinstall file..."
298cat > postinstall << _EOF
299#! ${SCRIPT_SHELL}
300#
301[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config ] || \\
302 cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config.default \\
303 \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config
304[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config ] || \\
305 cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config.default \\
306 \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config
307[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds.default ] && {
308 [ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds ] || \\
309 cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds.default \\
310 \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds
311}
312
313# make rc?.d dirs only if we are doing a test install
29eadd7c 314[ -n "${TEST_DIR}" ] && [ $DO_SMF -ne 1 ] && {
9cefe228 315 [ "$RCS_D" = yes ] && mkdir -p ${TEST_DIR}/etc/rcS.d
316 mkdir -p ${TEST_DIR}/etc/rc0.d
317 [ "$RC1_D" = no ] || mkdir -p ${TEST_DIR}/etc/rc1.d
318 mkdir -p ${TEST_DIR}/etc/rc2.d
319}
320
29eadd7c 321if [ $DO_SMF -eq 1 ]
9cefe228 322then
29eadd7c 323 # Delete the existing service, if it exists, then import the
324 # new one.
325 if svcs $OPENSSH_FMRI > /dev/null 2>&1
326 then
327 svccfg delete -f $OPENSSH_FMRI
328 fi
329 # NOTE, if manifest enables sshd by default, this will actually
330 # start the daemon, which may not be what the user wants.
331 svccfg import ${TEST_DIR}/var/svc/manifest/site/$OPENSSH_MANIFEST
9cefe228 332else
29eadd7c 333 if [ "\${USE_SYM_LINKS}" = yes ]
334 then
335 [ "$RCS_D" = yes ] && \
336 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
337 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
338 [ "$RC1_D" = no ] || \
339 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
340 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
341 else
342 [ "$RCS_D" = yes ] && \
343 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
344 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
345 [ "$RC1_D" = no ] || \
346 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
347 installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=\${PKG_INSTALL_ROOT}$TEST_DIR/etc/init.d/${SYSVINIT_NAME} l
348 fi
9cefe228 349fi
350
351# If piddir doesn't exist we add it. (Ie. --with-pid-dir=/var/opt/ssh)
352[ -d $piddir ] || installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR$piddir d 0755 root sys
353
354_EOF
355
356# local postinstall changes here
357[ -s "${PKG_POSTINSTALL_LOCAL}" ] && . ${PKG_POSTINSTALL_LOCAL}
358
359cat >> postinstall << _EOF
360installf -f ${PKGNAME}
361
362# Use chroot to handle PKG_INSTALL_ROOT
363if [ ! -z "\${PKG_INSTALL_ROOT}" ]
364then
365 chroot="chroot \${PKG_INSTALL_ROOT}"
366fi
367# If this is a test build, we will skip the groupadd/useradd/passwd commands
368if [ ! -z "${TEST_DIR}" ]
369then
370 chroot=echo
371fi
372
16082eaa 373 echo "PrivilegeSeparation user always required."
d386a795 374 if cut -f1 -d: \${PKG_INSTALL_ROOT}/etc/passwd | egrep '^'$SSH_PRIVSEP_USER'\$' >/dev/null
375 then
376 echo "PrivSep user $SSH_PRIVSEP_USER already exists."
377 SSH_PRIVSEP_GROUP=\`grep "^$SSH_PRIVSEP_USER:" \${PKG_INSTALL_ROOT}/etc/passwd | awk -F: '{print \$4}'\`
378 SSH_PRIVSEP_GROUP=\`grep ":\$SSH_PRIVSEP_GROUP:" \${PKG_INSTALL_ROOT}/etc/group | awk -F: '{print \$1}'\`
379 else
380 DO_PASSWD=yes
381 fi
382 [ -z "\$SSH_PRIVSEP_GROUP" ] && SSH_PRIVSEP_GROUP=$SSH_PRIVSEP_USER
383
384 # group required?
385 if cut -f1 -d: \${PKG_INSTALL_ROOT}/etc/group | egrep '^'\$SSH_PRIVSEP_GROUP'\$' >/dev/null
9cefe228 386 then
d386a795 387 echo "PrivSep group \$SSH_PRIVSEP_GROUP already exists."
9cefe228 388 else
d386a795 389 DO_GROUP=yes
390 fi
391
392 # create group if required
393 [ "\$DO_GROUP" = yes ] && {
9cefe228 394 # Use gid of 67 if possible
395 if cut -f3 -d: \${PKG_INSTALL_ROOT}/etc/group | egrep '^'$SSHDGID'\$' >/dev/null
396 then
397 :
398 else
399 sshdgid="-g $SSHDGID"
400 fi
d386a795 401 echo "Creating PrivSep group \$SSH_PRIVSEP_GROUP."
402 \$chroot ${PATH_GROUPADD_PROG} \$sshdgid \$SSH_PRIVSEP_GROUP
403 }
9cefe228 404
405 # Create user if required
d386a795 406 [ "\$DO_PASSWD" = yes ] && {
9cefe228 407 # Use uid of 67 if possible
b5c428f0 408 if cut -f3 -d: \${PKG_INSTALL_ROOT}/etc/passwd | egrep '^'$SSHDUID'\$' >/dev/null
9cefe228 409 then
410 :
411 else
412 sshduid="-u $SSHDUID"
413 fi
414 echo "Creating PrivSep user $SSH_PRIVSEP_USER."
415 \$chroot ${PATH_USERADD_PROG} -c 'SSHD PrivSep User' -s /bin/false -g $SSH_PRIVSEP_USER \$sshduid $SSH_PRIVSEP_USER
416 \$chroot ${PATH_PASSWD_PROG} -l $SSH_PRIVSEP_USER
d386a795 417 }
9cefe228 418
29eadd7c 419if [ "\${POST_INS_START}" = "yes" ]
420then
421 if [ $DO_SMF -eq 1 ]
422 then
423 # See svccfg import note above. The service may already
424 # be started.
425 svcadm enable $OPENSSH_FMRI
426 else
427 ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} start
428 fi
429fi
9cefe228 430exit 0
431_EOF
432
433## Build preremove file
434echo "Building preremove file..."
435cat > preremove << _EOF
436#! ${SCRIPT_SHELL}
437#
29eadd7c 438if [ $DO_SMF -eq 1 ]
439then
440 svcadm disable $OPENSSH_FMRI
441else
442 ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stop
443fi
9cefe228 444_EOF
445
446# local preremove changes here
447[ -s "${PKG_PREREMOVE_LOCAL}" ] && . ${PKG_PREREMOVE_LOCAL}
448
449cat >> preremove << _EOF
450exit 0
451_EOF
452
453## Build postremove file
454echo "Building postremove file..."
455cat > postremove << _EOF
456#! ${SCRIPT_SHELL}
457#
29eadd7c 458if [ $DO_SMF -eq 1 ]
459then
460 if svcs $OPENSSH_FMRI > /dev/null 2>&1
461 then
462 svccfg delete -f $OPENSSH_FMRI
463 fi
464fi
9cefe228 465_EOF
466
467# local postremove changes here
468[ -s "${PKG_POSTREMOVE_LOCAL}" ] && . ${PKG_POSTREMOVE_LOCAL}
469
470cat >> postremove << _EOF
471exit 0
472_EOF
473
474## Build request file
475echo "Building request file..."
476cat > request << _EOF
477trap 'exit 3' 15
478
479_EOF
480
481[ -x /usr/bin/ckyorn ] || cat >> request << _EOF
482
483ckyorn() {
484# for some strange reason OpenServer has no ckyorn
485# We build a striped down version here
486
487DEFAULT=n
488PROMPT="Yes or No [yes,no,?,quit]"
489HELP_PROMPT=" Enter y or yes if your answer is yes; n or no if your answer is no."
490USAGE="usage: ckyorn [options]
491where options may include:
492 -d default
493 -h help
494 -p prompt
495"
496
497if [ \$# != 0 ]
498then
499 while getopts d:p:h: c
500 do
501 case \$c in
502 h) HELP_PROMPT="\$OPTARG" ;;
503 d) DEFAULT=\$OPTARG ;;
504 p) PROMPT=\$OPTARG ;;
505 \\?) echo "\$USAGE" 1>&2
506 exit 1 ;;
507 esac
508 done
509 shift \`expr \$OPTIND - 1\`
510fi
511
512while true
513do
514 echo "\${PROMPT}\\c " 1>&2
515 read key
516 [ -z "\$key" ] && key=\$DEFAULT
517 case \$key in
518 [n,N]|[n,N][o,O]|[y,Y]|[y,Y][e,E][s,S]) echo "\${key}\\c"
519 exit 0 ;;
520 \\?) echo \$HELP_PROMPT 1>&2 ;;
521 q|quit) echo "q\\c" 1>&2
522 exit 3 ;;
523 esac
524done
525
526}
527
528_EOF
529
29eadd7c 530if [ $DO_SMF -eq 1 ]
531then
532 # This could get hairy, as the running sshd may not be under SMF.
533 # We'll assume an earlier version of OpenSSH started via SMF.
534 cat >> request << _EOF
535PRE_INS_STOP=no
536POST_INS_START=no
537# determine if should restart the daemon
538if [ -s ${piddir}/sshd.pid ] && \
539 /usr/bin/svcs $OPENSSH_FMRI 2>&1 | egrep "^online" > /dev/null 2>&1
540then
541 ans=\`ckyorn -d n \
542-p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$?
543 case \$ans in
544 [y,Y]*) PRE_INS_STOP=yes
545 POST_INS_START=yes
546 ;;
547 esac
548
549else
550
551# determine if we should start sshd
552 ans=\`ckyorn -d n \
553-p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$?
554 case \$ans in
555 [y,Y]*) POST_INS_START=yes ;;
556 esac
557fi
558
559# make parameters available to installation service,
560# and so to any other packaging scripts
561cat >\$1 <<!
562PRE_INS_STOP='\$PRE_INS_STOP'
563POST_INS_START='\$POST_INS_START'
564!
565
566_EOF
567else
568 cat >> request << _EOF
9cefe228 569USE_SYM_LINKS=no
570PRE_INS_STOP=no
571POST_INS_START=no
572# Use symbolic links?
573ans=\`ckyorn -d n \
574-p "Do you want symbolic links for the start/stop scripts? ${DEF_MSG}"\` || exit \$?
575case \$ans in
576 [y,Y]*) USE_SYM_LINKS=yes ;;
577esac
578
579# determine if should restart the daemon
580if [ -s ${piddir}/sshd.pid -a -f ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} ]
581then
582 ans=\`ckyorn -d n \
583-p "Should the running sshd daemon be restarted? ${DEF_MSG}"\` || exit \$?
584 case \$ans in
585 [y,Y]*) PRE_INS_STOP=yes
586 POST_INS_START=yes
587 ;;
588 esac
589
590else
591
592# determine if we should start sshd
593 ans=\`ckyorn -d n \
594-p "Start the sshd daemon after installing this package? ${DEF_MSG}"\` || exit \$?
595 case \$ans in
596 [y,Y]*) POST_INS_START=yes ;;
597 esac
598fi
599
600# make parameters available to installation service,
601# and so to any other packaging scripts
602cat >\$1 <<!
603USE_SYM_LINKS='\$USE_SYM_LINKS'
604PRE_INS_STOP='\$PRE_INS_STOP'
605POST_INS_START='\$POST_INS_START'
606!
607
608_EOF
29eadd7c 609fi
9cefe228 610
611# local request changes here
612[ -s "${PKG_REQUEST_LOCAL}" ] && . ${PKG_REQUEST_LOCAL}
613
614cat >> request << _EOF
615exit 0
616
617_EOF
618
619## Next Build our prototype
620echo "Building prototype file..."
621cat >mk-proto.awk << _EOF
622 BEGIN { print "i pkginfo"; print "i depend"; \\
623 print "i preinstall"; print "i postinstall"; \\
624 print "i preremove"; print "i postremove"; \\
625 print "i request"; print "i space"; \\
626 split("$SYSTEM_DIR",sys_files); }
627 {
628 for (dir in sys_files) { if ( \$3 != sys_files[dir] )
629 { if ( \$1 == "s" )
630 { \$5=""; \$6=""; }
631 else
632 { \$5="root"; \$6="sys"; }
633 }
634 else
635 { \$4="?"; \$5="?"; \$6="?"; break;}
636 } }
637 { print; }
638_EOF
639
640find . | egrep -v "prototype|pkginfo|mk-proto.awk" | sort | \
641 pkgproto $PROTO_ARGS | nawk -f mk-proto.awk > prototype
642
643# /usr/local is a symlink on some systems
644[ "${USR_LOCAL_IS_SYMLINK}" = yes ] && {
645 grep -v "^d none /usr/local ? ? ?$" prototype > prototype.new
646 mv prototype.new prototype
647}
648
649## Step back a directory and now build the package.
650cd ..
651# local prototype tweeks here
652[ -s "${POST_PROTOTYPE_EDITS}" ] && . ${POST_PROTOTYPE_EDITS}
653
654echo "Building package.."
655pkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -o
d386a795 656echo | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$VERSION$REV-$UNAME_S-$ARCH.pkg
9cefe228 657 ;;
658
659 justpkg.sh)
660rm -fr ${FAKE_ROOT}/${PKGNAME}
661grep -v "^PSTAMP=" $FAKE_ROOT/pkginfo > $$tmp
662mv $$tmp $FAKE_ROOT/pkginfo
663cat >> $FAKE_ROOT/pkginfo << _EOF
664PSTAMP="${UNAME_S} ${OS_VER} ${ARCH} `date '+%d%b%Y %H:%M'`"
665_EOF
666pkgmk -d ${FAKE_ROOT} -f $FAKE_ROOT/prototype -o
d386a795 667echo | pkgtrans -os ${FAKE_ROOT} ${START}/$PKGNAME-$VERSION$REV-$UNAME_S-$ARCH.pkg
9cefe228 668 ;;
669
670esac
671
672[ "${REMOVE_FAKE_ROOT_WHEN_DONE}" = yes ] && rm -rf $FAKE_ROOT
25616c13 673exit 0
9cefe228 674
This page took 0.177618 seconds and 5 git commands to generate.