File: mkpkg

package info (click to toggle)
sudo 1.8.5p2-1+nmu3+deb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 12,556 kB
  • sloc: ansic: 39,731; sh: 16,999; makefile: 1,974; yacc: 1,471; lex: 1,037; perl: 436
file content (289 lines) | stat: -rwxr-xr-x 7,878 bytes parent folder | download
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/bin/sh
#
# Build a binary package using polypkg
# Usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]
#

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

# Parse arguments
usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform] [--osversion ver]"
debug=0
flavor=vanilla
crossbuild=false
while test $# -gt 0; do
    case "$1" in
	--debug)
	    set -x
	    debug=1
	    PPFLAGS="--debug${PPFLAGS+$space}${PPFLAGS}"
	    ;;
	--flavor=?*)
	    flavor=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
	    PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
	    ;;
	--flavor)
	    if [ $# -lt 2 ]; then
		echo "$usage" 1>&2
		exit 1
	    fi
	    flavor="$2"
	    PPVARS="${PPVARS}${PPVARS+$space}flavor=$flavor"
	    shift
	    ;;
	--platform=?*)
	    arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
	    PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $arg"
	    ;;
	--platform)
	    if [ $# -lt 2 ]; then
		echo "$usage" 1>&2
		exit 1
	    fi
	    PPFLAGS="${PPFLAGS}${PPFLAGS+$space}--platform $2"
	    shift
	    ;;
	--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
	    ;;
	--build|--host)
	    crossbuild=true
	    configure_opts="${configure_opts}${configure_opts+$tab}$1"
	    ;;
	*)
	    # Pass unknown options to configure
	    configure_opts="${configure_opts}${configure_opts+$tab}$1"
	    ;;
    esac
    shift
done

top_srcdir=`dirname $0`

