--- /dev/null
+.rn '' }`
+''' $RCSfile$$Revision$$Date$
+'''
+''' $Log$
+''' Revision 1.1 1999-09-27 01:00:50 wakkerma
+''' Added some missing files
+'''
+'''
+.de Sh
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp
+.if t .sp .5v
+.if n .sp
+..
+.de Ip
+.br
+.ie \\n(.$>=3 .ne \\$3
+.el .ne 3
+.IP "\\$1" \\$2
+..
+.de Vb
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve
+.ft R
+
+.fi
+..
+'''
+'''
+''' Set up \*(-- to give an unbreakable dash;
+''' string Tr holds user defined translation string.
+''' Bell System Logo is used as a dummy character.
+'''
+.tr \(*W-|\(bv\*(Tr
+.ie n \{\
+.ds -- \(*W-
+.ds PI pi
+.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
+.ds L" ""
+.ds R" ""
+''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of
+''' \*(L" and \*(R", except that they are used on ".xx" lines,
+''' such as .IP and .SH, which do another additional levels of
+''' double-quote interpretation
+.ds M" """
+.ds S" """
+.ds N" """""
+.ds T" """""
+.ds L' '
+.ds R' '
+.ds M' '
+.ds S' '
+.ds N' '
+.ds T' '
+'br\}
+.el\{\
+.ds -- \(em\|
+.tr \*(Tr
+.ds L" ``
+.ds R" ''
+.ds M" ``
+.ds S" ''
+.ds N" ``
+.ds T" ''
+.ds L' `
+.ds R' '
+.ds M' `
+.ds S' '
+.ds N' `
+.ds T' '
+.ds PI \(*p
+'br\}
+.\" If the F register is turned on, we'll generate
+.\" index entries out stderr for the following things:
+.\" TH Title
+.\" SH Header
+.\" Sh Subsection
+.\" Ip Item
+.\" X<> Xref (embedded
+.\" Of course, you have to process the output yourself
+.\" in some meaninful fashion.
+.if \nF \{
+.de IX
+.tm Index:\\$1\t\\n%\t"\\$2"
+..
+.nr % 0
+.rr F
+.\}
+.TH DPKG-ARCHITECTURE 1 "perl 5.004, patch 04" "24/Jul/99" "User Contributed Perl Documentation"
+.UC
+.if n .hy 0
+.if n .na
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.de CQ \" put $1 in typewriter font
+.ft CW
+'if n "\c
+'if t \\&\\$1\c
+'if n \\&\\$1\c
+'if n \&"
+\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
+'.ft R
+..
+.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
+. \" AM - accent mark definitions
+.bd B 3
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds ? ?
+. ds ! !
+. ds /
+. ds q
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
+. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
+.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
+.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
+.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.ds oe o\h'-(\w'o'u*4/10)'e
+.ds Oe O\h'-(\w'O'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds v \h'-1'\o'\(aa\(ga'
+. ds _ \h'-1'^
+. ds . \h'-1'.
+. ds 3 3
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+. ds oe oe
+. ds Oe OE
+.\}
+.rm #[ #] #H #V #F C
+.SH "NAME"
+dpkg-architecture \- set and determine the architecture for package building
+.SH "SYNOPSIS"
+dpkg-architecture [options] [action]
+.PP
+Valid options:
+\fB\-a\fRDebian-Architecture
+\fB\-t\fRGnu-System-Type
+\fB\-f\fR
+.PP
+Valid actions:
+\fB\-l\fR, \fB\-q\fRVariable-Name, \fB\-s\fR, \fB\-u\fR, \fB\-c\fR Command
+.SH "DESCRIPTION"
+dpkg-architecture does provide a facility to determine and set the build and
+host architecture for package building.
+.SH "OVERVIEW"
+The build architecture is always determined by an external call to dpkg, and
+can not be set at the command line.
+.PP
+You can specify the host architecture by providing one or both of the options \fB\-a\fR
+and \fB\-t\fR. The default is determined by an external call to gcc, or the same as
+the build architecture if CC or gcc are both not available. One out of \fB\-a\fR and \fB\-t\fR
+is sufficient, the value of the other will be set to a usable default.
+Indeed, it is often better to only specify one, because dpkg-architecture
+will warn you if your choice doesn't match the default.
+.PP
+The default action is \fB\-l\fR, which prints the environment variales, one each line,
+in the format VARIABLE=value. If you are only interested in the value of a
+single variable, you can use \fB\-q\fR. If you specify \fB\-s\fR, it will output an export
+command. This can be used to set the environment variables using eval. \fB\-u\fR
+does return a similar command to unset all variables. \fB\-c\fR does execute a
+command in an environment which has all variables set to the determined
+value.
+.PP
+Existing environment variables with the same name as used by the scripts are
+not overwritten, except if the \fB\-f\fR force flag is present. This allows the user
+to override a value even when the call to dpkg-architecture is buried in
+some other script (for example dpkg-buildpackage). The \fB\-q\fR query option
+implies \fB\-f\fR, and is therefore not affected by existing environment settings.
+.SH "TERMS"
+.Ip "build machine" 4
+The machine the package is build on.
+.Ip "host machine" 4
+The machine the package is build for.
+.Ip "Debian Architecture" 4
+The Debian archietcture string, which specifies the binary tree in the \s-1FTP\s0
+archive. Examples: i386, sparc, hurd-i386.
+.Ip "\s-1GNU\s0 System Type" 4
+An architecture specification string consisting of two or three parts,
+cpu-system or cpu-vendor-system. Examples: i386-linux, sparc-linux, i386-gnu.
+.SH "EXAMPLES"
+dpkg-buildpackage accepts the \fB\-a\fR option and passes it to dpkg-architecture.
+Other examples:
+.PP
+CC=i386-gnu-gcc dpkg-architecture \f(CW-c\fR debian/rules build
+.PP
+eval `dpkg-architecture \f(CW-u\fR`
+.SH "VARIABLES"
+The following variables are set by dpkg-architecture:
+.Ip "\s-1DEB_BUILD_ARCH\s0" 4
+The Debian architecture of the build machine.
+.Ip "\s-1DEB_BUILD_GNU_TYPE\s0" 4
+The \s-1GNU\s0 system type of the build machine.
+.Ip "\s-1DEB_BUILD_GNU_CPU\s0" 4
+The \s-1CPU\s0 part of \s-1DEB_BUILD_GNU_TYPE\s0
+.Ip "\s-1DEB_BUILD_GNU_SYSTEM\s0" 4
+The System part of \s-1DEB_BUILD_GNU_TYPE\s0
+.Ip "\s-1DEB_HOST_ARCH\s0" 4
+The Debian architecture of the host machine.
+.Ip "\s-1DEB_HOST_GNU_TYPE\s0" 4
+The \s-1GNU\s0 system type of the host machine.
+.Ip "\s-1DEB_HOST_GNU_CPU\s0" 4
+The \s-1CPU\s0 part of \s-1DEB_HOST_GNU_TYPE\s0
+.Ip "\s-1DEB_HOST_GNU_SYSTEM\s0" 4
+The System part of \s-1DEB_HOST_GNU_TYPE\s0
+.SH "DEBIAN/RULES"
+The environment variables set by dpkg-architecture are passed to
+debian/rules as make variables (see make documentation). You can and should
+use them in the build process as needed. Here are some examples, which also
+show how you can improve the cross compilation support in your package:
+.PP
+Instead:
+.PP
+ARCH=`dpkg --print-architecture`
+configure $(ARCH)\-linux
+.PP
+please use the following:
+.PP
+B_ARCH=$(DEB_BUILD_GNU_TYPE)
+H_ARCH=$(DEB_HOST_GNU_TYPE)
+configure --build=$(B_ARCH) --host=$(H_ARCH)
+.PP
+Instead:
+.PP
+ARCH=`dpkg --print-architecture`
+ifeq ($(ARCH),alpha)
+ ...
+endif
+.PP
+please use:
+.PP
+ARCH=$(DEB_HOST_ARCH)
+ifeq ($(ARCH),alpha)
+ ...
+endif
+.PP
+In general, calling dpkg in the rules file to get architecture information
+is deprecated (until you want to provide backward compatibility, see below).
+Especially the --print-architecture option is unreliable since we have
+Debian architectures which don't equal a processor name.
+.SH "BACKWARD COMPATIBILITY"
+When providing a new facility, it is always a good idea to stay compatible with old
+versions of the programs. Note that dpkg-architecture does not affect old
+debian/rules files, so the only thing to consider is using old building
+scripts with new debian/rules files. The following does the job:
+.PP
+DEB_BUILD_ARCH := $(shell dpkg --print-installation-architecture)
+DEB_BUILD_GNU_CPU := $(patsubst hurd-%,%,$(DEB_BUILD_ARCH))
+ifeq ($(filter-out hurd-%,$(DEB_BUILD_ARCH)),)
+ DEB_BUILD_GNU_SYSTEM := gnu
+else
+ DEB_BUILD_GNU_SYSTEM := linux
+endif
+DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_CPU)\-$(DEB_BUILD_GNU_SYSTEM)
+.PP
+DEB_HOST_ARCH=$(DEB_BUILD_ARCH)
+DEB_HOST_GNU_CPU=$(DEB_BUILD_GNU_CPU)
+DEB_HOST_GNU_SYSTEM=$(DEB_BUILD_GNU_SYSTEM)
+DEB_HOST_GNU_TYPE=$(DEB_BUILD_GNU_TYPE)
+.PP
+Put a subset of these lines at the top of your debian/rules file; these
+default values will be overwritten if dpkg-architecture is used.
+.PP
+You don't need the full set. Choose a consistent set which contains the
+values you use in the rules file. For example, if you only need the host
+Debian architecture, `DEB_HOST_ARCH=`dpkg --print-installation-architecture`
+is sufficient (this is indeed the Debian architecture of the build machine,
+but remember that we are only trying to be backward compatible with native
+compilation).
+.PP
+You may not want to care about old build packages (for example, if you have
+sufficient source dependencies declared anyway). But you should at least
+support the traditional way to build packages by calling `debian/rules
+build\*(R' directly, without setting environment variables. To do this, use the
+\fB\-q\fR option to query suitable default values:
+.PP
+DEB_BUILD_ARCH=`dpkg-architecture \-qDEB_BUILD_ARCH`
+DEB_BUILD_GNU=`dpkg-architecture \-qDEB_BUILD_GNU`
+.PP
+etc. You get the idea. This way, you can ensure that the variables are never
+undeclared. Note that this breaks backwards compatibility with old build
+scripts, and you should only do that if source dependencies are implemented
+and declared accordingly.
+.SH "SEE ALSO"
+dpkg-buildpackage
+dpkg-cross
+.SH "CONTACT"
+If you have questions about the usage of the make variables in your rules
+files, or about cross compilation support in your packages, please email me.
+The addresse is Marcus Brinkmann <brinkmd@debian.org>.
+
+.rn }` ''
+.IX Title "DPKG-ARCHITECTURE 1"
+.IX Name "dpkg-architecture - set and determine the architecture for package building"
+
+.IX Header "NAME"
+
+.IX Header "SYNOPSIS"
+
+.IX Header "DESCRIPTION"
+
+.IX Header "OVERVIEW"
+
+.IX Header "TERMS"
+
+.IX Item "build machine"
+
+.IX Item "host machine"
+
+.IX Item "Debian Architecture"
+
+.IX Item "\s-1GNU\s0 System Type"
+
+.IX Header "EXAMPLES"
+
+.IX Header "VARIABLES"
+
+.IX Item "\s-1DEB_BUILD_ARCH\s0"
+
+.IX Item "\s-1DEB_BUILD_GNU_TYPE\s0"
+
+.IX Item "\s-1DEB_BUILD_GNU_CPU\s0"
+
+.IX Item "\s-1DEB_BUILD_GNU_SYSTEM\s0"
+
+.IX Item "\s-1DEB_HOST_ARCH\s0"
+
+.IX Item "\s-1DEB_HOST_GNU_TYPE\s0"
+
+.IX Item "\s-1DEB_HOST_GNU_CPU\s0"
+
+.IX Item "\s-1DEB_HOST_GNU_SYSTEM\s0"
+
+.IX Header "DEBIAN/RULES"
+
+.IX Header "BACKWARD COMPATIBILITY"
+
+.IX Header "SEE ALSO"
+
+.IX Header "CONTACT"
+
--- /dev/null
+#! /usr/bin/perl
+#
+# dpkg-architecture
+#
+# 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
+
+# History
+# 0.0.1 Initial release.
+# 0.0.2 Don't use dpkg to get default gnu system, so the default is
+# correct even on non-linux system.
+# Warn if the host gnu system does not match the gcc system.
+# Determine default from gcc if possible, else fall back to native
+# compilation.
+# Do not set environment variables which are already defined unless
+# force flag is given.
+# 1.0.0 Changed target to host, because this complies with GNU
+# nomenclature.
+# Added command facility.
+# 1.0.1 Moved to GNU nomenclature arch->cpu, system->type, os->system
+# 1.0.2 Add facility to query single values, suggested by Richard Braakman.
+# 1.0.3 Make it work with egcs, too.
+# 1.0.4 Suppress single "export" with "-s" when all env variables are already set
+# 1.0.5 Update default for rules files (i386->i486).
+# Print out overridden values, so make gets them, too.
+# 1.0.6 Revert to i386 to comply with policy § 5.1.
+
+$version="1.0.0";
+$0 = `basename $0`; chomp $0;
+
+$dpkglibdir="/usr/lib/dpkg";
+push(@INC,$dpkglibdir);
+require 'controllib.pl';
+
+%archtable=('i386', 'i386-linux',
+ 'sparc', 'sparc-linux',
+ 'alpha', 'alpha-linux',
+ 'm68k', 'm68k-linux',
+ 'arm', 'arm-linux',
+ 'powerpc', 'powerpc-linux',
+ 'hurd-i386', 'i386-gnu');
+
+sub usageversion {
+ print STDERR
+"Debian GNU/Linux $0 $version. Copyright (C) 1999 Marcus Brinkmann.
+This is free software; see the GNU General Public Licence version 2
+or later for copying conditions. There is NO warranty.
+
+Usage:
+ $0 [<option> ...] [<action>]
+Options:
+ -a<debian-arch> set Debian architecture
+ -t<gnu-system> set GNU system type
+ -f force flag (override variables set in environment)
+Actions:
+ -l list variables (default)
+ -q<variable> prints only the value of <variable>.
+ -s print command to set environment variables
+ -u print command to unset environment variables
+ -c <command> set environment and run the command in it.
+
+Known Debian Architectures are ".join(", ",keys %archtable)."
+Known GNU System Types are ".join(", ",map ($archtable{$_},keys %archtable))."
+";
+}
+
+sub rewrite_gnu_cpu {
+ local ($_) = @_;
+
+ s/(?:i386|i486|i586|i686|pentium)(.*linux)/i386$1/;
+ s/ppc/powerpc/;
+ return $_;
+}
+
+sub gnu_to_debian {
+ local ($gnu) = @_;
+ local (@list);
+ local ($a);
+
+ $gnu = &rewrite_gnu_cpu($gnu);
+
+ foreach $a (keys %archtable) {
+ push @list, $a if $archtable{$a} eq $gnu;
+ }
+ return @list;
+}
+
+# Set default values:
+
+$deb_build_arch = `dpkg --print-installation-architecture`;
+chomp $deb_build_arch;
+$deb_build_gnu_type = $archtable{$deb_build_arch};
+$deb_build_gnu_cpu = $deb_build_gnu_type;
+$deb_build_gnu_system = $deb_build_gnu_type;
+$deb_build_gnu_cpu =~ s/-.*$//;
+$deb_build_gnu_system =~ s/^.*-//;
+
+# Default host: Current gcc.
+$gcc = `\${CC:-gcc} --print-libgcc-file-name`;
+$gcc =~ s!^.*gcc-lib/(.*)/(?:egcs-)?\d+(?:.\d+)*/libgcc.*$!$1!s;
+if ($gcc eq '') {
+ &warn ("Couldn't determine gcc system type, falling back to default (native compilation)");
+} else {
+ @list = &gnu_to_debian($gcc);
+ if (!defined(@list)) {
+ &warn ("Unknown gcc system type $gcc, falling back to default (native compilation)"),
+ } elsif ($#list > 0) {
+ &warn ("Ambiguous gcc system type $gcc, you must specify Debian architecture, too (one of ".join(", ",@list).")");
+ } else {
+ $gcc=$archtable{$list[0]};
+ $deb_host_arch = $list[0];
+ $deb_host_gnu_type = $gcc;
+ $deb_host_gnu_cpu = $gcc;
+ $deb_host_gnu_system = $gcc;
+ $deb_host_gnu_cpu =~ s/-.*$//;
+ $deb_host_gnu_system =~ s/^.*-//;
+ }
+}
+if (!defined($deb_host_arch)) {
+ # Default host: Native compilation.
+ $deb_host_arch = $deb_build_arch;
+ $deb_host_gnu_cpu = $deb_build_gnu_cpu;
+ $deb_host_gnu_system = $deb_build_gnu_system;
+ $deb_host_gnu_type = $deb_build_gnu_type;
+}
+
+
+$req_host_arch = '';
+$req_host_gnu_type = '';
+$action='l';
+$force=0;
+
+while (@ARGV) {
+ $_=shift(@ARGV);
+ if (m/^-a/) {
+ $req_host_arch = $';
+ } elsif (m/^-t/) {
+ $req_host_gnu_type = &rewrite_gnu_cpu($');
+ } elsif (m/^-[lsu]$/) {
+ $action = $_;
+ $action =~ s/^-//;
+ } elsif (m/^-f$/) {
+ $force=1;
+ } elsif (m/^-q/) {
+ $req_variable_to_print = $';
+ $action = 'q';
+ $force=1;
+ } elsif (m/^-c$/) {
+ $action = 'c';
+ last;
+ } else {
+ usageerr("unknown option \`$_'");
+ }
+}
+
+if ($req_host_arch ne '' && $req_host_gnu_type eq '') {
+ die ("unknown Debian architecture $req_host_arch, you must specify GNU system type, too") if !exists $archtable{$req_host_arch};
+ $req_host_gnu_type = $archtable{$req_host_arch}
+}
+
+if ($req_host_gnu_type ne '' && $req_host_arch eq '') {
+ @list = &gnu_to_debian ($req_host_gnu_type);
+ die ("unknown GNU system type $req_host_gnu_type, you must specify Debian architecture, too") if !defined(@list);
+ die ("ambiguous GNU system type $req_host_gnu_type, you must specify Debian architecture, too (one of ".join(", ",@list).")") if $#list > 0;
+ $req_host_arch = $list[0];
+}
+
+if (exists $archtable{$req_host_arch}) {
+ &warn("Default GNU system type $archtable{$req_host_arch} for Debian arch $req_host_arch does not match specified GNU system type $req_host_gnu_type\n") if $archtable{$req_host_arch} ne $req_host_gnu_type;
+}
+
+die "couldn't parse GNU system type $req_host_gnu_type, must be arch-os or arch-vendor-os" if $req_host_gnu_type !~ m/^([\w\d]+(-[\w\d]+){1,2})?$/;
+
+$deb_host_arch = $req_host_arch if $req_host_arch ne '';
+if ($req_host_gnu_type ne '') {
+ $deb_host_gnu_cpu = $deb_host_gnu_system = $deb_host_gnu_type = $req_host_gnu_type;
+ $deb_host_gnu_cpu =~ s/-.*$//;
+ $deb_host_gnu_system =~ s/^.*-//;
+}
+
+#$gcc = `\${CC:-gcc} --print-libgcc-file-name`;
+#$gcc =~ s!^.*gcc-lib/(.*)/\d+(?:.\d+)*/libgcc.*$!$1!s;
+&warn("Specified GNU system type $deb_host_gnu_type does not match gcc system type $gcc.") if ($gcc ne '') && ($gcc ne $deb_host_gnu_type);
+
+undef @env;
+if (!$force) {
+ $deb_build_arch = $ENV{DEB_BUILD_ARCH} if (exists $ENV{DEB_BUILD_ARCH});
+ $deb_build_gnu_cpu = $ENV{DEB_BUILD_GNU_CPU} if (exists $ENV{DEB_BUILD_GNU_CPU});
+ $deb_build_gnu_system = $ENV{DEB_BUILD_GNU_SYSTEM} if (exists $ENV{DEB_BUILD_GNU_SYSTEM});
+ $deb_build_gnu_type = $ENV{DEB_BUILD_GNU_TYPE} if (exists $ENV{DEB_BUILD_GNU_TYPE});
+ $deb_host_arch = $ENV{DEB_HOST_ARCH} if (exists $ENV{DEB_HOST_ARCH});
+ $deb_host_gnu_cpu = $ENV{DEB_HOST_GNU_CPU} if (exists $ENV{DEB_HOST_GNU_CPU});
+ $deb_host_gnu_system = $ENV{DEB_HOST_GNU_SYSTEM} if (exists $ENV{DEB_HOST_GNU_SYSTEM});
+ $deb_host_gnu_type = $ENV{DEB_HOST_GNU_TYPE} if (exists $ENV{DEB_HOST_GNU_TYPE});
+}
+
+push @env, "DEB_BUILD_ARCH=$deb_build_arch";
+push @env, "DEB_BUILD_GNU_CPU=$deb_build_gnu_cpu";
+push @env, "DEB_BUILD_GNU_SYSTEM=$deb_build_gnu_system";
+push @env, "DEB_BUILD_GNU_TYPE=$deb_build_gnu_type";
+push @env, "DEB_HOST_ARCH=$deb_host_arch";
+push @env, "DEB_HOST_GNU_CPU=$deb_host_gnu_cpu";
+push @env, "DEB_HOST_GNU_SYSTEM=$deb_host_gnu_system";
+push @env, "DEB_HOST_GNU_TYPE=$deb_host_gnu_type";
+
+if ($action eq 'l') {
+ print join("\n",@env)."\n";
+} elsif ($action eq 's') {
+ print "export ".join("\n",@env)."\n" if ($#env != 0);
+} elsif ($action eq 'u') {
+ print "unset DEB_BUILD_ARCH DEB_BUILD_GNU_CPU DEB_BUILD_GNU_SYSTEM DEB_BUILD_GNU_TYPE DEB_HOST_ARCH DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE\n";
+} elsif ($action eq 'c') {
+ foreach $_ (@env) {
+ m/^(.*)=(.*)$/;
+ $ENV{$1}=$2;
+ }
+ exec @ARGV;
+} elsif ($action eq 'q') {
+ undef %env;
+ foreach $_ (@env) {
+ m/^(.*)=(.*)$/;
+ $env{$1}=$2;
+ }
+ if (exists $env{$req_variable_to_print}) {
+ print "$env{$req_variable_to_print}\n"; # works because -q implies -f !
+ } else {
+ die "$req_variable_to_print is not a supported variable name";
+ }
+}
+
+__END__
+
+=head1 NAME
+
+dpkg-architecture - set and determine the architecture for package building
+
+=head1 SYNOPSIS
+
+dpkg-architecture [options] [action]
+
+Valid options:
+B<-a>Debian-Architecture
+B<-t>Gnu-System-Type
+B<-f>
+
+Valid actions:
+B<-l>, B<-q>Variable-Name, B<-s>, B<-u>, B<-c> Command
+
+=head1 DESCRIPTION
+
+dpkg-architecture does provide a facility to determine and set the build and
+host architecture for package building.
+
+=head1 OVERVIEW
+
+The build architecture is always determined by an external call to dpkg, and
+can not be set at the command line.
+
+You can specify the host architecture by providing one or both of the options B<-a>
+and B<-t>. The default is determined by an external call to gcc, or the same as
+the build architecture if CC or gcc are both not available. One out of B<-a> and B<-t>
+is sufficient, the value of the other will be set to a usable default.
+Indeed, it is often better to only specify one, because dpkg-architecture
+will warn you if your choice doesn't match the default.
+
+The default action is B<-l>, which prints the environment variales, one each line,
+in the format VARIABLE=value. If you are only interested in the value of a
+single variable, you can use B<-q>. If you specify B<-s>, it will output an export
+command. This can be used to set the environment variables using eval. B<-u>
+does return a similar command to unset all variables. B<-c> does execute a
+command in an environment which has all variables set to the determined
+value.
+
+Existing environment variables with the same name as used by the scripts are
+not overwritten, except if the B<-f> force flag is present. This allows the user
+to override a value even when the call to dpkg-architecture is buried in
+some other script (for example dpkg-buildpackage). The B<-q> query option
+implies B<-f>, and is therefore not affected by existing environment settings.
+
+=head1 TERMS
+
+=over 4
+
+=item build machine
+
+The machine the package is build on.
+
+=item host machine
+
+The machine the package is build for.
+
+=item Debian Architecture
+
+The Debian archietcture string, which specifies the binary tree in the FTP
+archive. Examples: i386, sparc, hurd-i386.
+
+=item GNU System Type
+
+An architecture specification string consisting of two or three parts,
+cpu-system or cpu-vendor-system. Examples: i386-linux, sparc-linux, i386-gnu.
+
+=back
+
+=head1 EXAMPLES
+
+dpkg-buildpackage accepts the B<-a> option and passes it to dpkg-architecture.
+Other examples:
+
+CC=i386-gnu-gcc dpkg-architecture C<-c> debian/rules build
+
+eval `dpkg-architecture C<-u>`
+
+=head1 VARIABLES
+
+The following variables are set by dpkg-architecture:
+
+=over 4
+
+=item DEB_BUILD_ARCH
+
+The Debian architecture of the build machine.
+
+=item DEB_BUILD_GNU_TYPE
+
+The GNU system type of the build machine.
+
+=item DEB_BUILD_GNU_CPU
+
+The CPU part of DEB_BUILD_GNU_TYPE
+
+=item DEB_BUILD_GNU_SYSTEM
+
+The System part of DEB_BUILD_GNU_TYPE
+
+=item DEB_HOST_ARCH
+
+The Debian architecture of the host machine.
+
+=item DEB_HOST_GNU_TYPE
+
+The GNU system type of the host machine.
+
+=item DEB_HOST_GNU_CPU
+
+The CPU part of DEB_HOST_GNU_TYPE
+
+=item DEB_HOST_GNU_SYSTEM
+
+The System part of DEB_HOST_GNU_TYPE
+
+=back
+
+=head1 DEBIAN/RULES
+
+The environment variables set by dpkg-architecture are passed to
+debian/rules as make variables (see make documentation). You can and should
+use them in the build process as needed. Here are some examples, which also
+show how you can improve the cross compilation support in your package:
+
+Instead:
+
+ARCH=`dpkg --print-architecture`
+configure $(ARCH)-linux
+
+please use the following:
+
+B_ARCH=$(DEB_BUILD_GNU_TYPE)
+H_ARCH=$(DEB_HOST_GNU_TYPE)
+configure --build=$(B_ARCH) --host=$(H_ARCH)
+
+Instead:
+
+ARCH=`dpkg --print-architecture`
+ifeq ($(ARCH),alpha)
+ ...
+endif
+
+please use:
+
+ARCH=$(DEB_HOST_ARCH)
+ifeq ($(ARCH),alpha)
+ ...
+endif
+
+In general, calling dpkg in the rules file to get architecture information
+is deprecated (until you want to provide backward compatibility, see below).
+Especially the --print-architecture option is unreliable since we have
+Debian architectures which don't equal a processor name.
+
+=head1 BACKWARD COMPATIBILITY
+
+When providing a new facility, it is always a good idea to stay compatible with old
+versions of the programs. Note that dpkg-architecture does not affect old
+debian/rules files, so the only thing to consider is using old building
+scripts with new debian/rules files. The following does the job:
+
+DEB_BUILD_ARCH := $(shell dpkg --print-installation-architecture)
+DEB_BUILD_GNU_CPU := $(patsubst hurd-%,%,$(DEB_BUILD_ARCH))
+ifeq ($(filter-out hurd-%,$(DEB_BUILD_ARCH)),)
+ DEB_BUILD_GNU_SYSTEM := gnu
+else
+ DEB_BUILD_GNU_SYSTEM := linux
+endif
+DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_CPU)-$(DEB_BUILD_GNU_SYSTEM)
+
+DEB_HOST_ARCH=$(DEB_BUILD_ARCH)
+DEB_HOST_GNU_CPU=$(DEB_BUILD_GNU_CPU)
+DEB_HOST_GNU_SYSTEM=$(DEB_BUILD_GNU_SYSTEM)
+DEB_HOST_GNU_TYPE=$(DEB_BUILD_GNU_TYPE)
+
+Put a subset of these lines at the top of your debian/rules file; these
+default values will be overwritten if dpkg-architecture is used.
+
+You don't need the full set. Choose a consistent set which contains the
+values you use in the rules file. For example, if you only need the host
+Debian architecture, `DEB_HOST_ARCH=`dpkg --print-installation-architecture`
+is sufficient (this is indeed the Debian architecture of the build machine,
+but remember that we are only trying to be backward compatible with native
+compilation).
+
+You may not want to care about old build packages (for example, if you have
+sufficient source dependencies declared anyway). But you should at least
+support the traditional way to build packages by calling `debian/rules
+build' directly, without setting environment variables. To do this, use the
+B<-q> option to query suitable default values:
+
+DEB_BUILD_ARCH=`dpkg-architecture -qDEB_BUILD_ARCH`
+DEB_BUILD_GNU=`dpkg-architecture -qDEB_BUILD_GNU`
+
+etc. You get the idea. This way, you can ensure that the variables are never
+undeclared. Note that this breaks backwards compatibility with old build
+scripts, and you should only do that if source dependencies are implemented
+and declared accordingly.
+
+=head1 SEE ALSO
+
+dpkg-buildpackage
+dpkg-cross
+
+=head1 CONTACT
+
+If you have questions about the usage of the make variables in your rules
+files, or about cross compilation support in your packages, please email me.
+The addresse is Marcus Brinkmann <brinkmd@debian.org>.
--- /dev/null
+.rn '' }`
+''' $RCSfile$$Revision$$Date$
+'''
+''' $Log$
+''' Revision 1.1 1999-09-27 01:00:50 wakkerma
+''' Added some missing files
+'''
+''' Revision 1.1 1999/03/21 22:45:17 maor
+''' manpage
+'''
+'''
+.de Sh
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp
+.if t .sp .5v
+.if n .sp
+..
+.de Ip
+.br
+.ie \\n(.$>=3 .ne \\$3
+.el .ne 3
+.IP "\\$1" \\$2
+..
+.de Vb
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve
+.ft R
+
+.fi
+..
+'''
+'''
+''' Set up \*(-- to give an unbreakable dash;
+''' string Tr holds user defined translation string.
+''' Bell System Logo is used as a dummy character.
+'''
+.tr \(*W-|\(bv\*(Tr
+.ie n \{\
+.ds -- \(*W-
+.ds PI pi
+.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
+.ds L" ""
+.ds R" ""
+''' \*(M", \*(S", \*(N" and \*(T" are the equivalent of
+''' \*(L" and \*(R", except that they are used on ".xx" lines,
+''' such as .IP and .SH, which do another additional levels of
+''' double-quote interpretation
+.ds M" """
+.ds S" """
+.ds N" """""
+.ds T" """""
+.ds L' '
+.ds R' '
+.ds M' '
+.ds S' '
+.ds N' '
+.ds T' '
+'br\}
+.el\{\
+.ds -- \(em\|
+.tr \*(Tr
+.ds L" ``
+.ds R" ''
+.ds M" ``
+.ds S" ''
+.ds N" ``
+.ds T" ''
+.ds L' `
+.ds R' '
+.ds M' `
+.ds S' '
+.ds N' `
+.ds T' '
+.ds PI \(*p
+'br\}
+.\" If the F register is turned on, we'll generate
+.\" index entries out stderr for the following things:
+.\" TH Title
+.\" SH Header
+.\" Sh Subsection
+.\" Ip Item
+.\" X<> Xref (embedded
+.\" Of course, you have to process the output yourself
+.\" in some meaninful fashion.
+.if \nF \{
+.de IX
+.tm Index:\\$1\t\\n%\t"\\$2"
+..
+.nr % 0
+.rr F
+.\}
+.TH DPKG-SCANSOURCES 1 "perl 5.004, patch 04" "28/Feb/99" "User Contributed Perl Documentation"
+.UC
+.if n .hy 0
+.if n .na
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.de CQ \" put $1 in typewriter font
+.ft CW
+'if n "\c
+'if t \\&\\$1\c
+'if n \\&\\$1\c
+'if n \&"
+\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
+'.ft R
+..
+.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
+. \" AM - accent mark definitions
+.bd B 3
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds ? ?
+. ds ! !
+. ds /
+. ds q
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
+. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
+.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
+.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
+.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.ds oe o\h'-(\w'o'u*4/10)'e
+.ds Oe O\h'-(\w'O'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds v \h'-1'\o'\(aa\(ga'
+. ds _ \h'-1'^
+. ds . \h'-1'.
+. ds 3 3
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+. ds oe oe
+. ds Oe OE
+.\}
+.rm #[ #] #H #V #F C
+.SH "NAME"
+dpkg-scansources \- prog
+.SH "SYNOPSIS"
+\fBdpkg-scansources\fR [switch]... \fIbinary-dir\fR [\fIoverride-file\fR
+[\fIpath-prefix\fR]] > Sources
+.SH "DESCRIPTION"
+\fBdpkg-scansources\fR scans the given \fIbinary-dir\fR for \fI.dsc\fR files.
+These are used to create a Debian source index, which is output to
+stdout.
+.PP
+The \fIoverride-file\fR, if given, is used to set priorities in the resulting
+index records and to override the maintainer field given in the \fI.dsc\fR
+files. See the \fIdpkg-scanpackages\fR manpage for the format of this file. NB: Since
+the override file is indexed by binary, not source, packages, there's a bit
+of a problem here. The current implementation uses the highest priority of
+all the binary packages produced by a \fI.dsc\fR file for the priority of the
+source package, and the override entry for the first binary package listed
+in the \fI.dsc\fR file to modify maintainer information. This might change.
+.PP
+The \fIpath-prefix\fR, if given, is prepended to the directory field in the
+generated source index. You generally use this to make the directory
+fields contain the path from the top of the Debian archive hierarchy.
+.SH "OPTIONS"
+.Ip "\fB--debug\fR" 4
+Turn debugging on.
+.Ip "\fB--help\fR" 4
+Show the usage message and die.
+.Ip "\fB\-n\fR, \fB--no-sort\fR" 4
+Don't sort the index records. Normally they are sorted by source package
+name.
+.Ip "\fB\-s\fR, \fB--source-override\fR \fIfile\fR" 4
+Use \fIfile\fR as the source override file. The default is the name of the
+override file you specified with \fI.src\fR appended.
+.Sp
+The source override file is in a different format from the binary override
+file. It contains only two whitespace separated fields, the first is the
+source package name and the second is the section. Blank lines and comment
+lines are ignored in the normal manner. If a package appears in both files
+the source override takes precedence for setting the section.
+.Ip "\fB--version\fR" 4
+Print the version number and exit.
+.SH "SEE ALSO"
+dpkg-\fIscanpackages\fR\|(8)
+.SH "AUTHOR"
+Roderick Schertler <roderick@argon.org>
+
+.rn }` ''
+.IX Title "DPKG-SCANSOURCES 1"
+.IX Name "dpkg-scansources - prog"
+
+.IX Header "NAME"
+
+.IX Header "SYNOPSIS"
+
+.IX Header "DESCRIPTION"
+
+.IX Header "OPTIONS"
+
+.IX Item "\fB--debug\fR"
+
+.IX Item "\fB--help\fR"
+
+.IX Item "\fB\-n\fR, \fB--no-sort\fR"
+
+.IX Item "\fB\-s\fR, \fB--source-override\fR \fIfile\fR"
+
+.IX Item "\fB--version\fR"
+
+.IX Header "SEE ALSO"
+
+.IX Header "AUTHOR"
+
--- /dev/null
+#!/usr/bin/perl -w
+use strict;
+
+# $Id$
+
+# Copyright (C) 1999 Roderick Schertler
+#
+# 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.
+#
+# For a copy of the GNU General Public License write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# User documentation is at the __END__.
+#
+# Errors with a single package are warned about but don't affect the
+# exit code. Only errors which affect everything cause a non-zero exit.
+#
+# Dependencies are by request non-existant. I used to use the MD5 and
+# Proc::WaitStat modules.
+
+use Getopt::Long ();
+
+my $Exit = 0;
+(my $Me = $0) =~ s-.*/--;
+my $Version = q$Revision$ =~ /(\d\S+)/ ? $1 : '?';
+
+# %Override is a hash of lists. The subs following describe what's in
+# the lists.
+
+my %Override;
+sub O_PRIORITY () { 0 }
+sub O_SECTION () { 1 }
+sub O_MAINT_FROM () { 2 } # undef for non-specific, else listref
+sub O_MAINT_TO () { 3 } # undef if there's no maint override
+
+my %Priority = (
+ 'extra' => 1,
+ 'optional' => 2,
+ 'standard' => 3,
+ 'important' => 4,
+ 'required' => 5,
+);
+
+# Switches
+
+my $Debug = 0;
+my $No_sort = 0;
+my $Src_override = undef;
+
+my @Option_spec = (
+ 'debug!' => \$Debug,
+ 'help!' => sub { usage() },
+ 'no-sort|n!' => \$No_sort,
+ 'source-override|s=s' => \$Src_override,
+ 'version' => sub { print "$Me version $Version\n"; exit },
+);
+
+my $Usage = <<EOF;
+usage: $Me [switch]... binary-dir [override-file [path-prefix]] > Sources
+
+switches:
+ --debug turn debugging on
+ --help show this and then die
+ -n, --no-sort don\'t sort by package before outputting
+ -s, --source-override file
+ use file for additional source overrides, default
+ is regular override file with .src appended
+ --version show the version and exit
+
+See the man page or \`perldoc $Me\' for the full documentation.
+EOF
+
+sub debug {
+ print @_, "\n" if $Debug;
+}
+
+sub xwarndie_mess {
+ my @mess = ("$Me: ", @_);
+ $mess[$#mess] =~ s/:$/: $!\n/; # XXX loses if it's really /:\n/
+ return @mess;
+}
+
+sub xdie {
+ die xwarndie_mess @_;
+}
+
+sub xwarn {
+ warn xwarndie_mess @_;
+ $Exit ||= 1;
+}
+
+sub xwarn_noerror {
+ warn xwarndie_mess @_;
+}
+
+sub usage {
+ xwarn @_ if @_;
+ die $Usage;
+}
+
+# Getopt::Long has some really awful defaults. This function loads it
+# then configures it to use more sane settings.
+
+sub getopt;
+sub configure_getopt {
+ Getopt::Long->import(2.11);
+ *getopt = \&Getopt::Long::GetOptions;
+
+ # I'm setting this environment variable lest he sneaks more bad
+ # defaults into the module.
+ local $ENV{POSIXLY_CORRECT} = 1;
+ Getopt::Long::config qw(
+ default
+ no_autoabbrev
+ no_getopt_compat
+ require_order
+ bundling
+ no_ignorecase
+ );
+}
+
+sub close_msg {
+ my $name = shift;
+ return "error closing $name (\$? $?, \$! `$!')\n";
+}
+
+sub init {
+ configure_getopt;
+ getopt @Option_spec or usage;
+}
+
+sub load_override {
+ my $file = shift;
+ local $_;
+
+ open OVERRIDE, $file or xdie "can't read override file $file:";
+ while (<OVERRIDE>) {
+ s/#.*//;
+ next if /^\s*$/;
+ s/\s+$//;
+
+ my @data = split ' ', $_, 4;
+ unless (@data == 3 || @data == 4) {
+ xwarn_noerror "invalid override entry at line $. (",
+ 0+@data, " fields)\n";
+ next;
+ }
+ my ($package, $priority, $section, $maintainer) = @data;
+ if (exists $Override{$package}) {
+ xwarn_noerror "ignoring duplicate override entry for $package",
+ " at line $.\n";
+ next;
+ }
+ if (!$Priority{$priority}) {
+ xwarn_noerror "ignoring override entry for $package,",
+ " invalid priority $priority\n";
+ next;
+ }
+
+ $Override{$package} = [];
+ $Override{$package}[O_PRIORITY] = $priority;
+ $Override{$package}[O_SECTION] = $section;
+ if (!defined $maintainer) {
+ # do nothing
+ }
+ elsif ($maintainer =~ /^(.*\S)\s*=>\s*(.*)$/) {
+ $Override{$package}[O_MAINT_FROM] = [split m-\s*//\s*-, $1];
+ $Override{$package}[O_MAINT_TO] = $2;
+ }
+ else {
+ $Override{$package}[O_MAINT_TO] = $maintainer;
+ }
+ }
+ close OVERRIDE or xdie "error closing override file:";
+}
+
+sub load_src_override {
+ my ($user_file, $regular_file) = @_;
+ my ($file);
+ local $_;
+
+ if (defined $user_file) {
+ $file = $user_file;
+ }
+ elsif (defined $regular_file) {
+ $file = "$regular_file.src";
+ }
+ else {
+ return;
+ }
+
+ debug "source override file $file";
+ unless (open SRC_OVERRIDE, $file) {
+ return if !defined $user_file;
+ xdie "can't read source override file $file:";
+ }
+ while (<SRC_OVERRIDE>) {
+ s/#.*//;
+ next if /^\s*$/;
+ s/\s+$//;
+
+ my @data = split ' ', $_;
+ unless (@data == 2) {
+ xwarn_noerror "invalid source override entry at line $. (",
+ 0+@data, " fields)\n";
+ next;
+ }
+
+ my ($package, $section) = @data;
+ my $key = "source/$package";
+ if (exists $Override{$key}) {
+ xwarn_noerror "ignoring duplicate source override entry",
+ " for $package at line $.\n";
+ next;
+ }
+ $Override{$key} = [];
+ $Override{$key}[O_SECTION] = $section;
+ }
+ close SRC_OVERRIDE or xdie "error closing source override file:";
+}
+
+# Given FILENAME (for error reporting) and STRING, drop the PGP info
+# from the string and undo the encoding (if present) and return it.
+
+sub de_pgp {
+ my ($file, $s) = @_;
+ if ($s =~ s/^-----BEGIN PGP SIGNED MESSAGE-----\n(?:[^:]+: [^\n]+\n)*\n//) {
+ unless ($s =~ s/\n
+ -----BEGIN\040PGP\040SIGNATURE-----\n
+ .*?\n
+ -----END\040PGP\040SIGNATURE-----\n
+ //xs) {
+ xwarn_noerror "$file has PGP start token but not end token\n";
+ return;
+ }
+ $s =~ s/^- //mg;
+ }
+ return $s;
+}
+
+# Load DSC-FILE and return its size, MD5 and translated (de-PGPed)
+# contents.
+
+sub read_dsc {
+ my $file = shift;
+ my ($size, $md5, $nread, $contents);
+
+ unless (open FILE, $file) {
+ xwarn_noerror "can't read $file:";
+ return;
+ }
+
+ $size = -s FILE;
+ unless (defined $size) {
+ xwarn_noerror "error doing fstat on $file:";
+ return;
+ }
+
+ $contents = '';
+ do {
+ $nread = read FILE, $contents, 16*1024, length $contents;
+ unless (defined $nread) {
+ xwarn_noerror "error reading from $file:";
+ return;
+ }
+ } while $nread > 0;
+
+ # Rewind the .dsc file and feed it to md5sum as stdin.
+ my $pid = open MD5, '-|';
+ unless (defined $pid) {
+ xwarn_noerror "can't fork:";
+ return;
+ }
+ if (!$pid) {
+ open STDIN, '<&FILE' or xdie "can't dup $file:";
+ seek STDIN, 0, 0 or xdie "can't rewind $file:";
+ exec 'md5sum' or xdie "can't exec md5sum:";
+ }
+ chomp($md5 = join '', <MD5>);
+ unless (close MD5) {
+ xwarn_noerror close_msg 'md5sum';
+ return;
+ }
+ unless (length($md5) == 32 && $md5 !~ /[^\da-f]/i) {
+ xwarn_noerror "invalid md5 output for $file ($md5)\n";
+ return;
+ }
+
+ unless (close FILE) {
+ xwarn_noerror "error closing $file:";
+ return;
+ }
+
+ $contents = de_pgp $file, $contents;
+ return unless defined $contents;
+
+ return $size, $md5, $contents;
+}
+
+# Given PREFIX and DSC-FILE, process the file and returning the source
+# package name and index record.
+
+sub process_dsc {
+ my ($prefix, $file) = @_;
+ my ($source, @binary, $priority, $section, $maintainer_override,
+ $dir, $dir_field, $dsc_field_start);
+
+ my ($size, $md5, $contents) = read_dsc $file or return;
+
+ if ($contents =~ /^\n/ || $contents =~ /\n\n/) {
+ xwarn_noerror "$file invalid (contains blank line)\n";
+ return;
+ }
+
+ # Take the $contents and create a list of (possibly multi-line)
+ # fields. Fields can be continued by starting the next line with
+ # white space. The tricky part is I don't want to modify the data
+ # at all, so I can't just collapse continued fields.
+ #
+ # Implementation is to start from the last line and work backwards
+ # to the second. If this line starts with space, append it to the
+ # previous line and undef it. When done drop the undef entries.
+ my @line = split /\n/, $contents;
+ for (my $i = $#line; $i > 0; $i--) {
+ if ($line[$i] =~ /^\s/) {
+ $line[$i-1] .= "\n$line[$i]";
+ $line[$i] = undef;
+ }
+ }
+ my @field = map { "$_\n" } grep { defined } @line;
+
+ # Extract information from the record.
+ for my $orig_field (@field) {
+ my $s = $orig_field;
+ $s =~ s/\s+$//;
+ $s =~ s/\n\s+/ /g;
+ unless ($s =~ s/^([^:\s]+):\s*//) {
+ xwarn_noerror "invalid field in $file: $orig_field";
+ return;
+ }
+ my ($key, $val) = (lc $1, $s);
+
+ # $source
+ if ($key eq 'source') {
+ if (defined $source) {
+ xwarn_noerror "duplicate source field in $file\n";
+ return;
+ }
+ if ($val =~ /\s/) {
+ xwarn_noerror "invalid source field in $file\n";
+ return;
+ }
+ $source = $val;
+ next;
+ }
+
+ # @binary
+ if ($key eq 'binary') {
+ if (@binary) {
+ xwarn_noerror "duplicate binary field in $file\n";
+ return;
+ }
+ @binary = split /\s*,\s*/, $val;
+ unless (@binary) {
+ xwarn_noerror "no binary packages specified in $file\n";
+ return;
+ }
+ }
+ }
+
+ # The priority for the source package is the highest priority of the
+ # binary packages it produces.
+ my @binary_by_priority = sort {
+ ($Override{$a} ? $Priority{$Override{$a}[O_PRIORITY]} : 0)
+ <=>
+ ($Override{$b} ? $Priority{$Override{$b}[O_PRIORITY]} : 0)
+ } @binary;
+ my $priority_override = $Override{$binary_by_priority[-1]};
+ $priority = $priority_override
+ ? $priority_override->[O_PRIORITY]
+ : undef;
+
+ # For the section override, first check for a record from the source
+ # override file, else use the regular override file.
+ my $section_override = $Override{"source/$source"} || $Override{$source};
+ $section = $section_override
+ ? $section_override->[O_SECTION]
+ : undef;
+
+ # For the maintainer override, use the override record for the first
+ # binary.
+ $maintainer_override = $Override{$binary[0]};
+
+ # A directory field will be inserted just before the files field.
+ $dir = ($file =~ s-(.*)/--) ? $1 : '';
+ $dir = "$prefix$dir";
+ $dir =~ s-/+$--;
+ $dir = '.' if $dir eq '';
+ $dir_field .= "Directory: $dir\n";
+
+ # The files field will get an entry for the .dsc file itself.
+ $dsc_field_start = "Files:\n $md5 $size $file\n";
+
+ # Loop through @field, doing nececessary processing and building up
+ # @new_field.
+ my @new_field;
+ for (@field) {
+ # Rename the source field to package.
+ s/^Source:/Package:/i;
+
+ # Override the user's priority field.
+ if (/^Priority:/i && defined $priority) {
+ $_ = "Priority: $priority\n";
+ undef $priority;
+ }
+
+ # Override the user's section field.
+ if (/^Section:/i && defined $section) {
+ $_ = "Section: $section\n";
+ undef $section;
+ }
+
+ # Insert the directory line just before the files entry, and add
+ # the dsc file to the files list.
+ if (defined $dir_field && s/^Files:\s*//i) {
+ push @new_field, $dir_field;
+ $dir_field = undef;
+ $_ = " $_" if length;
+ $_ = "$dsc_field_start$_";
+ }
+
+ # Modify the maintainer if necessary.
+ if ($maintainer_override
+ && defined $maintainer_override->[O_MAINT_TO]
+ && /^Maintainer:\s*(.*)\n/is) {
+ my $maintainer = $1;
+ $maintainer =~ s/\n\s+/ /g;
+ if (!defined $maintainer_override->[O_MAINT_FROM]
+ || grep { $maintainer eq $_ }
+ @{ $maintainer_override->[O_MAINT_FROM] }){
+ $_ = "Maintainer: $maintainer_override->[O_MAINT_TO]\n";
+ }
+ }
+ }
+ continue {
+ push @new_field, $_ if defined $_;
+ }
+
+ # If there was no files entry, add one.
+ if (defined $dir_field) {
+ push @new_field, $dir_field;
+ push @new_field, $dsc_field_start;
+ }
+
+ # Add the section field if it didn't override one the user supplied.
+ if (defined $section) {
+ # If the record starts with a package field put it after that,
+ # otherwise put it first.
+ my $pos = $new_field[0] =~ /^Package:/i ? 1 : 0;
+ splice @new_field, $pos, 0, "Section: $section\n";
+ }
+
+ # Add the priority field if it didn't override one the user supplied.
+ if (defined $priority) {
+ # If the record starts with a package field put it after that,
+ # otherwise put it first.
+ my $pos = $new_field[0] =~ /^Package:/i ? 1 : 0;
+ splice @new_field, $pos, 0, "Priority: $priority\n";
+ }
+
+ return $source, join '', @new_field, "\n";
+}
+
+sub main {
+ my (@out);
+
+ init;
+ @ARGV >= 1 && @ARGV <= 3 or usage "1 to 3 args expected\n";
+
+ push @ARGV, undef if @ARGV < 2;
+ push @ARGV, '' if @ARGV < 3;
+ my ($dir, $override, $prefix) = @ARGV;
+
+ load_override $override if defined $override;
+ load_src_override $Src_override, $override;
+
+ open FIND, "find \Q$dir\E -follow -name '*.dsc' -print |"
+ or xdie "can't fork:";
+ while (<FIND>) {
+ chomp;
+ s-^\./+--;
+ my ($source, $out) = process_dsc $prefix, $_ or next;
+ if ($No_sort) {
+ print $out;
+ }
+ else {
+ push @out, [$source, $out];
+ }
+ }
+ close FIND or xdie close_msg 'find';
+
+ if (@out) {
+ print map { $_->[1] } sort { $a->[0] cmp $b->[0] } @out;
+ }
+
+ return 0;
+}
+
+$Exit = main || $Exit;
+$Exit = 1 if $Exit and not $Exit % 256;
+exit $Exit;
+
+__END__
+
+=head1 NAME
+
+dpkg-scansources - prog
+
+=head1 SYNOPSIS
+
+B<dpkg-scansources> [switch]... I<binary-dir> [I<override-file>
+[I<path-prefix>]] > Sources
+
+=head1 DESCRIPTION
+
+B<dpkg-scansources> scans the given I<binary-dir> for F<.dsc> files.
+These are used to create a Debian source index, which is output to
+stdout.
+
+The I<override-file>, if given, is used to set priorities in the resulting
+index records and to override the maintainer field given in the F<.dsc>
+files. See L<dpkg-scanpackages> for the format of this file. NB: Since
+the override file is indexed by binary, not source, packages, there's a bit
+of a problem here. The current implementation uses the highest priority of
+all the binary packages produced by a F<.dsc> file for the priority of the
+source package, and the override entry for the first binary package listed
+in the F<.dsc> file to modify maintainer information. This might change.
+
+The I<path-prefix>, if given, is prepended to the directory field in the
+generated source index. You generally use this to make the directory
+fields contain the path from the top of the Debian archive hierarchy.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--debug>
+
+Turn debugging on.
+
+=item B<--help>
+
+Show the usage message and die.
+
+=item B<-n>, B<--no-sort>
+
+Don't sort the index records. Normally they are sorted by source package
+name.
+
+=item B<-s>, B<--source-override> I<file>
+
+Use I<file> as the source override file. The default is the name of the
+override file you specified with I<.src> appended.
+
+The source override file is in a different format from the binary override
+file. It contains only two whitespace separated fields, the first is the
+source package name and the second is the section. Blank lines and comment
+lines are ignored in the normal manner. If a package appears in both files
+the source override takes precedence for setting the section.
+
+=item B<--version>
+
+Print the version number and exit.
+
+=back
+
+=head1 SEE ALSO
+
+dpkg-scanpackages(8)
+
+=head1 AUTHOR
+
+Roderick Schertler <roderick@argon.org>
+
+=cut
+
--- /dev/null
+#!/bin/sh
+# Copyright (C) 1995 Free Software Foundation, Inc.
+# François Pinard <pinard@iro.umontreal.ca>, 1995.
+#
+# 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, 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.
+
+# This script byte-compiles all `.el' files which are part of its
+# arguments, using GNU Emacs, and put the resulting `.elc' files into
+# the current directory, so disregarding the original directories used
+# in `.el' arguments.
+#
+# This script manages in such a way that all Emacs LISP files to
+# be compiled are made visible between themselves, in the event
+# they require or load-library one another.
+
+if test $# = 0; then
+ echo 1>&2 "No files given to $0"
+ exit 1
+else
+ if test -z "$EMACS" || test "$EMACS" = "t"; then
+ # Value of "t" means we are running in a shell under Emacs.
+ # Just assume Emacs is called "emacs".
+ EMACS=emacs
+ fi
+
+ tempdir=elc.$$
+ mkdir $tempdir
+ cp $* $tempdir
+ cd $tempdir
+
+ echo "(setq load-path (cons nil load-path))" > script
+ $EMACS -q -batch -l script -f batch-byte-compile *.el
+ mv *.elc ..
+
+ cd ..
+ rm -fr $tempdir
+fi