From: Ole Streicher <olebole@debian.org>
Date: Mon, 26 Mar 2018 17:13:33 +0200
Subject: [Fv] Change default temp location to /tmp

According to FHS, temporary files should be written to /tmp, and not to
the home directory. This patch moves the temp files there while keeping the
FVTMP behaviour intact.
---
 ftools/guis/fv/class/fvApp.tcl | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/ftools/guis/fv/class/fvApp.tcl b/ftools/guis/fv/class/fvApp.tcl
index e347cf0..74b8f26 100644
--- a/ftools/guis/fv/class/fvApp.tcl
+++ b/ftools/guis/fv/class/fvApp.tcl
@@ -445,37 +445,45 @@ itcl::body fvApp::_setupBackup { } {
    if { $isWin } {
       set fvBackupDir "fv_tmp"
       set fvHOME FV_HOME
+      set fvTMP TMP
    } elseif { $isMac } {
       set fvBackupDir "fv_temp_folder"
       set fvHOME HOME
+      set fvTMP TMPDIR
    } else {
       set fvBackupDir "fvtmp"
       set fvHOME HOME
+      set fvTMP TMPDIR
    }
      
    set currentTime [clock seconds]
    set currentPid  [pid]
 
-   set fvTmp "$fvBackupDir/fvTmp_${currentPid}_$currentTime"
+   set fvTmp "fvTmp_${currentPid}_$currentTime"
 
    if { ![info exist env(FVTMP)] } {
       if { ![info exist env($fvHOME)] } {
          error "Please set up your $fvHOME enviroment first"
          exit 
       } else {
-         if { [file exist [file join $env($fvHOME) $fvTmp]] } {
-	    file stat [file join $env($fvHOME) $fvTmp] fstat
+         if { ![info exist env($fvTMP)] } {
+	    set tmpdir "/tmp"
+	 } else {
+	    set tmpdir $env($fvTMP)
+	 }
+         if { [file exist [file join $tmpdir $fvTmp]] } {
+	    file stat [file join $tmpdir $fvTmp] fstat
 	    if { $fstat(type) != "directory"} {
-               puts "~/$fvTmp is not a directory, can not create back up files"
+               puts "$tmpdir/$fvTmp is not a directory, can not create back up files"
                exit
 	    } 
          } else {
-	    file mkdir [file join $env($fvHOME) $fvTmp]
+	    file mkdir [file join $tmpdir $fvTmp]
          }	       
-         set g_backupDir [file join $env($fvHOME) $fvTmp]
+         set g_backupDir [file join $tmpdir $fvTmp]
       }
    } else {
-      set g_backupDir $env(FVTMP)/$fvTmp
+      set g_backupDir $env(FVTMP)/$fvBackupDir/$fvTmp
       if ![file exists $g_backupDir] {
 	 file mkdir $g_backupDir
       }
