3 # Build a binary package using polypkg
4 # Usage: mkpkg [--debug] [--flavor flavor] [--platform platform]
7 # Make sure IFS is set to space, tab, newline in that order.
15 usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform]"
18 while test $# -gt 0; do
23 PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
26 flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
27 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
35 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
39 arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
40 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
47 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
51 # Pass unknown options to configure
52 configure_opts="${configure_opts}${configure_opts+$tab}$1"
58 top_srcdir=`dirname $0`
60 platform=`$top_srcdir/pp --probe` || exit 1
61 osrelease=`echo "$platform" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
66 # Linux distros may build binaries as pie files.
67 # This is really something libtool should figure out, but it does not.
69 *-s390*|*-sparc*|*-alpha*)
77 # Choose compiler options by platform.
80 # Use the HP ANSI C compiler on HP-UX if possible
81 if [ -z "$CC" -a -x /opt/ansic/bin/cc ]; then
82 CC=/opt/ansic/bin/cc; export CC
83 if [ -z "$CFLAGS" ]; then
84 CFLAGS=-O; export CFLAGS
87 configure_opts="${configure_opts}${configure_opts+$tab}--disable-zlib"
92 # Choose configure options by platform.
93 # We use the same configure options as vendor packages when possible.
97 if [ $osrelease -ge 50 ]; then
98 # RHEL 5 and up build pies and have audit support
99 export CFLAGS="$F_PIE" LDFLAGS="-pie"
100 configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
102 # Note, must indent with tabs, not spaces due to IFS trickery
103 configure_opts="$configure_opts
105 --with-logging=syslog
106 --with-logfac=authpriv
110 --with-editor=/bin/vi
116 --with-passprompt=[sudo] password for %p: "
120 if [ $osrelease -ge 10 ]; then
121 # SLES 10 and higher build pies
122 export CFLAGS="$F_PIE" LDFLAGS="-pie"
123 if [ $osrelease -ge 11 ]; then
124 # SLES 11 and higher has SELinux
125 configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
128 # SuSE doesn't have /usr/libexec
130 *64*) libexec=lib64;;
133 # Note, must indent with tabs, not spaces due to IFS trickery
134 # XXX - SuSE uses secure path but only for env_reset
135 configure_opts="$configure_opts
137 --libexecdir=$prefix/$libexec/sudo
138 --with-logging=syslog
143 --enable-shell-sets-home
144 --with-sudoers-mode=0440
149 --with-passprompt=%p\'s password: "
151 make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
155 # If Ubuntu, add --enable-admin-flag
158 configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
161 # Note, must indent with tabs, not spaces due to IFS trickery
162 if test "$flavor" = "ldap"; then
163 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
164 --with-ldap-conf-file=/etc/sudo-ldap.conf"
166 configure_opts="$configure_opts
173 --with-logging=syslog
174 --with-logfac=authpriv
176 --with-editor=/usr/bin/editor
178 --with-password-timeout=0
179 --with-passprompt=[sudo] password for %p:
180 --with-timedir=/var/lib/sudo
181 --disable-root-mailer
183 --with-sendmail=/usr/sbin/sendmail
184 --mandir=/usr/share/man
185 --libexecdir=/usr/lib/sudo
186 --with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"
189 if test "$flavor" = "ldap"; then
190 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
192 # Note, must indent with tabs, not spaces due to IFS trickery
193 configure_opts="$configure_opts
195 --with-insults=disabled
196 --with-logging=syslog
198 --with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
203 # Remove spaces from IFS when setting $@ so that passprompt may include them
206 set -- $configure_opts $extra_opts
208 if [ -r Makefile ]; then
209 make $make_opts distclean
211 $top_srcdir/configure "$@" || exit 1
212 make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
213 test $debug -eq 0 && rm -rf destdir