Changeset 96


Ignore:
Timestamp:
05/03/07 15:45:34 (17 years ago)
Author:
kdeugau
Message:

/trunk

Bugfixery and add a "fixme" note re: %if constructs outside of preamble

  • Cosmetic cleanup: swap (undef,undef...) = (function) for $var=(function)[n]
  • Expand macro defs from ~/.debmacros
  • Move expansion of %(...) constructs lower in expandmacros so that %{macro} expansions get done before the shell call
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r95 r96  
    266266# Needs to handle "other files"
    267267sub load_userconfig {
    268   my (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<);
     268  my $homedir = (getpwuid($<))[7];
    269269  if (-e "$homedir/.debmacros") {
    270270    open USERMACROS,"<$homedir/.debmacros";
     
    274274        my (undef,$tmp) = split /\s+/, $_;
    275275        $topdir = $tmp;
     276      }
     277      next if /^\%_/;
     278      # Allow arbitrary definitions.  Note that we're only doing simple defs here for now.
     279      if (/^\%([a-z0-9]+)\s+(.+)$/) {
     280        $specglobals{$1} = $2;
    276281      }
    277282    }
     
    497502      }
    498503
     504##fixme:  need to allow %if contructs to work in subsections like %prep
    499505      if (/^\%prep/) {
    500506        # %prep section.  May have %setup macro;  may include %patch tags,
     
    13181324  if ($section =~ /g/) {
    13191325
    1320     # special %define's.  Handle the general case where we eval anything.
    1321     # Even more general:  %(...) is a spec-parse-time shell code wrapper.
    1322     # Prime example:
    1323     #%define perl_vendorlib %(eval "`perl -V:installvendorlib`"; echo $installvendorlib)
    1324     if ($macrostring =~ /^\%\(.+\)$/) {
    1325       $macrostring =~ s/^\%\(//;
    1326       $macrostring =~ s/\)$//;
    1327       # Oy vey this gets silly for the perl bits.  Executing a shell to
    1328       # call Perl to get the vendorlib/sitelib/whatever "core" globals.
    1329       # This can do more, but...  eww.
    1330       # Next line is non-optimal - what if $macrostring contains ' characters?
    1331       $macrostring = qx { /bin/sh -c '$macrostring' };
    1332     }
    1333 
    13341326    $macrostring =~ s|%{_builddir}|%{_topdir}/BUILD|g;
    13351327    $macrostring =~ s|%{_topdir}|$topdir|g;
     
    13521344    foreach my $key (keys %specglobals) {
    13531345      $macrostring =~ s|%{$key}|$specglobals{$key}|g;
     1346    }
     1347
     1348    # special %define's.  Handle the general case where we eval anything.
     1349    # Even more general:  %(...) is a spec-parse-time shell code wrapper.
     1350    # Prime example:
     1351    #%define perl_vendorlib %(eval "`perl -V:installvendorlib`"; echo $installvendorlib)
     1352    if ($macrostring =~ /\%\((.+)\)/) {
     1353      my $shellstr = $1;
     1354      # Oy vey this gets silly for the perl bits.  Executing a shell to
     1355      # call Perl to get the vendorlib/sitelib/whatever "core" globals.
     1356      # This can do more, but...  eww.
     1357      $shellstr = qx { /bin/sh -c '$shellstr' };        # Yay!  ' characters apparently get properly exscapededed.
     1358      $macrostring =~ s/\%\(.+\)/$shellstr/;
    13541359    }
    13551360
Note: See TracChangeset for help on using the changeset viewer.