【问题】
折腾:
【未解决】patch打补丁时出错:patch: **** malformed patch at line
期间,是在打补丁期间出错了:
CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch. 1 out of 1 hunk ignored -- saving rejects to file lib/regcomp.c.rej Patch failed! Please fix m4-1.4.16-001-MB_CUR_MAX.patch! make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_patched] Error 1
如图:
即:
Reversed (or previously applied) patch detected! Assume -R? [n] |
【解决过程】
1.此问题,很明显是:
之前已经打过一次patch:
m4-1.4.16-001-MB_CUR_MAX.patch
了,所以此处再次打此patch,才会有此提示的。
2.而此处的目标是:
希望可以忽略此错误,不再重复打patch,继续往下执行。
但是,经过一些折腾,都还是会fail:
CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] Skipping patch. 1 out of 1 hunk ignored -- saving rejects to file lib/regcomp.c.rej Patch failed! Please fix m4-1.4.16-001-MB_CUR_MAX.patch! make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_patched] Error 1 CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] n Skipping patch. 1 out of 1 hunk ignored -- saving rejects to file lib/regcomp.c.rej Patch failed! Please fix m4-1.4.16-001-MB_CUR_MAX.patch! make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_patched] Error 1 CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n]
3.所以,此时,不知道如何做,才能达到上述目的:
忽略此错误,不重复打此patch,然后继续执行。
4.另外需要说的是:
其实此处是make编译buildroot,倒是可以通过
make clean & make
去删除此打过了patch的文件,从而忽略此错误,重新编译。
但是不想要规避问题,还是尽量搞懂,遇到这种重复打patch的时候,如何忽略,如何不重复打patch,如何继续执行。
5.参考:
[linux-pm] [PATCH] doc/power: move power-related files to Documentation/power/
有:
Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all y |
感觉是:
y=yes=继续应用,打patch;
n=no=不打patch
e=edit=修改patch?
v=view=查看patch?
a=accept all y=接受所有修改?
但是之前的操作,的确就是使用n,表示不继续打patch啊。
6.然后通过先n后y,使得可以继续下去了:
CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] y Hunk #1 succeeded at 891 with fuzz 2 (offset 20 lines).
效果如图:
7. 但是,此处要去确认一下:
lib/regcomp.c
是否正常,确认后,是正常的,因为patch:
D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\m4\m4-1.4.16-001-MB_CUR_MAX.patch
的内容是:
--- m4-1.4.8.orig/lib/regcomp.c 2006-09-24 06:28:37.000000000 +0200 +++ m4-1.4.8/lib/regcomp.c 2007-01-06 20:53:10.000000000 +0100 @@ -871,6 +871,10 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); dfa->state_hash_mask = table_size - 1; +#ifndef MB_CUR_MAX +#define MB_CUR_MAX (0) +#endif + dfa->mb_cur_max = MB_CUR_MAX; #ifdef _LIBC if (dfa->mb_cur_max == 6
而对应的:
D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\regcomp.c
的内容是:
dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); dfa->state_hash_mask = table_size - 1; #ifndef MB_CUR_MAX #define MB_CUR_MAX (0) #endif #ifndef MB_CUR_MAX #define MB_CUR_MAX (0) #endif dfa->mb_cur_max = MB_CUR_MAX;
【总结】
此处的,对于:
Reversed (or previously applied) patch detected! Assume -R? [n] |
回复:n=no=表示不R=不reverse?
对于接下来的:
Apply anyway? [n] |
回复:y=yes=无论如何都去应用(此patch)?
好像就可以实现了:
对于已经打了patch的文件,不去修改,而可以继续执行的效果了。
【后记】
1.经过后面的,使用同样的先n后y的逻辑,结果是出现了“Hunk #1 FAILED at 1.”之类的现象:
CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05 $ make >>> host-m4 1.4.16 Patching package//m4 Applying m4-1.4.16-001-MB_CUR_MAX.patch using patch: patching file lib/regcomp.c Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] y Hunk #1 succeeded at 891 with fuzz 2 (offset 20 lines). Applying m4-1.4.16-no-fpending-redefinition.patch using patch: patching file ChangeLog Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] y Hunk #1 FAILED at 1. 1 out of 1 hunk FAILED -- saving rejects to file ChangeLog.rej patching file lib/fpending.h Reversed (or previously applied) patch detected! Assume -R? [n] n Apply anyway? [n] y Hunk #1 FAILED at 20. 1 out of 1 hunk FAILED -- saving rejects to file lib/fpending.h.rej patching file m4/fpending.m4 Reversed (or previously applied) patch detected! Assume -R? [n]
2.所以,专门去看看patch的用法:
看到是:
-R:reverse,表示撤回打补丁,还原内容 |
所以,此处的:
Assume -R? |
可以去试试,y=yes,看看效果,结果却直接退出了:
patching file m4/fpending.m4 Reversed (or previously applied) patch detected! Assume -R? [n] y Patch failed! Please fix m4-1.4.16-no-fpending-redefinition.patch! make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_patched] Error 1
这与我的目标:
能继续执行,相违背。所以,不管之前的先n后y是否是好做法,也还是继续先n后y的做法吧。。。
转载请注明:在路上 » 【已解决】打patch补丁时出错:Reversed (or previously applied) patch detected! Assume -R? [n]