Check for permissions to write temporary files. Bug #142308
authorfuzzyray <fuzzyray@gentoo.org>
Sun, 3 Sep 2006 21:26:12 +0000 (21:26 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Sun, 3 Sep 2006 21:26:12 +0000 (21:26 -0000)
svn path=/; revision=313

trunk/src/revdep-rebuild/revdep-rebuild

index 94a3f456e5536324a61b03787c609bb47a1531b6..9093b400c9764f83a606c82092e45bf434ad132c 100755 (executable)
@@ -135,7 +135,25 @@ done
 NOCOLOR=$(portageq envvar NOCOLOR)
 
 # Base of temporary files names.
-LIST=~/.revdep-rebuild
+touch ${HOME}/.revdep-rebuild_0.test 2>/dev/null
+if [ $? -eq 0 ]
+then
+       LIST="${HOME}/.revdep-rebuild"
+       rm ~/.revdep-rebuild_0.test
+else
+       # Try to use /var/tmp since $HOME is not available
+       touch /var/tmp/.revdep-rebuild_0.test 2>/dev/null
+       if [ $? -eq 0 ]
+       then
+               LIST="/var/tmp/.revdep-rebuild"
+               rm /var/tmp/.revdep-rebuild_0.test
+       else
+               echo
+               echo "!!! Unable to write temporary files to either $HOME or /var/tmp !!!"
+               echo
+               exit 1
+       fi
+fi
 
 shopt -s nullglob
 shopt -s expand_aliases