- Timestamp:
- 06/08/07 16:57:49 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r102 r103 456 456 $pkgdata{main}{arch} = $hostarch; 457 457 458 my $stage = 'preamble'; 459 my $subname = 'main'; 460 my $scriptlet; 461 462 # Basic algorithm: 463 # For each line 464 # if it's a member of an %if construct, branch and see which segment of the 465 # spec file we need to parse and which one gets discarded, then 466 # short-circuit back to the top of the loop. 467 # if it's a %section, bump the stage. Preparse addons to the %section line 468 # (eg subpackage) and stuff them in suitable loop-global variables, then 469 # short-circuit back to the top of the loop. 470 # Otherwise, parse the line according to which section we're supposedly 471 # parsing right now 472 458 473 LINE: while (<SPECFILE>) { 459 next if /^#/; # Ignore comments... 460 next if /^\s*$/; # ... and blank lines. 461 462 if (/^\%/) { 463 # A macro that needs further processing. 464 465 if (my ($key, $def) = (/^\%define\s+([^\s]+)\s+(.+)$/) ) { 466 $specglobals{$key} = expandmacros($def,'g'); 467 } 468 469 if (/^\%if/) { 470 s/^\%if//; 471 chomp; 472 my $expr = expandmacros($_, 'g'); 473 $iflevel++; 474 475 if ($expr !~ /^\s*\d+\s*$/) { 476 # gots a logic statement we want to turn into a 1 or a 0. most likely by eval'ing it. 477 478 $expr =~ s/\s+//g; 479 $expr =~ s/^(\w+)/"$1"/ if $expr !~ /^['"]\w['"]/; 480 $expr =~ s/(\w+)$/"$1"/ if $expr !~ /['"]\w['"]$/; 481 482 # Done in this order so we don't cascade incorrectly. Yes, those spaces ARE correct in the replacements! 483 $expr =~ s/==/ eq /; 484 $expr =~ s/!=/ ne /; 485 $expr =~ s/<=>/ cmp /; 486 $expr =~ s/<=/ le /; 487 $expr =~ s/>=/ ge /; 488 $expr =~ s/</ lt /; 489 $expr =~ s/>/ gt /; 490 491 # Turn it into something that eval's to a number. Maybe not needed? O_o 492 #$expr = "( $expr ? 1 : 0 )"; 493 494 $expr = eval $expr; 495 } 496 497 next LINE if $expr != 0; # This appears to be the only case we call false. 498 while (<SPECFILE>) { 499 if (/^\%endif/) { 500 $iflevel--; 501 next LINE; 502 } elsif (/^\%else/) { 503 next LINE; 504 } 505 } 506 } 507 if (/^\%else/) { 508 while (<SPECFILE>) { 509 if (/^\%endif/) { 510 $iflevel--; 511 next LINE; 512 } 513 } 514 } 515 if (/^\%endif/) { 516 $iflevel--; 517 next LINE; 518 } 519 520 if (/^\%description(?:\s+(?:-n\s+)?(.+))?/) { 521 my $subname = "main"; 522 if ($1) { 523 my $tmp = expandmacros("$1", 'g'); 524 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; } 525 } 526 while (<SPECFILE>) { 527 next if /^#/; # Messy. Should be possible to do better. :/ 528 redo LINE if /^\%[a-z]/; 529 $pkgdata{$subname}{desc} .= " $_"; 474 next if /^#/; # Ignore comments... 475 next if /^\s*$/; # ... and blank lines. 476 477 # preprocess %define's 478 if (my ($key, $def) = (/^\%define\s+([^\s]+)\s+(.+)$/) ) { 479 $specglobals{$key} = expandmacros($def,'g'); 480 } 481 482 if (/^\%if/) { 483 s/^\%if//; 484 chomp; 485 my $expr = expandmacros($_, 'g'); 486 $iflevel++; 487 488 if ($expr !~ /^\s*\d+\s*$/) { 489 # gots a logic statement we want to turn into a 1 or a 0. most likely by eval'ing it. 490 491 $expr =~ s/\s+//g; 492 $expr =~ s/^(\w+)/"$1"/ if $expr !~ /^['"]\w['"]/; 493 $expr =~ s/(\w+)$/"$1"/ if $expr !~ /['"]\w['"]$/; 494 495 # Done in this order so we don't cascade incorrectly. Yes, those spaces ARE correct in the replacements! 496 $expr =~ s/==/ eq /; 497 $expr =~ s/!=/ ne /; 498 $expr =~ s/<=>/ cmp /; 499 $expr =~ s/<=/ le /; 500 $expr =~ s/>=/ ge /; 501 $expr =~ s/</ lt /; 502 $expr =~ s/>/ gt /; 503 504 # Turn it into something that eval's to a number. Maybe not needed? O_o 505 #$expr = "( $expr ? 1 : 0 )"; 506 507 $expr = eval $expr; 508 } 509 510 next LINE if $expr != 0; # This appears to be the only case we call false. 511 while (<SPECFILE>) { 512 if (/^\%endif/) { 513 $iflevel--; 514 next LINE; 515 } elsif (/^\%else/) { 516 next LINE; 530 517 } 531 518 } 532 if (/^\%package\s+(?:-n\s+)?(.+)/) { 533 # gotta expand %defines here. Whee. 534 my $subname = expandmacros("$1", 'g'); 535 if (! /-n/) { $subname = "$pkgdata{main}{name}-$1"; } 536 push @pkglist, $subname; 537 $pkgdata{$subname}{name} = $subname; 538 $pkgdata{$subname}{version} = $pkgdata{main}{version}; 519 } 520 if (/^\%else/) { 521 while (<SPECFILE>) { 522 if (/^\%endif/) { 523 $iflevel--; 524 next LINE; 525 } 526 } 527 } 528 if (/^\%endif/) { 529 $iflevel--; 530 next LINE; 531 } # %if/%else/%endif 532 533 # description. not going to parse for %ifs in it. 534 if (/^\%description(?:\s+(?:-n\s+)?(.+))?/) { 535 $subname = "main"; 536 if ($1) { # Magic to add entries to the right package 537 my $tmp = expandmacros("$1", 'g'); 538 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; } 539 } 540 while (<SPECFILE>) { 541 next if /^#/; # Messy. Should be possible to do better. :/ 542 redo LINE if /^\%[a-z]/; 543 $pkgdata{$subname}{desc} .= " $_"; 544 } 545 } # %description 546 547 # now we pick out the sections and set "state" to parse that section. Fugly but I can't see a better way. >:( 548 549 if (/^\%package\s+(?:-n\s+)?(.+)/) { 550 $stage = 'package'; 551 if ($1) { # Magic to add entries to the right package 552 my $tmp = expandmacros("$1", 'g'); 553 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; } 554 } 555 push @pkglist, $subname; 556 $pkgdata{$subname}{name} = $subname; 557 $pkgdata{$subname}{version} = $pkgdata{main}{version}; 539 558 # Build "same arch as previous package found" by default. Where rpm just picks the 540 559 # *very* last one, we want to allow arch<native>+arch-all 541 560 # (eg, Apache is i386, but apache-manual is all) 542 $pkgdata{$subname}{arch} = $buildarch; # Since it's likely subpackages will NOT have a BuildArch line... 543 while (<SPECFILE>) { 544 redo LINE if /^\%[a-z]/; 545 if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides|BuildArch(?:itecture)?):\s+(.+)$/i)) { 546 $dname =~ tr/[A-Z]/[a-z]/; 547 if ($dname =~ /^BuildArch/i) { 548 $dvalue =~ s/^noarch/all/ig; 549 $buildarch = $dvalue; # Emulate rpm's behaviour to a degree 550 $dname = 'arch'; 551 } 552 $pkgdata{$subname}{$dname} = expandmacros($dvalue, 'gp'); 553 } 554 } 555 } 556 557 ##fixme: need to allow %if contructs to work in subsections like %prep 558 if (/^\%prep/) { 559 # %prep section. May have %setup macro; may include %patch tags, 560 # may be just a bare shell script. 561 562 # This really should be local-ish, but we need just the filename for the source 563 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|; 564 565 # Replace some core macros 566 $pkgdata{main}{source} = expandmacros($pkgdata{main}{source},'gp'); 567 568 PREPSCRIPT: while (<SPECFILE>) { 569 if (/^\%setup/) { 570 # Parse out the %setup macro. Note that we aren't supporting 571 # many of RPM's %setup features. 572 $prepscript .= "cd $topdir/BUILD\n"; 573 if ( /\s+-n\s+([^\s]+)\s+/ ) { 574 $tarballdir = $1; 575 } 576 $tarballdir = expandmacros($tarballdir,'gp'); 577 $prepscript .= "rm -rf $tarballdir\n"; 578 if (/\s+-c\s+/) { 579 $prepscript .= "mkdir $tarballdir\ncd $tarballdir\n"; 580 } 581 $prepscript .= "tar -". 561 $pkgdata{$subname}{arch} = $buildarch; # Since it's likely subpackages will NOT have a BuildArch line... 562 next LINE; 563 } # %package 564 565 if (/^\%prep/) { 566 $stage = 'prep'; 567 # This really should be local-ish, but we need just the filename for the source 568 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|; 569 # Replace some core macros 570 $pkgdata{main}{source} = expandmacros($pkgdata{main}{source},'gp'); 571 next LINE; 572 } # %prep 573 574 if (/^\%build/) { 575 $stage = 'build'; 576 $buildscript .= "cd $tarballdir\n"; 577 next LINE; 578 } # %build 579 580 if (/^\%install/) { 581 $stage = 'install'; 582 $installscript .= "cd $tarballdir\n"; 583 next LINE; 584 } # %install 585 586 if (/^\%clean/) { 587 $stage = 'clean'; 588 $cleanscript .= "cd $tarballdir\n"; 589 next LINE; 590 } # %clean 591 592 if (/^\%(pre|post|preun|postun)\b(?:\s+(?:-n\s+)?(.+))?/i) { 593 $stage = 'prepost'; 594 $scriptlet = lc $1; 595 $subname = 'main'; 596 if ($2) { # Magic to add entries to the right package 597 my $tmp = expandmacros("$2", 'g'); 598 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; } 599 } 600 next LINE; 601 } # %pre/%post/%preun/%postun 602 603 if (/^\%files(?:\s+(?:-n\s+)?(.+))?/) { 604 $stage = 'files'; 605 $subname = 'main'; 606 if ($1) { # Magic to add entries to the right list of files 607 my $tmp = expandmacros("$1", 'g'); 608 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; } 609 } 610 next LINE; 611 } # %files 612 613 if (/^\%changelog/) { 614 $stage = 'changelog'; 615 $pkgdata{main}{changelog} = ''; 616 next LINE; 617 } 618 619 # now we handle individual lines from the various sections 620 621 if ($stage eq 'package') { 622 # gotta expand %defines here. Whee. 623 if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides|BuildArch(?:itecture)?):\s+(.+)$/i)) { 624 $dname =~ tr/[A-Z]/[a-z]/; 625 if ($dname =~ /^BuildArch/i) { 626 $dvalue =~ s/^noarch/all/ig; 627 $buildarch = $dvalue; # Emulate rpm's behaviour to a degree 628 $dname = 'arch'; 629 } 630 $pkgdata{$subname}{$dname} = expandmacros($dvalue, 'gp'); 631 } 632 } # package 633 634 if ($stage eq 'prep') { 635 # Actual handling for %prep section. May have %setup macro; may 636 # include %patch tags, may be just a bare shell script. 637 if (/^\%setup/) { 638 # Parse out the %setup macro. Note that we aren't supporting 639 # many of RPM's %setup features. 640 $prepscript .= "cd $topdir/BUILD\n"; 641 if ( /\s+-n\s+([^\s]+)\s+/ ) { 642 $tarballdir = $1; 643 } 644 $tarballdir = expandmacros($tarballdir,'gp'); 645 $prepscript .= "rm -rf $tarballdir\n"; 646 if (/\s+-c\s+/) { 647 $prepscript .= "mkdir $tarballdir\ncd $tarballdir\n"; 648 } 649 $prepscript .= "tar -". 582 650 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "z" : "" ). 583 651 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "j" : "" ). … … 589 657 qq([ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .\n). 590 658 qq(/bin/chmod -Rf a+rX,g-w,o-w .\n); 591 592 593 659 } elsif ( my ($patchnum,$patchopts) = (/^\%patch([^\s]+)(\s+.+)?$/) ) { 660 chomp $patchnum; 661 $prepscript .= qq(echo "Patch #$patchnum ($pkgdata{main}{"patch$patchnum"}):"\n). 594 662 "patch "; 595 # If there are options passed, use'em. 596 # Otherwise, catch a bare %patch and ASS-U-ME it's '-p0'-able. 597 # Will break on options that don't provide -pnn, but what the hell. 598 $prepscript .= $patchopts if $patchopts; 599 $prepscript .= "-p0" if !$patchopts; 600 $prepscript .= " -s <$topdir/SOURCES/".$pkgdata{main}{"patch$patchnum"}."\n"; 601 } else { 602 last PREPSCRIPT if /^\%/; 603 $prepscript .= $_; 604 } 605 } 606 redo LINE; 607 } 608 if (/^\%build/) { 609 # %build. This is pretty much just a shell script. There 610 # *are* a few macros, but we're not going to deal with them yet. 611 $buildscript .= "cd $tarballdir\n"; 612 BUILDSCRIPT: while (<SPECFILE>) { 613 if (/^\%configure/) { 614 $buildscript .= expandmacros($_,'cgbp'); 615 } elsif (/^\%\{__make\}/) { 616 $buildscript .= expandmacros($_,'mgbp'); 617 } else { 618 last BUILDSCRIPT if /^\%[^{]/; 619 $buildscript .= $_; 620 } 621 } 622 redo LINE; 623 } 624 if (/^\%install/) { 625 $installscript .= "cd $tarballdir\n"; 626 INSTALLSCRIPT: while (<SPECFILE>) { 627 if (/^\%makeinstall/) { 628 $installscript .= expandmacros($_,'igbp'); 629 } else { 630 last INSTALLSCRIPT if /^\%/; 631 $installscript .= $_; 632 } 633 } 634 redo LINE; 635 } 636 if (/^\%clean/) { 637 while (<SPECFILE>) { 638 redo LINE if /^\%[a-z]/; 639 $cleanscript .= $_; 640 } 641 $cleanscript = expandmacros($cleanscript,'gp'); 642 } 643 644 # pre/post (un)install scripts. Note that we expand macros later anyway, so we'll leave them unexpanded here. 645 if (/^\%(pre|post|preun|postun)\b(?:\s+(?:-n\s+)?(.+))?/i) { 646 my $scriptlet = lc $1; 647 my $pkgname = 'main'; 648 if ($2) { # Magic to add entries to the right list of files 649 my $tmp = expandmacros("$2", 'g'); 650 if (/-n/) { $pkgname = $tmp; } else { $pkgname = "$pkgdata{main}{name}-$tmp"; } 651 } 652 while (<SPECFILE>) { 653 redo LINE if /^\%[a-z]/; 654 $pkgdata{$pkgname}{$scriptlet} .= $_; 655 } 656 } 657 # done %pre/%post scripts 658 659 if (/^\%files(?:\s+(?:-n\s+)?(.+))?/) { 660 my $pkgname = 'main'; 661 if ($1) { # Magic to add entries to the right list of files 662 my $tmp = expandmacros("$1", 'g'); 663 if (/-n/) { $pkgname = $tmp; } else { $pkgname = "$pkgdata{main}{name}-$tmp"; } 664 } 665 666 # Set this now, so it can be flipped a bit later, and used much later. 667 #$pkgdata{$pkgname}{conffiles} = 0; 668 669 while (<SPECFILE>) { 670 chomp; 671 next if /^#/; 672 # need to update this to deal (properly) with %dir, %attr, etc 673 next if /^\%dir/; 674 next if /^\%defattr/; 675 676 # Debian dpkg doesn't speak "%docdir". Meh. 677 next if /^\%docdir/; 678 663 # If there are options passed, use'em. 664 # Otherwise, catch a bare %patch and ASS-U-ME it's '-p0'-able. 665 # Will break on options that don't provide -pnn, but what the hell. 666 $prepscript .= $patchopts if $patchopts; 667 $prepscript .= "-p0" if !$patchopts; 668 $prepscript .= " -s <$topdir/SOURCES/".$pkgdata{main}{"patch$patchnum"}."\n"; 669 } else { 670 $prepscript .= $_; 671 } 672 next LINE; 673 } # prep 674 675 if ($stage eq 'build') { 676 # %build. This is pretty much just a shell script. There 677 # aren't many local macros to deal with. 678 if (/^\%configure/) { 679 $buildscript .= expandmacros($_,'cgbp'); 680 } elsif (/^\%\{__make\}/) { 681 $buildscript .= expandmacros($_,'mgbp'); 682 } else { 683 $buildscript .= $_; 684 } 685 next LINE; 686 } # build 687 688 if ($stage eq 'install') { 689 if (/^\%makeinstall/) { 690 $installscript .= expandmacros($_,'igbp'); 691 } else { 692 $installscript .= $_; 693 } 694 next LINE; 695 } # install 696 697 if ($stage eq 'clean') { 698 $cleanscript .= $_; 699 next LINE; 700 } # clean 701 702 if ($stage eq 'prepost') { 703 $pkgdata{$subname}{$scriptlet} .= $_; 704 next LINE; 705 } # prepost 706 707 if ($stage eq 'files') { 708 # need to update this to deal (properly) with %dir, %attr, etc 709 next LINE if /^\%dir/; 710 next LINE if /^\%defattr/; 711 # Debian dpkg doesn't speak "%docdir". Meh. 712 next LINE if /^\%docdir/; 679 713 ##fixme 680 714 # Note that big chunks of this section don't match rpm's behaviour; among other things, 681 715 # rpm accepts more than one %-directive on one line for a file or set of files. 682 683 684 685 686 687 688 689 $filelist{$pkgname} .= " $filelist";690 691 $args =~ s/"//g;# don't think quotes are ever necessary, but they're *allowed*692 716 # make sure files get suitable permissions and so on 717 if (/^\%attr/) { 718 # We're going to collapse whitespace before processing. PTHBT. 719 # While this breaks pathnames with spaces, anyone expecting command-line 720 # tools with spaces to work (never mind work *properly* or *well*) under 721 # any *nix has their head so far up their ass they can see out their mouth. 722 my ($args,$filelist) = split /\)/; 723 $filelist{$subname} .= " $filelist"; 724 $args =~ s/\s+//g; 725 $args =~ s/"//g; # don't think quotes are ever necessary, but they're *allowed* 726 my ($perms,$owner,$group) = ($args =~ /\(([\d-]+),([a-zA-Z0-9-]+),([a-zA-Z0-9-]+)/); 693 727 # due to Debian's total lack of real permissions-processing in its actual package 694 728 # handling component (dpkg-deb), this can't really be done "properly". We'll have 695 729 # to add chown/chmod commands to the postinst instead. Feh. 696 $pkgdata{$pkgname}{'post'} .= "chown $owner $filelist\n" if $owner ne '-'; 697 $pkgdata{$pkgname}{'post'} .= "chgrp $group $filelist\n" if $group ne '-'; 698 $pkgdata{$pkgname}{'post'} .= "chmod $perms $filelist\n" if $perms ne '-'; 699 next; 700 } 701 702 # %doc needs extra processing, because it can be a space-separated list. 703 if (/^\%doc/) { 704 s/^\%doc\s+//; 705 foreach (split()) { 706 $filelist{$pkgname} .= " %{_docdir}/$_"; 707 } 708 next; 709 } 710 711 # Conffiles. Note that Debian and RH have similar, but not 712 # *quite* identical ideas of what constitutes a conffile. Nrgh. 713 if (/^\%config\s+(.+)$/) { 714 $pkgdata{$pkgname}{conffiles} = 1; # Flag it for later 715 my $tmp = $1; # Now we can mangleificationate it. And we probably need to. :/ 716 $tmp = expandmacros($tmp, 'gp'); # Expand common macros 717 if ($tmp !~ /\s+/) { 718 # Simplest case, just a file. Whew. 719 push @{$pkgdata{$pkgname}{conflist}}, $tmp; 720 $filelist{$pkgname} .= " $tmp"; 721 } else { 722 # Wot? Spaces? That means extra %-macros. Which, for the most part, can be ignored. 723 ($tmp) = ($tmp =~ /.+\s([^\s]+)/); # Strip everything before the last space 724 push @{$pkgdata{$pkgname}{conflist}}, $tmp; 725 $filelist{$pkgname} .= " $tmp"; 726 } 727 next; 728 } 729 730 # and finally we can fall through %{_<FHS>}-prefixed locations... 731 if (/^\%\{_/) { 732 $filelist{$pkgname} .= " $_"; 733 next; 734 } 735 # EW. Necessary to clear up %define expansions before we exit with redo. 736 $_ = expandmacros $_, 'g'; 737 738 # ... unknown or "next section" % directives ... 739 redo LINE if /^\%[a-z]/; 740 741 # ... and "normal" files 742 $filelist{$pkgname} .= " $_"; 743 } 744 } # done %file section 745 746 if (/^\%changelog/) { 747 $pkgdata{main}{changelog} = ''; 748 while (<SPECFILE>) { 749 redo LINE if /^\%[a-z]/; 750 $pkgdata{main}{changelog} .= $_; 751 } 752 } 753 # don't add any segments after this (%changelog), because something in the (Perl) parser gets 754 # thoroughly confuzzled if it tries to manipulate file data after EOL. Feh. 755 756 } else { # Data from the spec file "header" 757 730 $pkgdata{$subname}{'post'} .= "chown $owner $filelist\n" if $owner ne '-'; 731 $pkgdata{$subname}{'post'} .= "chgrp $group $filelist\n" if $group ne '-'; 732 $pkgdata{$subname}{'post'} .= "chmod $perms $filelist\n" if $perms ne '-'; 733 next LINE; 734 } 735 # %doc needs extra processing, because it can be a space-separated list. 736 if (/^\%doc/) { 737 s/^\%doc\s+//; 738 foreach (split()) { 739 $filelist{$subname} .= " %{_docdir}/$_"; 740 } 741 next LINE; 742 } 743 # Conffiles. Note that Debian and RH have similar, but not 744 # *quite* identical ideas of what constitutes a conffile. Nrgh. 745 if (/^\%config\s+(.+)$/) { 746 $pkgdata{$subname}{conffiles} = 1; # Flag it for later 747 my $tmp = $1; # Now we can mangleificationate it. And we probably need to. :/ 748 $tmp = expandmacros($tmp, 'gp'); # Expand common macros 749 if ($tmp !~ /\s+/) { 750 # Simplest case, just a file. Whew. 751 push @{$pkgdata{$subname}{conflist}}, $tmp; 752 $filelist{$subname} .= " $tmp"; 753 } else { 754 # Wot? Spaces? That means extra %-macros. Which, for the most part, can be ignored. 755 ($tmp) = ($tmp =~ /.+\s([^\s]+)/); # Strip everything before the last space 756 push @{$pkgdata{$subname}{conflist}}, $tmp; 757 $filelist{$subname} .= " $tmp"; 758 } 759 next LINE; 760 } 761 # ... and finally everything else 762 $filelist{$subname} .= " $_"; 763 next LINE; 764 } # files 765 766 if ($stage eq 'changelog') { 767 $pkgdata{main}{changelog} .= $_; 768 } 769 770 if ($stage eq 'preamble') { 758 771 if (/^summary:\s+(.+)/i) { 759 772 $pkgdata{main}{summary} = $1; 760 773 } elsif (/^name:\s+(.+)/i) { 761 774 $pkgdata{main}{name} = expandmacros($1,'g'); 762 775 } elsif (/^version:\s+(.+)/i) { 763 776 $pkgdata{main}{version} = expandmacros($1,'g'); 764 777 } elsif (/^release:\s+(.+)/i) { 765 778 $pkgdata{main}{release} = expandmacros($1,'g'); 766 779 } elsif (/^group:\s+(.+)/i) { 767 780 $pkgdata{main}{group} = $1; 768 781 } elsif (/^copyright:\s+(.+)/i) { 769 782 $pkgdata{main}{copyright} = $1; 770 783 } elsif (/^url:\s+(.+)/i) { 771 784 $pkgdata{main}{url} = $1; 772 785 } elsif (/^packager:\s+(.+)/i) { 773 786 $pkgdata{main}{packager} = $1; 774 787 } elsif (/^buildroot:\s+(.+)/i) { 775 788 $buildroot = $1; 776 789 } elsif (/^source0?:\s+(.+)/i) { 777 778 790 $pkgdata{main}{source} = $1; 791 die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/; 779 792 } elsif (/^source([0-9]+):\s+(.+)/i) { 780 793 $pkgdata{sources}{$1} = $2; 781 794 } elsif (/^patch([^:]+):\s+(.+)$/i) { 782 783 784 785 786 787 788 789 795 my $patchname = "patch$1"; 796 $pkgdata{main}{$patchname} = $2; 797 if ($pkgdata{main}{$patchname} =~ /\//) { 798 # URL-style patch. Rare but not unheard-of. 799 my @patchbits = split '/', $pkgdata{main}{$patchname}; 800 $pkgdata{main}{$patchname} = $patchbits[$#patchbits]; 801 } 802 chomp $pkgdata{main}{$patchname}; 790 803 } elsif (/^buildarch(?:itecture)?:\s+(.+)/i) { 791 792 793 804 $pkgdata{main}{arch} = $1; 805 $pkgdata{main}{arch} =~ s/^noarch$/all/; 806 $buildarch = $pkgdata{main}{arch}; 794 807 } elsif (/^buildreq(?:uires)?:\s+(.+)/i) { 795 808 $buildreq .= ", $1"; 796 809 } elsif (/^requires:\s+(.+)/i) { 797 810 $pkgdata{main}{requires} .= ", ".expandmacros("$1", 'gp'); 798 811 } elsif (/^provides:\s+(.+)/i) { 799 812 $pkgdata{main}{provides} .= ", $1"; 800 813 } elsif (/^conflicts:\s+(.+)/i) { 801 $pkgdata{main}{conflicts} .= ", $1"; 802 } 803 #Name: suwrap 804 #Version: 0.04 805 #Release: 3 806 #Group: Applications/System 807 #Copyright: WebHart internal ONLY. :( 808 #BuildArchitectures: i386 809 #BuildRoot: /tmp/%{name}-%{version} 810 #Url: http://virtual.webhart.net 811 #Packager: Kris Deugau <kdeugau@deepnet.cx> 812 #Source: ftp://virtual.webhart.net/%{name}-%{version}.tar.gz 813 814 } 815 } 814 $pkgdata{main}{conflicts} .= ", $1"; 815 } 816 next LINE; 817 } # preamble 818 819 } # while <SPEC> 816 820 817 821 # Parse and replace some more macros. More will be replaced even later. … … 819 823 # Expand macros as necessary. 820 824 $scriptletbase = expandmacros($scriptletbase,'gp'); 825 826 $cleanscript = expandmacros($cleanscript,'gp'); 821 827 822 828 $buildroot = $cmdbuildroot if $cmdbuildroot;
Note:
See TracChangeset
for help on using the changeset viewer.