#!/usr/bin/perl # Copyright (C) 2009 Neil Williams # This package 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 3 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, see . use Config::Auto; use File::Basename; use Emdebian::Tools; use strict; use warnings; use vars qw/ $progname $our_version $vendor $package $key $cfile $config $value /; $progname = basename($0); $our_version = &tools_version(); sub usageversion { print(STDERR < "ini"); $value = $config->{"$package"}->{"$key"}; die ("\n") if (not defined $value); print "$value\n"; exit (0); # and we're done. =pod =head1 Name emvendor - retrieve vendor-specific package configuration strings =head1 Synopsis emvendor -V|--vendor VENDOR -p|--package PACKAGE -k|--key KEY emvendor -?|-h|--help|--version =head1 Commands -v|--vendor VENDOR: the vendor name from dpkg-vendor -p|--package PACKAGE: the package name (usually source) -k|--key KEY: arbitrary string for the key of the data All commands must be specified every time. On success, the string is printed and $progname exits with zero. In the case of error, $progname dies with an empty string on STDERR and exits with a non-zero return value. =head1 Description emvendor provides a way for debian/rules to call in a string for a particular package that fits into the rules for that package B conforms to the requirements of the vendor. http://wiki.debian.org/EmdebianAuditDetail#Vendor It is fairly obvious that specifying each vendor in the F file of each package is not going to be particularly flexible. DEB_VENDOR=$(shell dpkg-vendor --query vendor) ifeq (Debian,$(DEB_VENDOR)) # Debian build EXCONFARGS=--disable-mono --disable-monodoc else # any-vendor build EXCONFARGS=$(shell emvendor --vendor $(DEB_VENDOR) --package avahi --key EXCONFARGS) endif or use the short options: EXCONFARGS=$(shell foo-bar -V $(DEB_VENDOR) -p avahi -k EXCONFARGS) The values themselves are in a vendor-specific conf file in F $ cat /etc/foo-bar.d/emdebian-crush [avahi] EXCONFARGS=--disable-mono --disable-monodoc --disable-python --disable-doxygen-doc --disable-pygtk --disable-python-dbus --disable-core-docs --disable-qt3 --disable-qt4 --disable-gobject --with-distro debian [busybox] foo= (Note that the value has to be all on one line which is a little awkward - also note that values are not able to include the equals sign which could be more of an issue.) Packages that need two strings can do so - the key string is entirely arbitrary as long as it fits in the style of a typical ini file. Therefore, the key can be matched to the needs of the relevant package. C provides F with all the content for all packages that need such details. =head1 emvendor and dpkg-vendor F supports vendor functionality but F adds an extra hierarchy, organised by Debian source package name. It would be possible to include the relevant strings in F but each identifier string would need to be unique across all packages for each vendor, which is an unrealistic limitation. =cut