Author: eelco
Date: Sun Dec  5 17:36:02 2010
New Revision: 24976
URL: https://svn.nixos.org/websvn/nix/?rev=24976&sc=1

Log:
* Add a script `nix-generate-patches'.
* Fix the binary patching test.

Added:
   nix/branches/sqlite/scripts/nix-generate-patches.in
Modified:
   nix/branches/sqlite/scripts/   (props changed)
   nix/branches/sqlite/scripts/Makefile.am
   nix/branches/sqlite/tests/binary-patching.sh
   nix/branches/sqlite/tests/init.sh

Modified: nix/branches/sqlite/scripts/Makefile.am
==============================================================================
--- nix/branches/sqlite/scripts/Makefile.am     Sun Dec  5 17:28:41 2010        
(r24975)
+++ nix/branches/sqlite/scripts/Makefile.am     Sun Dec  5 17:36:02 2010        
(r24976)
@@ -1,7 +1,7 @@
 bin_SCRIPTS = nix-collect-garbage \
   nix-pull nix-push nix-prefetch-url \
   nix-install-package nix-channel nix-build \
-  nix-copy-closure 
+  nix-copy-closure nix-generate-patches
 
 noinst_SCRIPTS = nix-profile.sh GeneratePatches.pm \
   find-runtime-roots.pl build-remote.pl nix-reduce-build \
@@ -41,4 +41,5 @@
   find-runtime-roots.pl.in \
   build-remote.pl.in \
   nix-reduce-build.in \
-  nix-http-export.cgi.in 
+  nix-http-export.cgi.in \
+  nix-generate-patches.in

Added: nix/branches/sqlite/scripts/nix-generate-patches.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nix/branches/sqlite/scripts/nix-generate-patches.in Sun Dec  5 17:36:02 
2010        (r24976)
@@ -0,0 +1,42 @@
+#! @perl@ -w -...@libexecdir@/nix
+
+use strict;
+use File::Temp qw(tempdir);
+use readmanifest;
+use GeneratePatches;
+
+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);
+readManifest $srcManifest, \%srcNarFiles, \%srcLocalPaths, \%srcPatches;
+
+my (%dstNarFiles, %dstLocalPaths, %dstPatches);
+readManifest $dstManifest, \%dstNarFiles, \%dstLocalPaths, \%dstPatches;
+
+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;
+
+writeManifest $dstManifest, \%dstNarFiles, \%dstPatches;

Modified: nix/branches/sqlite/tests/binary-patching.sh
==============================================================================
--- nix/branches/sqlite/tests/binary-patching.sh        Sun Dec  5 17:28:41 
2010        (r24975)
+++ nix/branches/sqlite/tests/binary-patching.sh        Sun Dec  5 17:36:02 
2010        (r24976)
@@ -19,10 +19,10 @@
 rm $RESULT
 
 # Generate binary patches.
-$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
+$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2
 
-$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
+$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
     file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3
 
 grep -q "patch {" $TEST_ROOT/manifest3
@@ -45,7 +45,7 @@
 [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ]
 
 # Add a patch from version 1 directly to version 3.
-$NIX_BIN_DIR/generate-patches.pl $TEST_ROOT/cache2 $TEST_ROOT/patches \
+$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \
     file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3
 
 # Rebuild version 3.  This should use the direct patch rather than the

Modified: nix/branches/sqlite/tests/init.sh
==============================================================================
--- nix/branches/sqlite/tests/init.sh   Sun Dec  5 17:28:41 2010        (r24975)
+++ nix/branches/sqlite/tests/init.sh   Sun Dec  5 17:36:02 2010        (r24976)
@@ -31,12 +31,13 @@
 ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/
 ln -s $TOP/scripts/nix-push $NIX_BIN_DIR/
 ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/
+ln -s $TOP/scripts/nix-generate-patches $NIX_BIN_DIR/
 mkdir $NIX_BIN_DIR/nix
 ln -s $bzip2_bin_test/bzip2 $NIX_BIN_DIR/nix/
 ln -s $bzip2_bin_test/bunzip2 $NIX_BIN_DIR/nix/
 ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/
 ln -s $TOP/scripts/download-using-manifests.pl $NIX_BIN_DIR/nix/
-ln -s $TOP/scripts/generate-patches.pl $NIX_BIN_DIR/
+ln -s $TOP/scripts/GeneratePatches.pm $NIX_BIN_DIR/nix/
 ln -s $TOP/scripts/readmanifest.pm $NIX_BIN_DIR/nix/
 
 cat > "$NIX_CONF_DIR"/nix.conf <<EOF
@@ -60,8 +61,9 @@
     $NIX_BIN_DIR/nix-install-package \
     $NIX_BIN_DIR/nix-push \
     $NIX_BIN_DIR/nix-pull \
+    $NIX_BIN_DIR/nix-generate-patches \
     $NIX_BIN_DIR/nix/readmanifest.pm \
-    $NIX_BIN_DIR/generate-patches.pl \
+    $NIX_BIN_DIR/nix/GeneratePatches.pm \
     ; do
     sed < $i > $i.tmp \
         -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to