Linux 为什么补丁找不到这个文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20646643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:40:11  来源:igfitidea点击:

Why does patch not find this file?

linuxfilepatchu-boot

提问by stdcerr

I would like to apply a patch to the u-boot sources but some how, Linux doesn't let me. What I have:

我想对 u-boot 源应用补丁,但有些方法,Linux 不允许我这样做。我拥有的:

reg@ubuntu:~/NextGen/trunk/FW/thirdparty/u-boot$ patch -p1 < ../u-boot/u-boot-2013.01-wr.patch 
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -uNr u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c u-boot-2013.01.modified/arch/powerpc/cpu/mpc85xx/cpu_init.c
|--- u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c 2013-01-15 13:47:42.000000000 -0800
|+++ u-boot-2013.01.modified/arch/powerpc/cpu/mpc85xx/cpu_init.c        2013-05-16 10:58:08.973906692 -0700
--------------------------
File to patch: ^C
reg@ubuntu:~/NextGen/trunk/FW/thirdparty/u-boot$ ls -l u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c
-rw-r--r-- 1 reg reg 16745 Jan 15  2013 u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c
reg@ubuntu:~/NextGen/trunk/FW/thirdparty/u-boot$ 

So why can it not find the file when it's perfectly at the right location? What's going on here?

那么为什么它在完全正确的位置找不到文件呢?这里发生了什么?

采纳答案by that other guy

There are three file paths involved here:

这里涉及三个文件路径:

  • The patch's original file: u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c
  • The patch's target file: u-boot-2013.01.modified/arch/powerpc/cpu/mpc85xx/cpu_init.c
  • The stripped target file due to -p1: arch/powerpc/cpu/mpc85xx/cpu_init.c
  • 补丁的原始文件: u-boot-2013.01/arch/powerpc/cpu/mpc85xx/cpu_init.c
  • 补丁的目标文件: u-boot-2013.01.modified/arch/powerpc/cpu/mpc85xx/cpu_init.c
  • 由于以下原因被剥离的目标文件-p1arch/powerpc/cpu/mpc85xx/cpu_init.c

Patch looks for the stripped target file, and it doesn't exist.

Patch 查找剥离的目标文件,但它不存在。

cd u-boot-2013.01and then patch -p1 < ../../u-boot/u-boot-2013.01-wr.patch, and you should have more luck.

cd u-boot-2013.01然后patch -p1 < ../../u-boot/u-boot-2013.01-wr.patch,你应该有更多的运气。