mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
* A utility to generate patches between releases based on their
manifests.
This commit is contained in:
parent
77fc1c6c5c
commit
e1e9c036f9
2 changed files with 249 additions and 25 deletions
|
@ -1,6 +1,34 @@
|
|||
use strict;
|
||||
|
||||
|
||||
sub addPatch {
|
||||
my $patches = shift;
|
||||
my $storePath = shift;
|
||||
my $patch = shift;
|
||||
|
||||
$$patches{$storePath} = []
|
||||
unless defined $$patches{$storePath};
|
||||
|
||||
my $patchList = $$patches{$storePath};
|
||||
|
||||
my $found = 0;
|
||||
foreach my $patch2 (@{$patchList}) {
|
||||
if ($patch2->{url} eq $patch->{url}) {
|
||||
if ($patch2->{hash} eq $patch->{hash}) {
|
||||
$found = 1 if ($patch2->{basePath} eq $patch->{basePath});
|
||||
} else {
|
||||
die "conflicting hashes for URL $patch->{url}, " .
|
||||
"namely $patch2->{hash} and $patch->{hash}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
push @{$patchList}, $patch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub readManifest {
|
||||
my $manifest = shift;
|
||||
my $narFiles = shift;
|
||||
|
@ -81,31 +109,11 @@ sub readManifest {
|
|||
}
|
||||
|
||||
elsif ($type eq "patch") {
|
||||
|
||||
$$patches{$storePath} = []
|
||||
unless defined $$patches{$storePath};
|
||||
|
||||
my $patchList = $$patches{$storePath};
|
||||
|
||||
my $found = 0;
|
||||
foreach my $patch (@{$patchList}) {
|
||||
if ($patch->{url} eq $url) {
|
||||
if ($patch->{hash} eq $hash) {
|
||||
$found = 1 if ($patch->{basePath} eq $basePath);
|
||||
} else {
|
||||
die "conflicting hashes for URL $url, " .
|
||||
"namely $patch->{hash} and $hash";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
push @{$patchList},
|
||||
{ url => $url, hash => $hash, size => $size
|
||||
, basePath => $basePath, baseHash => $baseHash
|
||||
, narHash => $narHash, type => $patchType
|
||||
};
|
||||
}
|
||||
|
||||
addPatch $patches, $storePath,
|
||||
{ url => $url, hash => $hash, size => $size
|
||||
, basePath => $basePath, baseHash => $baseHash
|
||||
, narHash => $narHash, patchType => $patchType
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue