-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrbkt
executable file
·60 lines (56 loc) · 2.13 KB
/
rbkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
# build one package with reduced indeterminism
# returns 0 for a reproducible build
# returns 1 for an unreproducible build
# returns 255 for a failed build
# usage:
# CLEAN=1 rbkt 0 0 1 0 0 0 # to build with sorted filesystem
# CLEAN=1 rbkt 1 1 1 1 1 1 1 1 1 1 # to build with as little indeterminism as possible
# rbkt 12 is decoded as hex for 0 1 0 0 1
use strict;
sub rbk(@)
{
my @tweakbits=@_;
my @extrapkg=();
if($ENV{CLEAN}) { $ENV{clean}="--clean --offline"} else { $ENV{clean}="--offline" }
# bit 1
if(shift) { $ENV{datediff}=100 }
# bit 2
my $hosttweak=shift||0;
if($hosttweak&1) { $ENV{host2}="buildhosta" }
if($hosttweak&2) { push(@extrapkg, "reproducible-faketools-hostname") }
# bit 3
if(shift) { push(@extrapkg, "reproducible-faketools-filesys") }
if(shift) { push(@extrapkg, "reproducible-faketools-date") }
if(shift) { $ENV{rbsnd}=1 } # use strip-nondeterminism
# bit 6
if(shift) { $ENV{project}="home:bmwiedemann:reproducible:test" }
if(shift) { push(@extrapkg, "reproducible-faketools-tar") }
# bit 8
if(shift) { $ENV{parallelism}=1; $ENV{parallelism2}=1 }
if(shift) { push(@extrapkg, "reproducible-faketools-aslr") }
# bit 10
if(shift) { push(@extrapkg, "reproducible-faketools-pid") }
if(shift) { push(@extrapkg, "reproducible-faketools-random") }
if(shift) { $ENV{cputype2}="host" }
if(shift) { push(@extrapkg, "reproducible-faketools-faketime") }
if(shift) { push(@extrapkg, "reproducible-faketools-strace") } # get extra r-b debug info
if(@extrapkg) { $ENV{oscbuildextrapkg}=join " ", map {"--extra-pkgs=$_"} @extrapkg }
system("rbk");
system("echo @tweakbits > .build-rbkt");
system("jsonresultcache ."); # update with tweakbits
my $resultfile=$ENV{rbminor}?".build-compare-retval":".build-differed";
open(my $resultfd, "<", $resultfile) || die $!;
my $result=<$resultfd>;chomp($result);
if($result>1) {$result=1}
return $result;
}
sub run(@)
{
if(@_==1) { # decode hex
@_=reverse(split("", sprintf("%b", hex(shift))));
}
#print "trying @_\n";
rbk(@_);
}
exit run(@ARGV);