]> granicus.if.org Git - sudo/commitdiff
Add simple arg parsing for mkpkg so we can set debug, flavor or platform.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 26 Jul 2010 15:15:19 +0000 (11:15 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 26 Jul 2010 15:15:19 +0000 (11:15 -0400)
--HG--
branch : 1.7

Makefile.in
mkpkg
sudo.pp

index 971e850c500e92d640f572f02d99d7f86b0359b9..edfce660cb45edfc5dd20241cf592a155d10ad7a 100644 (file)
@@ -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 0a16694ac88ed3a8651ddad24b045cce647ef5ae..9b415699d8ad2159ab0e4f4920209bacf76ab6e7 100755 (executable)
--- 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 1023ad589e88d526a98f18982232d1b150eafcb1..5eb908064c4c4c69e8b3b4a0ac3d6e51f017b73b 100644 (file)
--- 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