Changeset 87


Ignore:
Timestamp:
04/17/07 16:16:29 (17 years ago)
Author:
kdeugau
Message:

/trunk

Handle BuildArch (more or less), and allow debbuild to run "correctly"
without modification on any arch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r86 r87  
    7878                's' => 'Build source'
    7979        );
     80# Ah, the joys of multiple architectures.  :(  Feh.
     81# As copied from rpm
     82my %optflags = ( 'i386' =>      '-O2 -g -march=i386 -mcpu=i686',
     83                'amd64' =>      '-O2 -g'
     84        );
     85my $hostarch;   # we set this later...
    8086my $scriptletbase =
    8187q(#!/bin/sh
     
    8389  RPM_SOURCE_DIR="%{_topdir}/SOURCES"
    8490  RPM_BUILD_DIR="%{_topdir}/BUILD"
    85   RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686"
    86   RPM_ARCH="i386"
     91  RPM_OPT_FLAGS="%{optflags}"
     92  RPM_ARCH="%{_arch}"
    8793  RPM_OS="linux"
    8894  export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
     
    99105  s/=(.+)/="$1"/;
    100106  $scriptletbase .= "  $_";
     107  ($hostarch) = (/^DEB_HOST_ARCH="(.+)"$/) if /DEB_HOST_ARCH/;
    101108}
    102109$scriptletbase .=
     
    153160    $pkgdata{$pkg}{name} =~ tr/_/-/;
    154161
    155     my $pkgfullname = "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_i386.deb";
     162    my $pkgfullname = "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb";
    156163
    157164    print "$pkgfullname\n" if $filelist{$pkg};
     
    402409  open SPECFILE,"<$specfile" or die "specfile ($specfile) barfed: $!";
    403410
     411  my $buildarch = $hostarch;
     412
    404413LINE: while (<SPECFILE>) {
    405414    next if /^#/;       # Ignore comments...
     
    432441        $pkgdata{$subname}{name} = $subname;
    433442        $pkgdata{$subname}{version} = $pkgdata{main}{version};
     443  # Build "same arch as previous package found" by default.  Where rpm just picks the
     444  # *very* last one, we want to allow arch<native>+arch-all
     445  # (eg, Apache is i386, but apache-manual is all)
     446        $pkgdata{$subname}{arch} = $buildarch;  # Since it's likely subpackages will NOT have a BuildArch line...
    434447        while (<SPECFILE>) {
    435448          redo LINE if /^\%/;
    436           if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides):\s+(.+)$/i)) {
     449          if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides|BuildArch(?:itecture)?):\s+(.+)$/i)) {
    437450            $dname =~ tr/[A-Z]/[a-z]/;
     451            if ($dname =~ /^BuildArch/i) {
     452              $buildarch = $dvalue;     # Emulate rpm's behaviour to a degree
     453              $dname = 'arch';
     454            }
    438455            $pkgdata{$subname}{$dname} = expandmacros($dvalue, 'gp');
    439456          }
     
    673690        }
    674691        chomp $pkgdata{main}{$patchname};
     692      } elsif (/^buildarch(?:itecture)?:\s+(.+)/i) {
     693        $pkgdata{main}{arch} = $1;
     694        $buildarch = $pkgdata{main}{arch};
    675695      } elsif (/^buildreq(?:uires)?:\s+(.+)/i) {
    676696        $buildreq .= ", $1";
     
    789809# Should handle simple subpackages
    790810sub binpackage {
    791   # Make sure we have somewhere to write the .deb file
    792   if (!-e "$topdir/DEBS/i386") {
    793     mkdir "$topdir/DEBS/i386";
    794   }
    795811
    796812  foreach my $pkg (@pkglist) {
     813
     814    $pkgdata{$pkg}{arch} = $hostarch if !$pkgdata{$pkg}{arch};  # Just In Case.
     815    $pkgdata{$pkg}{arch} =~ s/^noarch/all/ig;
     816
     817    # Make sure we have somewhere to write the .deb file
     818    if (!-e "$topdir/DEBS/$pkgdata{$pkg}{arch}") {
     819      mkdir "$topdir/DEBS/$pkgdata{$pkg}{arch}";
     820    }
    797821
    798822    # Skip building a package if it doesn't actually have any files.  NB:  This
     
    871895        or die $!;
    872896    print DEBSCRIPT $scriptletbase;
    873     print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot/$pkg $topdir/DEBS/i386/".
    874         "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_i386.deb\n";
     897    print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot/$pkg $topdir/DEBS/$pkgdata{$pkg}{arch}/".
     898        "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb\n";
    875899      # %$&$%@#@@#%@@@ Debian and their horrible ugly package names.  >:(
    876900    close DEBSCRIPT;
     
    880904        "Section: $pkgdata{$pkg}{group}\n".
    881905        "Priority: optional\n".
    882         "Architecture: i386\n".
     906        "Architecture: $pkgdata{$pkg}{arch}\n".
    883907        "Maintainer: $pkgdata{main}{packager}\n".
    884908        ( $pkgdata{$pkg}{requires} ne '' ? "Depends: $pkgdata{$pkg}{requires}\n" : '' ).
     
    942966
    943967    $finalmessages .= "Wrote binary package ".
    944         "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_i386.deb".
    945         " in $topdir/DEBS/i386\n";
     968        "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb".
     969        " in $topdir/DEBS/$pkgdata{$pkg}{arch}\n";
    946970    # and clean up
    947971    unlink $debscriptfile;
     
    12961320      $macrostring =~ s|%{__([a-z0-9_-]+)}|$1|g;
    12971321    }
     1322
     1323    # Misc expansions
     1324    $macrostring =~ s|%{_arch}|$hostarch|g;
     1325    $macrostring =~ s|%{optflags}|$optflags{$hostarch}|g;
     1326
    12981327  } # done with globals section
    12991328
Note: See TracChangeset for help on using the changeset viewer.