📄 buildpkg.sh.in
字号:
#!/bin/sh## Fake Root Solaris/SVR4/SVR5 Build System - Prototype## 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# nor my employer if you break it. - Ben Lindstrom (mouring@eviladmin.org)#umask 022## Options for building the package# You can create a openssh-config.local with your customized options#REMOVE_FAKE_ROOT_WHEN_DONE=yes## uncommenting TEST_DIR and using# configure --prefix=/var/tmp --with-privsep-path=/var/tmp/empty# and# PKGNAME=tOpenSSH should allow testing a package without interfering# with a real OpenSSH package on a system. This is not needed on systems# that support the -R option to pkgadd.#TEST_DIR=/var/tmp # leave commented out for production buildPKGNAME=OpenSSH# revisions within the same version (REV=a)#REV=SYSVINIT_NAME=opensshdMAKE=${MAKE:="make"}SSHDUID=67 # Default privsep uidSSHDGID=67 # Default privsep gid# uncomment these next three as needed#PERMIT_ROOT_LOGIN=no#X11_FORWARDING=yes#USR_LOCAL_IS_SYMLINK=yes# System V init run levelsSYSVINITSTART=S98SYSVINITSTOPT=K30# We will source these if they existPOST_MAKE_INSTALL_FIXES=./pkg_post_make_install_fixes.shPOST_PROTOTYPE_EDITS=./pkg-post-prototype-edit.sh# We'll be one level deeper looking for thesePKG_PREINSTALL_LOCAL=../pkg-preinstall.localPKG_POSTINSTALL_LOCAL=../pkg-postinstall.localPKG_PREREMOVE_LOCAL=../pkg-preremove.localPKG_POSTREMOVE_LOCAL=../pkg-postremove.localPKG_REQUEST_LOCAL=../pkg-request.local# end of sourced files#OPENSSHD=opensshd.initPATH_GROUPADD_PROG=@PATH_GROUPADD_PROG@PATH_USERADD_PROG=@PATH_USERADD_PROG@PATH_PASSWD_PROG=@PATH_PASSWD_PROG@## list of system directories we do NOT want to change owner/group/perms# when installing our packageSYSTEM_DIR="/etc \/etc/init.d \/etc/rcS.d \/etc/rc0.d \/etc/rc1.d \/etc/rc2.d \/etc/opt \/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/opt \/var/run \/var/tmp \/tmp"# We may need to build as root so we make sure PATH is set up# only set the path if it's not set already[ -d /opt/bin ] && { echo $PATH | grep ":/opt/bin" > /dev/null 2>&1 [ $? -ne 0 ] && PATH=$PATH:/opt/bin}[ -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 openssh-config.local to override the above options[ -s ./openssh-config.local ] && . ./openssh-config.localSTART=`pwd`FAKE_ROOT=$START/pkg## Fill in some details, like prefix and sysconfdirfor confvar in prefix exec_prefix bindir sbindir libexecdir datadir mandir sysconfdir piddir srcdirdo eval $confvar=`grep "^$confvar=" Makefile | cut -d = -f 2`done## Collect value of privsep userfor confvar in SSH_PRIVSEP_USERdo eval $confvar=`awk '/#define[ \t]'$confvar'/{print $3}' config.h`done## Set privsep defaults if not definedif [ -z "$SSH_PRIVSEP_USER" ]then SSH_PRIVSEP_USER=sshdfi## Extract common info requires for the 'info' part of the package.VERSION=`./ssh -V 2>&1 | sed -e 's/,.*//'`ARCH=`uname -m`DEF_MSG="\n"OS_VER=`uname -v`SCRIPT_SHELL=/sbin/shUNAME_S=`uname -s`case ${UNAME_S} in SunOS) UNAME_S=Solaris ARCH=`uname -p` RCS_D=yes DEF_MSG="(default: n)" ;; SCO_SV) UNAME_S=OpenServer OS_VER=`uname -X | grep Release | sed -e 's/^Rel.*3.2v//'` SCRIPT_SHELL=/bin/sh RC1_D=no DEF_MSG="(default: n)" ;;esaccase `basename $0` in buildpkg.sh)## Start by faking root installecho "Faking root install..."[ -d $FAKE_ROOT ] && rm -fr $FAKE_ROOTmkdir $FAKE_ROOT${MAKE} install-nokeys DESTDIR=$FAKE_ROOTif [ $? -gt 0 ]then echo "Fake root install failed, stopping." exit 1fi## Setup our run level stuff while we are at it.mkdir -p $FAKE_ROOT${TEST_DIR}/etc/init.dcp ${OPENSSHD} $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}chmod 744 $FAKE_ROOT${TEST_DIR}/etc/init.d/${SYSVINIT_NAME}[ "${PERMIT_ROOT_LOGIN}" = no ] && \ perl -p -i -e "s/#PermitRootLogin yes/PermitRootLogin no/" \ $FAKE_ROOT/${sysconfdir}/sshd_config[ "${X11_FORWARDING}" = yes ] && \ perl -p -i -e "s/#X11Forwarding no/X11Forwarding yes/" \ $FAKE_ROOT/${sysconfdir}/sshd_config# fix PrintMotdperl -p -i -e "s/#PrintMotd yes/PrintMotd no/" \ $FAKE_ROOT/${sysconfdir}/sshd_config# We don't want to overwrite config files on multiple installsmv $FAKE_ROOT/${sysconfdir}/ssh_config $FAKE_ROOT/${sysconfdir}/ssh_config.defaultmv $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# local tweeks here[ -s "${POST_MAKE_INSTALL_FIXES}" ] && . ${POST_MAKE_INSTALL_FIXES}cd $FAKE_ROOT## Ok, this is outright wrong, but it will work. I'm tired of pkgmk## whining.for i in *; do PROTO_ARGS="$PROTO_ARGS $i=/$i";done## Build info fileecho "Building pkginfo file..."cat > pkginfo << _EOFPKG=$PKGNAMENAME="OpenSSH Portable for ${UNAME_S}"DESC="Secure Shell remote access utility; replaces telnet and rlogin/rsh."VENDOR="OpenSSH Portable Team - http://www.openssh.com/portable.html"ARCH=$ARCHVERSION=$VERSION$REVCATEGORY="Security,application"BASEDIR=/CLASSES="none"PSTAMP="${UNAME_S} ${OS_VER} ${ARCH} `date '+%d%b%Y %H:%M'`"_EOF## Build empty depend file that may get updated by $POST_PROTOTYPE_EDITSecho "Building depend file..."touch depend## Build space fileecho "Building space file..."cat > space << _EOF# extra space required by start/stop links added by installf in postinstall$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME} 0 1_EOF[ "$RC1_D" = no ] || \echo "$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space[ "$RCS_D" = yes ] && \echo "$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME} 0 1" >> space## Build preinstall fileecho "Building preinstall file..."cat > preinstall << _EOF#! ${SCRIPT_SHELL}#_EOF# local preinstall changes here[ -s "${PKG_PREINSTALL_LOCAL}" ] && . ${PKG_PREINSTALL_LOCAL}cat >> preinstall << _EOF#[ "\${PRE_INS_STOP}" = "yes" ] && ${TEST_DIR}/etc/init.d/${SYSVINIT_NAME} stopexit 0_EOF## Build postinstall fileecho "Building postinstall file..."cat > postinstall << _EOF#! ${SCRIPT_SHELL}#[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config ] || \\ cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config.default \\ \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_config[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config ] || \\ cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config.default \\ \${PKG_INSTALL_ROOT}${sysconfdir}/sshd_config[ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds.default ] && { [ -f \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds ] || \\ cp -p \${PKG_INSTALL_ROOT}${sysconfdir}/ssh_prng_cmds.default \\ \${PKG_INSTALL_ROOT}${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 [ "$RC1_D" = no ] || 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} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rcS.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc0.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s [ "$RC1_D" = no ] || \ installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc1.d/${SYSVINITSTOPT}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s installf ${PKGNAME} \${PKG_INSTALL_ROOT}$TEST_DIR/etc/rc2.d/${SYSVINITSTART}${SYSVINIT_NAME}=../init.d/${SYSVINIT_NAME} s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -