2010-07-13 08:33:46 -04:00
#!/bin/sh
2010-07-14 09:36:05 -04:00
#
2019-04-29 07:21:51 -06:00
# SPDX-License-Identifier: ISC
#
2020-04-07 14:03:58 -06:00
# Copyright (c) 2010-2020 Todd C. Miller <Todd.Miller@sudo.ws>
2013-04-24 15:47:39 -04:00
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
2010-07-14 09:36:05 -04:00
# Build a binary package using polypkg
2011-03-07 10:34:47 -05:00
# Usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]
2010-07-14 09:36:05 -04:00
#
2010-07-13 08:33:46 -04:00
2010-07-15 16:35:38 -04:00
# Make sure IFS is set to space, tab, newline in that order.
2010-07-27 18:10:34 -04:00
space=' '
tab=' '
2010-07-15 16:35:38 -04:00
nl='
'
IFS=" $nl"
2010-07-13 08:33:46 -04:00
2010-07-26 11:15:50 -04:00
# Parse arguments
2011-03-07 10:34:47 -05:00
usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]"
2010-07-26 11:15:50 -04:00
debug=0
2010-07-27 18:10:34 -04:00
flavor=vanilla
2011-03-18 17:40:24 -04:00
crossbuild=false
2010-07-26 11:15:50 -04:00
while test $# -gt 0; do
case "$1" in
--debug)
set -x
2010-07-27 18:10:34 -04:00
debug=1
PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
2010-07-26 11:15:50 -04:00
;;
--flavor=?*)
2010-07-27 18:10:34 -04:00
flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
2010-07-26 11:15:50 -04:00
;;
--flavor)
if [ $# -lt 2 ]; then
echo "$usage" 1>&2
exit 1
fi
2010-07-27 18:10:34 -04:00
flavor="$2"
PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
2010-07-26 11:15:50 -04:00
shift
;;
--platform=?*)
arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
2010-07-27 18:10:34 -04:00
PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
2010-07-26 11:15:50 -04:00
;;
--platform)
if [ $# -lt 2 ]; then
echo "$usage" 1>&2
exit 1
fi
2010-07-27 18:10:34 -04:00
PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
2010-07-26 11:15:50 -04:00
shift
;;
2011-03-07 10:34:47 -05:00
--osversion=?*)
arg=`echo "$1" | sed -n 's/^--osversion=\(.*\)/\1/p'`
osversion="$arg"
;;
--osversion)
if [ $# -lt 2 ]; then
echo "$usage" 1>&2
exit 1
fi
osversion="$2"
shift
;;
2011-03-18 17:40:24 -04:00
--build|--host)
crossbuild=true
configure_opts="${configure_opts}${configure_opts+$tab}$1"
;;
2010-07-27 14:49:53 -04:00
*)
# Pass unknown options to configure
2010-07-27 18:10:34 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}$1"
2010-07-27 14:49:53 -04:00
;;
2010-07-26 11:15:50 -04:00
esac
shift
done
2020-02-06 14:30:26 -07:00
scriptdir=`dirname $0`
configure="${scriptdir}/../configure"
2010-07-13 08:33:46 -04:00
2020-02-06 14:30:26 -07:00
: ${osversion="`$scriptdir/pp --probe`"}
2011-03-08 16:09:48 -05:00
test -n "$osversion" || exit 1
2011-03-07 10:34:47 -05:00
osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
2018-08-17 13:27:01 -06:00
: ${MAKE=make}
2010-07-13 08:33:46 -04:00
2016-08-03 06:15:25 -06:00
# If using GNU make, set number of jobs
2018-08-17 13:27:01 -06:00
if ${MAKE} --version 2>&1 | grep GNU >/dev/null; then
2016-08-03 06:31:17 -06:00
NJOBS=0
2016-08-03 06:15:25 -06:00
case "`uname`" in
Darwin)
2017-06-02 16:10:37 -06:00
# macOS
2016-08-03 06:15:25 -06:00
NJOBS=`sysctl -n hw.ncpu`
;;
Linux)
2016-08-03 06:31:17 -06:00
if [ -r /proc/cpuinfo ]; then
for c in `sed -n 's/^cpu cores[ ]*: *//p' /proc/cpuinfo`; do
2016-11-09 06:03:31 -07:00
NJOBS=`expr $NJOBS + $c`
2016-08-03 06:31:17 -06:00
done
2016-08-03 06:15:25 -06:00
fi
;;
SunOS)
# Solaris
if [ -x /usr/sbin/psrinfo ]; then
NJOBS=`/usr/sbin/psrinfo | wc -l`
fi
;;
2018-08-17 13:27:01 -06:00
HP-UX)
NJOBS=`sar -Mu 1 1 | awk 'END {print NR-5}'`
;;
2018-08-18 20:29:39 -06:00
AIX)
NJOBS=`bindprocessor -q | awk '{print NF-4}'`
;;
2016-08-03 06:15:25 -06:00
esac
if [ $NJOBS -gt 1 ]; then
2021-09-17 09:10:27 -06:00
if [ $NJOBS -gt 16 ]; then
NJOBS=16
fi
2016-08-03 06:15:25 -06:00
make_opts="-j$NJOBS"
fi
fi
2011-03-18 17:40:24 -04:00
# Choose compiler options by osversion if not cross-compiling.
if [ "$crossbuild" = "false" ]; then
case "$osversion" in
2021-05-12 15:19:43 -06:00
FreeBSD*|macos*)
# Use the system compiler on FreeBSD and macOS
if [ -z "$CC" -a -x /usr/bin/cc ]; then
CC=/usr/bin/cc; export CC
2017-05-23 12:56:59 -06:00
fi
;;
2011-03-18 17:40:24 -04:00
esac
fi
2010-07-27 14:26:59 -04:00
2018-08-22 08:09:46 -06:00
# Give configure a hint that we are building a package.
# Some libc functions are only available on certain OS revisions.
configure_opts="${configure_opts}${configure_opts+$tab}--enable-package-build"
2020-03-19 06:05:32 -06:00
# Some systems don't have a recent enough OpenSSL for the I/O log server.
with_openssl=false
2020-04-08 14:10:03 -06:00
# Not all systems have Python 3.
with_python=false
2011-03-07 10:34:47 -05:00
# Choose configure options by osversion.
2010-07-13 08:33:46 -04:00
# We use the same configure options as vendor packages when possible.
2011-03-07 10:34:47 -05:00
case "$osversion" in
2016-02-01 11:07:10 -07:00
centos*|rhel*|f[0-9]*)
case "$osversion" in
centos*|rhel*)
2022-05-12 09:42:34 -06:00
osmajor=`sed -n -e 's/^.*release \([0-9][0-9]*\).*$/\1/p' /etc/redhat-release`
2019-02-06 06:30:00 -07:00
if [ $osmajor -ge 4 ]; then
2016-02-01 11:07:10 -07:00
# RHEL 4 and up support SELinux
with_selinux=true
2019-02-06 06:30:00 -07:00
if [ $osmajor -ge 5 ]; then
2016-02-01 11:07:10 -07:00
# RHEL 5 and up has audit support and uses a
# separate PAM config file for "sudo -i".
with_linux_audit=true
with_pam_login=true
2019-02-06 06:30:00 -07:00
if [ $osmajor -ge 6 ]; then
2016-02-01 11:07:10 -07:00
# RHEL 6 and above builds sudo with SSSD support
with_sssd=true
# RHEL 6 and above use /etc/sudo-ldap.conf
with_sudo_ldap_conf=true
2020-03-19 06:05:32 -06:00
# Encrypted remote I/O log support.
with_openssl=true
2020-05-15 09:50:46 -06:00
fi
2021-05-06 18:59:51 -06:00
if [ $osmajor -ge 6 ]; then
2020-04-07 14:03:58 -06:00
# Python plugins
with_python=true
2020-03-19 06:05:32 -06:00
fi
2016-02-01 11:07:10 -07:00
fi
fi
;;
f[0-9]*)
# XXX - investigate which features were in which fedora version
with_selinux=true
with_linux_audit=true
with_pam_login=true
with_sssd=true
2020-03-19 06:05:32 -06:00
with_openssl=true
2021-11-04 10:59:24 -06:00
with_python=true
2016-02-01 11:07:10 -07:00
;;
esac
if [ X"$with_selinux" = X"true" ]; then
2011-08-23 15:24:55 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
fi
2016-02-01 11:07:10 -07:00
if [ X"$with_linux_audit" = X"true" ]; then
2010-07-27 18:10:34 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
2011-01-14 15:03:57 -05:00
PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0"
2010-07-15 22:19:13 -04:00
fi
2016-02-01 11:07:10 -07:00
if [ X"$with_pam_login" = X"true" ]; then
configure_opts="${configure_opts}${configure_opts+$tab}--with-pam-login"
fi
if [ X"$with_sssd" = X"true" ]; then
2013-12-03 15:18:42 -07:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd"
2022-02-23 20:03:33 -07:00
if [ "`getconf LONG_BIT`" = "64" ]; then
2015-07-27 07:07:38 -06:00
# SSSD backend needs to know where to find the sssd lib
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd-lib=/usr/lib64"
fi
2016-02-01 11:07:10 -07:00
fi
if [ X"$with_sudo_ldap_conf" = X"true" ]; then
configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap-conf-file=/etc/sudo-ldap.conf"
2013-12-03 15:18:42 -07:00
fi
2010-07-13 08:33:46 -04:00
# Note, must indent with tabs, not spaces due to IFS trickery
2012-06-08 13:26:16 -04:00
configure_opts="--prefix=/usr
2010-07-13 08:33:46 -04:00
--with-logging=syslog
--with-logfac=authpriv
--with-pam
2010-10-28 12:24:05 -04:00
--enable-zlib=system
2010-07-13 08:33:46 -04:00
--with-editor=/bin/vi
--with-env-editor
--with-ignore-dot
--with-ldap
2011-08-12 11:04:25 -04:00
--with-passprompt=[sudo] password for %p:
2013-05-03 10:51:04 -04:00
--with-sendmail=/usr/sbin/sendmail
2011-08-12 11:04:25 -04:00
$configure_opts"
2010-07-13 08:33:46 -04:00
;;
2010-07-14 15:54:09 -04:00
sles*)
2010-07-15 22:19:13 -04:00
if [ $osrelease -ge 10 ]; then
if [ $osrelease -ge 11 ]; then
2020-04-07 14:03:58 -06:00
# SLES 11 and higher have SELinux
2010-07-27 18:10:34 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
2010-07-15 22:19:13 -04:00
fi
2020-03-19 06:05:32 -06:00
if [ $osrelease -ge 12 ]; then
2020-04-07 14:03:58 -06:00
# Encrypted remote I/O log support.
2020-03-19 06:05:32 -06:00
with_openssl=true
2020-04-07 14:03:58 -06:00
# Python plugins
with_python=true
2020-03-19 06:05:32 -06:00
fi
2010-07-15 22:19:13 -04:00
fi
2010-07-13 08:33:46 -04:00
# SuSE doesn't have /usr/libexec
2011-07-05 12:42:55 -04:00
libexec=lib
2011-03-07 10:34:47 -05:00
case "$osversion" in
2011-07-05 12:42:55 -04:00
*64*) gcc -v 2>&1 | grep "with-cpu=[^ ]*32" >/dev/null || libexec=lib64
;;
2010-07-13 08:33:46 -04:00
esac
# Note, must indent with tabs, not spaces due to IFS trickery
2010-07-14 09:36:05 -04:00
# XXX - SuSE uses secure path but only for env_reset
2012-06-08 13:26:16 -04:00
configure_opts="--prefix=/usr
2013-02-06 14:06:51 -05:00
--libexecdir=/usr/$libexec
2010-07-13 08:33:46 -04:00
--with-logging=syslog
--with-logfac=auth
--with-all-insults
--with-ignore-dot
--enable-shell-sets-home
--with-sudoers-mode=0440
--with-pam
2010-10-28 12:24:05 -04:00
--enable-zlib=system
2010-07-13 08:33:46 -04:00
--with-ldap
--with-env-editor
2011-08-12 11:04:25 -04:00
--with-passprompt=%p\'s password:
2013-05-03 10:51:04 -04:00
--with-sendmail=/usr/sbin/sendmail
2011-08-12 11:04:25 -04:00
$configure_opts"
2010-07-13 08:33:46 -04:00
2016-08-22 07:13:02 -06:00
make_opts="${make_opts}${make_opts+ }"'docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
2010-07-13 08:33:46 -04:00
;;
2010-07-28 16:34:11 -04:00
deb*|ubu*)
2022-05-23 00:55:16 -06:00
# AppArmor is enabled by default starting in
# Debian: Debian 10 (Buster)
# Ubuntu: Ubuntu 12.04 (Precise Pangolin)
osmajor=`sed -n -e 's/^VERSION_ID=\"\([0-9]*\).*$/\1/p' /etc/os-release`
case "$osversion" in
deb*)
if [ -z $osmajor ] || [ $osmajor -ge 10 ]; then
with_apparmor=true
fi
;;
ubu*)
if [ -z $osmajor ] || [ $osmajor -ge 14 ]; then
with_apparmor=true
fi
;;
esac
2020-03-19 06:05:32 -06:00
# Encrypted remote I/O log support.
with_openssl=true
2020-04-07 14:03:58 -06:00
# Python plugins
with_python=true
2012-05-31 14:03:41 -04:00
# Man pages should be compressed in .deb files
export MANCOMPRESS='gzip -9'
export MANCOMPRESSEXT='.gz'
2010-07-28 16:34:11 -04:00
# If Ubuntu, add --enable-admin-flag
2011-03-07 10:34:47 -05:00
case "$osversion" in
2010-07-28 16:34:11 -04:00
ubu*)
configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
;;
esac
2015-07-08 18:13:39 -06:00
# Newer Debian uses arch-specific lib dirs
2015-07-09 09:34:22 -06:00
MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null`
2010-07-13 17:52:50 -04:00
# Note, must indent with tabs, not spaces due to IFS trickery
2022-02-23 20:03:33 -07:00
if [ "$flavor" = "ldap" ]; then
2010-07-27 18:10:34 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
2010-07-14 14:09:34 -04:00
--with-ldap-conf-file=/etc/sudo-ldap.conf"
2015-07-08 16:15:53 -06:00
else
2015-07-08 18:13:39 -06:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd"
2022-02-23 20:03:33 -07:00
if [ -n "$MULTIARCH" ]; then
2015-07-08 18:13:39 -06:00
# SSSD backend needs to know where to find the sssd lib
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd-lib=/usr/lib/$MULTIARCH"
fi
2010-07-14 14:09:34 -04:00
fi
2022-05-23 00:55:16 -06:00
if [ X"$with_apparmor" = X"true" ]; then
configure_opts="${configure_opts}${configure_opts+$tab}--with-apparmor"
fi
2011-08-12 11:04:25 -04:00
configure_opts="--prefix=/usr
2010-07-13 17:52:50 -04:00
--with-all-insults
--with-pam
2010-10-28 12:24:05 -04:00
--enable-zlib=system
2010-07-13 17:52:50 -04:00
--with-fqdn
--with-logging=syslog
--with-logfac=authpriv
--with-env-editor
--with-editor=/usr/bin/editor
--with-timeout=15
--with-password-timeout=0
2010-07-14 09:36:05 -04:00
--with-passprompt=[sudo] password for %p:
2010-07-13 17:52:50 -04:00
--disable-root-mailer
--with-sendmail=/usr/sbin/sendmail
--mandir=/usr/share/man
2013-02-06 14:06:51 -05:00
--libexecdir=/usr/lib
2015-07-08 16:15:53 -06:00
--with-linux-audit
2011-08-12 11:04:25 -04:00
$configure_opts"
2015-07-08 18:13:39 -06:00
# Use correct libaudit dependency
2015-07-09 13:01:43 -06:00
for f in /lib/${MULTIARCH}${MULTIARCH:+/}libaudit.so.[0-9]* /lib/libaudit.so.[0-9]*; do
2022-02-23 20:03:33 -07:00
if [ -f "$f" ]; then
2015-07-09 13:01:43 -06:00
linux_audit=`dpkg-query -S "$f" 2>/dev/null | sed -n 's/:.*//p'`
2022-03-29 16:53:37 -06:00
test -n "$linux_audit" && break
2015-07-09 13:01:43 -06:00
fi
done
2019-08-23 11:37:55 -06:00
if [ -z "$linux_audit" ]; then
2015-07-09 13:01:43 -06:00
echo "unable to determine package for libaudit" 1>&2
exit 1
fi
2015-07-08 18:13:39 -06:00
PPVARS="${PPVARS}${PPVARS+$space}linux_audit=$linux_audit"
2020-08-05 12:58:02 -06:00
# Use correct libssl dependency
2022-05-15 07:45:51 -06:00
libssl_dep=`dpkg-query -S /usr/lib/${MULTIARCH}${MULTIARCH:+/}libssl.so.[1-9]* /lib/${MULTIARCH}${MULTIARCH:+/}libssl.so.[1-9]* 2>/dev/null | sort -rn | awk -F: '{ print $1; exit }'`
2020-08-05 12:58:02 -06:00
if [ -z "$libssl_dep" ]; then
echo "unable to determine package for libssl" 1>&2
exit 1
fi
PPVARS="${PPVARS}${PPVARS+$space}libssl_dep=$libssl_dep"
2010-07-13 17:52:50 -04:00
;;
2012-02-07 11:49:46 -05:00
macos*)
2020-03-19 06:05:32 -06:00
# TODO: openssl (homebrew?)
2012-04-20 10:38:43 -04:00
case "$osversion" in
2015-10-25 09:10:15 -06:00
macos10[0-6]-i386|macos10[0-6]-x86_64)
2015-04-28 14:54:44 -06:00
# Build intel universal binaries for 10.6 and below
2022-02-23 20:04:21 -07:00
: ${ARCH_FLAGS="-arch i386 -arch x86_64"}
2012-04-20 10:38:43 -04:00
;;
2022-02-23 20:04:21 -07:00
macos1[1-9]*)
2021-10-29 13:03:36 -06:00
# Build arm64/x86_64 universal binaries for macOS 11
2022-02-23 20:04:21 -07:00
: ${ARCH_FLAGS="-arch arm64 -arch x86_64"}
2020-11-13 09:46:00 -07:00
;;
2012-04-20 10:38:43 -04:00
esac
2022-02-23 20:03:33 -07:00
if [ "${osversion}" != "`$scriptdir/pp --probe`" ]; then
2021-11-18 15:40:36 -07:00
sdkvers=`echo "${osversion}" | sed -e 's/^macos\([0-9][0-9]\)\([0-9]*\)-.*$/\1.\2/' -e 's/\.$//'`
2019-05-22 08:57:48 -06:00
# SDKs may be under Xcode.app or CommandLineTools (for non-Xcode)
if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then
SDK_DIR="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
elif [ -d "/Library/Developer/CommandLineTools/SDKs" ]; then
SDK_DIR="/Library/Developer/CommandLineTools/SDKs"
else
echo "unable to find macOS SDKs directory" 1>&2
exit 1
fi
SDK_DIR="${SDK_DIR}/MacOSX${sdkvers}.sdk"
2022-02-23 20:03:33 -07:00
if [ -d "${SDK_DIR}" ]; then
2019-05-22 08:57:48 -06:00
SDK_FLAGS="-isysroot ${SDK_DIR} -mmacosx-version-min=${sdkvers}"
else
echo "unable to find SDKs directory for macOS $sdkvers" 1>&2
exit 1
2013-08-06 10:58:50 -06:00
fi
2012-04-16 10:14:56 -04:00
fi
2012-02-24 13:40:39 -05:00
export CFLAGS="-O2 -g $ARCH_FLAGS $SDK_FLAGS"
export LDFLAGS="$ARCH_FLAGS $SDK_FLAGS"
2012-02-07 11:49:46 -05:00
# Note, must indent with tabs, not spaces due to IFS trickery
2012-06-08 13:26:16 -04:00
configure_opts="--with-pam
2013-08-15 10:41:48 -06:00
--with-bsm-audit
2021-08-02 11:11:05 -06:00
--with-password-timeout=0
2012-02-07 11:49:46 -05:00
--enable-zlib=system
--with-ldap
--with-insults=disabled
--with-logging=syslog
--with-logfac=authpriv
--with-editor=/usr/bin/vim
--with-env-editor
$configure_opts"
;;
2012-06-11 15:07:16 -04:00
aix*)
2020-03-19 06:05:32 -06:00
# TODO: openssl (AIX freeware?)
2013-06-17 16:48:32 -04:00
# Use -gxcoff with gcc instead of -g for dbx-style debugging symbols.
2022-03-29 16:53:37 -06:00
if test -z "$CC" && gcc -v >/dev/null 2>&1; then
2019-05-24 16:02:58 -06:00
CFLAGS="-O2 -gxcoff"; export CFLAGS
2013-06-17 16:48:32 -04:00
fi
2012-06-11 15:07:16 -04:00
# Note, must indent with tabs, not spaces due to IFS trickery
# Note: we include our own zlib instead of relying on the
# AIX freeware version being installed.
configure_opts="
--prefix=/opt/freeware
--mandir=/opt/freeware/man
--with-insults=disabled
--with-logging=syslog
--with-logfac=auth
--with-editor=/usr/bin/vi
--with-env-editor
--enable-zlib=builtin
2012-06-25 14:00:11 -04:00
--disable-nls
2013-05-03 10:51:04 -04:00
--with-sendmail=/usr/sbin/sendmail
2012-06-11 15:07:16 -04:00
$configure_opts"
2012-06-20 14:18:14 -04:00
PPVARS="${PPVARS}${PPVARS+$space}aix_freeware=true"
2012-06-11 15:07:16 -04:00
;;
2021-08-11 15:09:00 -06:00
FreeBSD*)
# Encrypted remote I/O log support.
with_openssl=true
# Python plugins
with_python=true
configure_opts="
--sysconfdir=/usr/local/etc
--with-ignore-dot
--with-tty-tickets
--with-env-editor
--with-logincap
--with-long-otp-prompt
--with-rundir=/var/run/sudo
--enable-zlib=system
--disable-nls
$configure_opts"
;;
2010-07-13 08:33:46 -04:00
*)
2010-10-28 12:24:05 -04:00
# For Solaris, add project support and use let configure choose zlib.
2011-08-12 11:04:25 -04:00
# For all others, use the builtin zlib and disable NLS support.
2011-03-07 10:34:47 -05:00
case "$osversion" in
2013-08-15 10:41:48 -06:00
sol*)
configure_opts="${configure_opts}${configure_opts+$tab}--with-project"
if [ $osrelease -ge 11 ]; then
2020-06-06 16:07:33 -06:00
# Build 64-bit binaries on Solaris 11 and above.
2021-02-07 15:38:11 -07:00
CFLAGS="${CFLAGS:--O2 -g} -m64"; export CFLAGS
LDFLAGS="-m64${LDFLAGS:+ }${LDFLAGS}"; export LDFLAGS
2020-06-06 16:07:33 -06:00
# Solaris audit is not supported by Illumos
2022-02-23 20:03:33 -07:00
if [ X"`uname -o 2>/dev/null`" = X"illumos" ]; then
2020-06-04 14:41:28 -06:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-bsm-audit"
else
configure_opts="${configure_opts}${configure_opts+$tab}--with-solaris-audit"
fi
2020-03-19 06:05:32 -06:00
# Encrypted remote I/O log support.
with_openssl=true
2020-06-06 16:07:33 -06:00
# Python plugins
with_python=true
2020-06-06 18:45:28 -06:00
# We prefer the system version of python3 to the
# csw one (which may be 32-bit)
if [ -z "$PYTHON" ]; then
if [ -x /usr/bin/python3 ]; then
PYTHON="/usr/bin/python3"; export PYTHON
else
# Sometimes the /usr/bin/python3 is missing
2022-05-15 07:45:51 -06:00
for f in /usr/bin/python3.11 /usr/bin/python3.10 /usr/bin/python3.9 /usr/bin/python3.8 /usr/bin/python3.7 /usr/bin/python3.6 /usr/bin/python3.5 /usr/bin/python3.4; do
2020-06-06 18:45:28 -06:00
if [ -x $f ]; then
PYTHON="$f"; export PYTHON
break
fi
done
fi
fi
2013-08-15 10:41:48 -06:00
fi
;;
2020-10-20 14:40:32 -06:00
hpux*-ia64)
# Build 64-bit binaries on HP-UX ia64
if test -z "$CC" && gcc -v >/dev/null 2>&1; then
CC="gcc -mlp64"; export CC
fi
# TODO: openssl
configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls"
;;
2013-08-15 10:41:48 -06:00
*)
2020-03-19 06:05:32 -06:00
# TODO: openssl
2013-08-15 10:41:48 -06:00
configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls"
;;
2010-10-01 11:36:14 -04:00
esac
2022-02-23 20:03:33 -07:00
if [ "$flavor" = "ldap" ]; then
2010-07-27 18:10:34 -04:00
configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
2010-07-14 15:56:37 -04:00
fi
2010-07-13 08:33:46 -04:00
# Note, must indent with tabs, not spaces due to IFS trickery
2012-06-08 13:26:16 -04:00
configure_opts="
2010-07-13 08:33:46 -04:00
--with-insults=disabled
--with-logging=syslog
--with-logfac=auth
--with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
2011-08-12 11:04:25 -04:00
--with-env-editor
$configure_opts"
2010-07-13 08:33:46 -04:00
;;
esac
2020-03-19 06:05:32 -06:00
# Don't enable OpenSSL if user disabled it.
case "$configure_opts" in
*--disable-openssl*) with_openssl=false;;
esac
if [ X"$with_openssl" = X"true" ]; then
configure_opts="${configure_opts}${configure_opts+$tab}--enable-openssl"
fi
2020-04-07 14:03:58 -06:00
if [ X"$with_python" = X"true" ]; then
configure_opts="${configure_opts}${configure_opts+$tab}--enable-python"
fi
2020-03-19 06:05:32 -06:00
2015-04-07 15:35:01 -06:00
# The postinstall script will create tmpfiles.d/sudo.conf for us
configure_opts="${configure_opts}${configure_opts+$tab}--disable-tmpfiles.d"
2010-07-13 08:33:46 -04:00
# Remove spaces from IFS when setting $@ so that passprompt may include them
OIFS="$IFS"
2010-07-15 16:35:38 -04:00
IFS=" $nl"
2010-07-27 14:49:53 -04:00
set -- $configure_opts $extra_opts
2010-07-13 08:33:46 -04:00
IFS="$OIFS"
2010-07-27 18:10:34 -04:00
if [ -r Makefile ]; then
2018-08-17 13:27:01 -06:00
${MAKE} $make_opts distclean
2010-07-27 18:10:34 -04:00
fi
2021-10-10 16:14:52 -06:00
${configure} "$@" || exit $?
${MAKE} $make_opts || exit $?
${MAKE} $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
exitval=$?
2010-07-27 18:10:34 -04:00
test $debug -eq 0 && rm -rf destdir
2021-10-10 16:14:52 -06:00
exit $exitval