Changeset 23


Ignore:
Timestamp:
12/01/05 17:58:24 (18 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r22 r23  
    3939my $cmdbuildroot;
    4040my $tarballdir; # This should really be initialized, but the coding makes it, um, ugly.
     41my %specglobals;        # For %define's in specfile, among other things.
    4142
    4243# Initialized globals
     
    9394# 10/31/2005 Maybe this should be flatter?  -kgd
    9495my %pkgdata;
     96# Files listing.  Embedding this in %pkgdata would be, um, messy.
     97my %filelist;
    9598
    9699# Scriptlets
    97100my $prepscript;
    98101my $buildscript;
    99 my $installscript;
     102# %install doesn't need the full treatment from %clean;  just an empty place to install to.
     103# NB - rpm doesn't do this;  is it really necessary?
     104my $installscript = '[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT'."\n";
    100105my $cleanscript;
    101106# pre/post (un)install scripts.  Note that these will likely barf as-is.  :/
     
    302307    if (/^\%/) {
    303308      # A macro that needs further processing.
     309
     310      if (/^\%define\s+([^\s]+)\s+([^\s]+)/) {
     311        $specglobals{$1} = expandmacros($2,'g');
     312      }
    304313
    305314      if (/^\%description/) {
     
    384393          $cleanscript .= $_;
    385394        }
     395print "before:\n$cleanscript\n";
    386396        $cleanscript = expandmacros($cleanscript,'gp');
     397print "\nafter:\n$cleanscript\n";
     398exit 0;
    387399      }
    388400    # pre/post (un)install scripts
     
    411423        }
    412424      }
    413       if (/^\%files/) {
     425      if (/^\%files(?:\s+(?:-n\s+)?([a-zA-z0-9]+))?/) {
     426        my $pkgname = 'main';
     427        if ($1) {
     428          if (/-n/) { $pkgname = $1; } else { $pkgname = "$name-$1"; }
     429          # subpackage not based on "main" package
     430          while (<SPECFILE>) {
     431            # need to update this to deal with %dir, %attr, etc
     432            redo LINE if /^\%/;
     433            $filelist{$pkgname} .= $_;
     434          }
     435        }
     436        # do we replace \n's with \s in $filelist{$pkgname}?
    414437        # Danger! Danger!
    415438      }
     
    482505  $prepscript = expandmacros($prepscript,'gp');
    483506
     507print $prepscript; exit 0;
     508
    484509  # create script filename
    485510  my $prepscriptfile = "$tmpdir/deb-tmp.prep.".int(rand(99998)+1);
     
    535560        or die $!;
    536561  print INSTSCRIPT $scriptletbase;
    537   print INSTSCRIPT $cleanscript;        # Clean up our install target before installing into it.
     562#  print INSTSCRIPT $cleanscript;       # Clean up our install target before installing into it.
    538563  print INSTSCRIPT $installscript;
    539564  close INSTSCRIPT;
     
    750775    $macrostring =~ s|%{_tmppath}|$tmpdir|g;
    751776    $macrostring =~ s'%{_docdir}'/usr/share/doc'g;
     777
     778    # %define's
     779    foreach my $key (keys %specglobals) {
     780      $macrostring =~ s|%{$key}|$specglobals{$key}|g;
     781    }
     782
     783    # system programs.  RPM uses a global config file for these;  we'll just
     784    # ASS-U-ME and make life a little simpler.
     785    if ($macrostring =~ /\%\{\_\_([a-z0-9_-]+)\}/) {
     786      $macrostring =~ s|%{__([a-z0-9_-]+)}|$1|g;
     787    }
    752788  } # done with globals section
    753789
Note: See TracChangeset for help on using the changeset viewer.