tar:文件在我们读取时已更改 [英] tar: file changed as we read it

查看:2114
本文介绍了tar:文件在我们读取时已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用maketar进行备份.执行makefile时,tar命令显示file changed as we read it.在这种情况下,

I am using make and tar to backup. When executing makefile, tar command shows file changed as we read it. In this case,

  • 出现警告时tar包没问题
  • 但是它停止了用于以下备份的tar命令
  • 显示警告的文件实际上并没有改变-发出警告真的很奇怪
  • 显示警告的文件是随机出现的,我的意思是,每次运行makefile时,显示警告的文件都是不同的
  • --ignore-failed-read没有帮助.我在MinGW中使用tar 1.23
  • 我刚刚将计算机更改为WIN7 64位.该脚本在旧版WIN7 32位上运行良好.但是tar版本不像1.23那样新.
  • the tar package is ok when the warning comes up
  • but it stops the tar command for the following backup
  • the file showing the warning in fact doesn't change -- it is really strange that the warning comes up
  • the files showing the warning come up randomly, I mean, everytime I run my makefile, the files showing the warning are different
  • --ignore-failed-read doesn't help. I am using tar 1.23 in MinGW
  • I just changed my computer to WIN7 64 bit. The script works well in old WIN7 32 bit. But the tar version is not as new as the 1.23.

如何在警告之后停止tar的警告以停止备份?

How can I stop the tar's warning to stop my backup following the warning?

编辑2 :这可能是原因

如上所述,bash shell脚本在我的旧计算机上运行良好.与旧计算机相比,msys版本有所不同. tar命令的版本也是如此.在旧计算机中,tar是1.13.19,在新计算机中是1.23.我复制了旧的tar命令,而没有将其依赖项msys-1.0.dll复制到新计算机上,并将其重命名为tar_old.我还更新了shell脚本中的tar命令并运行了该脚本.那一切都很好.因此,问题似乎出在tar命令上.我确定去皮时没有任何文件更改.新版本中的tar命令有问题吗?我不知道.

As I said above, the bash shell script worked well in my old computer. Comparing with the old computer, the msys version is different. So is the version of tar command. In the old computer, tar is 1.13.19 and it is 1.23 in the new computer. I copied the old tar command without copying its dependency msys-1.0.dll to the new computer and renamed it tar_old. And I also updated the tar command in the shell script and run the script. Then everything is ok. So, it seemed that the problem is the tar command. I am sure that there is no any file changed when taring. Is it a bug for tar command in new version? I don't know.

编辑1 :添加更多详细信息

备份由bash shell脚本调用.它扫描目标目录并生成makefile,然后调用make以使用tar命令进行备份.接下来是bash shell脚本构建的典型makefile.

The backup is invoked by a bash shell script. It scans the target directory and builds makefile then invokes make to use tar command for backup. Followed is a typical makefile built by the bash shell script.

#--------------------------------------------
# backup VC
#--------------------------------------------
# the program for packing
PACK_TOOL=tar

# the option for packing tool
PACK_OPTION=cjvf

# M$: C driver
WIN_C_DIR=c:

# M$: D driver
WIN_D_DIR=d:

# M$: where the software is
WIN_PRG_DIR=wuyu/tools
# WIN_PRG_DIR=

# where to save the backup files
BAKDIR=/home/Wu.Y/MS_bak_MSYS

VC_FRAMEWORK=/home/Wu.Y/MS_bak_MSYS/tools/VC/VC_framework.tar.bz2
VC_2010=/home/Wu.Y/MS_bak_MSYS/tools/VC/VC_2010.tar.bz2

.PHONY: all

all: $(VC_FRAMEWORK) $(VC_2010)

$(VC_FRAMEWORK): $(WIN_C_DIR)/$(WIN_PRG_DIR)/VC/Framework/*
    @$(PACK_TOOL) $(PACK_OPTION) "$@" --ignore-failed-read /c/$(WIN_PRG_DIR)/VC/Framework
$(VC_2010): $(WIN_C_DIR)/$(WIN_PRG_DIR)/VC/VS2010/*
    @$(PACK_TOOL) $(PACK_OPTION) "$@" --ignore-failed-read /c/$(WIN_PRG_DIR)/VC/VS2010

如您所见,tar包存储在〜/MS_bak_MSYS/tools/VC/VC_2010.tar.bz2中.我在〜/qqaa中运行脚本. ~/MS_bak_MSYS从tar命令中排除.因此,我正在创建的tar文件不在我尝试放入tar文件的目录内.这就是为什么我对发出警告感到奇怪.

As you can see, the tar package is stored in ~/MS_bak_MSYS/tools/VC/VC_2010.tar.bz2. I run the script in ~/qqaa. ~/MS_bak_MSYS is excluded from tar command. So, the tar file I am creating is not inside a directory I am trying to put into tar file. This is why I felt it strange that the warning came up.

推荐答案

我还遇到了tar消息在阅读时发生了变化".对我来说,这些消息是在bitbake构建环境中制作Linux文件系统的tar文件时发生的.此错误是偶发的.

I also encounter the tar messages "changed as we read it". For me these message occurred when I was making tar file of Linux file system in bitbake build environment. This error was sporadic.

对我来说,这不是由于从同一目录创建tar文件.我假设在tar文件创建过程中实际上有一些文件被覆盖或更改.

For me this was not due to creating tar file from the same directory. I am assuming there is actually some file overwritten or changed during tar file creation.

该消息是警告,并且仍会创建tar文件.我们仍然可以通过设置选项

The message is a warning and it still creates the tar file. We can still suppress these warning message by setting option

--warning=no-file-changed

( http://www.gnu.org/software/tar/manual/html_section/warnings.html )

在警告消息情况下,tar返回的退出代码仍为"1": http://www.gnu.org/software/tar/manual/html_section/Synopsis.html

Still the exit code return by the tar is "1" in warning message case: http://www.gnu.org/software/tar/manual/html_section/Synopsis.html

因此,如果我们从脚本中的某些函数调用tar文件,则可以处理如下退出代码:

So if we are calling the tar file from some function in scripts, we can handle the exit code something like this:

set +e 
tar -czf sample.tar.gz dir1 dir2
exitcode=$?

if [ "$exitcode" != "1" ] && [ "$exitcode" != "0" ]; then
    exit $exitcode
fi
set -e

这篇关于tar:文件在我们读取时已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