: ${osversion="`$top_srcdir/pp --probe`"}
test -n "$osversion" || exit 1
osrelease=`echo "$osversion" | 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 "$osversion" in
    *-s390*|*-sparc*|*-alpha*)
	F_PIE=-fPIE
	;;
    *)
	F_PIE=-fpie
	;;
esac

# Choose compiler options by osversion if not cross-compiling.
if [ "$crossbuild" = "false" ]; then
    case "$osversion" in
	hpux*)
	    # Use the HP ANSI C compiler on HP-UX if possible
	    if [ -z "$CC" -a -x /opt/ansic/bin/cc ]; then
		CC=/opt/ansic/bin/cc; export CC
		if [ -z "$CFLAGS" ]; then
		    CFLAGS=-O; export CFLAGS
		fi
	    fi
	    ;;
	sol[0-9]*)
	    # Use the Sun Studio C compiler on Solaris if possible
	    if [ -z "$CC" -a -x /usr/bin/cc ]; then
		CC=/usr/bin/cc; export CC
		if [ -z "$CFLAGS" ]; then
		    CFLAGS=-O; export CFLAGS
		fi
	    fi
	    ;;
    esac
fi

# Choose configure options by osversion.
# We use the same configure options as vendor packages when possible.
case "$osversion" in
    centos*|rhel*)
	prefix=/usr
	if [ $osrelease -ge 40 ]; then
	    # RHEL 4 and up support SELinux
	    configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
	fi
	if [ $osrelease -ge 50 ]; then
	    # RHEL 5 and up build pies, have audit support and use a
	    # separate PAM config file for "sudo -i".
	    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
	    configure_opts="${configure_opts}${configure_opts+$tab}--with-linux-audit"
	    configure_opts="${configure_opts}${configure_opts+$tab}--with-pam-login"
	    PPVARS="${PPVARS}${PPVARS+$space}linux_audit=1.4.0"
	fi
	# Note, must indent with tabs, not spaces due to IFS trickery
	configure_opts="--prefix=$prefix
		--with-logging=syslog
		--with-logfac=authpriv
		--with-pam
		--enable-zlib=system
		--with-editor=/bin/vi
		--with-env-editor
		--with-ignore-dot
		--with-tty-tickets
		--with-ldap
		--with-passprompt=[sudo] password for %p: 
		$configure_opts"
	;;
    sles*)
	prefix=/usr
	if [ $osrelease -ge 10 ]; then
	    # SLES 10 and higher build pies
	    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
	    if [ $osrelease -ge 11 ]; then
		# SLES 11 and higher has SELinux
		configure_opts="${configure_opts}${configure_opts+$tab}--with-selinux"
	    fi
	fi
	# SuSE doesn't have /usr/libexec
	libexec=lib
	case "$osversion" in
	    *64*)	gcc -v 2>&1 | grep "with-cpu=[^ ]*32" >/dev/null || libexec=lib64
			;;
	esac
	# Note, must indent with tabs, not spaces due to IFS trickery
	# XXX - SuSE uses secure path but only for env_reset
	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=system
		--with-ldap
		--with-env-editor
		--with-passprompt=%p\'s password: 
		$configure_opts"

	make_opts='docdir=$(datarootdir)/doc/packages/$(PACKAGE_TARNAME)'
	;;
    deb*|ubu*)
	prefix=/usr
	# If Ubuntu, add --enable-admin-flag
	case "$osversion" in
	    ubu*)
		configure_opts="${configure_opts}${configure_opts+$tab}--enable-admin-flag${tab}--without-lecture"
		if [ $osrelease -ge 1004 ]; then
		    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
		fi
		;;
	    deb*)
		if [ $osrelease -ge 600 ]; then
		    export CFLAGS="-O2 -g $F_PIE" LDFLAGS="-pie"
		fi
		;;
	esac
	# Note, must indent with tabs, not spaces due to IFS trickery
	if test "$flavor" = "ldap"; then
	    configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap
		--with-ldap-conf-file=/etc/sudo-ldap.conf"
	fi
	configure_opts="--prefix=/usr
		--with-all-insults
		--with-pam
		--enable-zlib=system
		--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
		$configure_opts"
	;;
    macos*)
	case "$osversion" in
	    *i386|*x86_64)
		# Build intel-only universal binaries
		ARCH_FLAGS="-arch i386 -arch x86_64"
		;;
	esac
	if test "${osversion}" != "`$top_srcdir/pp --probe`"; then
	    sdkvers=`echo "${osversion}" | sed 's/^macos\([0-9][0-9]\)\([0-9]*\)-.*$/\1.\2/'`
	    SDK_FLAGS="-isysroot /Developer/SDKs/MacOSX${sdkvers}.sdk -mmacosx-version-min=${sdkvers}"
	fi
	export CFLAGS="-O2 -g $ARCH_FLAGS $SDK_FLAGS"
	export LDFLAGS="$ARCH_FLAGS $SDK_FLAGS"
	if [ $osrelease -ge 105 ]; then
	    CFLAGS="$CFLAGS $F_PIE"
	    LDFLAGS="$LDFLAGS -Wl,-pie"
	fi
	# Note, must indent with tabs, not spaces due to IFS trickery
	configure_opts="--prefix=$prefix
		--with-pam
		--without-tty-tickets
		--enable-zlib=system
		--with-ldap
		--with-insults=disabled
		--with-logging=syslog
		--with-logfac=authpriv
		--with-editor=/usr/bin/vim
		--with-env-editor
		$configure_opts"
	;;
    *)
	# For Solaris, add project support and use let configure choose zlib.
	# For all others, use the builtin zlib and disable NLS support.
	case "$osversion" in
	    sol*) configure_opts="${configure_opts}${configure_opts+$tab}--with-project";;
	    *) configure_opts="${configure_opts}${configure_opts+$tab}--enable-zlib=builtin${tab}--disable-nls";;
	esac
	if test "$flavor" = "ldap"; then
	    configure_opts="${configure_opts}${configure_opts+$tab}--with-ldap"
	fi
	# Note, must indent with tabs, not spaces due to IFS trickery
	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
		$configure_opts"
	;;
esac

# Remove spaces from IFS when setting $@ so that passprompt may include them
OIFS="$IFS"
IFS="	$nl"
set -- $configure_opts $extra_opts
IFS="$OIFS"
if [ -r Makefile ]; then
    make $make_opts distclean
fi
$top_srcdir/configure "$@" || exit 1
make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package
test $debug -eq 0 && rm -rf destdir