配置脚本的问题

发布于 2024-10-10 01:42:51 字数 926 浏览 7 评论 0原文

我遇到了 ffmpeg 的 ./configure 脚本问题。我的 Linux 环境使用 busybox,它只允许使用有限的 Linux 命令集。 ffmpeg ./configure 脚本中使用的一个命令是 mktemp -u,这里的问题是 Linux 的 busybox 无法将 -u 开关识别为有效,因此它抱怨它并破坏了配置过程。

这是 ./configure 中使用 mktemp -u 命令的相关代码:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
    }
fi

tmpfile(){
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
        (set -C; exec > $tmp) 2>/dev/null ||
        die "Unable to create temporary file in $TMPDIR."
    append TMPFILES $tmp
    eval $1=$tmp
}

我根本不擅长 bash 脚本编写,所以我想知道是否有人有关于如何强制此配置脚本不使用 mktemp -u 并使用上面代码片段中提供的“替换”替代选项的想法。谢谢。

顺便说一句...简单地删除 -u 开关是行不通的。也不能将其替换为 -t-p。我相信必须完全绕过mktemp

I am running into a problem with the ./configure script for ffmpeg. My linux environment uses busybox, which only allows for limited set of linux commands. One command which is used in the ffmpeg ./configure script is mktemp -u, the problem here is the busybox for linux does not recognize the -u switch as valid, so it complains about it and breaks the configure process.

This is the relevant code in ./configure which uses the mktemp -u command:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$"
    }
fi

tmpfile(){
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
        (set -C; exec > $tmp) 2>/dev/null ||
        die "Unable to create temporary file in $TMPDIR."
    append TMPFILES $tmp
    eval $1=$tmp
}

I am not good with bash scripting at all, so I was wondering if anyone one had an idea on how I can force this configure script to not use mktemp -u and use the 'replacement' alternative option that is available in as per the snippet above. Thanks.

btw... simply removing the -u switch does not work. Nor does replacing it with -t, or -p. I believe the mktemp has to be bypassed completely.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

来日方长 2024-10-17 01:42:51

更改为:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$"
    }
fi

#if ! check_cmd type mktemp; then
if true; then # Force the use of mktemp()
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$"
    }
fi

可以选择删除整个 if fi 构造,以便剩下的只是 mktemp() 定义,但我'我宁愿把它们留下来,以记住需要做什么以及以防万一您需要返回。

Change this:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$"
    }
fi

To this:

#if ! check_cmd type mktemp; then
if true; then # Force the use of mktemp()
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$"
    }
fi

You could alternatively remove the entire if fi constructs so that what's left is just the mktemp() definition but I'd rather leave them in as a way to remember what needed to be done and in case you need to go back.

您的好友蓝忘机已上羡 2024-10-17 01:42:51

我只需更改配置脚本,将 -u 选项删除为 mktemp 并删除 set -C; (它设置 no-clobber 模式,并且要求该文件不存在;删除 -u 意味着您还需要删除 set -C)。

mktemp(1) 的 MacOS X 手册页说:

-u 在“不安全”模式下运行。在 mktemp 退出之前,临时文件将被取消链接。这比 mktemp(3) 稍好一些,但仍然引入了竞争条件。使用
不鼓励使用此选项。

生成的文件名由 mktemp 取消链接,然后立即由配置脚本重新创建,这有点愚蠢。删除 -u 意味着文件名已经存在,并且已安全创建。

如果您经常使用该软件,请将问题报告给该软件的开发人员或维护人员。

I would just change the configure script to drop the -u option to mktemp and remove the set -C; (which sets no-clobber mode, and requires the file to be absent; removing the -u means you need to remove the set -C too).

The MacOS X manual pages for mktemp(1) say:

-u Operate in ``unsafe'' mode. The temp file will be unlinked before mktemp exits. This is slightly better than mktemp(3) but still introduces a race condition. Use of
this option is not encouraged.

The generated file name is unlinked by mktemp, and then immediately re-created by the configure script, which is a trifle silly. Dropping the -u means that the file name will already exist, having been created securely.

If the software is something you are going to use often, then report the issue to the developer or maintainer of the software.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文