我想在makefile中应用补丁.如果尚未应用补丁,则此工作正常.但是,如果我尝试在原始文件已经修补之后进行修改,则会导致makefile在完成之前退出.
Makefile –
all:
echo "starting patch"
patch -N < patchfiles/foo.patch
echo "patched"
在文件已经修补后尝试运行后的结果 –
usr-mbp:makefile usr$make
echo "starting patch"
starting patch
patch -N < patchfiles/foo.patch
patching file foo
Reversed (or prevIoUsly applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file foo.rej
make: *** [all] Error 1
我认为使用-N选项只会跳过补丁而不会导致任何错误.显然我错了.有关如何修复makefile的任何想法,以便它不会将跳过的补丁解释为错误?
谢谢!
编辑:
如果我想在补丁之前cd到目录,那么使用-patch不起作用.这是结果:
Makefile文件:
all:
echo "starting..."
cd tmp && \
-patch -N < ../patchfiles/Makefile.linux-p3041-3_0.patch
echo "finished."
结果:
usr-mbp:makefile usr$make
echo "starting..."
starting...
cd tmp && \
-patch -N < ../patchfiles/Makefile.linux-p3041-3_0.patch
/bin/sh: line 1: -patch: command not found
make: *** [all] Error 127
最佳答案
在命令causes Make to ignore its exit status前添加减号.
原文链接:https://www.f2er.com/linux/439997.html-patch -N < patchfiles/foo.patch
不过,你真的必须考虑到这一点;如果命令也可能因为你想要检测的原因而失败怎么办?也许在实际的补丁命令之前或之后添加一些健全性检查.