[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#33659: dpkg-architecture in dpkg 1.4.1.6



severity fixed
thank you

dpkg-architecture will be in dpkg 1.4.1.6 NMU, which is in incoming.

This change is quite large, but needs to be done to be policy compliant (see
packaging manual).

The latest version is attached, it is a diff against your dpkg 1.5.4 tree,
for your convenience!

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org   finger brinkmd@ 
Marcus Brinkmann              GNU    http://www.gnu.org     master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09
diff -Nru ../dpkg-1.5.4.old/debian/changelog ./debian/changelog
--- ../dpkg-1.5.4.old/debian/changelog	Sun Jul 25 19:25:52 1999
+++ ./debian/changelog	Sun Jul 25 23:44:06 1999
@@ -1,3 +1,5 @@
+  * scripts/dpkg-architecture.pl, dpkg-architecture.1: New files.
+
 dpkg (1.5.4) experimental; urgency=low
 
   * Include dpkg-buildpackage from NMU series.
diff -Nru ../dpkg-1.5.4.old/debian/rules ./debian/rules
--- ../dpkg-1.5.4.old/debian/rules	Sun Jul 25 19:03:40 1999
+++ ./debian/rules	Mon Jul 26 00:33:03 1999
@@ -58,9 +58,9 @@
 	cp TODO debian/tmp-dev/usr/doc/dpkg/WISHLIST
 	set -e; for f in \
  usr/doc/dpkg/{programmer.html,changelog.manuals.gz} \
- usr/bin/dpkg-{source,genchanges,gencontrol,shlibdeps,buildpackage,parsechangelog} \
+ usr/bin/dpkg-{source,genchanges,gencontrol,shlibdeps,buildpackage,parsechangelog,architecture} \
  usr/bin/{dpkg-distaddfile,822-date,dpkg-scanpackages,dpkg-name} \
- usr/man/man1/dpkg-{source,name,genchanges,gencontrol,shlibdeps,buildpackage}.1.gz \
+ usr/man/man1/dpkg-{source,name,genchanges,gencontrol,shlibdeps,buildpackage,architecture}.1.gz \
  usr/man/man1/{dpkg-parsechangelog,dpkg-distaddfile,822-date}.1.gz \
  usr/man/man5 usr/man/man8/dpkg-scanpackages.8.gz usr/share/emacs \
  usr/lib/dpkg/parsechangelog usr/lib/dpkg/controllib.pl \
diff -Nru ../dpkg-1.5.4.old/scripts/Makefile.in ./scripts/Makefile.in
--- ../dpkg-1.5.4.old/scripts/Makefile.in	Thu Jul 22 02:12:13 1999
+++ ./scripts/Makefile.in	Sun Jul 25 23:45:22 1999
@@ -37,7 +37,7 @@
 altsetcdir = $(etcdir)/alternatives
 perlpath = @perlpath@
 
-MAN1 =  dpkg-name dpkg-source 822-date
+MAN1 =  dpkg-name dpkg-source 822-date dpkg-architecture
 LSMAN = dpkg-source.$(man1)
 LSMANL=	dpkg-gencontrol dpkg-genchanges dpkg-buildpackage \
 	dpkg-distaddfile dpkg-parsechangelog dpkg-shlibdeps
diff -Nru ../dpkg-1.5.4.old/scripts/controllib.pl ./scripts/controllib.pl
--- ../dpkg-1.5.4.old/scripts/controllib.pl	Thu Jul 22 02:53:21 1999
+++ ./scripts/controllib.pl	Sun Jul 25 23:54:51 1999
@@ -16,9 +16,13 @@
 }
 
 sub findarch {
-    $arch=`dpkg --print-architecture`;
-    $? && &subprocerr("dpkg --print-architecture");
-    $arch =~ s/\n$//;
+    if (exists $ENV{DEB_HOST_ARCH}) {
+       $arch=$ENV{DEB_HOST_ARCH};
+    } else {
+       $arch=`dpkg --print-architecture`;
+       $? && &subprocerr("dpkg --print-architecture");
+       $arch =~ s/\n$//;
+    }
     $substvar{'Arch'}= $arch;
 }
 
