Changeset 12 for trunk


Ignore:
Timestamp:
11/04/05 17:55:08 (19 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint
%prep, %build, and %install should all be (almost) complete
Still need handling for %{sourcenn} outside of %prep

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r11 r12  
    333333        redo LINE;
    334334      }
    335         if (/^\%build/) {
     335      if (/^\%build/) {
    336336        # %build.  This is pretty much just a shell script.  There
    337337        # *are* a few macros, but we're not going to deal with them yet.
     
    339339BUILDSCRIPT: while (<SPECFILE>) {
    340340          if (/^\%configure/) {
    341             my $tmp = expandmacros($_,'cg');
    342             $buildscript .= $tmp;
     341            $buildscript .= expandmacros($_,'cgbp');
     342          } elsif (/^\%\{(__)?make\}/) {
     343            $buildscript .= expandmacros($_,'mgbp');
    343344          } else {
    344         # Need to handle %make
    345345            last BUILDSCRIPT if /^\%/;
    346346            $buildscript .= $_;
     
    351351      if (/^\%install/) {
    352352        $installscript .= "cd $tarballdir\n";
    353         while (<SPECFILE>) {
    354         # Need to handle %makeinstall
    355           redo LINE if /^\%/;
    356           $installscript .= $_;
    357         }
     353INSTALLSCRIPT: while (<SPECFILE>) {
     354          if (/^\%makeinstall/) {
     355            $installscript .= expandmacros($_,'igbp');
     356print $installscript;
     357#print "\n$tmp\n"; die;
     358#            $installscript .= $tmp;
     359          } else {
     360            last INSTALLSCRIPT if /^\%/;
     361            $installscript .= $_;
     362          }
     363        }
     364        redo LINE;
    358365      }
    359366      if (/^\%clean/) {
     
    362369          $cleanscript .= $_;
    363370        }
     371        $cleanscript = expandmacros($cleanscript,'gp');
    364372      }
    365373      if (/^\%post/) {
     
    414422
    415423  # Expand macros as necessary.
    416   $scriptletbase = expandmacros($scriptletbase,'g');
     424  $scriptletbase = expandmacros($scriptletbase,'gp');
    417425
    418426  $buildroot = $cmdbuildroot if $cmdbuildroot;
    419   $buildroot = expandmacros($buildroot,'pg');
     427  $buildroot = expandmacros($buildroot,'gp');
    420428
    421429} # end parse_spec()
     
    428436sub prep {
    429437  # Replace some things here just to make sure.
    430   $prepscript =~ s/\%\{name\}/$pkgdata{main}{name}/g;
     438  $prepscript = expandmacros($prepscript,'gp');
    431439
    432440  # create script filename
     
    452460# to do as rpm does and actually create a little shell script.
    453461sub build {
     462  # Expand the macros
     463  $buildscript = expandmacros($buildscript,'cgbp');
     464
    454465  # create script filename
    455466  my $buildscriptfile = "/var/tmp/deb-tmp.build.".int(rand(99998)+1);
     
    457468        or die $!;
    458469  print BUILDSCRIPT $scriptletbase;
    459 
    460   $buildscript = expandmacros($buildscript,'cg');
    461470  print BUILDSCRIPT $buildscript;
    462471  close BUILDSCRIPT;
     
    477486# Creates and executes %install script(let)
    478487sub install {
     488  # Expand the macros
     489  $installscript = expandmacros($installscript,'igbp');
     490
    479491  # create script filename
    480492  my $installscriptfile = "/var/tmp/deb-tmp.inst.".int(rand(99998)+1);
     
    568580  my $section = shift;  # We'll want to split things up a bit eventually.
    569581
     582  # To allow the FHS-ish %configure, %make, and %makeinstall to work The Right Way.
     583  # (Without clobbering the global $buildroot.)
     584  my $prefix = '';
     585
     586# %configure, %make, and %makeinstall all share quite a pile.
     587# I call it the FHS block, so it gets pushed forward as %{fhs}.
    570588  if ($section =~ /c/) {
    571     # %configure-ish macros
    572     # Note that these are processed in reverse order to get the substitution order right
    573     # Foistly, %configure itself:
     589    # %configure macro
     590    $macrostring =~ s'%configure'./configure %{fhs}';
     591  } # done %configure
     592
     593  if ($section =~ /m/) {
     594    $macrostring =~ s'%make'make %{fhs}';
     595    $macrostring =~ s'%{__make}'make ';
     596  } # done %make
     597
     598  if ($section =~ /i/) {
     599    # This is where we need to mangle $prefix.
     600    $macrostring =~ s'%makeinstall'make %{fhs}
     601        install';
     602    $prefix = $buildroot;
     603  } # done %install and/or %makeinstall
     604
     605  # Build data
     606  # Note that these are processed in reverse order to get the substitution order right
     607  if ($section =~ /b/) {
    574608# Don't know what it's for, don't have a useful default replacement
    575609#       --program-prefix=%{_program_prefix} \
    576 # Coding Q:  Why does this not work if I move the subst string into its own isolated quotes?
    577     $macrostring =~ s'%configure'./configure --host=$DEB_HOST_GNU_TYPE \
     610    $macrostring =~ s'%{fhs}'--host=$DEB_HOST_GNU_TYPE \
    578611        --build=$DEB_BUILD_GNU_TYPE \
    579612        --prefix=%{_prefix} \
     
    592625
    593626    # Note that the above regex terminates with the extra space
    594     # "Just In Case" of user additions to the %configure line,
    595     # which will then get neatly tagged on the end where they
    596     # take precedence (supposedly) over the "default" ones.
    597 
    598     $macrostring =~ s'%{_mandir}'%{_prefix}/man'g;
    599     $macrostring =~ s'%{_infodir}'%{_prefix}/info'g;
    600     $macrostring =~ s'%{_oldincludedir}'/usr/include'g;
    601     $macrostring =~ s'%{_includedir}'%{_prefix}/include'g;
    602     $macrostring =~ s'%{_libdir}'%{_exec_prefix}/%{_lib}'g;
    603     $macrostring =~ s'%{_lib}'lib'g;
    604     $macrostring =~ s'%{_localstatedir}'%{_prefix}/var'g;
    605     $macrostring =~ s'%{_sharedstatedir}'%{_prefix}/com'g;
    606     $macrostring =~ s'%{_sysconfdir}'%{_prefix}/etc'g;
    607     $macrostring =~ s'%{_datadir}'%{_prefix}/share'g;
    608     $macrostring =~ s'%{_libexecdir}'%{_exec_prefix}/libexec'g;
    609     $macrostring =~ s'%{_sbindir}'%{_exec_prefix}/sbin'g;
    610     $macrostring =~ s'%{_bindir}'%{_exec_prefix}/bin'g;
    611     $macrostring =~ s'%{_exec_prefix}'%{_prefix}'g;
    612     $macrostring =~ s'%{_prefix}'/usr'g;
     627    # "Just In Case" of user additions, which will then get neatly
     628    # tagged on the end where they take precedence (supposedly)
     629    # over the "default" ones.
     630
     631    $macrostring =~ s|%{_mandir}|%{_datadir}/man|g;     #/usr/share/man
     632    $macrostring =~ s|%{_infodir}|%{_datadir}/info|g;   #/usr/share/info
     633    $macrostring =~ s|%{_oldincludedir}|$prefix/usr/include|g;  #/usr/include
     634    $macrostring =~ s|%{_includedir}|$prefix%{_prefix\}/include|g;      #/usr/include
     635    $macrostring =~ s|%{_libdir}|$prefix%{_exec_prefix}/%{_lib}|g;      #/usr/lib
     636    $macrostring =~ s|%{_lib}|lib|g;                                            #?
     637    $macrostring =~ s|%{_localstatedir}|$prefix/var|g;                  #/var
     638    $macrostring =~ s|%{_sharedstatedir}|$prefix%{_prefix}/com|g;       #/usr/com WTF?
     639    $macrostring =~ s|%{_sysconfdir}|$prefix/etc|g;                             #/etc
     640    $macrostring =~ s|%{_datadir}|$prefix%{_prefix}/share|g;            #/usr/share
     641    $macrostring =~ s|%{_libexecdir}|$prefix%{_exec_prefix}/libexec|g;  #/usr/libexec
     642    $macrostring =~ s|%{_sbindir}|$prefix%{_exec_prefix}/sbin|g;                #/usr/sbin
     643    $macrostring =~ s|%{_bindir}|$prefix%{_exec_prefix}/bin|g;          #/usr/bin
     644    $macrostring =~ s|%{_exec_prefix}|$prefix%{_prefix}|g;              #/usr
     645    $macrostring =~ s|%{_prefix}|/usr|g;                        #/usr
    613646  } # done with config section
    614647
    615   if ($section =~ /g/) {
    616     $macrostring =~ s/\%\{_topdir\}/$topdir/g;
    617 
    618     # "fake" globals (may be tweaked by package)
     648  # Package data
     649  if ($section =~ /p/) {
    619650    $macrostring =~ s/\%\{buildroot\}/$buildroot/g;
    620651
    621     # sub-package(compatible) stuff
    622     $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/g;
    623     $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/g;
    624     $macrostring =~ s/\%\{release\}/$pkgdata{main}{release}/g;
    625   } # done with globals section
    626 
    627   if ($section =~ /p/) {
    628652    $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/g;
    629653    $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/g;
     
    631655  }
    632656
     657  # Globals, and not-so-globals
     658  if ($section =~ /g/) {
     659    $macrostring =~ s/\%\{_topdir\}/$topdir/g;
     660    $macrostring =~ s'%{_tmppath}'/var/tmp'g;
     661    $macrostring =~ s'%{_docdir}'/usr/share/doc'g;
     662  } # done with globals section
     663
    633664  return $macrostring;
    634665} # end expandmacros()
Note: See TracChangeset for help on using the changeset viewer.