2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 18:08:23 +00:00

Add simple arg parsing for mkpkg so we can set debug, flavor or platform.

This commit is contained in:
Todd C. Miller 2010-07-26 11:15:50 -04:00
parent d02489ff40
commit 551791a51f
3 changed files with 45 additions and 8 deletions

View File

@ -88,7 +88,7 @@ package: sudo.pp
DESTDIR=`cd $(top_builddir) && pwd`/destdir; rm -rf $$DESTDIR; \
$(SHELL) $(srcdir)/mkinstalldirs $$DESTDIR/$(timedir) && \
$(MAKE) install DESTDIR=$$DESTDIR && \
$(SHELL) $(srcdir)/pp \
$(SHELL) $(srcdir)/pp $(PPFLAGS) \
--destdir=$$DESTDIR \
$(srcdir)/sudo.pp \
bindir=$(bindir) \
@ -103,7 +103,7 @@ package: sudo.pp
sudoers_uid=$(sudoers_uid) \
sudoers_gid=$(sudoers_gid) \
sudoers_mode=$(sudoers_mode) \
version=$(VERSION)
version=$(VERSION) $(PPVARS)
clean: config.status
for d in $(SUBDIRS) $(SAMPLES); do (cd $$d && $(MAKE) $@); done

41
mkpkg
View File

@ -1,7 +1,7 @@
#!/bin/sh
#
# Build a binary package using polypkg
# Usage: mkpkg
# Usage: mkpkg [--debug] [--flavor flavor] [--platform platform]
#
# Make sure IFS is set to space, tab, newline in that order.
@ -9,6 +9,43 @@ nl='
'
IFS=" $nl"
# Parse arguments
usage="usage: mkpkg [--debug] [--flavor flavor] [--platform platform]"
debug=0
while test $# -gt 0; do
case "$1" in
--debug)
set -x
PPFLAGS="--debug${PPFLAGS+ }${PPFLAGS}"
;;
--flavor=?*)
arg=`echo "$1" | sed -n 's/^--flavor=\(.*\)/\1/p'`
PPVARS="${PPVARS}${PPVARS+ }flavor=$arg"
;;
--flavor)
if [ $# -lt 2 ]; then
echo "$usage" 1>&2
exit 1
fi
PPVARS="${PPVARS}${PPVARS+ }flavor=$2"
shift
;;
--platform=?*)
arg=`echo "$1" | sed -n 's/^--platform=\(.*\)/\1/p'`
PPVARS="${PPVARS}${PPVARS+ }platform=$arg"
;;
--platform)
if [ $# -lt 2 ]; then
echo "$usage" 1>&2
exit 1
fi
PPVARS="${PPVARS}${PPVARS+ }platform=$2"
shift
;;
esac
shift
done
top_srcdir=`dirname $0`
platform=`$top_srcdir/pp --probe` || exit 1
@ -139,4 +176,4 @@ IFS=" $nl"
set -- $configure_opts
IFS="$OIFS"
$top_srcdir/configure "$@" || exit 1
make $make_opts && make $make_opts package
make $make_opts && make $make_opts PPFLAGS="$PPFLAGS" PPVARS="$PPVARS" package

View File

@ -1,6 +1,6 @@
%set
if test -n "$SUDO_FLAVOR"; then
name="sudo-$SUDO_FLAVOR"
if test -n "$flavor"; then
name="sudo-$flavor"
else
name="sudo"
fi
@ -183,7 +183,7 @@ still allow people to get their work done."
# create symlink to ease transition to new path for ldap config
# if old config file exists and new one doesn't
if test X"%{SUDO_FLAVOR}" = X"ldap" -a \
if test X"%{flavor}" = X"ldap" -a \
-r /etc/ldap/ldap.conf -a ! -r /etc/sudo-ldap.conf; then
ln -s /etc/ldap/ldap.conf /etc/sudo-ldap.conf
fi
@ -213,7 +213,7 @@ still allow people to get their work done."
%preun [deb]
# Remove the /etc/ldap/ldap.conf -> /etc/sudo-ldap.conf symlink if
# it matches what we created in the postinstall script.
if test X"%{SUDO_FLAVOR}" = X"ldap" -a \
if test X"%{flavor}" = X"ldap" -a \
X"`readlink /etc/sudo-ldap.conf 2>/dev/null`" = X"/etc/ldap/ldap.conf"; then
rm -f /etc/sudo-ldap.conf
fi