[求助]有人知道patch文件怎样编译吗?

重复贴和参考价值不大的帖子,版主维护
回复
ruanx
帖子: 3
注册时间: 2007-08-16 20:33
送出感谢: 0
接收感谢: 0

[求助]有人知道patch文件怎样编译吗?

#1

帖子 ruanx » 2008-02-05 0:33

最近买了个ipod video,装了rockbox系统,有不少插件都是patch文件,说是要自己编译,不知道这些文件要怎样编译阿。
看了他们的论坛的教学帖是这样说的:
Preparation

Download the patch file after following the links on http://www.rockbox.org/patches.shtml... the file should either end in .diff or .patch
This file can be opened by Wordpad - double click on the file and select Wordpad as the program
You can see what files this patch is going to edit... for example:

Index: apps/status.c
===================================================================
RCS file: /cvsroot/rockbox/apps/status.c,v
retrieving revision 1.72
diff -u -r1.72 status.c
--- apps/status.c 6 Jul 2005 22:57:54 -0000 1.72
+++ apps/status.c 1 Aug 2005 15:34:12 -0000
@@ -82,6 +82,13 @@
status_draw(false);
}
+enum playmode status_get_ffmode(void)

The above code is part of a patch file... you can see that this part of the code is going to modify the file status.c in the apps folder
A patch or diff file can contain many sections of code like this and modify many files in one go
Move the .diff or .patch file to the source folder (eg C:\Rockbox\home\guest\rockbox-daily-XXXXXXXX\)

Patching

In the cmd window, go to the directory containing the patch (use the commands mentioned earlier on in this guide)
Type the command patch --binary -p0 < patchfilename where patchfilename is the name of the patch file you downloaded (eg jpeg.diff)
The Patch program should then patch the file... if this fails then try patch --binary -p1 < patchfilename instead (increase the number each time, up to a maximum of 5)
After you have finished patching the files, simply continue with Configuring Build instructions above
Sometimes (if the patch file isn't correctly generated) having the patch file in the root of the source files does not work, so move the patch file to the location of the files to be patched and run continue the steps below from there. In addition to this, some patches may required patching files in different locations... so repeat the process at all the different locations, until all the files have been patched (Note: first try all the patching attempts below before resorting to this)
If this fails too, then it is most likely because the patch was not designed for that particular version of the file you are patching, if this is the case then you will usually see messages telling you that a HUNK has failed eg. HUNK #2 failed at line 345 or something similar. Unless you like programming there isn't much you can do about this
If you wish to remove a patch then you just need to add a -R switch eg. patch --binary -p0 -R < patchfilename. As you can see this is identical to the command used for applying the patch but with a -R before the <
但是我用patch命令提示的是command not found!有哪位大虾能指点一下吗,谢谢
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#2

帖子 eexpress » 2008-02-05 0:50

只是你的这系统上面没patch命令吧。安装吧。
● 鸣学
ruanx
帖子: 3
注册时间: 2007-08-16 20:33
送出感谢: 0
接收感谢: 0

#3

帖子 ruanx » 2008-02-07 1:53

请问如何安装patch命令?
头像
boydd
帖子: 255
注册时间: 2007-05-10 19:42
来自: 南京, Deutschland, Karlsruhe
送出感谢: 0
接收感谢: 0
联系:

#4

帖子 boydd » 2008-02-07 4:04

sudo apt-get install patch
patch的作用就是把diff文件中做的改动添加到源文件上
回复

回到 “归档贴”