Production and application of patches in Linux

Source: Internet
Author: User
In Linux, patch production and application command introduction www.2cto.com use diff and patch. Diffdiff can compare two things and record the differences between the two. The general usage and common options during patch creation are: diff [option] source file (folder) purpose...
In Linux, patch production and application command introduction www.2cto.com use diff and patch. Diffdiff can compare two things and record the differences between the two. The general usage and common options for patching are: diff [option] source file (folder) destination file (folder)-r recursion. After the settings, diff compares all the corresponding files in the source code directories of two different versions, including subdirectory files. -N option ensures that the patch file correctly processes the files that have been created or deleted. -U outputs three rows before and after each modification. you can also use-u5 to specify more contexts. -E,-B,-w,-B, -- strip-trailing-cr ignores various gaps. for details, refer to the documentation and select as needed. Patchpatch applies the diff record results (that is, patches) to the corresponding files (clips. The most common usage is patch-pNUM. -P Num: ignore several layers of folders. -E option indicates that if an empty file is found, delete the patch that-R has canceled. To explain the-p parameter, you need to look at the following patch file segment: --- old/modules/pcitable Mon Sep 27 11:03:56 1999 ++ new/modules/pcitable Tue Dec 19 20:05:41 2000 if the parameter-p0 is used, it indicates finding a folder named old from the current directory, and then searching for the modules/pcitable file under it to execute the patch operation. If the-p1 parameter is used, ignore the first-level Directory (regardless of the old directory), find the folder of modules from the current directory, and then find pcitable under it. The application uses the preceding command to process a single file patch: # generate patch diff-uN from-file to-file> to-file.patch # patching patch-p0 <to-file.patch # cancel patch-RE-p0 <to-file.patch to patch the entire folder: # generate patch diff-uNr from-docu to-docu> to-docu.patch # patch cd to-docu patch-p1 <to-docu.patch # unpatch patch-R-p1 Because test1.patch is a single file, the-r option is not required. This command is patched as follows: --- test0 09:12:01. 000000000 + 0800 ++ test1 09:13:09. 000000000 + 0800 @-1, 3 + 1, 4 @ + 222222 111111-111111 + 222222 111111 to apply patches, you only need: $ patch-p0 <test1.patch patching file test0 now test0 is the same as test1. If you want to cancel the patch change, restore the old version: $ patch-RE-p0 <test1.patch patching file test0 folder patch www.2cto.com with the following environment: -- prj0/test0 prj0name -- prj1/test1 prj1nameprj0/prj0name contains the following three lines: -------- prj0/prj0name -------- prj1/prj1name contains the following three lines: -------- prj1/prj1name -------- use diff-uNr to create a patch. the patch file obtained by diff-uNr prj0 prj1> prj1.patch is: diff-uNr prj0/prj0name prj1/prj0name --- prj0/prj0name 09:25:11. 000000000 + 0800 ++ prj1/prj0name 08:00:00. 000000000 + 0800 @-+ @ ----------prj0/prj0name --------- diff-uNr prj0/prj1name prj1/prj1name --- prj0/prj1name 08:00:00. 000000000 + 0800 ++ prj1/prj1name 09:26:36. 000000000 + 0800 @-+ @ + --------- + prj1/prj1name + --------- diff-uNr prj0/test0 prj1/test0 --- prj0/test0 09:23:53. 000000000 + 0800 ++ prj1/test0 08:00:00. 000000000 + 0800 @-111111 + 111111 @-111111--diff-uNr prj0/test1 prj1/test1 --- prj0/test1 08:00:00. 000000000 + 0800 ++ prj1/test1 09:26:00. 000000000 + 0800 @-222222 0 + 111111 @ + 222222 + 111111 + + to apply this patch: $ ls prj0 prj1 prj1.patch $ cd prj0 $ patch-p1 <.. /prj1.patch patching file prj0name patching file prj1name patching file test0 patching file test1 at this time, you can use ls to see the patch result: $ ls prj1name test1, if you want to roll back the patch operation: $ patch-R-p1 <.. /prj1.patch patching file prj0name patching file prj1name patching file test0 patching file test1 $ ls prj0name test0
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.