10

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

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?

stdcerr
  • 13,725
  • 25
  • 71
  • 128

1 Answers1

20

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

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

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

that other guy
  • 116,971
  • 11
  • 170
  • 194
  • 7
    Or instead of `cd`ing, just switch to `-p0`. What brought me here is that without `-p` it seems to ignore path. – x-yuri Oct 10 '18 at 10:40
  • 1
    `-p0` does indeed work, and in this case `patch` will look in both `u-boot-2013.01` and `u-boot-2013.01.modified` (in that order) for the file to patch. Neat. – that other guy Oct 10 '18 at 17:58