Changeset 121 for trunk


Ignore:
Timestamp:
08/01/07 15:10:37 (17 years ago)
Author:
kdeugau
Message:

/trunk

Massive cleanup of %files handling. Still not "complete", but much better.
%attr + %config + %doc (in all possible combinations) should be handled
about as close as I can get to rpmbuild's behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r120 r121  
    738738
    739739    if ($stage eq 'files') {
    740       # need to update this to deal (properly) with %dir, %attr, etc
     740      # need to deal with these someday
    741741      next LINE if /^\%dir/;
    742742      next LINE if /^\%defattr/;
     743      next LINE if /^\%verify/;
     744      # dunno what to do with this; not sure if there's space in Debian's package structure for it.
     745      next LINE if /^\%ghost/;
    743746      # Debian dpkg doesn't speak "%docdir".  Meh.
    744747      next LINE if /^\%docdir/;
    745       # dunno what to do with this; not sure if there's space in Debian's package structure for it.
    746       next LINE if /^\%ghost/;
     748#      my $singleton = 0;       # don't recall what this was for
     749
     750# create and initialize flags
     751      my ($perms, $owner, $group, $conf, $filesline);
     752      $perms = $owner = $group = $conf = '-';
     753
     754      $filesline = $_;
     755
     756      # strip and flag %attr constructs
     757      if ($filesline =~ /\%attr\b/) {
     758        # Extract %attr...
     759        my ($args) = (/(\%attr\s*\(\s*[\d-]+\s*,\s*["a-zA-Z0-9-]+\s*,\s*["a-zA-Z0-9-]+\s*\))/);
     760        $args =~ s/\s+//g;
     761        $args =~ s/"//g;    # don't think quotes are ever necessary, but they're *allowed*
     762        # ... and parse it ...
     763        ($perms,$owner,$group) = ($args =~ /\(([\d-]+),([a-zA-Z0-9-]+),([a-zA-Z0-9-]+)/);
     764        # ... and wipe it when we're done.
     765        $filesline =~ s/\%attr\s*\(\s*[\d-]+\s*,\s*["a-zA-Z0-9-]+\s*,\s*["a-zA-Z0-9-]+\s*\)//;
     766      }
     767
     768      # Conffiles.  Note that Debian and RH have similar, but not
     769      # *quite* identical ideas of what constitutes a conffile.  Nrgh.
     770      # Note that dpkg will always ask if you want to replace the file - noreplace
     771      # is more or less permanently enabled.
    747772##fixme
    748 # Note that big chunks of this section don't match rpm's behaviour;  among other things,
    749 # rpm accepts more than one %-directive on one line for a file or set of files.
    750       # make sure files get suitable permissions and so on
    751       if (/^\%attr/) {
    752         # We're going to collapse whitespace before processing.  PTHBT.
    753         # While this breaks pathnames with spaces, anyone expecting command-line
    754         # tools with spaces to work (never mind work *properly* or *well*) under
    755         # any *nix has their head so far up their ass they can see out their mouth.
    756         my ($args,$filelist) = split /\)/;
    757         $filelist{$subname} .= " $filelist";
    758         $args =~ s/\s+//g;
    759         $args =~ s/"//g;    # don't think quotes are ever necessary, but they're *allowed*
    760         my ($perms,$owner,$group) = ($args =~ /\(([\d-]+),([a-zA-Z0-9-]+),([a-zA-Z0-9-]+)/);
    761 # due to Debian's total lack of real permissions-processing in its actual package
    762 # handling component (dpkg-deb), this can't really be done "properly".  We'll have
    763 # to add chown/chmod commands to the postinst instead.  Feh.
    764         $pkgdata{$subname}{'post'} .= "chown $owner $filelist\n" if $owner ne '-';
    765         $pkgdata{$subname}{'post'} .= "chgrp $group $filelist\n" if $group ne '-';
    766         $pkgdata{$subname}{'post'} .= "chmod $perms $filelist\n" if $perms ne '-';
    767         next LINE;
    768       }
     773# also need to handle missingok (file that doesn't exist, but should be removed on uninstall)
     774# hmm.  not sure if such is **POSSIBLE** with Debian...  maybe an addition to %post?
     775      if ($filesline =~ /\%config\b(?:\s*\(\s*noreplace\s*\)\s*)?/) {
     776        $pkgdata{$subname}{conffiles} = 1;  # Flag it for later
     777        $conf = 'y';
     778        $filesline =~ s/\%config\b(?:\s*\(\s*noreplace\s*\)\s*)?//;
     779      }
     780
    769781      # %doc needs extra processing, because it can be a space-separated list, and may
    770782      # include both full and partial pathnames.  The partial pathnames must be fiddled
     
    772784      # of "documentation file" that rpm does.  (Debian "documentation files" are files
    773785      # in /usr/share/doc/<packagename>.)
    774       if (/^\%doc/) {
    775         s/^\%doc\s+//;
    776         foreach (split()) {
    777           if (m|^/|) {
    778             $filelist{$subname} .= " $_";       # and we process this in the processing of the install script
    779           } else {
    780             my $pkgname = $pkgdata{$subname}{name};
    781             $pkgname =~ tr/_/-/;
    782 
     786##fixme:  unhandled case: %doc %defattr.  Eeep.
     787# don't really know what to do with %defattr, generally.  :(
     788      if ($filesline =~ /\%doc\b/) {
     789        $filesline =~ s/\s*\%doc\s+//;
     790
     791# this could probably go elsewhere.
     792        my $pkgname = $pkgdata{$subname}{name};
     793        $pkgname =~ tr/_/-/;
     794
     795        # have to extract the partial pathnames that %doc installs automagically
     796        foreach (split /\s+/, $filesline) {
     797          if (! (/^\%/ or m|^/|) ) {
    783798            $doclist{$subname} .= " $_";
    784             s|^[^/]+/||g;       # Gotta strip leading blah/ bits.  Won't handle * (well) yet...  (glob()?)
    785             $filelist{$subname} .= " \%{_docdir}/$pkgname/$_";
     799            my ($element) = m|([^/\s]+/?)$|;
     800            $filesline =~ s|$_|\%{_docdir}/$pkgname/$element|;
    786801          }
    787         }
    788         next LINE;
    789       }
    790       # Conffiles.  Note that Debian and RH have similar, but not
    791       # *quite* identical ideas of what constitutes a conffile.  Nrgh.
    792       # Note that dpkg will always ask if you want to replace the file - noreplace
    793       # is more or less permanently enabled.
     802        }
     803      } # $filesline =~ /\%doc\b/
     804
     805      $filesline =~ s/^\s*//;   # Just In Case.  For, uh, neatness.
     806
     807# due to Debian's total lack of real permissions-processing in its actual package
     808# handling component (dpkg-deb), this can't really be done "properly".  We'll have
     809# to add chown/chmod commands to the postinst instead.  Feh.
     810      $pkgdata{$subname}{'post'} .= "chown $owner $filesline\n" if $owner ne '-';
     811      $pkgdata{$subname}{'post'} .= "chgrp $group $filesline\n" if $group ne '-';
     812      $pkgdata{$subname}{'post'} .= "chmod $perms $filesline\n" if $perms ne '-';
     813
    794814##fixme
    795 # also need to handle missingok (file that should be removed on uninstall)
    796       if (/^\%config(?:\(noreplace\))?\s+(.+)$/) {
    797         $pkgdata{$subname}{conffiles} = 1;  # Flag it for later
    798         my $tmp = $1;       # Now we can mangleificationate it.  And we probably need to.  :/
    799         $tmp = expandmacros($tmp, 'gp');  # Expand common macros
    800         if ($tmp !~ /\s+/) {
    801           # Simplest case, just a file.  Whew.
    802           push @{$pkgdata{$subname}{conflist}}, $tmp;
    803           $filelist{$subname} .= " $tmp";
    804         } else {
    805           # Wot?  Spaces?  That means extra %-macros.  Which, for the most part, can be ignored.
    806           ($tmp) = ($tmp =~ /.+\s([^\s]+)/);  # Strip everything before the last space
    807           push @{$pkgdata{$subname}{conflist}}, $tmp;
    808           $filelist{$subname} .= " $tmp";
    809         }
    810         next LINE;
    811       }
     815# need hackery to assure only one filespec per %config.  NB:  "*" is one filespec.  <g>
     816      push @{$pkgdata{$subname}{conflist}}, $filesline if $conf ne '-';
     817
     818      # now that we've got the specials out of the way, we can add things to the appropriate list of files.
    812819      # ... and finally everything else
    813       $filelist{$subname} .= " $_";
     820      $filelist{$subname} .= " $filesline";
     821
    814822      next LINE;
    815823    } # files
Note: See TracChangeset for help on using the changeset viewer.