> You forgot patch itself :)
Every time I say, do not forget to attach the file, the file
do not forget to do it but... >}8|

--
Raphael Bossek
diff --exclude=CVS -Nru dpkg-cross.cvs/ChangeLog 
dpkg-cross-1.20.4.checkbuilddeps.1/ChangeLog
--- dpkg-cross.cvs/ChangeLog    2004-12-03 22:42:55.000000000 +0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/ChangeLog        2004-12-15 
10:59:00.000000000 +0100
@@ -1,3 +1,22 @@
+2004-12-14  Raphael Bossek <[EMAIL PROTECTED]>
+
+       * dpkg-cross, dpkg-cross.pl: moved rewrite_dependencies(),
+       rewrite_alternatives() and rewrite_item() to dpkg-cross.pl for reusage 
in
+       dpkg-checkbuilddeps. rewrite_item() rename only packages that are in
+       section libdevel or libs or are listed in "crossdeps" configuration
+       variable. Set DPKGCROSSARCH environment variable so dpkg-checkbuilddeps
+       know to run in dpkg-cross environment. Fixed issue where @keepdeps and
+       @removedeps are are not set as arrays. Introduced the "checkbuilddeps"
+       configuration variable which should be set to 1 if dpkg-checkbuilddeps
+       support is designated. ARCH is set but not used to determine if we are
+       wihtin a dpkg-cross envrionment. DPKGCROSSARCH was introduced to avoid
+       interferences with the "unset" feature and packages which uses ARCH for
+       its own purposes.
+       * dpkg-checkbuilddeps: support for Build-* information in debian/control
+       in sence of dpkg-cross and cross-build environments added.
+       * cross-compile.example: added "crossdeps" and "checkbuilddeps"
+       documentation.
+
 2004-12-03  Nikita V. Youshchenko <[EMAIL PROTECTED]>
 
        * dpkg-cross.pl: implemented 'unset' feature for configuration file.
diff --exclude=CVS -Nru dpkg-cross.cvs/cross-compile.example 
dpkg-cross-1.20.4.checkbuilddeps.1/cross-compile.example
--- dpkg-cross.cvs/cross-compile.example        2004-12-03 22:42:55.000000000 
+0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/cross-compile.example    2004-12-15 
10:43:10.000000000 +0100
@@ -31,6 +31,13 @@
 #  keepdeps   : comma-separated list of package names thet should be kept
 #               in depends/conflicts/etc fields as is, without adding
 #               -arch-cross.
+#  crossdeps  : comma-seperated list of package names that have to be
+#               extended with -arch-cross. This is required because only
+#               packages which belongs to sections libdevel and libs are
+#               renamed by default.
+#  checkbuilddeps : By default the Build-* dependencies are not validated
+#               by the dpkg-cross tool chain. You have to set checkbuilddeps
+#               to 1 if you intent to check Build-* dependencies.
 #
 # Usually, you need only set crossbase, or maybe also crossdir
 #
diff --exclude=CVS -Nru dpkg-cross.cvs/debian/changelog 
dpkg-cross-1.20.4.checkbuilddeps.1/debian/changelog
--- dpkg-cross.cvs/debian/changelog     2004-12-03 22:42:55.000000000 +0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/debian/changelog 2004-12-15 
11:08:05.000000000 +0100
@@ -1,3 +1,9 @@
+dpkg-cross (1.20.4.checkbuilddeps.1) unstable; urgency=low
+
+  * Added support for dpkg-checkbuilddeps.
+
+ -- Raphael Bossek <[EMAIL PROTECTED]>  Sun, 12 Dec 2004 17:32:26 +0100
+
 dpkg-cross (1.20.4) unstable; urgency=low
 
   * Implemented 'unset' feature for configuration file (Closes: #246061).
diff --exclude=CVS -Nru dpkg-cross.cvs/debian/control 
dpkg-cross-1.20.4.checkbuilddeps.1/debian/control
--- dpkg-cross.cvs/debian/control       2004-10-29 23:13:19.000000000 +0200
+++ dpkg-cross-1.20.4.checkbuilddeps.1/debian/control   2004-12-14 
10:23:35.000000000 +0100
@@ -7,7 +7,7 @@
 
 Package: dpkg-cross
 Architecture: all
-Depends: dpkg-dev (>= 1.9.21), binutils, file
+Depends: dpkg-dev (>= 1.9.21), binutils, file, libapt-pkg-perl
 Suggests: binutils-multiarch, fakeroot
 Conflicts: pkg-config (<< 0.15.0)
 Description: Tools for cross compiling Debian packages
diff --exclude=CVS -Nru dpkg-cross.cvs/debian/postrm 
dpkg-cross-1.20.4.checkbuilddeps.1/debian/postrm
--- dpkg-cross.cvs/debian/postrm        2004-08-25 03:11:14.000000000 +0200
+++ dpkg-cross-1.20.4.checkbuilddeps.1/debian/postrm    2004-12-14 
10:43:07.000000000 +0100
@@ -27,6 +27,10 @@
         dpkg-divert --package dpkg-cross --remove --rename \
             --divert /usr/bin/dpkg-shlibdeps.orig \
             /usr/bin/dpkg-shlibdeps
+
+        dpkg-divert --package dpkg-cross --remove --rename \
+            --divert /usr/bin/dpkg-checkbuilddeps.orig \
+            /usr/bin/dpkg-checkbuilddeps
     ;;
 
     purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
diff --exclude=CVS -Nru dpkg-cross.cvs/debian/preinst 
dpkg-cross-1.20.4.checkbuilddeps.1/debian/preinst
--- dpkg-cross.cvs/debian/preinst       2004-08-25 03:11:14.000000000 +0200
+++ dpkg-cross-1.20.4.checkbuilddeps.1/debian/preinst   2004-12-12 
17:35:12.000000000 +0100
@@ -22,6 +22,9 @@
 
         dpkg-divert --package dpkg-cross --add --rename \
             --divert /usr/bin/dpkg-shlibdeps.orig /usr/bin/dpkg-shlibdeps
+
+        dpkg-divert --package dpkg-cross --add --rename \
+            --divert /usr/bin/dpkg-checkbuilddeps.orig 
/usr/bin/dpkg-checkbuilddeps
     ;;
 
     abort-upgrade)
