Changeset 38


Ignore:
Timestamp:
02/22/06 13:01:46 (19 years ago)
Author:
kdeugau
Message:

/trunk

First iteration of build-deps and install reqs:

  • Build requirements are checked, including version requirements.
  • Specified "Requires" will be listed in the Depends field in the package's control file; subpackage Requires should be added the same way. Versioned Require:'s are NOT (yet) supported.
  • Automatic shlibs requirements are partially processed - package names are added to the list, but versions are NOT. (dpkg's tool dpkg-shlibdeps seems to generate versions on *some* libs, but not all, without any immediately obvious pattern.)
  • Provides are passed through as-is.

Requires:/Depends: and Provides: versioning are not supported because
of the format used for dpkg to specify versions.

Debian does not support dependencies on library sonames, just the containing package name
or a virtual package. :/ Any package providing a soname I want to depend on will have to
Provide: something suitable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r37 r38  
    9494# This is the form of $pkgdata{pkgname}{meta}
    9595# 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
    9798# 10/31/2005 Maybe this should be flatter?  -kgd
    9899my %pkgdata;
     
    100101# Files listing.  Embedding this in %pkgdata would be, um, messy.
    101102my %filelist;
     103my $buildreq;
    102104
    103105# Scriptlets
     
    133135  # this also generates most of the shell script required.
    134136  parse_spec();
     137  die "Can't build $pkgdata{main}{name}:  build requirements not met.\n"
     138    if !checkbuildreq();
    135139}
    136140
     
    341345        while (<SPECFILE>) {
    342346          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)) {
    344348            $dname =~ tr/[A-Z]/[a-z]/;
    345349            $pkgdata{$subname}{$dname} = $dvalue;
     
    547551          $pkgdata{main}{$patchname} = $patchbits[$#patchbits];
    548552        }
     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";
    549559      }
    550560#Name: suwrap
     
    678688    }
    679689
     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
    680698    # Gotta do this next, otherwise the control file has nowhere to go.  >:(
    681699    mkdir "$buildroot/$pkg/DEBIAN";
     
    701719        "Architecture: i386\n".
    702720        "Maintainer: $pkgdata{main}{packager}\n".
     721        "Depends: $pkgdata{$pkg}{depends}\n".
     722        "Provides: $pkgdata{$pkg}{provides}\n".
    703723        "Description: $pkgdata{$pkg}{summary}\n";
    704724    $control .= "$pkgdata{$pkg}{desc}\n";
     
    827847  print "Wrote source package $pkgsrcname in $topdir/SDEBS.\n";
    828848}
     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.
     855sub 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)
     916sub 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()
    829949
    830950
     
    9601080
    9611081
     1082__END__
     1083
     1084
     1085
    9621086=head1 NAME
    9631087
Note: See TracChangeset for help on using the changeset viewer.