summaryrefslogtreecommitdiff
path: root/mkpkg
blob: 0a16694ac88ed3a8651ddad24b045cce647ef5ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
#
# Build a binary package using polypkg
# Usage: mkpkg
#

# Make sure IFS is set to space, tab, newline in that order.
nl='
'
IFS=" 	$nl"

top_srcdir=`dirname $0`

platform=`$top_srcdir/pp --probe` || exit 1
osrelease=`echo "$platform" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`

# Default paths
prefix=/usr/local

# Linux distros may build binaries as pie files.
# This is really something libtool should figure out, but it does not.
case "$platform" in
    *-s390*|*-sparc*|*-alpha*)
	F_PIE=-fPIE
	;;
    *)
	F_PIE=-fpie
	;;
esac

# Choose configure options by platform.
# We use the same configure options as vendor packages when possible.
case "$platform" in
    centos*|rhel*)
	prefix=/usr
	if [ $osrelease -ge 50 ]; then
	    # RHEL 5 and up build pies and have audit support
	    export CFLAGS="$F_PIE" LDFLAGS="-pie"
	    configure_opts="--with-linux-audit"
	fi
	# Note, must indent with tabs, not spaces due to IFS trickery
	configure_opts="$configure_opts
		--prefix=$prefix
		--with-logging=syslog
		--with-logfac=authpriv
		--with-pam
		--with-pam-login
		--enable-zlib
		--with-editor=/bin/vi
		--with-env-editor
		--with-ignore-dot
		--with-tty-tickets
		--with-ldap
		--with-selinux
		--with-passprompt=[sudo] password for %p: "
	;;
    sles*)
	prefix=/usr
	if [ $osrelease -ge 10 ]; then
	    # SLES 10 and higher build pies
	    export CFLAGS="$F_PIE" LDFLAGS="-pie"
	    if [ $osrelease -ge 11 ]; then
		# SLES 11 and higher has SELinux
		configure_opts="--with-selinux"
	    fi
	fi
	# SuSE doesn't have /usr/libexec
	case "$platform" in
	    *64*)	libexec=lib64;;
	    *)		libexec=lib;;
	esac
	# Note, must indent with tabs, not spaces due to IFS trickery
	# XXX - SuSE uses secure path but only for env_reset
	configure_opts="$configure_opts
		--prefix=$prefix
		--libexecdir=$prefix/$libexec/sudo
		--with-logging=syslog
		--with-logfac=auth
		--with-all-insults
		--with-ignore-dot
		--with-tty-tickets
		--enable-shell-sets-home
		--with-sudoers-mode=0440
		--with-pam
		--enable-zlib
		--with-ldap
		--with-env-editor
		--with-passprompt=%p\'s password: "

	make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
	;;
    deb*)
	prefix=/usr
	# Note, must indent with tabs, not spaces due to IFS trickery
	if test "${SUDO_FLAVOR:-vanilla}" = "ldap"; then
	    configure_opts="--with-ldap
		--with-ldap-conf-file=/etc/sudo-ldap.conf"
	fi
	configure_opts="$configure_opts
		--prefix=/usr
		--with-all-insults
		--with-exempt=sudo
		--with-pam
		--enable-zlib
		--with-fqdn
		--with-logging=syslog
		--with-logfac=authpriv
		--with-env-editor
		--with-editor=/usr/bin/editor
		--with-timeout=15
		--with-password-timeout=0
		--with-passprompt=[sudo] password for %p: 
		--with-timedir=/var/lib/sudo
		--disable-root-mailer
		--disable-setresuid
		--with-sendmail=/usr/sbin/sendmail
		--mandir=/usr/share/man
		--libexecdir=/usr/lib/sudo
		--with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
	;;
    *)
	if test "${SUDO_FLAVOR:-vanilla}" = "ldap"; then
	    configure_opts="--with-ldap"
	fi
	# Note, must indent with tabs, not spaces due to IFS trickery
	configure_opts="$configure_opts
		--prefix=$prefix
		--with-insults=disabled
		--with-logging=syslog
		--with-logfac=auth
		--with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
		--with-env-editor"
	;;
esac

# Remove spaces from IFS when setting $@ so that passprompt may include them
OIFS="$IFS"
IFS="	$nl"
set -- $configure_opts
IFS="$OIFS"
$top_srcdir/configure "$@" || exit 1
make $make_opts && make $make_opts package