diff --exclude=CVS -Nru dpkg-cross.cvs/dpkg-buildpackage 
dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-buildpackage
--- dpkg-cross.cvs/dpkg-buildpackage    2004-11-15 22:22:38.000000000 +0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-buildpackage        2004-12-15 
12:06:19.427003727 +0100
@@ -114,6 +114,13 @@
                }
        }
        $ENV{'PATH'} = "$gccrossdir:" . $ENV{'PATH'};
+
+       if ($checkbuilddeps != 0) {
+               # Force dpkg-buildpackage.orig to use dpkg-checkbuilddeps by 
adding -D at
+               # the end of the command line parameters. It is important to 
set -D as
+               # last because other parameters override this setting, e.g. -a.
+               push (@ADD_ARGS, "-D");
+       }
 }
 
 # If exactly one .changes file for the current package exists in the parent
diff --exclude=CVS -Nru dpkg-cross.cvs/dpkg-checkbuilddeps 
dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-checkbuilddeps
--- dpkg-cross.cvs/dpkg-checkbuilddeps  1970-01-01 01:00:00.000000000 +0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-checkbuilddeps      2004-12-15 
12:07:17.785293612 +0100
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+#
+#  dpkg-checkbuilddeps - Support for dpkg-cross build packages
+#  Copyright (C) 2004  Raphael Bossek <[EMAIL PROTECTED]>
+#
+#  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
+#
+#  $Id$
+
+require "dpkg-cross.pl";
+
+dpkgcross_application();
+
+read_config();
+setup();
+
+# Where to find the debian/control file. This can be changed by 
dpkg-checkbuilddeps
+# option.
+$debian_control_file = "debian/control";
+$tmp_control_file = "";
[EMAIL PROTECTED] = ();
+
+# We search the options for an alternative debian/control file.
+foreach $arg (@ARGV) {
+       if ($arg =~ /^-/) {
+               push (@new_argv, $arg);
+       }
+       else {
+               $debian_control_file = $arg;
+       }
+}
+
+# Recreate the $debian_control_file file with new package names.
+if (-f $debian_control_file) {
+       $tmp_control_file = `tempfile`;
+       open (OUTF, ">$tmp_control_file") || die "Cannot open $tmp_control_file 
for writting: $!\n";
+       open (INF, "<$debian_control_file") || die "Cannot open 
$debian_control_file for reading: $!\n";
+       while (<INF>) {
+               chomp;
+               if (/^(Build-\S+):\s+(.*)/) {
+                       print OUTF "$1: " . rewrite_dependencies ($2) . "\n";
+               }
+               else {
+                       print OUTF "$_\n";
+               }
+       }
+       close (INF);
+       close (OUTF);
+
+       $debian_control_file = $tmp_control_file;
+}
+push (@new_argv, $debian_control_file);
+
+$rv = system ("/usr/bin/dpkg-checkbuilddeps.orig", @new_argv) >> 8;
+
+if ($debian_control_file eq $tmp_control_file) {
+       unlink ($tmp_control_file);
+}
+
+exit $rv;
diff --exclude=CVS -Nru dpkg-cross.cvs/dpkg-cross 
dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-cross
--- dpkg-cross.cvs/dpkg-cross   2004-08-26 21:51:12.000000000 +0200
+++ dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-cross       2004-12-12 
17:09:03.000000000 +0100
@@ -850,37 +850,3 @@
        return $? == 0;
 }
 
