📄 00000064.htm
字号:
Both of these defaults can be overridden by command-line switches in this <BR>format: patch-kernel [ sourcedir [
<BR>patchdir ] ]. Patch-kernel will abort if any part of the patch fails, but if <BR>the patch applies cleanly it will invoke find, which
<BR>will delete all of the *.orig files which patch leaves behind.
<BR>
<BR>If you prefer to see the output of commands, or perhaps you would rather keep <BR>the *.orig files until you are certain the patched
<BR>source compiles, running patch directly (with the patch located in the kernel <BR>source top-level directory, as outlined above) has
<BR>been very reliable in my experience. In order to avoid uncompressing the <BR>patch before applying it a simple pipe will do the trick:
<BR>
<BR>gzip -cd patchXX.gz | patch -p1
<BR>
<BR>or:
<BR>
<BR>bzip2 -dc patchXX.bz2 | patch -p1
<BR>
<BR>After the patch has been applied the find utility can be used to check for <BR>rejected files:
<BR>
<BR>find . -name \*.rej
<BR>
<BR>At first the syntax of this command is confusing. The period indicates that <BR>find should look in the current directory and recursively
<BR>in all subdirectories beneath it. Remember the period should have a space <BR>both before and after it. The backslash before the
<BR>wildcard "*" "escapes" the asterisk in order to avoid confusing the shell, <BR>for which an asterisk has another meaning. If find locates
<BR>any *.rej files it will print the filenames on the screen. If find exits <BR>without any visible output it's nearly certain the patch
<BR>applied correctly.
<BR>
<BR>Another job for find is to remove the *.orig files:
<BR>
<BR>find . -name \*.orig -print0 | xargs -0r rm -f
<BR>
<BR>This command is sufficiently cumbersome to type that it would be a good <BR>candidate for a new shell alias. A line in your ~/.bashrc
<BR>file such as:
<BR>
<BR>alias findorig 'find . -name \*.orig -print0 | xargs -0r rm -f'
<BR>
<BR>will allow just typing findorig to invoke the above command. The single <BR>quotes in the alias definition are necessary if an
<BR>aliased command contains spaces. In order to use a new alias without logging <BR>out and then back in again, just type source
<BR>~/.bashrc at the prompt.
<BR>
<BR> Incidental Comments and Conclusion
<BR>
<BR>While putting this article together I upgraded the version of patch on my <BR>machine from version 2.1 to version 2.5. Both of these
<BR>versions come from the current FSF/GNU maintainers. Immediately I noticed <BR>that the default output of version 2.5 has been
<BR>changed, with less information appearing on the screen. Gone is Larry Wall's <BR>"...hmm" which used to appear while patch was
<BR>attempting to determine the proper lines to patch. The output of version 2.5 <BR>is simply a list of messages such as "patching file
<BR>[filename]", rather than the more copious information shown by earlier <BR>versions. Admittedly, the information scrolled by too quickly
<BR>to read, but the output could be redirected to a file for later perusal. This <BR>change doesn't affect the functionality of the program,
<BR>but does lessen the human element. It seems to me that touches such as the <BR>old "...hmm" messages, as well as comments in
<BR>source code, are valuable in that they remind the user that a program is the <BR>result of work performed by a living, breathing human
<BR>being, rather than a sterile collection of bits. The old behavior can be <BR>restored by appending the switch --verbose to the patch
<BR>command-line, but I'm sure that many users either won't be aware of the <BR>option or won't bother to type it in. Another difference
<BR>between 2.1 and 2.5 is that the *.orig back-up files aren't created unless <BR>patch is given the -b option.
<BR>
<BR>Patch is not strictly necessary for an end-user who isn't interested in <BR>trying out and providing bug-reports for "bleeding-edge"
<BR>software and kernels, but often the most interesting developments in the <BR>Linux world belong in this category. It isn't difficult to get
<BR>the hang of using patch, and the effort will be amply repaid.
<BR>
<BR>
<BR>Last modified: Mon 31 Aug 1998
<BR>
<BR>
<BR>
<BR> <BR>-- <BR> 白马带著她一步步的回到中原。白马已经老了,只能慢慢的走, <BR>但终是能回到中原的。江南有杨柳、桃花,有燕子、金鱼…… <BR>汉人中有的是英俊勇武的少年,倜傥潇洒的少年……但这个美 <BR>丽的姑娘就像古高昌国人那样固执: <BR> <BR> 「那都是很好很好的,可是我偏不喜欢。」 <BR> <BR>※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.99.18.67] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -