Mailinglist Archive: opensuse-buildservice (189 mails)

< Previous Next >
[opensuse-buildservice] inject local rpm data for buildinfo calculation
  • From: Marcus Hüwe <suse-tux@xxxxxx>
  • Date: Mon, 23 Feb 2009 01:54:12 +0100
  • Message-id: <20090223005412.GA3142@xxxxxxxxxxxxxxxxxxx>
Hi,

I wrote a small patch to inject rpm/deb/whatever data to the buildinfo
calculation. This means one can collect the rpm/deb provides and requires
of local packages and send them to the obs which uses them to calculate
the buildinfo for local builds.

Usecase:
* you submitted a new package to the obs: before you can build a local package
which depends on this new package you have to wait until the obs has built it
(now you could simply do sth. like "osc build ... -p /path/to/local/pkgs"
and it'll directly start the local build).

How it works:
A client like osc collects the requires and provides of some local packages,
stores these information in a xml file and finally creates a cpio archive
which contains the xml + a spec/dsc file and sends it to the obs.
(Note: I decided to store the data in a xml because I didn't want to introduce
yet another metadata format - this results in less additional code)
Example xml:
<localdeps>
<package name="foobar" version="3.0.1" release="0" arch="i586">
<provides>foobar = 3.0.1-0</provides>
<requires>glibc</requires>
<requires>libfoo-devel >= 2.0</requires>
</package>
...
</localdeps>

Any feedback, corrections etc. are welcome:)
If there are no objections I'll commit it within the next few days.


Marcus
Index: BSXML.pm
===================================================================
--- BSXML.pm (Revision 6536)
+++ BSXML.pm (Arbeitskopie)
@@ -255,6 +255,19 @@
[ 'enhances' ],
];

+our $localdeps = [
+ 'localdeps' =>
+ [],
+ [[ 'package' =>
+ 'name',
+ 'version',
+ 'release',
+ 'arch',
+ [ 'provides' ],
+ [ 'requires' ],
+ ]],
+];
+
our $buildinfo = [
'buildinfo' =>
'project',
Index: bs_repserver
===================================================================
--- bs_repserver (Revision 6537)
+++ bs_repserver (Arbeitskopie)
@@ -1151,6 +1151,7 @@
die("no such project/repository\n") unless $projpack->{'project'};
$uploaded = 1;
}
+ my $ldeps = $pdata->{'localdeps'};
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, $ldeps if defined($ldeps);
my %dep2src;
my %dep2rpm;
my %dep2prp;
@@ -1370,6 +1372,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 +1384,7 @@
($_->{'project'}, $_->{'repository'}) = split('/',
$dep2prp{$_->{'name'}}, 2);
}
my $r = $bdepsp{$_->{'name'}};
+ $r = $ldeps->{$_->{'name'}} if (defined($ldeps) && !defined($r));
if ($r) {
$_->{'version'} = $r->{'version'};
$_->{'release'} = $r->{'release'} if exists $r->{'release'};
@@ -1451,8 +1455,27 @@
my $bconf = Build::read_config($arch, [split("\n", $config)]);

mkdir_p("$uploaddir");
- my $fn = "$uploaddir/$$";
- die("upload failed\n") unless BSServer::read_file($fn);
+ my $dir = "$uploaddir/$$.dir";
+ my $fn;
+ my %localdeps;
+ # FIXME: is there a to check for the cpio magic?
+ if ($cgi->{'cpio'}) {
+ mkdir_p($dir);
+ my $uploaded = BSServer::read_cpio($dir);
+ die("upload failed\n") unless $uploaded;
+ # should we check if the cpio archive contains <= 2 files?
+ my $depfile = (grep { $_->{'name'} eq 'deps' } @$uploaded)[0];
+ $fn = (grep { $_->{'name'} ne 'deps' } @$uploaded)[0];
+ die("no spec/dsc/kiwi file found\n") unless $fn;
+ $fn = "$dir/$fn->{'name'}";
+ if (defined($depfile)) {
+ my $xml = readxml("$dir/$depfile->{'name'}", $BSXML::localdeps, 1);
+ %localdeps = map { $_->{'name'} => $_ } @{$xml->{'package'}};
+ }
+ } else {
+ $fn = "$uploaddir/$$";
+ die("upload failed\n") unless BSServer::read_file($fn);
+ }
my $d;
my $info = {'repository' => $repoid};
if (looks_like_dsc($fn)) {
@@ -1468,6 +1491,8 @@
$info->{'file'} = 'upload.spec';
}
unlink($fn);
+ unlink($_) for ls($dir);
+ rmdir($dir) if -d $dir;
die("parse error\n") unless defined $d->{'name'};
$info->{'name'} = $d->{'name'};
$info->{'dep'} = $d->{'deps'};
@@ -1477,6 +1502,7 @@
$info->{'prereq'} = \@prereqs if @prereqs;
}
my $pdata = {'info' => [ $info ]};
+ $pdata->{'localdeps'} = \%localdeps if scalar(keys %localdeps);

return getbuildinfo($cgi, $projid, $repoid, $arch, $packid, $pdata);
}
@@ -2008,7 +2034,7 @@
'POST:/build/$project/$repository/$arch/_relsync' => \&postrelsync,
'/build/$project/$repository/$arch/_relsync' => \&getrelsync,
'/build/$project/$repository/$arch/$package:package_repository view:?
binary:filename*' => \&getbinarylist,
- 'POST:/build/$project/$repository/$arch/$package_repository/_buildinfo add:*
internal:bool? deps:bool?' => \&getbuildinfo_post,
+ 'POST:/build/$project/$repository/$arch/$package_repository/_buildinfo add:*
internal:bool? deps:bool? cpio:bool?' => \&getbuildinfo_post,
'/build/$project/$repository/$arch/$package/_buildinfo add:* internal:bool?
debug:bool? deps:bool?' => \&getbuildinfo,
'/build/$project/$repository/$arch/$package/_reason' => \&getbuildreason,
'/build/$project/$repository/$arch/$package/_status' => \&getbuildstatus,
Index: bs_srcserver
===================================================================
--- bs_srcserver (Revision 6536)
+++ bs_srcserver (Arbeitskopie)
@@ -2444,6 +2444,7 @@
'data' => \&BSServer::forward_sender,
'chunked' => 1,
};
+ push @args, "cpio=$cgi->{'cpio'}" if defined($cgi->{'cpio'});
my $buildinfo = BSWatcher::rpc($param, $BSXML::buildinfo, @args);
return ($buildinfo, $BSXML::buildinfo);
}
@@ -3366,7 +3367,7 @@
'/build/$project/$repository/$arch/_jobhistory package* code:*' =>
\&getjobhistory,
'POST:/build/$project/$repository/$arch/_repository match:' => \&postrepo,
'/build/$project/$repository/$arch/$package_repository view:?
binary:filename*' => \&getbinarylist,
- 'POST:/build/$project/$repository/$arch/$package_repository/_buildinfo
add:*' => \&getbuildinfo_post,
+ 'POST:/build/$project/$repository/$arch/$package_repository/_buildinfo add:*
cpio:bool?' => \&getbuildinfo_post,
'/build/$project/$repository/$arch/$package/_buildinfo add:* internal:bool?'
=> \&getbuildinfo,
'/build/$project/$repository/$arch/$package/_log nostream:bool? start:num?
end:num?' => \&getlogfile,
'/build/$project/$repository/$arch/$package/_reason' => \&getbuildreason,
< Previous Next >