Mailinglist Archive: opensuse-buildservice (206 mails)

< Previous Next >
Re: [opensuse-buildservice] inject local rpm data for buildinfo calculation
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Mon, 2 Mar 2009 02:51:41 +0100
  • Message-id: <20090302015141.GA3144@xxxxxxxxxxxxxxxxxxx>
On 2009-02-27 11:00:01 +0100, Michael Schroeder wrote:
On Thu, Feb 26, 2009 at 08:43:35PM +0100, Marcus Hüwe wrote:
My proposal is to separate <name>, <version> and <release> with a whitespace
instead of the dash because it would be easier to parse the name version and
release of a package (I need this info in order to send back a "clean"
buildinfo).

We could do that, but it really isn't that hard to split the
version/release with the current version...

Here's a new version of the patch:
build/Build.pm:
* rewrote some parts of readdeps(), it parses the current format which is used
by build and also supports debian requires/provides (foo | bar (>> 3.1)...)
* removed $strip_versions module variable
* the former $pkgidp ref of readdeps() is now used to store package
information (version, release, arch) (the self provides of a package is used
to determine this information)
backend/bs_repserver:
* some minor changes with regard to the last patch
* local packages are preferred


Feedback, objections etc. are welcome:)


Marcus
Index: build/Build.pm
===================================================================
--- build/Build.pm (Revision 6242)
+++ build/Build.pm (Arbeitskopie)
@@ -7,7 +7,6 @@
use Data::Dumper;

our $expand_dbg;
-our $strip_versions;

our $do_rpm;
our $do_deb;
@@ -357,7 +356,7 @@
###########################################################################

sub readdeps {
- my ($config, $pkgidp, @depfiles) = @_;
+ my ($config, $pkginfo, @depfiles) = @_;

my %whatprovides = ();
my %requires = ();
@@ -366,8 +365,8 @@
for my $depfile (@depfiles) {
if (ref($depfile) eq 'HASH') {
for my $rr (keys %$depfile) {
- $provides{$rr} = $depfile->{$rr}->{'provides'};
- $requires{$rr} = $depfile->{$rr}->{'requires'};
+ $provides{$rr} = $depfile->{$rr}->{'provides'};
+ $requires{$rr} = $depfile->{$rr}->{'requires'};
}
next;
}
@@ -377,35 +376,45 @@
my $s = shift @s;
my @ss;
while (@s) {
- if ($s[0] =~ /^\//) {
- shift @s;
- next;
- }
- if ($s[0] =~ /^rpmlib\(/) {
- shift @s;
- shift @s;
- shift @s;
- next;
- }
- push @ss, shift @s;
- if (@s && $s[0] =~ /^[<=>]/) {
- $ss[-1] .= " $s[0] $s[1]" unless $strip_versions;
- shift @s;
- shift @s;
- }
+ if ($s[0] =~ /^\//) {
+ shift @s;
+ next;
+ }
+ if ($s[0] =~ /^rpmlib\(/) {
+ splice(@s, 0, 3);
+ next;
+ }
+ push @ss, shift @s;
+ while (@s) {
+ if ($s[0] =~ /^[\(<=>|]/) {
+ $ss[-1] .= " $s[0] $s[1]";
+ $ss[-1] =~ s/\((.*)\)/$1/;
+ $ss[-1] =~ s/(<|>){2}/$1/;
+ splice(@s, 0, 2);
+ } else {
+ last;
+ }
+ }
}
my %ss;
@ss = grep {!$ss{$_}++} @ss;
- if ($s =~ s/^P:(.*):$/$1/) {
- my $pkgid = $s;
- $s =~ s/-[^-]+-[^-]+-[^-]+$//;
- $provides{$s} = \@ss;
- $pkgidp->{$s} = $pkgid if $pkgidp;
- } elsif ($s =~ s/^R:(.*):$/$1/) {
- my $pkgid = $s;
- $s =~ s/-[^-]+-[^-]+-[^-]+$//;
- $requires{$s} = \@ss;
- $pkgidp->{$s} = $pkgid if $pkgidp;
+ if ($s =~ /^(P|R):(.*)\.(.*)-\d+\/\d+\/\d+:$/) {
+ my $pkgid = $2;
+ my $arch = $3;
+ if ($1 eq "R") {
+ $requires{$pkgid} = \@ss;
+ next;
+ }
+ # handle provides
+ $provides{$pkgid} = [ @ss ];
+ if ($pkginfo) {
+ # extract ver and rel from self provides
+ my ($v, $r) = map { /\Q$pkgid\E = ([^-]+)(?:-(.+))?$/ } @ss;
+ die("$pkgid: no self provides\n") unless $v;
+ $pkginfo->{$pkgid}->{'version'} = $v;
+ $pkginfo->{$pkgid}->{'release'} = $r if defined($r);
+ $pkginfo->{$pkgid}->{'arch'} = $arch;
+ }
}
}
close F;
Index: backend/bs_repserver
===================================================================
--- backend/bs_repserver (Revision 6638)
+++ backend/bs_repserver (Arbeitskopie)
@@ -1151,6 +1151,7 @@
die("no such project/repository\n") unless $projpack->{'project'};
$uploaded = 1;
}
+ my $ldepfile = $pdata->{'ldepfile'};
my %remotemap = map {$_->{'project'} => $_} @{$projpack->{'remotemap'} ||
[]};
my $proj = $projpack->{'project'}->[0];
die("no such project\n") unless $proj && $proj->{'name'} eq $projid;
@@ -1269,6 +1270,7 @@
$repodata{$prp} = $cache;
}
my @repos = map {$repodata{$_} || {}} @prp;
+ unshift @repos, $ldepfile if defined($ldepfile);
my %dep2src;
my %dep2rpm;
my %dep2prp;
@@ -1286,7 +1288,8 @@
my $pname = $info->{'name'};
my @subpacks = grep {$dep2src{$_} eq $pname} keys %dep2src;
#$ret->{'subpack'} = \@subpacks;
- Build::readdeps($bconf, undef, reverse @repos);
+ my %localdeps;
+ Build::readdeps($bconf, \%localdeps, reverse @repos);
my @deps = ( @{$info->{'dep'} || []}, @{$info->{'prereq'} || []} );
$Build::expand_dbg = 1 if $cgi->{'debug'};
@subpacks = () if $packtype eq 'kiwi';
@@ -1370,6 +1373,7 @@
if (!$cgi->{'internal'}) {
for (@bdeps) {
my $p = $dep2rpm{$_}->{'path'};
+ next unless $p;
push @bdepsp, "$reporoot/$dep2prp{$_}/$arch/:full/$p";
}
@bdepsp = getbinarydata(@bdepsp);
@@ -1381,6 +1385,11 @@
($_->{'project'}, $_->{'repository'}) = split('/',
$dep2prp{$_->{'name'}}, 2);
}
my $r = $bdepsp{$_->{'name'}};
+ if (exists $localdeps{$_->{'name'}}) {
+ $r = $localdeps{$_->{'name'}};
+ delete $_->{'project'};
+ delete $_->{'repository'};
+ }
if ($r) {
$_->{'version'} = $r->{'version'};
$_->{'release'} = $r->{'release'} if exists $r->{'release'};
@@ -1450,25 +1459,49 @@
my $config = BSRPC::rpc("$BSConfig::srcserver/getconfig", undef,
"project=$projid", "repository=$repoid");
my $bconf = Build::read_config($arch, [split("\n", $config)]);

+ my $fn = "$uploaddir/$$";
+ my $descr = $fn;
+ my $dir = "$uploaddir/$$.dir";
+ my $depfile;
mkdir_p("$uploaddir");
- my $fn = "$uploaddir/$$";
die("upload failed\n") unless BSServer::read_file($fn);
+
+ local *F;
+ open(F, '<', "$fn") || die("$fn: $!\n");
+ my $magic;
+ sysread(F, $magic, 6);
+ if ($magic eq "070701") {
+ sysseek(F, 0, 0);
+ mkdir_p($dir);
+ my $uploaded = BSHTTP::cpio_receiver(BSHTTP::fd2hdr(\*F), {'directory' =>
$dir});
+ # should we check if the cpio archive contains <= 2 files?
+ ($depfile) = map { $_->{'name'} =~ /(deps)/ } @$uploaded;
+ $depfile = "$dir/$depfile";
+ $descr = (grep { $_->{'name'} ne "deps" } @$uploaded)[0];
+ die("no spec/dsc/kiwi file found\n") unless $descr;
+ $descr = "$dir/$descr->{'name'}";
+ }
+ close(F);
my $d;
my $info = {'repository' => $repoid};
- if (looks_like_dsc($fn)) {
- $d = Build::Deb::parse($bconf, $fn);
+ if (looks_like_dsc($descr)) {
+ $d = Build::Deb::parse($bconf, $descr);
$info->{'file'} = 'upload.dsc';
- } elsif (looks_like_kiwi($fn)) {
- $d = Build::Kiwi::parse($bconf, $fn);
+ } elsif (looks_like_kiwi($descr)) {
+ $d = Build::Kiwi::parse($bconf, $descr);
$info->{'imagetype'} = $d->{'imagetype'};
$info->{'path'} = $d->{'path'};
$info->{'file'} = 'upload.kiwi';
} else {
- $d = Build::Rpm::parse($bconf, $fn);
+ $d = Build::Rpm::parse($bconf, $descr);
$info->{'file'} = 'upload.spec';
}
unlink($fn);
- die("parse error\n") unless defined $d->{'name'};
+ unless (defined $d->{'name'}) {
+ unlink("$dir/$_") for ls($dir);
+ rmdir($dir) if -d $dir;
+ die("parse error\n");
+ }
$info->{'name'} = $d->{'name'};
$info->{'dep'} = $d->{'deps'};
if ($d->{'prereqs'}) {
@@ -1477,8 +1510,16 @@
$info->{'prereq'} = \@prereqs if @prereqs;
}
my $pdata = {'info' => [ $info ]};
+ $pdata->{'ldepfile'} = $depfile if $depfile;

- return getbuildinfo($cgi, $projid, $repoid, $arch, $packid, $pdata);
+ my @r;
+ eval {
+ @r = getbuildinfo($cgi, $projid, $repoid, $arch, $packid, $pdata);
+ };
+ unlink("$dir/$_") for ls($dir);
+ rmdir($dir) if -d $dir;
+ die("$@\n") if $@;
+ return @r;
}

sub getbuilddepinfo {
< Previous Next >
Follow Ups