Author: eelco
Date: Wed Nov 17 14:31:42 2010
New Revision: 24734
URL: https://svn.nixos.org/websvn/nix/?rev=24734&sc=1
Log:
* Before a build, show the disk space that the downloaded store paths
will approximately require.
Modified:
nix/branches/sqlite/scripts/copy-from-other-stores.pl.in
nix/branches/sqlite/scripts/download-using-manifests.pl.in
nix/branches/sqlite/scripts/readmanifest.pm.in
nix/branches/sqlite/src/libmain/shared.cc
nix/branches/sqlite/src/libstore/local-store.cc
nix/branches/sqlite/src/libstore/misc.cc
nix/branches/sqlite/src/libstore/misc.hh
nix/branches/sqlite/src/libstore/remote-store.cc
nix/branches/sqlite/src/libstore/store-api.hh
nix/branches/sqlite/src/libstore/worker-protocol.hh
nix/branches/sqlite/src/nix-worker/nix-worker.cc
Modified: nix/branches/sqlite/scripts/copy-from-other-stores.pl.in
==============================================================================
--- nix/branches/sqlite/scripts/copy-from-other-stores.pl.in Wed Nov 17
13:11:41 2010 (r24733)
+++ nix/branches/sqlite/scripts/copy-from-other-stores.pl.in Wed Nov 17
14:31:42 2010 (r24734)
@@ -63,10 +63,15 @@
`...@bindir@/nix-store --query --references $storePath`;
die "cannot query references of `$storePath'" if $? != 0;
+ my $narSize = `...@bindir@/nix-store --query --size $storePath`;
+ die "cannot query size of `$storePath'" if $? != 0;
+ chomp $narSize;
+
print "$deriver\n";
print scalar @references, "\n";
print "$_\n" foreach @references;
- print "0\n"; # !!! showing size not supported (yet)
+ print "$narSize\n";
+ print "$narSize\n";
}
else { die "unknown command `$cmd'"; }
Modified: nix/branches/sqlite/scripts/download-using-manifests.pl.in
==============================================================================
--- nix/branches/sqlite/scripts/download-using-manifests.pl.in Wed Nov 17
13:11:41 2010 (r24733)
+++ nix/branches/sqlite/scripts/download-using-manifests.pl.in Wed Nov 17
14:31:42 2010 (r24734)
@@ -64,6 +64,8 @@
print "$_\n" foreach @references;
my $size = $info->{size} || 0;
print "$size\n";
+ my $narSize = $info->{narSize} || 0;
+ print "$narSize\n";
}
else { die "unknown command `$cmd'"; }
Modified: nix/branches/sqlite/scripts/readmanifest.pm.in
==============================================================================
--- nix/branches/sqlite/scripts/readmanifest.pm.in Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/scripts/readmanifest.pm.in Wed Nov 17 14:31:42
2010 (r24734)
@@ -33,18 +33,8 @@
my $manifestVersion = 2;
- my $storePath;
- my $url;
- my $hash;
- my $size;
- my $basePath;
- my $baseHash;
- my $patchType;
- my $narHash;
- my $references;
- my $deriver;
- my $hashAlgo;
- my $copyFrom;
+ my ($storePath, $url, $hash, $size, $basePath, $baseHash, $patchType);
+ my ($narHash, $narSize, $references, $deriver, $hashAlgo, $copyFrom);
while (<MANIFEST>) {
chomp;
@@ -62,6 +52,7 @@
undef $hash;
undef $size;
undef $narHash;
+ undef $narSize;
undef $basePath;
undef $baseHash;
undef $patchType;
@@ -89,7 +80,8 @@
if (!$found) {
push @{$narFileList},
{ url => $url, hash => $hash, size => $size
- , narHash => $narHash, references => $references
+ , narHash => $narHash, narSize => $narSize
+ , references => $references
, deriver => $deriver, hashAlgo => $hashAlgo
};
}
@@ -100,8 +92,8 @@
addPatch $patches, $storePath,
{ url => $url, hash => $hash, size => $size
, basePath => $basePath, baseHash => $baseHash
- , narHash => $narHash, patchType => $patchType
- , hashAlgo => $hashAlgo
+ , narHash => $narHash, narSize => $narSize
+ , patchType => $patchType, hashAlgo => $hashAlgo
};
}
@@ -132,6 +124,7 @@
elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; }
elsif (/^\s*Type:\s*(\S+)\s*$/) { $patchType = $1; }
elsif (/^\s*NarHash:\s*(\S+)\s*$/) { $narHash = $1; }
+ elsif (/^\s*NarSize:\s*(\d+)\s*$/) { $narSize = $1; }
elsif (/^\s*References:\s*(.*)\s*$/) { $references = $1; }
elsif (/^\s*Deriver:\s*(\S+)\s*$/) { $deriver = $1; }
elsif (/^\s*ManifestVersion:\s*(\d+)\s*$/) { $manifestVersion =
$1; }
@@ -183,8 +176,9 @@
print MANIFEST " StorePath: $storePath\n";
print MANIFEST " NarURL: $patch->{url}\n";
print MANIFEST " Hash: $patch->{hash}\n";
- print MANIFEST " NarHash: $patch->{narHash}\n";
print MANIFEST " Size: $patch->{size}\n";
+ print MANIFEST " NarHash: $patch->{narHash}\n";
+ print MANIFEST " NarSize: $patch->{narSize}\n" if
$patch->{narSize};
print MANIFEST " BasePath: $patch->{basePath}\n";
print MANIFEST " BaseHash: $patch->{baseHash}\n";
print MANIFEST " Type: $patch->{patchType}\n";
Modified: nix/branches/sqlite/src/libmain/shared.cc
==============================================================================
--- nix/branches/sqlite/src/libmain/shared.cc Wed Nov 17 13:11:41 2010
(r24733)
+++ nix/branches/sqlite/src/libmain/shared.cc Wed Nov 17 14:31:42 2010
(r24734)
@@ -54,25 +54,26 @@
void printMissing(const PathSet & paths)
{
- unsigned long long downloadSize;
+ unsigned long long downloadSize, narSize;
PathSet willBuild, willSubstitute, unknown;
- queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize);
+ queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize,
narSize);
if (!willBuild.empty()) {
- printMsg(lvlInfo, format("the following derivations will be built:"));
+ printMsg(lvlInfo, format("these derivations will be built:"));
foreach (PathSet::iterator, i, willBuild)
printMsg(lvlInfo, format(" %1%") % *i);
}
if (!willSubstitute.empty()) {
- printMsg(lvlInfo, format("the following paths will be
downloaded/copied (%.2f MiB):") %
- (downloadSize / (1024.0 * 1024.0)));
+ printMsg(lvlInfo, format("these paths will be downloaded/copied (%.2f
MiB download, %.2f MiB unpacked):")
+ % (downloadSize / (1024.0 * 1024.0))
+ % (narSize / (1024.0 * 1024.0)));
foreach (PathSet::iterator, i, willSubstitute)
printMsg(lvlInfo, format(" %1%") % *i);
}
if (!unknown.empty()) {
- printMsg(lvlInfo, format("don't know how to build the following
paths%1%:")
+ printMsg(lvlInfo, format("don't know how to build these paths%1%:")
% (readOnlyMode ? " (may be caused by read-only store access)" :
""));
foreach (PathSet::iterator, i, unknown)
printMsg(lvlInfo, format(" %1%") % *i);
Modified: nix/branches/sqlite/src/libstore/local-store.cc
==============================================================================
--- nix/branches/sqlite/src/libstore/local-store.cc Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/src/libstore/local-store.cc Wed Nov 17 14:31:42
2010 (r24734)
@@ -839,6 +839,7 @@
info.references.insert(p);
}
info.downloadSize = getIntLine<long long>(run.from);
+ info.narSize = getIntLine<long long>(run.from);
return true;
}
Modified: nix/branches/sqlite/src/libstore/misc.cc
==============================================================================
--- nix/branches/sqlite/src/libstore/misc.cc Wed Nov 17 13:11:41 2010
(r24733)
+++ nix/branches/sqlite/src/libstore/misc.cc Wed Nov 17 14:31:42 2010
(r24734)
@@ -48,9 +48,9 @@
void queryMissing(const PathSet & targets,
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
- unsigned long long & downloadSize)
+ unsigned long long & downloadSize, unsigned long long & narSize)
{
- downloadSize = 0;
+ downloadSize = narSize = 0;
PathSet todo(targets.begin(), targets.end()), done;
@@ -88,6 +88,7 @@
if (store->querySubstitutablePathInfo(p, info)) {
willSubstitute.insert(p);
downloadSize += info.downloadSize;
+ narSize += info.narSize;
todo.insert(info.references.begin(), info.references.end());
} else
unknown.insert(p);
Modified: nix/branches/sqlite/src/libstore/misc.hh
==============================================================================
--- nix/branches/sqlite/src/libstore/misc.hh Wed Nov 17 13:11:41 2010
(r24733)
+++ nix/branches/sqlite/src/libstore/misc.hh Wed Nov 17 14:31:42 2010
(r24734)
@@ -31,7 +31,7 @@
will be substituted. */
void queryMissing(const PathSet & targets,
PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
- unsigned long long & downloadSize);
+ unsigned long long & downloadSize, unsigned long long & narSize);
}
Modified: nix/branches/sqlite/src/libstore/remote-store.cc
==============================================================================
--- nix/branches/sqlite/src/libstore/remote-store.cc Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/src/libstore/remote-store.cc Wed Nov 17 14:31:42
2010 (r24734)
@@ -191,9 +191,8 @@
writeInt(logType, to);
writeInt(printBuildTrace, to);
}
- if (GET_PROTOCOL_MINOR(daemonVersion) >= 6) {
+ if (GET_PROTOCOL_MINOR(daemonVersion) >= 6)
writeInt(buildCores, to);
- }
processStderr();
}
@@ -243,6 +242,7 @@
if (info.deriver != "") assertStorePath(info.deriver);
info.references = readStorePaths(from);
info.downloadSize = readLongLong(from);
+ info.narSize = GET_PROTOCOL_MINOR(daemonVersion) >= 7 ? readLongLong(from)
: 0;
return true;
}
Modified: nix/branches/sqlite/src/libstore/store-api.hh
==============================================================================
--- nix/branches/sqlite/src/libstore/store-api.hh Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/src/libstore/store-api.hh Wed Nov 17 14:31:42
2010 (r24734)
@@ -87,6 +87,7 @@
Path deriver;
PathSet references;
unsigned long long downloadSize; /* 0 = unknown or inapplicable */
+ unsigned long long narSize; /* 0 = unknown */
};
Modified: nix/branches/sqlite/src/libstore/worker-protocol.hh
==============================================================================
--- nix/branches/sqlite/src/libstore/worker-protocol.hh Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/src/libstore/worker-protocol.hh Wed Nov 17 14:31:42
2010 (r24734)
@@ -8,7 +8,7 @@
#define WORKER_MAGIC_1 0x6e697863
#define WORKER_MAGIC_2 0x6478696f
-#define PROTOCOL_VERSION 0x106
+#define PROTOCOL_VERSION 0x107
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
Modified: nix/branches/sqlite/src/nix-worker/nix-worker.cc
==============================================================================
--- nix/branches/sqlite/src/nix-worker/nix-worker.cc Wed Nov 17 13:11:41
2010 (r24733)
+++ nix/branches/sqlite/src/nix-worker/nix-worker.cc Wed Nov 17 14:31:42
2010 (r24734)
@@ -521,6 +521,8 @@
writeString(info.deriver, to);
writeStringSet(info.references, to);
writeLongLong(info.downloadSize, to);
+ if (GET_PROTOCOL_MINOR(clientVersion) >= 7)
+ writeLongLong(info.narSize, to);
}
break;
}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits