2011-10-11 00:11:08 +03:00
|
|
|
#! @perl@ -w @perlFlags@
|
2010-12-05 19:36:02 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use File::Temp qw(tempdir);
|
2011-10-11 00:11:08 +03:00
|
|
|
use Nix::Manifest;
|
|
|
|
use Nix::GeneratePatches;
|
2010-12-05 19:36:02 +02:00
|
|
|
|
|
|
|
if (scalar @ARGV != 5) {
|
|
|
|
print STDERR <<EOF;
|
|
|
|
Usage: nix-generate-patches NAR-DIR PATCH-DIR PATCH-URI OLD-MANIFEST NEW-MANIFEST
|
|
|
|
|
|
|
|
This command generates binary patches between NAR files listed in
|
|
|
|
OLD-MANIFEST and NEW-MANIFEST. The patches are written to the
|
|
|
|
directory PATCH-DIR, and the prefix PATCH-URI is used to generate URIs
|
|
|
|
for the patches. The patches are added to NEW-MANIFEST. All NARs are
|
|
|
|
required to exist in NAR-DIR. Patches are generated between
|
|
|
|
succeeding versions of packages with the same name.
|
|
|
|
EOF
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $narPath = $ARGV[0];
|
|
|
|
my $patchesPath = $ARGV[1];
|
|
|
|
my $patchesURL = $ARGV[2];
|
|
|
|
my $srcManifest = $ARGV[3];
|
|
|
|
my $dstManifest = $ARGV[4];
|
|
|
|
|
|
|
|
my (%srcNarFiles, %srcLocalPaths, %srcPatches);
|
2011-04-06 12:16:22 +03:00
|
|
|
readManifest $srcManifest, \%srcNarFiles, \%srcPatches;
|
2010-12-05 19:36:02 +02:00
|
|
|
|
|
|
|
my (%dstNarFiles, %dstLocalPaths, %dstPatches);
|
2011-04-06 12:16:22 +03:00
|
|
|
readManifest $dstManifest, \%dstNarFiles, \%dstPatches;
|
2010-12-05 19:36:02 +02:00
|
|
|
|
|
|
|
my $tmpDir = tempdir("nix-generate-patches.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
|
|
|
or die "cannot create a temporary directory";
|
|
|
|
|
|
|
|
generatePatches \%srcNarFiles, \%dstNarFiles, \%srcPatches, \%dstPatches,
|
|
|
|
$narPath, $patchesPath, $patchesURL, $tmpDir;
|
|
|
|
|
|
|
|
propagatePatches \%srcPatches, \%dstNarFiles, \%dstPatches;
|
|
|
|
|
2012-04-04 23:46:18 +03:00
|
|
|
# Optionally add all new patches to the manifest in $NIX_ALL_PATCHES.
|
|
|
|
my $allPatchesFile = $ENV{"NIX_ALL_PATCHES"};
|
|
|
|
if (defined $allPatchesFile) {
|
|
|
|
my (%dummy, %allPatches);
|
|
|
|
readManifest("$patchesPath/all-patches", \%dummy, \%allPatches)
|
|
|
|
if -f $allPatchesFile;
|
|
|
|
copyPatches \%dstPatches, \%allPatches;
|
|
|
|
writeManifest($allPatchesFile, {}, \%allPatches, 0);
|
|
|
|
}
|
|
|
|
|
2010-12-05 19:36:02 +02:00
|
|
|
writeManifest $dstManifest, \%dstNarFiles, \%dstPatches;
|