File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / sudo / mkpkg
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:26:49 2012 UTC (12 years, 1 month ago) by misho
Branches: sudo, MAIN
CVS tags: v1_8_5p1, HEAD
sudo 1.8.5p1

    1: #!/bin/sh
    2: #
    3: # Build a binary package using polypkg
    4: # Usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]
    5: #
    6: 
    7: # Make sure IFS is set to space, tab, newline in that order.
    8: space=' '
    9: tab='	'
   10: nl='
   11: '
   12: IFS=" 	$nl"
   13: 
   14: # Parse arguments
   15: usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]"
   16: debug=0
   17: flavor=vanilla
   18: crossbuild=false
   19: while test $# -gt 0; do
   20:     case "$1" in
   21: 	--debug)
   22: 	    set -x
   23: 	    debug=1
   24: 	    PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
   25: 	    ;;
   26: 	--flavor=?*)
   27: 	    flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
   28: 	    PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
   29: 	    ;;
   30: 	--flavor)
   31: 	    if [ $# -lt 2 ]; then
   32: 		echo "$usage" 1>&2
   33: 		exit 1
   34: 	    fi
   35: 	    flavor="$2"
   36: 	    PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
   37: 	    shift
   38: 	    ;;
   39: 	--platform=?*)
   40: 	    arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
   41: 	    PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
   42: 	    ;;
   43: 	--platform)
   44: 	    if [ $# -lt 2 ]; then
   45: 		echo "$usage" 1>&2
   46: 		exit 1
   47: 	    fi
   48: 	    PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
   49: 	    shift
   50: 	    ;;
   51: 	--osversion=?*)
   52: 	    arg=`echo "$1" | sed -n 's/^--osversion=\(.*\)/\1/p'`
   53: 	    osversion="$arg"
   54: 	    ;;
   55: 	--osversion)
   56: 	    if [ $# -lt 2 ]; then
   57: 		echo "$usage" 1>&2
   58: 		exit 1
   59: 	    fi
   60: 	    osversion="$2"
   61: 	    shift
   62: 	    ;;
   63: 	--build|--host)
   64: 	    crossbuild=true
   65: 	    configure_opts="${configure_opts}${configure_opts+$tab}$1"
   66: 	    ;;
   67: 	*)
   68: 	    # Pass unknown options to configure
   69: 	    configure_opts="${configure_opts}${configure_opts+$tab}$1"
   70: 	    ;;
   71:     esac
   72:     shift
   73: done
   74: 
   75: top_srcdir=`dirname $0`
   76: 
   77: : ${osversion="`$top_srcdir/pp --probe`"}
   78: test -n "$osversion" || exit 1
   79: osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
   80: 
   81: # Default paths
   82: prefix=/usr/local
   83: 
   84: # Linux distros may build binaries as pie files.
   85: # This is really something libtool should figure out, but it does not.
   86: case "$osversion" in
   87:     *-s390*|*-sparc*|*-alpha*)
   88: 	F_PIE=-fPIE
   89: 	;;
   90:     *)
   91: 	F_PIE=-fpie
   92: 	;;
   93: esac
   94: 
   95: # Choose compiler options by osversion if not cross-compiling.
   96: if [ "$crossbuild" = "false" ]; then
   97:     case "$osversion" in
   98: 	hpux*)
   99: 	    # Use the HP ANSI C compiler on HP-UX if possible
  100: 	    if [ -z "$CC" -a -x /opt/ansic/bin/cc ]; then
  101: 		CC=/opt/ansic/bin/cc; export CC
  102: 		if [ -z "$CFLAGS" ]; then
  103: 		    CFLAGS=-O; export CFLAGS
  104: 		fi
  105: 	    fi
  106: 	    ;;
  107: 	sol[0-9]*)
  108: 	    # Use the Sun Studio C compiler on Solaris if possible
  109: 	    if [ -z "$CC" -a -x /usr/bin/cc ]; then
  110: 		CC=/usr/bin/cc; export CC
  111: 		if [ -z "$CFLAGS" ]; then
  112: 		    CFLAGS=-O; export CFLAGS
  113: 		fi
  114: 	    fi
  115: 	    ;;
  116:     esac
  117: fi
  118: 
  119: # Choose configure options by osversion.
  120: # We use the same configure options as vendor packages when possible.
  121: case "$osversion" in
  122:     centos*|rhel*)
  123: 	prefix=/usr
  124: 	if [ $osrelease -ge 40 ]; then
  125: 	    # RHEL 4 and up support SELinux
  126: 	    configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
  127: 	fi
  128: 	if [ $osrelease -ge 50 ]; then
  129: 	    # RHEL 5 and up build pies, have audit support and use a
  130: 	    # separate PAM config file for "sudo -i".
  131: 	    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
  132: 	    configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
  133: 	    configure_opts="${configure_opts}${configure_opts+$tab}--with-pam-login"
  134: 	    PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0"
  135: 	fi
  136: 	# Note, must indent with tabs, not spaces due to IFS trickery
  137: 	configure_opts="--prefix=$prefix
  138: 		--with-logging=syslog
  139: 		--with-logfac=authpriv
  140: 		--with-pam
  141: 		--enable-zlib=system
  142: 		--with-editor=/bin/vi
  143: 		--with-env-editor
  144: 		--with-ignore-dot
  145: 		--with-tty-tickets
  146: 		--with-ldap
  147: 		--with-passprompt=[sudo] password for %p: 
  148: 		$configure_opts"
  149: 	;;
  150:     sles*)
  151: 	prefix=/usr
  152: 	if [ $osrelease -ge 10 ]; then
  153: 	    # SLES 10 and higher build pies
  154: 	    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
  155: 	    if [ $osrelease -ge 11 ]; then
  156: 		# SLES 11 and higher has SELinux
  157: 		configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
  158: 	    fi
  159: 	fi
  160: 	# SuSE doesn't have /usr/libexec
  161: 	libexec=lib
  162: 	case "$osversion" in
  163: 	    *64*)	gcc -v 2>&1 | grep "with-cpu=[^ ]*32" >/dev/null || libexec=lib64
  164: 			;;
  165: 	esac
  166: 	# Note, must indent with tabs, not spaces due to IFS trickery
  167: 	# XXX - SuSE uses secure path but only for env_reset
  168: 	configure_opts="--prefix=$prefix
  169: 		--libexecdir=$prefix/$libexec/sudo
  170: 		--with-logging=syslog
  171: 		--with-logfac=auth
  172: 		--with-all-insults
  173: 		--with-ignore-dot
  174: 		--with-tty-tickets
  175: 		--enable-shell-sets-home
  176: 		--with-sudoers-mode=0440
  177: 		--with-pam
  178: 		--enable-zlib=system
  179: 		--with-ldap
  180: 		--with-env-editor
  181: 		--with-passprompt=%p\'s password: 
  182: 		$configure_opts"
  183: 
  184: 	make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
  185: 	;;
  186:     deb*|ubu*)
  187: 	prefix=/usr
  188: 	# If Ubuntu, add --enable-admin-flag
  189: 	case "$osversion" in
  190: 	    ubu*)
  191: 		configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
  192: 		if [ $osrelease -ge 1004 ]; then
  193: 		    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
  194: 		fi
  195: 		;;
  196: 	    deb*)
  197: 		if [ $osrelease -ge 600 ]; then
  198: 		    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
  199: 		fi
  200: 		;;
  201: 	esac
  202: 	# Note, must indent with tabs, not spaces due to IFS trickery
  203: 	if test "$flavor" = "ldap"; then
  204: 	    configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
  205: 		--with-ldap-conf-file=/etc/sudo-ldap.conf"
  206: 	fi
  207: 	configure_opts="--prefix=/usr
  208: 		--with-all-insults
  209: 		--with-pam
  210: 		--enable-zlib=system
  211: 		--with-fqdn
  212: 		--with-logging=syslog
  213: 		--with-logfac=authpriv
  214: 		--with-env-editor
  215: 		--with-editor=/usr/bin/editor
  216: 		--with-timeout=15
  217: 		--with-password-timeout=0
  218: 		--with-passprompt=[sudo] password for %p: 
  219: 		--with-timedir=/var/lib/sudo
  220: 		--disable-root-mailer
  221: 		--disable-setresuid
  222: 		--with-sendmail=/usr/sbin/sendmail
  223: 		--mandir=/usr/share/man
  224: 		--libexecdir=/usr/lib/sudo
  225: 		--with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
  226: 		$configure_opts"
  227: 	;;
  228:     macos*)
  229: 	case "$osversion" in
  230: 	    *i386|*x86_64)
  231: 		# Build intel-only universal binaries
  232: 		ARCH_FLAGS="-arch i386 -arch x86_64"
  233: 		;;
  234: 	esac
  235: 	if test "${osversion}" != "`$top_srcdir/pp --probe`"; then
  236: 	    sdkvers=`echo "${osversion}" | sed 's/^macos\([0-9][0-9]\)\([0-9]*\)-.*$/\1.\2/'`
  237: 	    SDK_FLAGS="-isysroot /Developer/SDKs/MacOSX${sdkvers}.sdk -mmacosx-version-min=${sdkvers}"
  238: 	fi
  239: 	export CFLAGS="-O2 -g $ARCH_FLAGS $SDK_FLAGS"
  240: 	export LDFLAGS="$ARCH_FLAGS $SDK_FLAGS"
  241: 	if [ $osrelease -ge 105 ]; then
  242: 	    CFLAGS="$CFLAGS $F_PIE"
  243: 	    LDFLAGS="$LDFLAGS -Wl,-pie"
  244: 	fi
  245: 	# Note, must indent with tabs, not spaces due to IFS trickery
  246: 	configure_opts="--prefix=$prefix
  247: 		--with-pam
  248: 		--without-tty-tickets
  249: 		--enable-zlib=system
  250: 		--with-ldap
  251: 		--with-insults=disabled
  252: 		--with-logging=syslog
  253: 		--with-logfac=authpriv
  254: 		--with-editor=/usr/bin/vim
  255: 		--with-env-editor
  256: 		$configure_opts"
  257: 	;;
  258:     *)
  259: 	# For Solaris, add project support and use let configure choose zlib.
  260: 	# For all others, use the builtin zlib and disable NLS support.
  261: 	case "$osversion" in
  262: 	    sol*) configure_opts="${configure_opts}${configure_opts+$tab}--with-project";;
  263: 	    *) configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls";;
  264: 	esac
  265: 	if test "$flavor" = "ldap"; then
  266: 	    configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
  267: 	fi
  268: 	# Note, must indent with tabs, not spaces due to IFS trickery
  269: 	configure_opts="--prefix=$prefix
  270: 		--with-insults=disabled
  271: 		--with-logging=syslog
  272: 		--with-logfac=auth
  273: 		--with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
  274: 		--with-env-editor
  275: 		$configure_opts"
  276: 	;;
  277: esac
  278: 
  279: # Remove spaces from IFS when setting $@ so that passprompt may include them
  280: OIFS="$IFS"
  281: IFS="	$nl"
  282: set -- $configure_opts $extra_opts
  283: IFS="$OIFS"
  284: if [ -r Makefile ]; then
  285:     make $make_opts distclean
  286: fi
  287: $top_srcdir/configure "$@" || exit 1
  288: make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
  289: test $debug -eq 0 && rm -rf destdir

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>