Changeset 38
- Timestamp:
- 02/22/06 13:01:46 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r37 r38 94 94 # This is the form of $pkgdata{pkgname}{meta} 95 95 # meta includes Summary, Name, Version, Release, Group, Copyright, 96 # Source, URL, Packager, BuildRoot, Description 96 # Source, URL, Packager, BuildRoot, Description, BuildReq(uires), 97 # Requires, Provides 97 98 # 10/31/2005 Maybe this should be flatter? -kgd 98 99 my %pkgdata; … … 100 101 # Files listing. Embedding this in %pkgdata would be, um, messy. 101 102 my %filelist; 103 my $buildreq; 102 104 103 105 # Scriptlets … … 133 135 # this also generates most of the shell script required. 134 136 parse_spec(); 137 die "Can't build $pkgdata{main}{name}: build requirements not met.\n" 138 if !checkbuildreq(); 135 139 } 136 140 … … 341 345 while (<SPECFILE>) { 342 346 redo LINE if /^\%/; 343 if (my ($dname,$dvalue) = (/^(Summary|Group|Version ):\s+(.+)$/i)) {347 if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides):\s+(.+)$/i)) { 344 348 $dname =~ tr/[A-Z]/[a-z]/; 345 349 $pkgdata{$subname}{$dname} = $dvalue; … … 547 551 $pkgdata{main}{$patchname} = $patchbits[$#patchbits]; 548 552 } 553 } elsif (/^buildreq(?:uires)?:\s+(.+)/i) { 554 $buildreq .= ", $1"; 555 } elsif (/^requires:\s+(.+)/i) { 556 $pkgdata{main}{requires} .= ", $1"; 557 } elsif (/^provides:\s+(.+)/i) { 558 $pkgdata{main}{provides} .= ", $1"; 549 559 } 550 560 #Name: suwrap … … 678 688 } 679 689 690 # Get the "Depends" (Requires) a la RPM. Ish. We strip the leading 691 # comma and space here (if needed) in case there were "Requires" specified 692 # in the spec file - those would precede these. 693 ($pkgdata{$pkg}{depends} .= getreqs("$buildroot/$pkg")) =~ s/^, //; 694 695 # Do this here since we're doing {depends}... 696 $pkgdata{$pkg}{provides} =~ s/^, //; 697 680 698 # Gotta do this next, otherwise the control file has nowhere to go. >:( 681 699 mkdir "$buildroot/$pkg/DEBIAN"; … … 701 719 "Architecture: i386\n". 702 720 "Maintainer: $pkgdata{main}{packager}\n". 721 "Depends: $pkgdata{$pkg}{depends}\n". 722 "Provides: $pkgdata{$pkg}{provides}\n". 703 723 "Description: $pkgdata{$pkg}{summary}\n"; 704 724 $control .= "$pkgdata{$pkg}{desc}\n"; … … 827 847 print "Wrote source package $pkgsrcname in $topdir/SDEBS.\n"; 828 848 } 849 850 851 ## checkbuildreq() 852 # Checks the build requirements (if any) 853 # Spits out a rude warning and returns a true-false error if any 854 # requirements are not met. 855 sub checkbuildreq { 856 return 0 if $buildreq eq ''; # No use doing extra work. 857 858 my $reqflag = 1; # unset iff a buildreq is missing 859 860 $buildreq =~ s/^, //; # Strip the leading comma and space 861 my @reqlist = split /,\s+/, $buildreq; 862 863 foreach my $req (@reqlist) { 864 my ($pkg,$rel,$ver); 865 866 # We have two classes of requirements - versioned and unversioned. 867 if ($req =~ /[><=]/) { 868 # Pick up the details of versioned buildreqs 869 ($pkg,$rel,$ver) = ($req =~ /([a-z0-9._-]+)\s+([><=]+)\s+([a-z0-9._-]+)/); 870 } else { 871 # And the unversioned ones. 872 $pkg = $req; 873 $rel = '>='; 874 $ver = 0; 875 } 876 877 my @pkglist = qx { dpkg-query --showformat '\${status}\t\${version}\n' -W $pkg }; 878 # need to check if no lines returned - means a bad buildreq 879 my ($reqstat,undef,undef,$reqver) = split /\s+/, $pkglist[0]; 880 if ($reqstat !~ /install/) { 881 print " * Missing build-dependency $pkg!\n"; 882 $reqflag = 0; 883 } else { 884 # gotta be a better way to do this... :/ 885 if ($rel eq '>=' && !($reqver ge $ver)) { 886 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"; 887 $reqflag = 0; 888 } 889 if ($rel eq '>' && !($reqver gt $ver)) { 890 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"; 891 $reqflag = 0; 892 } 893 if ($rel eq '<=' && !($reqver le $ver)) { 894 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"; 895 $reqflag = 0; 896 } 897 if ($rel eq '<' && !($reqver lt $ver)) { 898 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"; 899 $reqflag = 0; 900 } 901 if ($rel eq '=' && !($reqver eq $ver)) { 902 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"; 903 $reqflag = 0; 904 } 905 } # end not installed/installed check 906 } # end req loop 907 908 return $reqflag; 909 } # end checkbuildreq() 910 911 912 ## getreqs() 913 # Find out which libraries/packages are required for any 914 # executables and libs in a given file tree. 915 # (Debian doesn't have soname-level deps; just package-level) 916 sub getreqs() { 917 my $pkgtree = $_[0]; 918 919 print "checking reqs on executables in $pkgtree...\n"; 920 my @reqlist = qx { find $pkgtree -type f -perm 755 | grep -v $pkgtree/etc | xargs ldd }; 921 922 my %reqs; 923 my $reqlibs; 924 925 foreach (@reqlist) { 926 next if /^$pkgtree/; 927 next if m|/lib/ld-linux.so|; 928 my ($req) = (/^\s+([a-z0-9._-]+)/); 929 930 $reqlibs .= " $req"; 931 } 932 933 foreach (qx { dpkg -S $reqlibs }) { 934 my ($libpkg,undef) = split /:\s+/; 935 $reqs{$libpkg} = 1; 936 } 937 938 my $deplist; 939 foreach (keys %reqs) { 940 $deplist .= ", $_"; 941 } 942 943 # For now, we're done. We're not going to meddle with versions yet. 944 # Among other things, it's messier than handling "simple" yes/no "do 945 # we have this lib?" deps. >:( 946 947 return $deplist; 948 } # end getreqs() 829 949 830 950 … … 960 1080 961 1081 1082 __END__ 1083 1084 1085 962 1086 =head1 NAME 963 1087
Note:
See TracChangeset
for help on using the changeset viewer.