| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# SPDX-License-Identifier: ISC |
| 4 |
# |
| 5 |
# Copyright (c) 2010-2023 Todd C. Miller <[email protected]> |
| 6 |
# |
| 7 |
# Permission to use, copy, modify, and distribute this software for any |
| 8 |
# purpose with or without fee is hereby granted, provided that the above |
| 9 |
# copyright notice and this permission notice appear in all copies. |
| 10 |
# |
| 11 |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 12 |
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 13 |
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 14 |
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 15 |
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 16 |
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 17 |
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 18 |
# |
| 19 |
# Build a binary package using polypkg |
| 20 |
# Usage: mkpkg [--arch arch] [--build-only] [--configure-only] [--debug] |
| 21 |
# [--flavor flavor] [--osversion ver] [--platform platform] |
| 22 |
# |
| 23 |
|
| 24 |
# Make sure IFS is set to space, tab, newline in that order. |
| 25 |
space=' ' |
| 26 |
tab=' ' |
| 27 |
nl=' |
| 28 |
' |
| 29 |
IFS=" $nl" |
| 30 |
|
| 31 |
# Parse arguments |
| 32 |
usage="usage: mkpkg [--arch arch] [--build-only] [--configure-only] [--debug] [--flavor flavor] [--osversion ver] [--platform platform]" |
| 33 |
debug=0 |
| 34 |
flavor=vanilla |
| 35 |
crossbuild=false |
| 36 |
build_packages=true; |
| 37 |
build_sudo=true; |
| 38 |
while test $# -gt 0; do |
| 39 |
case "$1" in |
| 40 |
--arch=?*) |
| 41 |
arch=`echo "$1" | sed -n 's/^--arch=\(.*\)/\1/p'` |
| 42 |
;; |
| 43 |
--arch) |
| 44 |
arch=`echo "$1" | sed -n 's/^--arch=\(.*\)/\1/p'` |
| 45 |
if [ $# -lt 2 ]; then |
| 46 |
echo "$usage" 1>&2 |
| 47 |
exit 1 |
| 48 |
fi |
| 49 |
arch="$2" |
| 50 |
shift |
| 51 |
;; |
| 52 |
--debug) |
| 53 |
set -x |
| 54 |
debug=1 |
| 55 |
PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}" |
| 56 |
;; |
| 57 |
--flavor=?*) |
| 58 |
flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'` |
| 59 |
PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor" |
| 60 |
;; |
| 61 |
--flavor) |
| 62 |
if [ $# -lt 2 ]; then |
| 63 |
echo "$usage" 1>&2 |
| 64 |
exit 1 |
| 65 |
fi |
| 66 |
flavor="$2" |
| 67 |
PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor" |
| 68 |
shift |
| 69 |
;; |
| 70 |
--platform=?*) |
| 71 |
arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'` |
| 72 |
PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg" |
| 73 |
;; |
| 74 |
--platform) |
| 75 |
if [ $# -lt 2 ]; then |
| 76 |
echo "$usage" 1>&2 |
| 77 |
exit 1 |
| 78 |
fi |
| 79 |
PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2" |
| 80 |
shift |
| 81 |
;; |
| 82 |
--osversion=?*) |
| 83 |
arg=`echo "$1" | sed -n 's/^--osversion=\(.*\)/\1/p'` |
| 84 |
osversion="$arg" |
| 85 |
;; |
| 86 |
--osversion) |
| 87 |
if [ $# -lt 2 ]; then |
| 88 |
echo "$usage" 1>&2 |
| 89 |
exit 1 |
| 90 |
fi |
| 91 |
osversion="$2" |
| 92 |
shift |
| 93 |
;; |
| 94 |
--build|--host) |
| 95 |
crossbuild=true |
| 96 |
configure_opts="${configure_opts}${configure_opts+$tab}$1" |
| 97 |
;; |
| 98 |
--build-only) |
| 99 |
build_packages=false |
| 100 |
;; |
| 101 |
--configure-only) |
| 102 |
build_sudo=false |
| 103 |
;; |
| 104 |
*) |
| 105 |
# Pass unknown options to configure |
| 106 |
configure_opts="${configure_opts}${configure_opts+$tab}$1" |
| 107 |
;; |
| 108 |
esac |
| 109 |
shift |
| 110 |
done |
| 111 |
|
| 112 |
scriptdir=`dirname $0` |
| 113 |
configure="${scriptdir}/../configure" |
| 114 |
|
| 115 |
: ${osversion="`$scriptdir/pp --probe 2>/dev/null || echo unknown`"} |
| 116 |
osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'` |
| 117 |
: ${MAKE=make} |
| 118 |
|
| 119 |
if [ $build_packages = true -a "$osversion" = "unknown" ]; then |
| 120 |
echo "unable to determine platform" 1>&2 |
| 121 |
exit 1 |
| 122 |
fi |
| 123 |
|
| 124 |
# If using GNU make, set number of jobs |
| 125 |
if ${MAKE} --version 2>&1 | grep GNU >/dev/null; then |
| 126 |
NJOBS=0 |
| 127 |
case "`uname`" in |
| 128 |
Darwin) |
| 129 |
# macOS |
| 130 |
NJOBS=`sysctl -n hw.ncpu` |
| 131 |
;; |
| 132 |
Linux) |
| 133 |
if [ -x /usr/bin/nproc ]; then |
| 134 |
NJOBS=`/usr/bin/nproc` |
| 135 |
elif [ -r /proc/cpuinfo ]; then |
| 136 |
NJOBS=`grep ^processor /proc/cpuinfo | wc -l` |
| 137 |
fi |
| 138 |
;; |
| 139 |
SunOS) |
| 140 |
# Solaris |
| 141 |
if [ -x /usr/sbin/psrinfo ]; then |
| 142 |
NJOBS=`/usr/sbin/psrinfo | wc -l` |
| 143 |
fi |
| 144 |
;; |
| 145 |
HP-UX) |
| 146 |
NJOBS=`sar -Mu 1 1 | awk 'END {print NR-5}'` |
| 147 |
;; |
| 148 |
AIX) |
| 149 |
NJOBS=`bindprocessor -q | awk '{print NF-4}'` |
| 150 |
;; |
| 151 |
esac |
| 152 |
if [ $NJOBS -gt 1 ]; then |
| 153 |
if [ $NJOBS -gt 16 ]; then |
| 154 |
NJOBS=16 |
| 155 |
fi |
| 156 |
make_opts="-j$NJOBS" |
| 157 |
fi |
| 158 |
fi |
| 159 |
|
| 160 |
# Choose compiler options by osversion if not cross-compiling. |
| 161 |
if [ "$crossbuild" = "false" ]; then |
| 162 |
case "$osversion" in |
| 163 |
FreeBSD*|macos*) |
| 164 |
# Use clang, not gcc, on FreeBSD and macOS |
| 165 |
if [ -z "$CC" ]; then |
| 166 |
CC=clang; export CC |
| 167 |
fi |
| 168 |
;; |
| 169 |
esac |
| 170 |
fi |
| 171 |
|
| 172 |
# Give configure a hint that we are building a package. |
| 173 |
# Some libc functions are only available on certain OS revisions. |
| 174 |
configure_opts="${configure_opts}${configure_opts+$tab}--enable-package-build" |
| 175 |
|
| 176 |
# Some systems don't have a recent enough OpenSSL for the I/O log server. |
| 177 |
with_openssl=false |
| 178 |
|
| 179 |
# Not all systems have Python 3. |
| 180 |
with_python=false |
| 181 |
|
| 182 |
# Choose configure options by osversion. |
| 183 |
# We use the same configure options as vendor packages when possible. |
| 184 |
case "$osversion" in |
| 185 |
centos*|rhel*|f[0-9]*) |
| 186 |
case "$osversion" in |
| 187 |
centos*|rhel*) |
| 188 |
osmajor=`sed -n -e 's/^.*release \([0-9][0-9]*\).*$/\1/p' /etc/redhat-release` |
| 189 |
if [ $osmajor -ge 4 ]; then |
| 190 |
# RHEL 4 and up support SELinux |
| 191 |
with_selinux=true |
| 192 |
if [ $osmajor -ge 5 ]; then |
| 193 |
# RHEL 5 and up has audit support and uses a |
| 194 |
# separate PAM config file for "sudo -i". |
| 195 |
with_linux_audit=true |
| 196 |
with_pam_login=true |
| 197 |
if [ $osmajor -ge 6 ]; then |
| 198 |
# RHEL 6 and above builds sudo with SSSD support |
| 199 |
with_sssd=true |
| 200 |
# RHEL 6 and above use /etc/sudo-ldap.conf |
| 201 |
with_sudo_ldap_conf=true |
| 202 |
# Encrypted remote I/O log support. |
| 203 |
with_openssl=true |
| 204 |
fi |
| 205 |
if [ $osmajor -ge 6 ]; then |
| 206 |
# Python plugins |
| 207 |
with_python=true |
| 208 |
fi |
| 209 |
fi |
| 210 |
fi |
| 211 |
;; |
| 212 |
f[0-9]*) |
| 213 |
# XXX - investigate which features were in which fedora version |
| 214 |
with_selinux=true |
| 215 |
with_linux_audit=true |
| 216 |
with_pam_login=true |
| 217 |
with_sssd=true |
| 218 |
with_openssl=true |
| 219 |
with_python=true |
| 220 |
;; |
| 221 |
esac |
| 222 |
|
| 223 |
if [ -n "$arch" ]; then |
| 224 |
# Override the default rpm arch for, e.g. x86_64_v2 |
| 225 |
PPVARS="${PPVARS}${PPVARS+$space}pp_rpm_arch_override=$arch" |
| 226 |
fi |
| 227 |
if [ X"$with_selinux" = X"true" ]; then |
| 228 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux" |
| 229 |
fi |
| 230 |
if [ X"$with_linux_audit" = X"true" ]; then |
| 231 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit" |
| 232 |
PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0" |
| 233 |
fi |
| 234 |
if [ X"$with_pam_login" = X"true" ]; then |
| 235 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-pam-login" |
| 236 |
fi |
| 237 |
if [ X"$with_sssd" = X"true" ]; then |
| 238 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd" |
| 239 |
if [ "`getconf LONG_BIT`" = "64" ]; then |
| 240 |
# SSSD backend needs to know where to find the sssd lib |
| 241 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-sssd-lib=/usr/lib64" |
| 242 |
fi |
| 243 |
fi |
| 244 |
if [ X"$with_sudo_ldap_conf" = X"true" ]; then |
| 245 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap-conf-file=/etc/sudo-ldap.conf" |
| 246 |
fi |
| 247 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 248 |
configure_opts="--prefix=/usr |
| 249 |
--with-logging=syslog |
| 250 |
--with-logfac=authpriv |
| 251 |
--with-pam |
| 252 |
--enable-zlib=system |
| 253 |
--with-editor=/bin/vi |
| 254 |
--with-env-editor |
| 255 |
--with-ignore-dot |
| 256 |
--with-ldap |
| 257 |
--with-passprompt=[sudo] password for %p: |
| 258 |
--with-sendmail=/usr/sbin/sendmail |
| 259 |
$configure_opts" |
| 260 |
;; |
| 261 |
sles*) |
| 262 |
if [ $osrelease -ge 10 ]; then |
| 263 |
if [ $osrelease -ge 11 ]; then |
| 264 |
# SLES 11 and higher have SELinux |
| 265 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux" |
| 266 |
fi |
| 267 |
if [ $osrelease -ge 12 ]; then |
| 268 |
# Encrypted remote I/O log support. |
| 269 |
with_openssl=true |
| 270 |
# Python plugins |
| 271 |
with_python=true |
| 272 |
fi |
| 273 |
fi |
| 274 |
# SuSE doesn't have /usr/libexec |
| 275 |
libexec=lib |
| 276 |
case "$osversion" in |
| 277 |
*64*) gcc -v 2>&1 | grep "with-cpu=[^ ]*32" >/dev/null || libexec=lib64 |
| 278 |
;; |
| 279 |
esac |
| 280 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 281 |
# XXX - SuSE uses secure path but only for env_reset |
| 282 |
configure_opts="--prefix=/usr |
| 283 |
--libexecdir=/usr/$libexec |
| 284 |
--with-logging=syslog |
| 285 |
--with-logfac=auth |
| 286 |
--with-all-insults |
| 287 |
--with-ignore-dot |
| 288 |
--enable-shell-sets-home |
| 289 |
--with-sudoers-mode=0440 |
| 290 |
--with-pam |
| 291 |
--enable-zlib=system |
| 292 |
--with-ldap |
| 293 |
--with-env-editor |
| 294 |
--with-passprompt=%p\'s password: |
| 295 |
--with-sendmail=/usr/sbin/sendmail |
| 296 |
$configure_opts" |
| 297 |
|
| 298 |
make_opts="${make_opts}${make_opts+ }"'docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)' |
| 299 |
;; |
| 300 |
deb*|ubu*) |
| 301 |
if [ "$crossbuild" = "true" ]; then |
| 302 |
osname="unknown" |
| 303 |
else |
| 304 |
osname="`uname`" |
| 305 |
fi |
| 306 |
|
| 307 |
# Sudo-specific executables moved to /usr/libexec/sudo starting in |
| 308 |
# Debian: Debian 12 (Bookworm) |
| 309 |
# Ubuntu: Ubuntu 22.04 (Jammy Jellyfish) |
| 310 |
# Previously, they were stored in /usr/lib/sudo. |
| 311 |
libexec=lib |
| 312 |
|
| 313 |
# AppArmor is enabled by default starting in |
| 314 |
# Debian: Debian 10 (Buster) |
| 315 |
# Ubuntu: Ubuntu 12.04 (Precise Pangolin) |
| 316 |
osmajor=`sed -n -e 's/^VERSION_ID=\"\([0-9]*\).*$/\1/p' /etc/os-release` |
| 317 |
case "$osversion" in |
| 318 |
deb*) |
| 319 |
if [ -z $osmajor ] || [ $osmajor -ge 12 ]; then |
| 320 |
libexec=libexec |
| 321 |
fi |
| 322 |
case "$osname" in |
| 323 |
Linux|unknown) |
| 324 |
if [ -z $osmajor ] || [ $osmajor -ge 10 ]; then |
| 325 |
with_apparmor=true |
| 326 |
fi |
| 327 |
;; |
| 328 |
esac |
| 329 |
;; |
| 330 |
ubu*) |
| 331 |
if [ -z $osmajor ] || [ $osmajor -ge 22 ]; then |
| 332 |
libexec=libexec |
| 333 |
fi |
| 334 |
if [ -z $osmajor ] || [ $osmajor -ge 14 ]; then |
| 335 |
with_apparmor=true |
| 336 |
fi |
| 337 |
configure_opts="--enable-admin-flag${tab}--without-lecture${configure_opts+$tab}${configure_opts}" |
| 338 |
;; |
| 339 |
esac |
| 340 |
|
| 341 |
case "$osname" in |
| 342 |
GNU) |
| 343 |
# GNU hurd doesn't have PAM, AppArmor or have Python packages |
| 344 |
;; |
| 345 |
*) |
| 346 |
# Python plugins |
| 347 |
with_python=true |
| 348 |
# PAM |
| 349 |
configure_opts="--with-pam${configure_opts+$tab}${configure_opts}" |
| 350 |
# Linux audit |
| 351 |
configure_opts="--with-linux-audit${configure_opts+$tab}${configure_opts}" |
| 352 |
# AppArmor |
| 353 |
if [ X"$with_apparmor" = X"true" ]; then |
| 354 |
configure_opts="--with-apparmor${configure_opts+$tab}${configure_opts}" |
| 355 |
fi |
| 356 |
;; |
| 357 |
esac |
| 358 |
# Encrypted remote I/O log support. |
| 359 |
with_openssl=true |
| 360 |
# Man pages should be compressed in .deb files |
| 361 |
export MANCOMPRESS='gzip -9' |
| 362 |
export MANCOMPRESSEXT='.gz' |
| 363 |
# Newer Debian uses arch-specific lib dirs |
| 364 |
MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` |
| 365 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 366 |
if [ "$flavor" = "ldap" ]; then |
| 367 |
configure_opts="--with-ldap${tab}--with-ldap-conf-file=/etc/sudo-ldap.conf${configure_opts+$tab}${configure_opts}" |
| 368 |
else |
| 369 |
configure_opts="--with-sssd${configure_opts+$tab}${configure_opts}" |
| 370 |
if [ -n "$MULTIARCH" ]; then |
| 371 |
# SSSD backend needs to know where to find the sssd lib |
| 372 |
configure_opts="--with-sssd-lib=/usr/lib/$MULTIARCH${configure_opts+$tab}${configure_opts}" |
| 373 |
fi |
| 374 |
fi |
| 375 |
configure_opts="--prefix=/usr |
| 376 |
--with-all-insults |
| 377 |
--enable-zlib=system |
| 378 |
--with-fqdn |
| 379 |
--with-logging=syslog |
| 380 |
--with-logfac=authpriv |
| 381 |
--with-env-editor |
| 382 |
--with-editor=/usr/bin/editor |
| 383 |
--with-timeout=15 |
| 384 |
--with-password-timeout=0 |
| 385 |
--with-passprompt=[sudo] password for %p: |
| 386 |
--disable-root-mailer |
| 387 |
--with-sendmail=/usr/sbin/sendmail |
| 388 |
--mandir=/usr/share/man |
| 389 |
--libexecdir=/usr/$libexec |
| 390 |
$configure_opts" |
| 391 |
# Use correct libaudit dependency for Linux audit |
| 392 |
case "$configure_opts" in |
| 393 |
*--with-linux-audit*) |
| 394 |
for f in /usr/lib/${MULTIARCH}${MULTIARCH:+/}libaudit.so.[0-9]* /usr/lib/libaudit.so.[0-9]* /lib/${MULTIARCH}${MULTIARCH:+/}libaudit.so.[0-9]* /lib/libaudit.so.[0-9]*; do |
| 395 |
if [ -f "$f" ]; then |
| 396 |
linux_audit=`dpkg-query -S "$f" 2>/dev/null | sed -n 's/:.*//p'` |
| 397 |
test -n "$linux_audit" && break |
| 398 |
fi |
| 399 |
done |
| 400 |
if [ -z "$linux_audit" ]; then |
| 401 |
echo "unable to determine package for libaudit" 1>&2 |
| 402 |
exit 1 |
| 403 |
fi |
| 404 |
PPVARS="${PPVARS}${PPVARS+$space}linux_audit=$linux_audit" |
| 405 |
;; |
| 406 |
esac |
| 407 |
# Use correct libssl dependency |
| 408 |
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 }'` |
| 409 |
if [ -z "$libssl_dep" ]; then |
| 410 |
echo "unable to determine package for libssl" 1>&2 |
| 411 |
exit 1 |
| 412 |
fi |
| 413 |
PPVARS="${PPVARS}${PPVARS+$space}libssl_dep=$libssl_dep" |
| 414 |
;; |
| 415 |
macos*) |
| 416 |
# TODO: openssl (homebrew?) |
| 417 |
case "$osversion" in |
| 418 |
macos10[0-6]-i386|macos10[0-6]-x86_64) |
| 419 |
# Build intel universal binaries for 10.6 and below |
| 420 |
: ${ARCH_FLAGS="-arch i386 -arch x86_64"} |
| 421 |
;; |
| 422 |
macos1[1-9]*) |
| 423 |
# Build arm64/x86_64 universal binaries for macOS 11 |
| 424 |
: ${ARCH_FLAGS="-arch arm64 -arch x86_64"} |
| 425 |
;; |
| 426 |
esac |
| 427 |
if [ "${osversion}" != "`$scriptdir/pp --probe`" ]; then |
| 428 |
sdkvers=`echo "${osversion}" | sed -e 's/^macos\([0-9][0-9]\)\([0-9]*\)-.*$/\1.\2/' -e 's/\.$//'` |
| 429 |
# SDKs may be under Xcode.app or CommandLineTools (for non-Xcode) |
| 430 |
if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" ]; then |
| 431 |
SDKS="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" |
| 432 |
elif [ -d "/Library/Developer/CommandLineTools/SDKs" ]; then |
| 433 |
SDKS="/Library/Developer/CommandLineTools/SDKs" |
| 434 |
else |
| 435 |
echo "unable to find macOS SDKs directory" 1>&2 |
| 436 |
exit 1 |
| 437 |
fi |
| 438 |
while :; do |
| 439 |
SDK_DIR="${SDKS}/MacOSX${sdkvers}.sdk" |
| 440 |
if [ -d "${SDK_DIR}" ]; then |
| 441 |
SDK_FLAGS="-isysroot ${SDK_DIR} -mmacosx-version-min=${sdkvers}" |
| 442 |
break |
| 443 |
fi |
| 444 |
case "$sdkvers" in |
| 445 |
*.00) |
| 446 |
# Try MacOSXMM.0.sdk |
| 447 |
sdkvers=${sdkvers%0} |
| 448 |
;; |
| 449 |
*.0) |
| 450 |
# Try MacOSXMM.sdk |
| 451 |
sdkvers=${sdkvers%.0} |
| 452 |
;; |
| 453 |
*) |
| 454 |
echo "missing $SDK_DIR" 1>&2 |
| 455 |
exit 1 |
| 456 |
;; |
| 457 |
esac |
| 458 |
done |
| 459 |
fi |
| 460 |
export CFLAGS="-O2 -g $ARCH_FLAGS $SDK_FLAGS" |
| 461 |
export LDFLAGS="$ARCH_FLAGS $SDK_FLAGS" |
| 462 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 463 |
configure_opts="--with-pam |
| 464 |
--with-bsm-audit |
| 465 |
--with-password-timeout=0 |
| 466 |
--enable-zlib=system |
| 467 |
--with-ldap |
| 468 |
--with-insults=disabled |
| 469 |
--with-logging=syslog |
| 470 |
--with-logfac=authpriv |
| 471 |
--with-editor=/usr/bin/vim |
| 472 |
--with-env-editor |
| 473 |
$configure_opts" |
| 474 |
;; |
| 475 |
aix*) |
| 476 |
# TODO: openssl (AIX freeware?) |
| 477 |
# Use -gxcoff with gcc instead of -g for dbx-style debugging symbols. |
| 478 |
if test -z "$CC" && gcc -v >/dev/null 2>&1; then |
| 479 |
CFLAGS="-O2 -gxcoff"; export CFLAGS |
| 480 |
fi |
| 481 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 482 |
# Note: we include our own zlib instead of relying on the |
| 483 |
# AIX freeware version being installed. |
| 484 |
configure_opts=" |
| 485 |
--prefix=/opt/freeware |
| 486 |
--mandir=/opt/freeware/man |
| 487 |
--with-insults=disabled |
| 488 |
--with-logging=syslog |
| 489 |
--with-logfac=auth |
| 490 |
--with-editor=/usr/bin/vi |
| 491 |
--with-env-editor |
| 492 |
--enable-zlib=builtin |
| 493 |
--disable-nls |
| 494 |
--with-sendmail=/usr/sbin/sendmail |
| 495 |
$configure_opts" |
| 496 |
PPVARS="${PPVARS}${PPVARS+$space}aix_freeware=true" |
| 497 |
;; |
| 498 |
FreeBSD*|DragonFly*) |
| 499 |
# Encrypted remote I/O log support. |
| 500 |
with_openssl=true |
| 501 |
|
| 502 |
# Python plugins |
| 503 |
with_python=true |
| 504 |
|
| 505 |
configure_opts=" |
| 506 |
--sysconfdir=/usr/local/etc |
| 507 |
--with-ignore-dot |
| 508 |
--with-tty-tickets |
| 509 |
--with-env-editor |
| 510 |
--with-logincap |
| 511 |
--with-long-otp-prompt |
| 512 |
--with-rundir=/var/run/sudo |
| 513 |
--enable-zlib=system |
| 514 |
--disable-nls |
| 515 |
$configure_opts" |
| 516 |
;; |
| 517 |
*) |
| 518 |
# For Solaris, add project support and use let configure choose zlib. |
| 519 |
# For all others, use the builtin zlib and disable NLS support. |
| 520 |
case "$osversion" in |
| 521 |
sol*) |
| 522 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-project" |
| 523 |
|
| 524 |
if [ $osrelease -ge 11 ]; then |
| 525 |
# Build 64-bit binaries on Solaris 11 and above. |
| 526 |
case "${CC}${CFLAGS}" in |
| 527 |
*-m32*|*-m64*) |
| 528 |
# User specified memory model flags |
| 529 |
;; |
| 530 |
*) |
| 531 |
CFLAGS="${CFLAGS:--O2 -g} -m64"; export CFLAGS |
| 532 |
LDFLAGS="-m64${LDFLAGS:+ }${LDFLAGS}"; export LDFLAGS |
| 533 |
;; |
| 534 |
esac |
| 535 |
# Solaris audit is not supported by Illumos |
| 536 |
if [ X"`uname -o 2>/dev/null`" = X"illumos" ]; then |
| 537 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-bsm-audit" |
| 538 |
else |
| 539 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-solaris-audit" |
| 540 |
fi |
| 541 |
# Encrypted remote I/O log support. |
| 542 |
with_openssl=true |
| 543 |
# Python plugins |
| 544 |
with_python=true |
| 545 |
|
| 546 |
# We prefer the system version of python3 to the |
| 547 |
# csw one (which may be 32-bit) |
| 548 |
if [ -z "$PYTHON" ]; then |
| 549 |
if [ -x /usr/bin/python3 ]; then |
| 550 |
PYTHON="/usr/bin/python3"; export PYTHON |
| 551 |
else |
| 552 |
# Sometimes the /usr/bin/python3 is missing |
| 553 |
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 |
| 554 |
if [ -x $f ]; then |
| 555 |
PYTHON="$f"; export PYTHON |
| 556 |
break |
| 557 |
fi |
| 558 |
done |
| 559 |
fi |
| 560 |
fi |
| 561 |
fi |
| 562 |
;; |
| 563 |
hpux*-ia64) |
| 564 |
# Build 64-bit binaries on HP-UX ia64 |
| 565 |
if test -z "$CC" && gcc -v >/dev/null 2>&1; then |
| 566 |
CC="gcc -mlp64"; export CC |
| 567 |
fi |
| 568 |
# TODO: openssl |
| 569 |
configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls" |
| 570 |
;; |
| 571 |
*) |
| 572 |
# TODO: openssl |
| 573 |
configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls" |
| 574 |
;; |
| 575 |
esac |
| 576 |
if [ "$flavor" = "ldap" ]; then |
| 577 |
configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap" |
| 578 |
fi |
| 579 |
# Note, must indent with tabs, not spaces due to IFS trickery |
| 580 |
configure_opts=" |
| 581 |
--with-insults=disabled |
| 582 |
--with-logging=syslog |
| 583 |
--with-logfac=auth |
| 584 |
--with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi |
| 585 |
--with-env-editor |
| 586 |
$configure_opts" |
| 587 |
;; |
| 588 |
esac |
| 589 |
|
| 590 |
# Don't enable OpenSSL or python if disabled by the user. |
| 591 |
case "$configure_opts" in |
| 592 |
*--disable-openssl*) with_openssl=false;; |
| 593 |
esac |
| 594 |
case "$configure_opts" in |
| 595 |
*--disable-python*) with_python=false;; |
| 596 |
esac |
| 597 |
if [ X"$with_openssl" = X"true" ]; then |
| 598 |
configure_opts="${configure_opts}${configure_opts+$tab}--enable-openssl" |
| 599 |
fi |
| 600 |
if [ X"$with_python" = X"true" ]; then |
| 601 |
configure_opts="${configure_opts}${configure_opts+$tab}--enable-python" |
| 602 |
fi |
| 603 |
|
| 604 |
# The postinstall script will create tmpfiles.d/sudo.conf for us |
| 605 |
configure_opts="${configure_opts}${configure_opts+$tab}--disable-tmpfiles.d" |
| 606 |
|
| 607 |
# Remove spaces from IFS when setting $@ so that passprompt may include them |
| 608 |
OIFS="$IFS" |
| 609 |
IFS=" $nl" |
| 610 |
set -- $configure_opts $extra_opts |
| 611 |
IFS="$OIFS" |
| 612 |
if [ -r Makefile ]; then |
| 613 |
${MAKE} $make_opts distclean |
| 614 |
fi |
| 615 |
${configure} "$@" || exit $? |
| 616 |
if [ $build_sudo = true ]; then |
| 617 |
${MAKE} $make_opts || exit $? |
| 618 |
if [ $build_packages = true ]; then |
| 619 |
${MAKE} $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package |
| 620 |
fi |
| 621 |
fi |
| 622 |
exitval=$? |
| 623 |
test $debug -eq 0 && rm -rf destdir |
| 624 |
|
| 625 |
exit $exitval |