[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
131/376: Use $XDG_RUNTIME_DIR for temporary files
From: |
Ludovic Courtès |
Subject: |
131/376: Use $XDG_RUNTIME_DIR for temporary files |
Date: |
Wed, 28 Jan 2015 22:04:31 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 3bea429ae8190565978104db3dbbb5e1a53fc018
Author: Eelco Dolstra <address@hidden>
Date: Wed Aug 13 23:12:57 2014 +0200
Use $XDG_RUNTIME_DIR for temporary files
---
perl/lib/Nix/Utils.pm | 10 +++++++++-
scripts/download-using-manifests.pl.in | 4 +---
scripts/nix-build.in | 4 +---
scripts/nix-generate-patches.in | 5 ++---
scripts/nix-install-package.in | 4 +---
scripts/nix-prefetch-url.in | 4 +---
scripts/nix-pull.in | 4 ----
scripts/nix-push.in | 4 +---
8 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/perl/lib/Nix/Utils.pm b/perl/lib/Nix/Utils.pm
index 78d3db5..05cd92b 100644
--- a/perl/lib/Nix/Utils.pm
+++ b/perl/lib/Nix/Utils.pm
@@ -1,7 +1,9 @@
package Nix::Utils;
+use File::Temp qw(tempdir);
+
our @ISA = qw(Exporter);
-our @EXPORT = qw(checkURL uniq writeFile readFile);
+our @EXPORT = qw(checkURL uniq writeFile readFile mkTempDir);
$urlRE = "(?:
[a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:address@hidden&\=\+\$\,\-\_\.\!\~\*]+
)";
@@ -36,3 +38,9 @@ sub readFile {
close TMP or die;
return $s;
}
+
+sub mkTempDir {
+ my ($name) = @_;
+ return tempdir("$name.XXXXXX", CLEANUP => 1, DIR => $ENV{"TMPDIR"} //
$ENV{"XDG_RUNTIME_DIR"} // "/tmp")
+ or die "cannot create a temporary directory";
+}
diff --git a/scripts/download-using-manifests.pl.in
b/scripts/download-using-manifests.pl.in
index b670163..de63aec 100755
--- a/scripts/download-using-manifests.pl.in
+++ b/scripts/download-using-manifests.pl.in
@@ -6,7 +6,6 @@ use Nix::Manifest;
use Nix::Store;
use Nix::Utils;
use POSIX qw(strftime);
-use File::Temp qw(tempdir);
STDOUT->autoflush(1);
@@ -247,8 +246,7 @@ $fast = 0;
# Create a temporary directory.
-my $tmpDir = tempdir("nix-download.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir("nix-download");
my $tmpNar = "$tmpDir/nar";
my $tmpNar2 = "$tmpDir/nar2";
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index 74307a5..cf7efa8 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -4,7 +4,6 @@ use strict;
use Nix::Config;
use Nix::Store;
use Nix::Utils;
-use File::Temp qw(tempdir);
my $dryRun = 0;
@@ -25,8 +24,7 @@ my @envExclude = ();
my $myName = $runEnv ? "nix-shell" : "nix-build";
-my $tmpDir = tempdir("$myName.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir($myName);
my $outLink = "./result";
my $drvLink = "$tmpDir/derivation";
diff --git a/scripts/nix-generate-patches.in b/scripts/nix-generate-patches.in
index 969af91..0a29c05 100755
--- a/scripts/nix-generate-patches.in
+++ b/scripts/nix-generate-patches.in
@@ -1,9 +1,9 @@
#! @perl@ -w @perlFlags@
use strict;
-use File::Temp qw(tempdir);
use Nix::Manifest;
use Nix::GeneratePatches;
+use Nix::Utils;
if (scalar @ARGV != 5) {
print STDERR <<EOF;
@@ -31,8 +31,7 @@ readManifest $srcManifest, \%srcNarFiles, \%srcPatches;
my (%dstNarFiles, %dstLocalPaths, %dstPatches);
readManifest $dstManifest, \%dstNarFiles, \%dstPatches;
-my $tmpDir = tempdir("nix-generate-patches.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir("nix-generate-patches");
generatePatches \%srcNarFiles, \%dstNarFiles, \%srcPatches, \%dstPatches,
$narPath, $patchesPath, $patchesURL, $tmpDir;
diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in
index 9414541..a3187c7 100755
--- a/scripts/nix-install-package.in
+++ b/scripts/nix-install-package.in
@@ -1,7 +1,6 @@
#! @perl@ -w @perlFlags@
use strict;
-use File::Temp qw(tempdir);
use Nix::Config;
use Nix::Utils;
@@ -50,8 +49,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) {
}
-my $tmpDir = tempdir("nix-install-package.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir("nix-install-package");
sub barf {
diff --git a/scripts/nix-prefetch-url.in b/scripts/nix-prefetch-url.in
index bcd9197..24753bd 100755
--- a/scripts/nix-prefetch-url.in
+++ b/scripts/nix-prefetch-url.in
@@ -2,7 +2,6 @@
use strict;
use File::Basename;
-use File::Temp qw(tempdir);
use File::stat;
use Nix::Store;
use Nix::Config;
@@ -38,8 +37,7 @@ EOF
exit 1;
}
-my $tmpDir = tempdir("nix-prefetch-url.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir("nix-prefetch-url");
# Hack to support the mirror:// scheme from Nixpkgs.
if ($url =~ /^mirror:\/\//) {
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index 58dd2cf..77fb33b 100755
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -1,13 +1,9 @@
#! @perl@ -w @perlFlags@
use strict;
-use File::Temp qw(tempdir);
use Nix::Config;
use Nix::Manifest;
-my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
-
my $manifestDir = $Nix::Config::manifestDir;
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index bdd128a..1343099 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -2,7 +2,6 @@
use strict;
use File::Basename;
-use File::Temp qw(tempdir);
use File::Path qw(mkpath);
use File::stat;
use File::Copy;
@@ -12,8 +11,7 @@ use Nix::Manifest;
use Nix::Utils;
use Nix::Crypto;
-my $tmpDir = tempdir("nix-push.XXXXXX", CLEANUP => 1, TMPDIR => 1)
- or die "cannot create a temporary directory";
+my $tmpDir = mkTempDir("nix-push");
my $nixExpr = "$tmpDir/create-nars.nix";
- 122/376: Warn about untrusted binary caches in extra-binary-caches, (continued)
- 122/376: Warn about untrusted binary caches in extra-binary-caches, Ludovic Courtès, 2015/01/28
- 113/376: Update manual, Ludovic Courtès, 2015/01/28
- 126/376: Handle compound single dash options properly, Ludovic Courtès, 2015/01/28
- 124/376: Fix warning about non-existant -I directories, Ludovic Courtès, 2015/01/28
- 127/376: Use regular file GC roots if possible, Ludovic Courtès, 2015/01/28
- 128/376: nix-log2xml: Handle UTF-8 characters, Ludovic Courtès, 2015/01/28
- 132/376: nix-shell: Use $XDG_RUNTIME_DIR, Ludovic Courtès, 2015/01/28
- 120/376: download-from-binary-cache.pl: Respect $SSL_CERT_FILE, Ludovic Courtès, 2015/01/28
- 123/376: Remove pointless NIX_LOG_TYPE environment variable, Ludovic Courtès, 2015/01/28
- 136/376: Propagate remote timeouts properly, Ludovic Courtès, 2015/01/28
- 131/376: Use $XDG_RUNTIME_DIR for temporary files,
Ludovic Courtès <=
- 137/376: Reduce verbosity, Ludovic Courtès, 2015/01/28
- 133/376: Fix download-via-ssh, Ludovic Courtès, 2015/01/28
- 130/376: nix-log2xml: Handle newlines, Ludovic Courtès, 2015/01/28
- 143/376: nix-store -l: Automatically pipe output into $PAGER, Ludovic Courtès, 2015/01/28
- 139/376: Fix --attr parsing, Ludovic Courtès, 2015/01/28
- 142/376: Reduce test verbosity, Ludovic Courtès, 2015/01/28
- 138/376: Doh, Ludovic Courtès, 2015/01/28
- 135/376: nix-build: Propagate exit status from nix-store -r, Ludovic Courtès, 2015/01/28
- 125/376: Refactor option handling, Ludovic Courtès, 2015/01/28
- 134/376: build-remote.pl: Provide defaults for $NIX_CURRENT_LOAD and $NIX_REMOTE_SYSTEMS, Ludovic Courtès, 2015/01/28