diff -Nru ../dpkg-1.5.4.old/scripts/dpkg-architecture.1 ./scripts/dpkg-architecture.1
--- ../dpkg-1.5.4.old/scripts/dpkg-architecture.1	Thu Jan  1 01:00:00 1970
+++ ./scripts/dpkg-architecture.1	Sun Jul 25 23:53:33 1999
@@ -0,0 +1,425 @@
+.rn '' }`
+''' $RCSfile$$Revision$$Date$
+'''
+''' $Log$
+'''
+.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" "25/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`
+.PP
+configure $(ARCH)\-linux
+.PP
+please use the following:
+.PP
+B_ARCH=$(DEB_BUILD_GNU_TYPE)
+.PP
+H_ARCH=$(DEB_HOST_GNU_TYPE)
+.PP
+configure --build=$(B_ARCH) --host=$(H_ARCH)
+.PP
+Instead:
+.PP
+ARCH=`dpkg --print-architecture`
+.PP
+ifeq ($(ARCH),alpha)
+.PP
+.Vb 1
+\&  ...
+.Ve
+endif
+.PP
+please use:
+.PP
+ARCH=$(DEB_HOST_ARCH)
+.PP
+ifeq ($(ARCH),alpha)
+.PP
+.Vb 1
+\&  ...
+.Ve
+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)
+.PP
+DEB_BUILD_GNU_CPU := $(patsubst hurd-%,%,$(DEB_BUILD_ARCH))
+.PP
+ifeq ($(filter-out hurd-%,$(DEB_BUILD_ARCH)),)
+.PP
+.Vb 1
+\&  DEB_BUILD_GNU_SYSTEM := gnu
+.Ve
+else
+.PP
+.Vb 1
+\&  DEB_BUILD_GNU_SYSTEM := linux
+.Ve
+endif
+.PP
+DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_CPU)\-$(DEB_BUILD_GNU_SYSTEM)
+.PP
+DEB_HOST_ARCH=$(DEB_BUILD_ARCH)
+.PP
+DEB_HOST_GNU_CPU=$(DEB_BUILD_GNU_CPU)
+.PP
+DEB_HOST_GNU_SYSTEM=$(DEB_BUILD_GNU_SYSTEM)
+.PP
+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`
+.PP
+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
+.PP
+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"
+
diff -Nru ../dpkg-1.5.4.old/scripts/dpkg-architecture.pl ./scripts/dpkg-architecture.pl
--- ../dpkg-1.5.4.old/scripts/dpkg-architecture.pl	Thu Jan  1 01:00:00 1970
+++ ./scripts/dpkg-architecture.pl	Sun Jul 25 23:52:35 1999
@@ -0,0 +1,478 @@
+#! /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>.
diff -Nru ../dpkg-1.5.4.old/scripts/dpkg-buildpackage.sh ./scripts/dpkg-buildpackage.sh
--- ../dpkg-1.5.4.old/scripts/dpkg-buildpackage.sh	Sun Jul 25 19:25:58 1999
+++ ./scripts/dpkg-buildpackage.sh	Sun Jul 25 23:59:46 1999
@@ -18,7 +18,7 @@
          -spgp         the sign-command is called like PGP 
          -us           unsigned source
          -uc           unsigned changes
-         -a<arch>      architecture field of the changes _file_name_
+         -a<arch>      Debian architecture we build for
          -b            binary-only, do not build source } also passed to
          -B            binary-only, no arch-indep files } dpkg-genchanges
          -v<version>   changes since version <version>      }
@@ -29,6 +29,7 @@
          -sd           uploaded src is diff and .dsc only   }
          -nc           do not clean source tree (implies -b)
          -tc           clean source tree when finished
+         -t<gnusystem> target gnu system, can be derived from -a<arch>
          -h            print this message
 END
 }
@@ -73,6 +74,7 @@
 	-sa)	sourcestyle=-sa ;;
 	-sd)	sourcestyle=-sd ;;
 	-tc)	cleansource=true ;;
+        -t*)    targetgnusystem="$value" ;;          # Order DOES matter!
 	-nc)	noclean=true; binaryonly=-b ;;
 	-b)	binaryonly=-b ;;
 	-B)	binaryonly=-B; binarytarget=binary-arch ;;
@@ -109,7 +111,10 @@
 mustsetvar version "`dpkg-parsechangelog | sed -n 's/^Version: //p'`" "source version"
 if [ -n "$maint" ]; then maintainer="$maint"; 
 else mustsetvar maintainer "`dpkg-parsechangelog | sed -n 's/^Maintainer: //p'`" "source maintainer"; fi
+command -v dpkg-architecture > /dev/null 2>&1 && eval `dpkg-architecture -a${arch} -t${targetgnusystem} -s`
+archlist=`dpkg-architecture -a${arch} -t${targetgnusystem} -f 2> /dev/null`
 test "${opt_a}" \
+	|| arch=`dpkg-architecture -a${arch} -t${targetgnusystem} -qDEB_HOST_ARCH 2> /dev/null` && test "${arch}" \
 	|| mustsetvar arch "`dpkg --print-architecture`" "build architecture"
 
 sversion=`echo "$version" | perl -pe 's/^\d+://'`
@@ -143,13 +148,13 @@
 if [ -n "$desc"		]; then set -- "$@" "-C$desc"		; fi
 
 if [ x$noclean != xtrue ]; then
-	withecho $rootcommand debian/rules clean
+	withecho $rootcommand debian/rules clean $archlist
 fi
 if [ x$binaryonly = x ]; then
 	cd ..; withecho dpkg-source -b "$dirn"; cd "$dirn"
 fi
-withecho debian/rules build
-withecho $rootcommand debian/rules $binarytarget
+withecho debian/rules build $archlist
+withecho $rootcommand debian/rules $binarytarget $archlist
 if [ x$binaryonly = x ]; then
         $signsource "$pv.dsc"
 fi
@@ -177,7 +182,7 @@
 $signchanges "$pva.changes"
 
 if $cleansource; then
-	withecho $rootcommand debian/rules clean
+	withecho $rootcommand debian/rules clean $archlist
 fi
 
 echo "dpkg-buildpackage: $srcmsg"
diff -Nru ../dpkg-1.5.4.old/scripts/dpkg-source.1 ./scripts/dpkg-source.1
--- ../dpkg-1.5.4.old/scripts/dpkg-source.1	Sat Mar 13 15:13:16 1999
+++ ./scripts/dpkg-source.1	Mon Jul 26 00:04:12 1999
@@ -546,6 +546,16 @@
 .TP
 .BR -us ", " -uc
 Do not PGP-sign the source package or the changelog, respectively.
+.TP
+.BI -a architecture
+Specify the Debian architecture we build for. The architecture of the
+machine we build on is determined automatically, and is also the default
+for the host machine.
+.TP
+.BI -t gnu system type
+Specify the GNU system type specifications string we build for. This value
+can usually be derived from the -a option and should only be used if a
+manual override is necessary.
 .SH DPKG-DISTADDFILE ARGUMENTS
 .B dpkg-distaddfile
 does not take any non-common options.  It takes three non-option

Reply to: