From: Todd C. Miller Date: Mon, 26 Jul 2010 15:15:19 +0000 (-0400) Subject: Add simple arg parsing for mkpkg so we can set debug, flavor or platform. X-Git-Tag: SUDO_1_7_4~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=10dc0da1f933b0c3a98eecc5479def3bd8e33e48;p=sudo Add simple arg parsing for mkpkg so we can set debug, flavor or platform. --HG-- branch : 1.7 --- diff --git a/Makefile.in b/Makefile.in index 971e850c5..edfce660c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -541,7 +541,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) \ @@ -555,6 +555,6 @@ package: sudo.pp sudoers_uid=$(sudoers_uid) \ sudoers_gid=$(sudoers_gid) \ sudoers_mode=$(sudoers_mode) \ - version=$(VERSION) + version=$(VERSION) $(PPVARS) .PHONY: ChangeLog diff --git a/mkpkg b/mkpkg index 0a16694ac..9b415699d 100755 --- a/mkpkg +++ b/mkpkg @@ -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 diff --git a/sudo.pp b/sudo.pp index 1023ad589..5eb908064 100644 --- a/sudo.pp +++ b/sudo.pp @@ -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 @@ -182,7 +182,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 @@ -212,7 +212,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