Use $XDG_RUNTIME_DIR for temporary files
This commit is contained in:
parent
fde819f2e2
commit
3bea429ae8
|
@ -1,7 +1,9 @@
|
||||||
package Nix::Utils;
|
package Nix::Utils;
|
||||||
|
|
||||||
|
use File::Temp qw(tempdir);
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
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\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*]+ )";
|
$urlRE = "(?: [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*]+ )";
|
||||||
|
|
||||||
|
@ -36,3 +38,9 @@ sub readFile {
|
||||||
close TMP or die;
|
close TMP or die;
|
||||||
return $s;
|
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";
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Nix::Manifest;
|
||||||
use Nix::Store;
|
use Nix::Store;
|
||||||
use Nix::Utils;
|
use Nix::Utils;
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
|
|
||||||
STDOUT->autoflush(1);
|
STDOUT->autoflush(1);
|
||||||
|
|
||||||
|
@ -247,8 +246,7 @@ $fast = 0;
|
||||||
|
|
||||||
|
|
||||||
# Create a temporary directory.
|
# Create a temporary directory.
|
||||||
my $tmpDir = tempdir("nix-download.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = mkTempDir("nix-download");
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
my $tmpNar = "$tmpDir/nar";
|
my $tmpNar = "$tmpDir/nar";
|
||||||
my $tmpNar2 = "$tmpDir/nar2";
|
my $tmpNar2 = "$tmpDir/nar2";
|
||||||
|
|
|
@ -4,7 +4,6 @@ use strict;
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
use Nix::Store;
|
use Nix::Store;
|
||||||
use Nix::Utils;
|
use Nix::Utils;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
|
|
||||||
|
|
||||||
my $dryRun = 0;
|
my $dryRun = 0;
|
||||||
|
@ -25,8 +24,7 @@ my @envExclude = ();
|
||||||
my $myName = $runEnv ? "nix-shell" : "nix-build";
|
my $myName = $runEnv ? "nix-shell" : "nix-build";
|
||||||
|
|
||||||
|
|
||||||
my $tmpDir = tempdir("$myName.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = mkTempDir($myName);
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
my $outLink = "./result";
|
my $outLink = "./result";
|
||||||
my $drvLink = "$tmpDir/derivation";
|
my $drvLink = "$tmpDir/derivation";
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#! @perl@ -w @perlFlags@
|
#! @perl@ -w @perlFlags@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
use Nix::Manifest;
|
use Nix::Manifest;
|
||||||
use Nix::GeneratePatches;
|
use Nix::GeneratePatches;
|
||||||
|
use Nix::Utils;
|
||||||
|
|
||||||
if (scalar @ARGV != 5) {
|
if (scalar @ARGV != 5) {
|
||||||
print STDERR <<EOF;
|
print STDERR <<EOF;
|
||||||
|
@ -31,8 +31,7 @@ readManifest $srcManifest, \%srcNarFiles, \%srcPatches;
|
||||||
my (%dstNarFiles, %dstLocalPaths, %dstPatches);
|
my (%dstNarFiles, %dstLocalPaths, %dstPatches);
|
||||||
readManifest $dstManifest, \%dstNarFiles, \%dstPatches;
|
readManifest $dstManifest, \%dstNarFiles, \%dstPatches;
|
||||||
|
|
||||||
my $tmpDir = tempdir("nix-generate-patches.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = mkTempDir("nix-generate-patches");
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
generatePatches \%srcNarFiles, \%dstNarFiles, \%srcPatches, \%dstPatches,
|
generatePatches \%srcNarFiles, \%dstNarFiles, \%srcPatches, \%dstPatches,
|
||||||
$narPath, $patchesPath, $patchesURL, $tmpDir;
|
$narPath, $patchesPath, $patchesURL, $tmpDir;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#! @perl@ -w @perlFlags@
|
#! @perl@ -w @perlFlags@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
use Nix::Utils;
|
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)
|
my $tmpDir = mkTempDir("nix-install-package");
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
|
|
||||||
sub barf {
|
sub barf {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use Nix::Store;
|
use Nix::Store;
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
|
@ -38,8 +37,7 @@ EOF
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tmpDir = tempdir("nix-prefetch-url.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = mkTempDir("nix-prefetch-url");
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
# Hack to support the mirror:// scheme from Nixpkgs.
|
# Hack to support the mirror:// scheme from Nixpkgs.
|
||||||
if ($url =~ /^mirror:\/\//) {
|
if ($url =~ /^mirror:\/\//) {
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
#! @perl@ -w @perlFlags@
|
#! @perl@ -w @perlFlags@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
use Nix::Config;
|
use Nix::Config;
|
||||||
use Nix::Manifest;
|
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;
|
my $manifestDir = $Nix::Config::manifestDir;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Temp qw(tempdir);
|
|
||||||
use File::Path qw(mkpath);
|
use File::Path qw(mkpath);
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
@ -12,8 +11,7 @@ use Nix::Manifest;
|
||||||
use Nix::Utils;
|
use Nix::Utils;
|
||||||
use Nix::Crypto;
|
use Nix::Crypto;
|
||||||
|
|
||||||
my $tmpDir = tempdir("nix-push.XXXXXX", CLEANUP => 1, TMPDIR => 1)
|
my $tmpDir = mkTempDir("nix-push");
|
||||||
or die "cannot create a temporary directory";
|
|
||||||
|
|
||||||
my $nixExpr = "$tmpDir/create-nars.nix";
|
my $nixExpr = "$tmpDir/create-nars.nix";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue