- Timestamp:
- 11/04/05 17:55:08 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r11 r12 333 333 redo LINE; 334 334 } 335 335 if (/^\%build/) { 336 336 # %build. This is pretty much just a shell script. There 337 337 # *are* a few macros, but we're not going to deal with them yet. … … 339 339 BUILDSCRIPT: while (<SPECFILE>) { 340 340 if (/^\%configure/) { 341 my $tmp = expandmacros($_,'cg'); 342 $buildscript .= $tmp; 341 $buildscript .= expandmacros($_,'cgbp'); 342 } elsif (/^\%\{(__)?make\}/) { 343 $buildscript .= expandmacros($_,'mgbp'); 343 344 } else { 344 # Need to handle %make345 345 last BUILDSCRIPT if /^\%/; 346 346 $buildscript .= $_; … … 351 351 if (/^\%install/) { 352 352 $installscript .= "cd $tarballdir\n"; 353 while (<SPECFILE>) { 354 # Need to handle %makeinstall 355 redo LINE if /^\%/; 356 $installscript .= $_; 357 } 353 INSTALLSCRIPT: while (<SPECFILE>) { 354 if (/^\%makeinstall/) { 355 $installscript .= expandmacros($_,'igbp'); 356 print $installscript; 357 #print "\n$tmp\n"; die; 358 # $installscript .= $tmp; 359 } else { 360 last INSTALLSCRIPT if /^\%/; 361 $installscript .= $_; 362 } 363 } 364 redo LINE; 358 365 } 359 366 if (/^\%clean/) { … … 362 369 $cleanscript .= $_; 363 370 } 371 $cleanscript = expandmacros($cleanscript,'gp'); 364 372 } 365 373 if (/^\%post/) { … … 414 422 415 423 # Expand macros as necessary. 416 $scriptletbase = expandmacros($scriptletbase,'g ');424 $scriptletbase = expandmacros($scriptletbase,'gp'); 417 425 418 426 $buildroot = $cmdbuildroot if $cmdbuildroot; 419 $buildroot = expandmacros($buildroot,' pg');427 $buildroot = expandmacros($buildroot,'gp'); 420 428 421 429 } # end parse_spec() … … 428 436 sub prep { 429 437 # Replace some things here just to make sure. 430 $prepscript = ~ s/\%\{name\}/$pkgdata{main}{name}/g;438 $prepscript = expandmacros($prepscript,'gp'); 431 439 432 440 # create script filename … … 452 460 # to do as rpm does and actually create a little shell script. 453 461 sub build { 462 # Expand the macros 463 $buildscript = expandmacros($buildscript,'cgbp'); 464 454 465 # create script filename 455 466 my $buildscriptfile = "/var/tmp/deb-tmp.build.".int(rand(99998)+1); … … 457 468 or die $!; 458 469 print BUILDSCRIPT $scriptletbase; 459 460 $buildscript = expandmacros($buildscript,'cg');461 470 print BUILDSCRIPT $buildscript; 462 471 close BUILDSCRIPT; … … 477 486 # Creates and executes %install script(let) 478 487 sub install { 488 # Expand the macros 489 $installscript = expandmacros($installscript,'igbp'); 490 479 491 # create script filename 480 492 my $installscriptfile = "/var/tmp/deb-tmp.inst.".int(rand(99998)+1); … … 568 580 my $section = shift; # We'll want to split things up a bit eventually. 569 581 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}. 570 588 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/) { 574 608 # Don't know what it's for, don't have a useful default replacement 575 609 # --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 \ 578 611 --build=$DEB_BUILD_GNU_TYPE \ 579 612 --prefix=%{_prefix} \ … … 592 625 593 626 # 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 they596 # 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 613 646 } # done with config section 614 647 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/) { 619 650 $macrostring =~ s/\%\{buildroot\}/$buildroot/g; 620 651 621 # sub-package(compatible) stuff622 $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 section626 627 if ($section =~ /p/) {628 652 $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/g; 629 653 $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/g; … … 631 655 } 632 656 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 633 664 return $macrostring; 634 665 } # end expandmacros()
Note:
See TracChangeset
for help on using the changeset viewer.