Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
reproducibleopensuse/jsonresult
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
117 lines (109 sloc)
3.63 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| use strict; | |
| use XML::Simple; | |
| use JSON; | |
| use POSIX; | |
| sub find_version($$) | |
| { | |
| my $dir=shift; | |
| my $name=shift; | |
| my $version=`sed -e '/^\(PreReq\|BuildRequires\|Requires\|Provides\|Recommends\|Suggests\):/d' $name.spec > $name.spec~ | rpmspec --query --srpm --queryformat="%{version}" $name.spec~ 2>/dev/null ; rm -f $name.spec~`; | |
| if($version eq "") { # could not parse .spec file | |
| $version=`grep '^Version:' $name.spec|head -1`; | |
| chomp($version); | |
| $version=~s/^Version:\s*//; | |
| $version=~s/\s+$//; | |
| if($version =~ /%/) { | |
| my $line=`grep "Wrote: .*\.src\.rpm" $dir/.build.log $dir/RPMS/.build.log`; | |
| if($line) { | |
| $line =~ /.*-([^-]+)-[^-]+\.src\.rpm/ && return $1; | |
| } | |
| warn "cannot find version for package $name - got $version"; | |
| return "unknown"; | |
| } | |
| } | |
| return $version; | |
| } | |
| sub getline($) | |
| { my $file=shift; | |
| open(my $f, "<", $file) or die "error opening $file : $!"; | |
| my $line=<$f>; | |
| chomp($line); | |
| return $line; | |
| } | |
| sub find_status($) | |
| { my $dir=shift; | |
| my $build=getline("$dir/.osc-build-retval"); | |
| if($build == 2) { return "notforus" } | |
| elsif($build ne "0") { | |
| #TODO: check .build.log for arch mismatch/unresolvable | |
| system(qw(grep -q), "error: Architecture is not included", "$dir/.build.log"); | |
| if(($?>>8) == 0) { return "notforus" } | |
| system(qw(grep -q), "^unresolvable: nothing provides", "$dir/RPMS/.build.log2"); | |
| if(($?>>8) == 0) { return "waitdep" } | |
| return "FTBFS"; | |
| } | |
| else { | |
| my $differed=eval{getline("$dir/.build-differed")}; | |
| if($@) { return "nobinaries" } # i.e. testsuite | |
| if($differed eq "0") { return "reproducible" } | |
| return "unreproducible"; | |
| } | |
| } | |
| sub find_verified($) | |
| { my $dir=shift; | |
| my $differed=eval{getline("$dir/.build-differed-nachbau")} //1; | |
| my $filtered=eval{getline("$dir/.build-compare-retval-nachbau")}; | |
| $::sigdate=undef; | |
| return undef unless defined $filtered; | |
| $_=eval{getline("$dir/binaries/signature")} // "unknown"; # grep -o "[^ ]* UTC" $dir/binaries/signature|head -1 | |
| m/\S+ UTC/ and $_=$&; | |
| $::sigdate=$_; | |
| return (($differed==0?1:0) + ($filtered==0?1:0)); | |
| } | |
| sub find_build_compare_status($) | |
| { my $dir=shift; | |
| my $differed=eval{getline("$dir/.build-compare-retval")}; | |
| if($@) { return "nobinaries" } # i.e. testsuite | |
| if($differed eq "0") { return "reproducible" } | |
| return "unreproducible"; | |
| } | |
| sub get_build_duration($) | |
| { my $in=shift; | |
| if(! -e $in) { return undef } | |
| my $duration=int(getline($in)); | |
| if(!$duration) {$duration=undef}; | |
| return $duration; | |
| } | |
| sub get_status_for_one_dir($) | |
| { | |
| my $dir=shift; | |
| print STDERR "processing $dir\n"; | |
| if(! -e "$dir/.osc-build-retval") {return () } # skip unbuilt | |
| my $oscdata=XMLin("$dir/.osc/_files"); | |
| my $name=$oscdata->{name}; | |
| my $version=find_version($dir, "$dir/$name"); | |
| my $data = { | |
| package=>$name, | |
| version=>"$version-$oscdata->{rev}", | |
| architecture=>(POSIX::uname())[4], | |
| status=>find_status($dir), | |
| verified=>find_verified($dir), | |
| release=>getline("$dir/.osc/_project"), | |
| opensusetweaks=>eval{getline("$dir/.build-rbkt")}||undef, | |
| opensuseautoclassify=>eval{getline("$dir/.rb.autoclassify")}||undef, | |
| build_date=>(stat("$dir/.osc-build-retval"))[9], | |
| build_duration=>get_build_duration("$dir/RPMS/build-time")||get_build_duration("$dir/binaries.nachbau/build-time"), | |
| }; | |
| if($::sigdate) {$data->{opensusesigdate}=$::sigdate} | |
| if($data->{status} eq "unreproducible") { | |
| $data->{build_compare_status}=find_build_compare_status($dir); | |
| } | |
| return $data; | |
| } | |
| my $result=[]; | |
| if($#ARGV == -1) {@ARGV=(".")} | |
| for my $dir (@ARGV) { | |
| push(@$result, get_status_for_one_dir($dir)); | |
| } | |
| print JSON->new->ascii->pretty->allow_nonref->canonical->encode($result); |