我在 CentOS 机器上编译一个软件时遇到了麻烦,下面列出的问题很具体,但我希望由此得出的正确方法可以应用于类似问题,因为这似乎不是特定于这个软件的方法。但说到重点...
在 CentOS 5.4 上构建标准化虚拟机时,我遇到了一个编译问题,我不知道 a) 为什么会发生这个错误,以及 b) 如何修复它,希望其他人也偶然遇到这个问题,我希望有人能帮助我在这里找到解决方案。
configure: error: newly created file is older than distributed files!
当我尝试运行安装程序并编译 Ruby Enterprise 时出现如下所示的错误,并且论坛上提供的解决方案(检查时间并触摸文件以更新与它们相关的时间)似乎没有帮助。
我可以采取什么步骤来找出该问题的原因?
[vagrant@vagrant-centos-5 ruby-enterprise-1.8.7-2009.10]$ sudo ./installer
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2009.10.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.
You can expect this from the installation process:
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
2. Ruby on Rails will be installed for Ruby Enterprise Edition.
3. You will learn how to tell Phusion Passenger to use Ruby Enterprise
Edition instead of regular Ruby.
Press Enter to continue, or Ctrl-C to abort.
Checking for required software...
* C compiler... found at /usr/bin/gcc
* C++ compiler... found at /usr/bin/g++
* The 'make' tool... found at /usr/bin/make
* Zlib development headers... found
* OpenSSL development headers... found
* GNU Readline development headers... found
--------------------------------------------
Target directory
Where would you like to install Ruby Enterprise Edition to?
(All Ruby Enterprise Edition files will be put inside that directory.)
[/opt/ruby-enterprise] :
--------------------------------------------
Compiling and optimizing the memory allocator for Ruby Enterprise Edition
In the mean time, feel free to grab a cup of coffee.
./configure --prefix=/opt/ruby-enterprise --disable-dependency-tracking
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock
这是在 virtualbox 上运行的虚拟机,主机和虚拟机的时间相同且是最新的。我也尝试过在使用 ntp-client 更新时间后运行此程序,但无济于事。我在阅读某人的这篇文章后尝试了此操作有类似的问题
[vagrant@vagrant-centos-5 ruby-enterprise-1.8.7-2009.10]$ date
Tue Apr 27 08:09:05 BST 2010
我尝试过的另一种方法是触摸构建文件夹中的顶层文件就像这里建议的那样,但这也没有起作用(说实话,我也不确定它为什么会起作用)
[vagrant@vagrant-centos-5 ruby-enterprise-1.8.7-2009.10]$ sudo touch ruby-enterprise-1.8.7-2009.10/*
我不确定接下来我可以做什么 - 问题似乎是返回此错误的 bash 配置脚本error: newly created file is older than distributed files!
,位于第 2214 行
{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5
echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; }
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$*" != "X $srcdir/configure conftest.file" \
&& test "$*" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
{ { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
alias in your environment" >&5
echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
alias in your environment" >&2;}
{ (exit 1); exit 1; }; }
fi
### PROBLEM LINE ####
# this line is the problem line - this is returned true, sometimes it isn't and I can't
# see a pattern that that determines when this will test will pass or not.
test "$2" = conftest.file
)
then
# Ok.
:
else
{ { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
Check your system clock" >&5
echo "$as_me: error: newly created file is older than distributed files!
Check your system clock" >&2;}
{ (exit 1); exit 1; }; }
fi
真正让人沮丧的是,这个脚本有时能工作,当虚拟机运行一个小时左右时,它可以工作,但在启动时却不行。我在 crontab 中没有看到任何提示运行每小时一次的任务,这些任务可能会改变系统状态,足以影响这个脚本的工作。
我对除此以外的事情一无所知。最好的方法是什么?
谢谢
答案1
今天我在新安装的机器上安装 ree-1.8.7-2011.03 时遇到了这个问题。
在配置 ntpd、检查硬件时钟并排除时钟和 tima 的实际问题后,错误消息仍然存在。最后,我将此错误追溯到包含的google-perftools目录。触摸该目录后配置脚本后,问题就解决了,并且 Ruby Enterprise Edition 的安装没有任何问题。
[mark@host347 ~]$ cd src/ree-1.8.7-2011.03/source/
[mark@host347 source]$ touch ./distro/google-perftools-1.7/configure
答案2
那个 configure shell 脚本中的“日期完整性检查”对我来说似乎很不合理,需要修复。看看这个:
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$*" != "X $srcdir/configure conftest.file" \
&& test "$*" != "X conftest.file $srcdir/configure"; then
因此,它会接触一个文件,然后尝试找出它的修改时间是否比的修改时间更新$srcdir/configure
,并通过调用ls
并将输出与固定字符串进行比较来实现这一点。作者写道
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
但我认为这是胡说八道。有太多版本/风格ls
和改变ls
' 输出 (他们甚至说出了一个) 的方法,无法确定ls
' 输出格式。
无论如何,还有更优雅的方法来实现这一点。例如在 bash 中(参见help test
):
if [ $FILE1 -nt $FILE2 ] ; then
echo "$FILE1 is newer than $FILE2"
elif [ $FILE2 -nt $FILE1 ] ; then
echo "$FILE2 is newer than $FILE1"
else
echo "$FILE1 and $FILE2 are equally new"
fi
或者寻找直接判断某个mtime是否是在未来!
find -L $FILE -newermt now -exec echo THE FILE {} IS COMING FROM THE FUTURE \;
或者
find -L $FILE -mtime -0 -exec echo THE FILE {} IS COMING FROM THE PRESENT OR THE FUTURE \;
现在自己编写补丁:-)
答案3
您没有过多谈论系统时钟性能。与其查看编译问题,不如测试系统时钟性能?NTP 可以帮助解决时钟漂移问题,但它无法修复不稳定的问题。如果硬件时钟坏了,您可能需要一块新主板。以下测试可能会有所帮助:
for i in `seq 1 60`
do
date
sleep 60
done
这应该会每分钟准确输出日期。如果输出看起来不像下面这样:
Tue Apr 27 13:33:28 ADT 2010
Tue Apr 27 13:34:28 ADT 2010
Tue Apr 27 13:35:28 ADT 2010
...
那么你遇到了硬件时钟问题。使用 NTP 等工具可能行不通。如果遇到硬件问题,硬件是最好的解决方案。