-sub rewrite_dependencies {
-       my $str = shift;
-
-       @list = map( rewrite_alternatives($_), split( /\s*,\s*/, $str));
-       # remove empty elements
-       @list = map { $_ ? ( $_ ) : () } @list;
-       return join(", ", @list );
-}
-
-sub rewrite_alternatives {
-       my $str = shift;
-
-       @list = map( rewrite_item($_), split( /\s*\|\s*/, $str ));
-       # if any of the alternatives became empty (because of @removedeps),
-       # the complete dependency should be removed
-       my @list = ();
-       for my $item (split( /\s*\|\s*/, $str )) {
-               $item = rewrite_item($item);
-               return () if not $item;
-               push @list, $item
-       }
-       return join( " | ", @list );
-}
-
-sub rewrite_item {
-       my $str = shift;
-
-       $str =~ /^([^ (]+)/;
-       return () if grep { $_ eq $1 } @removedeps;
-       return $str if grep { $_ eq $1 } @keepdeps;
-       $str =~ s/^([^ (]+)/$1-$arch-cross/;
-       return $str;
-}
-
diff --exclude=CVS -Nru dpkg-cross.cvs/dpkg-cross.pl 
dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-cross.pl
--- dpkg-cross.cvs/dpkg-cross.pl        2004-12-03 22:42:55.000000000 +0100
+++ dpkg-cross-1.20.4.checkbuilddeps.1/dpkg-cross.pl    2004-12-15 
12:09:44.756134430 +0100
@@ -19,6 +19,10 @@
 #
 #  $Id: dpkg-cross.pl,v 1.20 2004/12/03 21:42:55 yoush-guest Exp $
 
+# Use the libapt-pkg-perl module for simply and detailed retival of package
+# informations. This information is used for package name conversion.
+use AptPkg::Cache;
+
 # Determine if the system wide or user defined cross-compile configuration
 # have to be read.
 $conffile = "/etc/dpkg/cross-compile";
@@ -31,7 +35,8 @@
 # List of variables which can be overriden by the cross-compile
 # definitions.
 @intern_vars = qw( crossbase crossprefix crossdir crossbin crosslib crosslib64 
crossinc
-               crossinfo maintainer default_arch removedeps keepdeps 
compilerpath );
+               crossinfo maintainer default_arch removedeps keepdeps 
compilerpath
+               crossdeps checkbuilddeps );
 # Avoid warnings about unused @intern_vars variables.
 foreach my $var_ ( @intern_vars ) {
        eval( "\$$var_ = ''" );
@@ -162,6 +167,11 @@
        
        $current_mode_ ||= "default";
        
+       # The dpkg-checkbuilddeps feature is disabled by default. You have to
+       # enable it by setting the configuration variable ``checkbuilddeps''
+       # to 1.
+       $checkbuilddeps = 0;
+       
        open (F, "<$conffile") || return;
        while (<F>) {
                chomp;
@@ -232,10 +242,9 @@
 #     Returns the current architecture.
 # return: Current architecture or empty if not set.
 sub get_architecture {
-       return $ENV{'ARCH'} || $arch || $default_arch;
+       return $ENV{'DPKGCROSSARCH'} || $arch || $default_arch;
 }
 
-
 
################################################################################
 # setup():
 #     Set global variables ``$arch'', ``$arch_cpu'', ``$arch_os'',
@@ -298,6 +307,12 @@
                        subst (\$pkgvars{$scope_}{$var_}, $var_, @vars_);
                }
        }
+
+       # For easier use we convert ``removedeps'', ``keepdeps'' and 
``crossdeps''
+       # to an array of package names.
+       @removedeps = split (/[\s,]+/, $removedeps);
+       @keepdeps = split (/[\s,]+/, $keepdeps);
+       @crossdeps = split (/[\s,]+/, $crossdeps);
 }
 
 
################################################################################
@@ -456,6 +471,9 @@
        
        # Put ``$arch'' into environment through MAKEFLAGS.
        $makeflags_{'ARCH'} = $arch;
+       # Save ``$arch'' also as environment for dpkg-cross applications which
+       # are not called via Makefile (e.g. dpkg-checkbuilddeps).
+       $ENV{'DPKGCROSSARCH'} = $arch;
        
        # Also set new `dpkg-architecture' environment veriables.
        chomp ($tmp_ = `dpkg-architecture -a$arch -qDEB_HOST_ARCH 2>/dev/null`);
@@ -540,7 +558,7 @@
 # return: none
 sub dpkgcross_application {
        exec "$0.orig", @ARGV
-               unless (($arch = $ENV{'ARCH'}) && $ENV{'MAKEFLAGS'} =~ /\bCC=/) 
||
+               unless (($arch = $ENV{'DPKGCROSSARCH'}) && $ENV{'MAKEFLAGS'} =~ 
/\bCC=/) ||
                $arch =~ /^hurd-/;
 }
 
