diff -Nru dpkg-1.14.23/debian/changelog dpkg-1.14.24/debian/changelog
--- dpkg-1.14.23/debian/changelog	2008-09-09 16:17:35.000000000 +0200
+++ dpkg-1.14.24/debian/changelog	2008-09-09 15:06:29.000000000 +0200
@@ -1,3 +1,11 @@
+dpkg (1.14.24) unstable; urgency=low
+
+  [ Goswin von Brederlow ]
+  * Add /usr/bin/dpkg-vendor script
+  * Update /usr/share/dpkg/Makefile.dpkg to use dpkg-vendor
+
+ -- Goswin von Brederlow <goswin-v-b@web.de>  Tue, 09 Sep 2008 15:06:43 +0200
+
 dpkg (1.14.23) unstable; urgency=low
 
   [ Goswin von Brederlow ]
diff -Nru dpkg-1.14.23/debian/dpkg-dev.install dpkg-1.14.24/debian/dpkg-dev.install
--- dpkg-1.14.23/debian/dpkg-dev.install	2008-09-09 12:30:54.000000000 +0200
+++ dpkg-1.14.24/debian/dpkg-dev.install	2008-09-09 15:57:57.000000000 +0200
@@ -15,6 +15,7 @@
 usr/bin/dpkg-scansources
 usr/bin/dpkg-shlibdeps
 usr/bin/dpkg-source
+usr/bin/dpkg-vendor
 usr/lib/dpkg/parsechangelog
 usr/share/dpkg/Makefile.dpkg
 usr/share/locale/*/LC_MESSAGES/dpkg-dev.mo
@@ -64,4 +65,6 @@
 usr/share/man/*/dpkg-shlibdeps.1
 usr/share/man/*/*/dpkg-source.1
 usr/share/man/*/dpkg-source.1
+usr/share/man/*/*/dpkg-vendor.1
+usr/share/man/*/dpkg-vendor.1
 usr/share/perl5/Dpkg
diff -Nru dpkg-1.14.23/man/Makefile.am dpkg-1.14.24/man/Makefile.am
--- dpkg-1.14.23/man/Makefile.am	2008-07-01 19:07:54.000000000 +0200
+++ dpkg-1.14.24/man/Makefile.am	2008-09-09 15:57:19.000000000 +0200
@@ -95,6 +95,7 @@
 	dpkg-split.1 \
 	dpkg-statoverride.8 \
 	dpkg-trigger.1 \
+	dpkg-vendor.1 \
 	dpkg.1 \
 	dpkg.cfg.5 \
 	dselect.1 \
diff -Nru dpkg-1.14.23/man/Makefile.in dpkg-1.14.24/man/Makefile.in
--- dpkg-1.14.23/man/Makefile.in	2008-09-09 12:41:37.000000000 +0200
+++ dpkg-1.14.24/man/Makefile.in	2008-09-09 15:59:01.000000000 +0200
@@ -221,6 +221,7 @@
 	dpkg-split.1 \
 	dpkg-statoverride.8 \
 	dpkg-trigger.1 \
+	dpkg-vendor.1 \
 	dpkg.1 \
 	dpkg.cfg.5 \
 	dselect.1 \
diff -Nru dpkg-1.14.23/man/dpkg-vendor.1 dpkg-1.14.24/man/dpkg-vendor.1
--- dpkg-1.14.23/man/dpkg-vendor.1	1970-01-01 01:00:00.000000000 +0100
+++ dpkg-1.14.24/man/dpkg-vendor.1	2008-09-09 15:54:19.000000000 +0200
@@ -0,0 +1,77 @@
+.TH dpkg\-vendor 1 "2008-09-09" "Debian Project" "dpkg utilities"
+.SH "NAME"
+dpkg\-vendor \- determine the vendor, build-options and relationship for package building
+.
+.SH SYNOPSIS
+.B dpkg-vendor
+.RI [ commands ]
+.PP
+.
+.SH DESCRIPTION
+dpkg\-vendor does provides an interface to query the current vendor,
+vendor specific build options and relationship between vendors for
+package building.
+.PP
+You can specify a vendor by setting DEB_VENDOR in the environment or
+setting /etc/dpkg/origins/default. The later should be provided by
+your vendor already.
+.SH COMMANDS
+.TP
+.BI \-h | \-\-help
+Show the usage message and exit.
+.TP
+.B \-l
+Print the environment variables, one each line, in the format
+\fIVARIABLE=value\fP. This is the default action.
+.TP
+.BI \-q variable-name
+Print the value of a single variable.
+.TP
+.BI \-p | \-\-parent \ parent
+Check if the current vendor is parent or a child of parent. Returns 0
+on success and 1 otherwise.
+.
+.SH TERMS
+.IP "vendor" 4
+The vendor creating the distribution you are running.
+.IP "parent" 4
+Vendors can base their distribution on that of another vendor (parent)
+to inherit and modify the build options of that vendor.
+.
+.SH VARIABLES
+The following variables are known by \fBdpkg\-vendor\fP:
+.IP "\s-1DEB_VENDOR\s0" 4
+The vendor of the distribution to be building for.
+.IP "\s-1DEB_BUILD_OPTIONS\s0" 4
+The vendor specific build options to be used.
+.
+.SH "DEBIAN/RULES"
+\fBDpkg\-dev\fP provides a makefile fragment
+\fB/usr/share/dpkg/Makefile.dpkg\fP to set the standard environment
+variables for a build. This should be included in \fBdebian/rules\fP
+instead of querying the variables manually.
+.PP
+If you need to do something for a specific vendor please use:
+.IP
+.nf
+\&\s-1IS_VENDOR\s0 := $(shell dpkg\-vendor \-\-parent vendor && echo yes)
+
+ifeq ($(\s-1IS_VENDOR\s0),yes)
+  ...
+endif
+.fi
+.TP
+This way distributions based on vendor will also inherit that code.
+.
+.SH FILES
+.I /etc/dpkg/origins/debian
+Root vendor of the vendor hirachy.
+.TP
+.I /etc/dpkg/origins/default
+Default vendor for this distribution. Defaults to debian if missing.
+.
+.SH AUTHOR
+.B dpkg\-vendor
+was initially written by Goswin von Brederlow <goswin-v-b@web.de>.
+The manpage is based on dpkg-architecture.1 by
+Marcus Brinkmann <brinkmd@debian.org>.
diff -Nru dpkg-1.14.23/scripts/Makefile.am dpkg-1.14.24/scripts/Makefile.am
--- dpkg-1.14.23/scripts/Makefile.am	2008-09-09 12:40:55.000000000 +0200
+++ dpkg-1.14.24/scripts/Makefile.am	2008-09-09 15:03:23.000000000 +0200
@@ -16,7 +16,8 @@
 	dpkg-scanpackages \
 	dpkg-scansources \
 	dpkg-shlibdeps \
-	dpkg-source
+	dpkg-source \
+	dpkg-vendor
 
 sbin_SCRIPTS = \
 	cleanup-info \
diff -Nru dpkg-1.14.23/scripts/Makefile.dpkg dpkg-1.14.24/scripts/Makefile.dpkg
--- dpkg-1.14.23/scripts/Makefile.dpkg	2008-09-09 16:17:59.000000000 +0200
+++ dpkg-1.14.24/scripts/Makefile.dpkg	2008-09-09 15:05:51.000000000 +0200
@@ -21,10 +21,10 @@
 # This file should be included by every source and sets up some default
 # environment variables if they are unset
 
-vendor = $(shell if [ -r /etc/dpkg/origins/default ]; then cat /etc/dpkg/origins/default; else echo debian; fi )
-DEB_VENDOR ?= $(shell grep "^Vendor: " /etc/dpkg/origins/$(vendor) | cut -d" " -f2-)
+DEB_VENDOR        ?= $(shell dpkg-vendor -qDEB_VENDOR)
+DEB_BUILD_OPTIONS ?= $(shell dpkg-vendor -qDEB_BUILD_OPTIONS)
 
-export DEB_VENDOR
+export DEB_VENDOR DEB_BUILD_OPTIONS
 
 
 ifeq ($(findstring noopt,$(DEB_BUILD_OPTIONS)),)
diff -Nru dpkg-1.14.23/scripts/Makefile.in dpkg-1.14.24/scripts/Makefile.in
--- dpkg-1.14.23/scripts/Makefile.in	2008-09-09 12:41:38.000000000 +0200
+++ dpkg-1.14.24/scripts/Makefile.in	2008-09-09 15:09:57.000000000 +0200
@@ -225,7 +225,8 @@
 	dpkg-scanpackages \
 	dpkg-scansources \
 	dpkg-shlibdeps \
-	dpkg-source
+	dpkg-source \
+	dpkg-vendor
 
 sbin_SCRIPTS = \
 	cleanup-info \
diff -Nru dpkg-1.14.23/scripts/dpkg-vendor.sh dpkg-1.14.24/scripts/dpkg-vendor.sh
--- dpkg-1.14.23/scripts/dpkg-vendor.sh	1970-01-01 01:00:00.000000000 +0100
+++ dpkg-1.14.24/scripts/dpkg-vendor.sh	2008-09-09 16:25:31.000000000 +0200
@@ -0,0 +1,138 @@
+#! /bin/bash
+#
+# dpkg-vendor
+#
+# Copyright �� 2004-2005 Scott James Remnant <scott@netsplit.com>,
+# Copyright �� 1999 Marcus Brinkmann <brinkmd@debian.org>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+# Interface to the vendor hierachy
+
+set -ex
+
+get_vendor() {
+	if ! [ -z $DEB_VENDOR ]; then
+		echo "$DEB_VENDOR"
+		return
+	fi
+	local vendor="debian"
+	if [ -r /etc/dpkg/origins/default ]; then
+		vendor="$(cat /etc/dpkg/origins/default)"
+	fi
+	grep "^Vendor: " "/etc/dpkg/origins/$vendor" | cut -d" " -f2-
+}
+
+get_vendor_file() {
+	if ! [ -z $DEB_VENDOR ]; then
+	    	grep -l "^Vendor: $DEB_VENDOR$" /etc/dpkg/origins/*
+		return
+	fi
+	local vendor="debian"
+	if [ -r /etc/dpkg/origins/default ]; then
+		vendor="$(cat /etc/dpkg/origins/default)"
+	fi
+	echo "/etc/dpkg/origins/$vendor"
+}
+
+get_parent() {
+	grep "^Parent: " "$1" | cut -d" " -f2-
+}
+
+get_build_options() {
+	if ! [ -z $DEB_BUILD_OPTIONS ]; then
+		echo "$DEB_BUILD_OPTIONS"
+	fi
+	local vendor_file
+	if [ -n "$1" ]; then
+		vendor_file="$1"
+	else
+		vendor_file="$(get_vendor_file)"
+	fi
+	local parent="$(get_parent "$vendor_file")"
+	local deb_build_options=""
+	if ! [ -z $parent ]; then
+		deb_build_options="$(get_build_options "/etc/dpkg/origins/$parent")"
+		if ! [ -z "$deb_build_options" ]; then
+			deb_build_options=" $deb_build_options"
+		fi
+	fi
+	local build_options="$(grep "^Build-Options: " "$vendor_file" | cut -d" " -f2-)"
+	for option in $build_options; do
+		case "$option" in
+			"+"*) deb_build_options="$deb_build_options ${option:1}";;
+			"-"*) deb_build_options="$(echo "$deb_build_options" | sed s/" ${option:1}\b"//)";;
+			*) echo "Error in Build-Options in $vendor_file"
+				exit 1
+		esac
+	done
+	echo "${deb_build_options:1}"
+}
+
+usage() {
+	echo "$(basename $0)                      - list all variables"
+	echo "$(basename $0) -qVAR                - query VAR"
+	echo "$(basename $0) -p|--parent <parent> - is vendor child of <parent>?"
+}
+
+show_all() {
+	echo "DEB_VENDOR=\"$(get_vendor)\""
+	echo "DEB_BUILD_OPTIONS=\"$(get_build_options)\""
+	exit 0
+}
+
+get_var() {
+	case "$1" in
+		DEB_VENDOR) get_vendor;;
+		DEB_BUILD_OPTIONS) get_build_options;;
+    		"") echo "Argument to -q missing"
+		    exit 1;;
+		*) echo "Unknown argument to -q"
+		   exit 1;;
+	esac
+}
+
+is_parent() {
+	if [ -z "$1" ]; then
+		echo "Argument to -p|--parent missing"
+		exit 1
+	fi
+	parent="$1"
+	local vendor_file
+	if [ -n "$2" ]; then
+		vendor_file="$2"
+	else
+		vendor_file="$(get_vendor_file)"
+	fi
+	while ! [ "$vendor_file" = "/etc/dpkg/origins/" ]; do
+		local vendor="$(grep "^Vendor: " "$vendor_file" | cut -d" " -f2-)"
+		if [ "$parent" = "$vendor" ]; then
+			exit 0
+		fi
+		vendor_file="/etc/dpkg/origins/$(get_parent "$vendor_file")"
+	done
+	exit 1
+}
+
+case "$1" in
+	-h|--help) usage;;
+	-q) get_var "$2";;
+	-q*) get_var "${1:2}";;
+	-p|--parent) is_parent "$2";;
+	-l|"") show_all;;
+	*) echo "Bad arguments"
+	   usage
+	   exit 1;;
+esac
