This repository was archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDidbsPackageHasher.pm
More file actions
66 lines (53 loc) · 1.4 KB
/
DidbsPackageHasher.pm
File metadata and controls
66 lines (53 loc) · 1.4 KB
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
61
62
63
64
65
66
package DidbsPackageHasher;
use Digest::SHA;
use File::Basename;
use DidbsUtils;
sub new
{
my $self = bless{}, shift;
my $verbose = shift;
$self->{v} = $verbose;
return $self;
}
sub calculateEnvHash
{
my ($envFile, $supEnvFile, $elfwidth, $isa, $compiler) = (@_);
# Compute a sha256 sum of the contents of the package def dir
my $envSha = Digest::SHA->new("sha256");
$envSha->addfile($envFile);
$envSha->addfile($supEnvFile);
$envSha->add($elfwidth);
$envSha->add($isa);
$envSha->add($compiler);
return $envSha->b64digest;
}
sub calculatePackageDefHash
{
my ($verbose, $packageDefDir) = (@_);
# Compute a sha256 sum of the contents of the package def dir
my $packageSha = Digest::SHA->new("sha256");
my @PKGFILES = glob "$packageDefDir/*";
chomp(@PKGFILES);
for (@PKGFILES)
{
# I use emacs, it creates backup files named FILENAME~
next if (m/.*\~$/);
my $pkgHelperFile = basename($_);
$packageSha->addfile($packageDefDir."/".$pkgHelperFile);
}
# (!$verbose) && print "#";
return $packageSha->b64digest;
}
sub calculateEnvPacDepHash
{
my ($envHash, $packageDefHash, $dependencyHashesRef) = (@_);
my $packageSha = Digest::SHA->new("sha256");
$packageSha->add($envHash);
$packageSha->add($packageDefHash);
for( @{$dependencyHashesRef} )
{
$packageSha->add($_);
}
return $packageSha->b64digest;
}
1;