Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: sdk/lib/_internal/pub/lib/src/io.dart

Issue 465193002: Don't send tar a flag it can't understand. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/io.dart
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart
index bd0dd7a257c28bd6b80a987a20cf3ed6f6c9bd68..5be7cb1c563c43cb09efe337a734251dfb945c35 100644
--- a/sdk/lib/_internal/pub/lib/src/io.dart
+++ b/sdk/lib/_internal/pub/lib/src/io.dart
@@ -794,7 +794,7 @@ Future<bool> extractTarGz(Stream<List<int>> stream, String destination) {
}
var args = ["--extract", "--gunzip", "--directory", destination];
- if (Platform.operatingSystem == "linux") {
+ if (_noUnknownKeyword) {
// BSD tar (the default on OS X) can insert strange headers to a tarfile
// that GNU tar (the default on Linux) is unable to understand. This will
// cause GNU tar to emit a number of harmless but scary-looking warnings
@@ -822,6 +822,28 @@ Future<bool> extractTarGz(Stream<List<int>> stream, String destination) {
});
}
+/// Whether to include "--warning=no-unknown-keyword" when invoking tar.
+///
+/// This flag quiets warnings that come from opening OS X-generated tarballs on
+/// Linux, but only GNU tar >= 1.26 supports it.
+final bool _noUnknownKeyword = _computeNoUnknownKeyword();
+bool _computeNoUnknownKeyword() {
+ if (!Platform.isLinux) return false;
+ var result = Process.runSync("tar", ["--version"]);
+ if (result.exitCode != 0) {
+ throw new ApplicationException(
+ "Failed to run tar (exit code ${result.exitCode}):\n${result.stderr}");
+ }
+
+ var match = new RegExp(r"^tar \(GNU tar\) (\d+).(\d+)\n")
+ .firstMatch(result.stdout);
+ if (match == null) return false;
+
+ var major = int.parse(match[1]);
+ var minor = int.parse(match[2]);
+ return major >= 2 || (major == 1 && minor >= 23);
+}
+
String get pathTo7zip {
if (runningFromSdk) return assetPath(path.join('7zip', '7za.exe'));
return path.join(repoRoot, 'third_party', '7zip', '7za.exe');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698