shell - 如何将 TMPDIR 环境变量设置为另一个目录?

标签 shell unix

我正在尝试编译 ffmpeg 并且 tmp 目录有问题,因为它是用 noexec 挂载的:

./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared Unable to create and execute files in /tmp. Set the TMPDIR environment variable to another directory and make sure that it is not mounted noexec. Sanity test failed.

If you think configure made a mistake, make sure you are using the latest version from SVN. If the latest version fails, report the problem to the ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "config.err" produced by configure as this will help solving the problem.


如何将 TMPDIR 环境变量设置为另一个目录?

最佳答案

我能够使用下面的代码完成它:

$ export TMPDIR=~/tmp-ffmpeg

$ mkdir $TMPDIR

$ ./configure \
  --enable-gpl \
  --enable-version3 \
  --enable-shared \
  --enable-nonfree \
  --enable-postproc \
  --enable-libfaac \
  --enable-libmp3lame \
  --enable-libopencore-amrnb \
  --enable-libopencore-amrwb \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libxvid \
  --enable-x11grab \
  --extra-cflags="-I/usr/local/include" \
  --extra-ldflags="-L/usr/local/lib"

$ make
$ make install
$ rm -rf $TMPDIR
$ unset TMPDIR
还有mktemp(1)命令。这样您就可以按如下方式设置 TMPDIR:
$ TMPDIR="$(mktemp -d -q ~/tmp/tmp.XXXXX)"
$ echo $TMPDIR
/home/marcelo/tmp/tmp.I8V9H
这应该适用于 GNU coreutils 以及 BSD(macOs、FreeBSD 等)。另请注意,您无需导出 TMPDIR 然后取消设置。而是尝试直接传递变量来配置:
$ TMPDIR="/foo/bar/baz" ./configure ...
希望它可以帮助其他人;-)

关于shell - 如何将 TMPDIR 环境变量设置为另一个目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11697214/

相关文章:

android - 如何通过 ADB shell 广播带有附加功能的 Intent ?

java - 将 IDL 枚举解析为 Java 枚举

c# - 如何将 Unix 时间戳转换为 DateTime,反之亦然?

bash - 如何在 shell 脚本中使用 tail -f ?

shell - 在 shell 脚本中连接到 FTPS 服务器

unix - crontab - 在目录中运行

regex - 在 Linux 中查找具有匹配模式的文件

c - System V 共享内存权限位 : meaning, 以及如何更改

c - 解释 C 中的一些函数

linux - 用于检查 sybase iq 状态的 shell 脚本