3 # Build a binary package using polypkg
4 # Usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]
7 # Make sure IFS is set to space, tab, newline in that order.
15 usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]"
19 while test $# -gt 0; do
24 PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
27 flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
28 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
36 PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
40 arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
41 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
48 PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
52 arg=`echo "$1" | sed -n 's/^--osversion=\(.*\)/\1/p'`
65 configure_opts="${configure_opts}${configure_opts+$tab}$1"
68 # Pass unknown options to configure
69 configure_opts="${configure_opts}${configure_opts+$tab}$1"
75 top_srcdir=`dirname $0`
77 : ${osversion="`$top_srcdir/pp --probe`"}
78 test -n "$osversion" || exit 1
79 osrelease=`echo "$osversion" | sed -e 's/^[^0-9]*//' -e 's/-.*$//'`
81 # Choose compiler options by osversion if not cross-compiling.
82 if [ "$crossbuild" = "false" ]; then
85 # Use the HP ANSI C compiler on HP-UX if possible
86 if [ -z "$CC" -a -x /opt/ansic/bin/cc ]; then
87 CC=/opt/ansic/bin/cc; export CC
88 if [ -z "$CFLAGS" ]; then
89 CFLAGS=-O; export CFLAGS
94 # Use the Sun Studio C compiler on Solaris if possible
95 if [ -z "$CC" -a -x /usr/bin/cc ]; then
96 CC=/usr/bin/cc; export CC
97 if [ -z "$CFLAGS" ]; then
98 CFLAGS=-O; export CFLAGS
105 # Choose configure options by osversion.
106 # We use the same configure options as vendor packages when possible.
109 if [ $osrelease -ge 40 ]; then
110 # RHEL 4 and up support SELinux
111 configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
113 if [ $osrelease -ge 50 ]; then
114 # RHEL 5 and up has audit support and uses a separate PAM
115 # config file for "sudo -i".
116 configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
117 configure_opts="${configure_opts}${configure_opts+$tab}--with-pam-login"
118 PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0"
120 # Note, must indent with tabs, not spaces due to IFS trickery
121 configure_opts="--prefix=/usr
122 --with-logging=syslog
123 --with-logfac=authpriv
126 --with-editor=/bin/vi
131 --with-passprompt=[sudo] password for %p:
135 if [ $osrelease -ge 10 ]; then
136 # SLES 11 and higher has SELinux
137 if [ $osrelease -ge 11 ]; then
138 configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
141 # SuSE doesn't have /usr/libexec
144 *64*) gcc -v 2>&1 | grep "with-cpu=[^ ]*32" >/dev/null || libexec=lib64
147 # Note, must indent with tabs, not spaces due to IFS trickery
148 # XXX - SuSE uses secure path but only for env_reset
149 configure_opts="--prefix=/usr
150 --libexecdir=/usr/$libexec/sudo
151 --with-logging=syslog
156 --enable-shell-sets-home
157 --with-sudoers-mode=0440
162 --with-passprompt=%p\'s password:
165 make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
168 # Man pages should be compressed in .deb files
169 export MANCOMPRESS='gzip -9'
170 export MANCOMPRESSEXT='.gz'
171 # If Ubuntu, add --enable-admin-flag
174 configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
177 # Note, must indent with tabs, not spaces due to IFS trickery
178 if test "$flavor" = "ldap"; then
179 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
180 --with-ldap-conf-file=/etc/sudo-ldap.conf"
182 configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
183 configure_opts="--prefix=/usr
188 --with-logging=syslog
189 --with-logfac=authpriv
191 --with-editor=/usr/bin/editor
193 --with-password-timeout=0
194 --with-passprompt=[sudo] password for %p:
195 --with-timedir=/var/lib/sudo
196 --disable-root-mailer
198 --with-sendmail=/usr/sbin/sendmail
199 --mandir=/usr/share/man
200 --libexecdir=/usr/lib/sudo
201 --with-secure-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
207 # Build intel-only universal binaries
208 ARCH_FLAGS="-arch i386 -arch x86_64"
211 if test "${osversion}" != "`$top_srcdir/pp --probe`"; then
212 sdkvers=`echo "${osversion}" | sed 's/^macos\([0-9][0-9]\)\([0-9]*\)-.*$/\1.\2/'`
213 SDK_FLAGS="-isysroot /Developer/SDKs/MacOSX${sdkvers}.sdk -mmacosx-version-min=${sdkvers}"
215 export CFLAGS="-O2 -g $ARCH_FLAGS $SDK_FLAGS"
216 export LDFLAGS="$ARCH_FLAGS $SDK_FLAGS"
217 # Note, must indent with tabs, not spaces due to IFS trickery
218 configure_opts="--with-pam
219 --without-tty-tickets
222 --with-insults=disabled
223 --with-logging=syslog
224 --with-logfac=authpriv
225 --with-editor=/usr/bin/vim
230 # Note, must indent with tabs, not spaces due to IFS trickery
231 # Note: we include our own zlib instead of relying on the
232 # AIX freeware version being installed.
234 --prefix=/opt/freeware
235 --mandir=/opt/freeware/man
236 --with-insults=disabled
237 --with-logging=syslog
239 --with-editor=/usr/bin/vi
241 --enable-zlib=builtin
244 PPVARS="${PPVARS}${PPVARS+$space}aix_freeware=true"
247 # For Solaris, add project support and use let configure choose zlib.
248 # For all others, use the builtin zlib and disable NLS support.
250 sol*) configure_opts="${configure_opts}${configure_opts+$tab}--with-project${tab}--disable-pie";;
251 *) configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls";;
253 if test "$flavor" = "ldap"; then
254 configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
256 # Note, must indent with tabs, not spaces due to IFS trickery
258 --with-insults=disabled
259 --with-logging=syslog
261 --with-editor=/usr/bin/vim:/usr/bin/vi:/bin/vi
267 # Remove spaces from IFS when setting $@ so that passprompt may include them
270 set -- $configure_opts $extra_opts
272 if [ -r Makefile ]; then
273 make $make_opts distclean
275 $top_srcdir/configure "$@" || exit 1
276 make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
277 test $debug -eq 0 && rm -rf destdir