@@ -601,4 +619,99 @@
        return $path
 }
 
+################################################################################
+# rewrite_dependencies():
+#     Convert package names for a cross-compiler environment in the same
+#     manner as dpkg-cross does. This function support packages divided by a
+#     , (comma).
+#     By default only packages belongs to section libdevel or libs are
+#     converted. The package names will also be converted if section can
+#     not be determined.
+# $1: Packages to rewrite in sence of dpkg-cross naming.
+# return: Converted package names.
+sub rewrite_dependencies {
+       my $str_ = shift;
+
+       my @list_ = map( rewrite_alternatives($_), split( /\s*,\s*/, $str_));
+       # remove empty elements
+       @list = map { $_ ? ( $_ ) : () } @list_;
+       return join(", ", @list_);
+}
+
+################################################################################
+# rewrite_alternatives():
+#     Convert package names for a cross-compiler environment in the same
+#     manner as dpkg-cross does. This function support packages divided
+#     by a | (vertical bar).
+#     By default only packages belongs to section libdevel or libs are
+#     converted. The package names will also be converted if section can
+#     not be determined.
+# $1: Packages to rewrite in sence of dpkg-cross naming.
+# return: Converted package names.
+sub rewrite_alternatives {
+       my $str_ = shift;
+
+       my @list_ = map( rewrite_item($_), split( /\s*\|\s*/, $str_ ));
+       # if any of the alternatives became empty (because of @removedeps),
+       # the complete dependency should be removed
+       my @list_ = ();
+       for my $item_ (split( /\s*\|\s*/, $str_ )) {
+               $item_ = rewrite_item($item_);
+               return () if not $item_;
+               push @list_, $item_;
+       }
+       return join( " | ", @list_ );
+}
+
+################################################################################
+# rewrite_alternatives():
+#     Convert package names for a cross-compiler environment in the same
+#     manner as dpkg-cross does.
+#     By default only packages belongs to section libdevel or libs are
+#     converted. The package names will also be converted if section can
+#     not be determined.
+# $1: Packages to rewrite in sence of dpkg-cross naming.
+# return: Converted package names.
+sub rewrite_item {
+       my $str_ = shift;
+
+       $str_ =~ /^([^ (]+)/;
+       return () if grep { $_ eq $1 } @removedeps;
+       return $str_ if grep { $_ eq $1 } @keepdeps;
+
+       my $section_ = "";
+       if ($checkbuilddeps != 0 and not grep { $_ eq $1 } @crossdeps) {
+               $section_ = determine_package_section ($1);
+       }
+       # Maybe package not available for host architecture or package
+       # db is not uptodate. We assume old behaviour if $section_ is empty.
+       if ($section_ eq "" or $section_ eq "libdevel" or $section_ eq "libs") {
+               $str_ =~ s/^([^ (]+)/$1-$arch-cross/;
+       }
+       return $str_;
+}
+
+################################################################################
+# determine_package_section():
+#     Determine section of a package based on the dpkg databse.
+# $1: Package to determine the section for.
+# return: Section name for the package or an empty string if the package could
+#         not be found.
+sub determine_package_section {
+       my $pkg_ = shift;
+       if (not $aptpkg_cache) {
+               $aptpkg_cache = AptPkg::Cache->new;
+       }
+       my $data_ = $aptpkg_cache->{$pkg_};
+       my $section_;
+
+       if ($data_) {
+               $section_ = $data_->{"Section"};
+       }
+       else {
+               $section_ = "";
+       }
+       return $section_;
+}
+
 1;
diff --exclude=CVS -Nru dpkg-cross.cvs/Makefile 
dpkg-cross-1.20.4.checkbuilddeps.1/Makefile
--- dpkg-cross.cvs/Makefile     2004-10-29 22:41:55.000000000 +0200
+++ dpkg-cross-1.20.4.checkbuilddeps.1/Makefile 2004-12-12 17:39:17.000000000 
+0100
@@ -18,7 +18,7 @@
 #
 #  $Id: Makefile,v 1.11 2004/10/29 20:41:55 yoush-guest Exp $
 
-SCRIPTS = dpkg-cross dpkg-buildpackage dpkg-shlibdeps gccross
+SCRIPTS = dpkg-cross dpkg-buildpackage dpkg-shlibdeps gccross 
dpkg-checkbuilddeps
 SHARESCRIPTS = strip
 CONFFILES = $(shell ls -1 cross-config.*) crosstools
 MAN1 = dpkg-cross.1 gccross.1

Attachment: pgplVcDxkrvdK.pgp
Description: PGP signature

Reply via email to