After patching diffpatch in ubuntu, I will write my personal summary. if you are free, I will continue to look at it: a: The original file B: the modified file diff-uNba & gt; c. patch has been installed. in the current folder, you must check the article... for more information, install diff patch in ubuntu. First, write your personal summary. if you are free, go on to the following page: a: original file B: the modified file diff-uN B a> c. patch is installed. in the current folder, you must check the file order patch-p0 <c. patch patches B to a patch-RE-p0 <c. patch restores the preceding configurations, which is equivalent to having nothing to do before aa: The original folder bb: The modified folder diff-ruN bb aa> cc. patch is released. in the current file, you must check the folder order cp cc. patch bb to fill the folder Ding, copy the patch to the bb folder. patch-p1 <cc. patch now contains the same content as aa in the bb folder. patch-RE-p1 <cc. the patch is restored to the above, which is equivalent to a detailed explanation that you haven't done anything before! If you have time, let's take a look. if you don't have time, just remember the above. the purpose of this learning is to patch every time my android kernel is modified, so it takes several hundred MB, that's why we have to figure it out! First, describe diff and patch. All options in the man online document will not be described here, which is unnecessary. In the 99% period, we only use a few options. Therefore, you must learn these options. 1. diff ------------------ NAME diff-find differences between two files SYNOPSIS diff [options] from-file to-file -------------------- simply put, diff is used to compare two files, then record it, the so-called diff patch. Syntax format: diff [option] source file (folder) destination file (folder), that is, to patch the source file (folder) to make it into the destination file (folder ), the term is "upgrade ". The following describes the three most common options:-r is a recursive option. With this option set, diff compares all the corresponding files in the source code directories of two different versions, including sub-directory files. -N option ensures that the patch file correctly processes the files that have been created or deleted. -U option creates patch files in a uniform format, which is more compact than the default format. 2. patch ---------------- NAME patch-apply a diff file to an original SYNOPSIS patch [options] [originalfile [patchfile] but usually just patch-pnum ------------------ In short, patch refers to the use of patches made by diff to convert source files (clips) and target files (clips. This means you can have a source file (folder)?> The target File (folder) or the target File (folder)?> Source File (folder ). The following describes some of the most common options:-p0 option to find the target File (folder)-p1 option from the current directory to ignore the first-level directory and start searching from the current directory. **************************************** * ******************* Here, the instance description: --- 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 searching for the pcitable file under modules under it to perform the patch operation. If the-p1 parameter is used, ignore the first-level Directory (regardless of the old directory), find the modules folder from the current directory, and find pcitable under it. The premise is that the current directory must be the directory where modules is located. The diff patch file can be located anywhere, as long as the path of the diff patch file is specified. Of course, you can use relative paths or absolute paths. However, I usually use relative paths. **************************************** * *******************-E option indicates that if an empty file is found, delete it. the-R option indicates that the "new" file and "old" file in the patch file are to be replaced now (in fact, the new version is patched to make it an old version) the following examples are used to analyze and solve the problem. There are two types: patching a single file and patching multiple files in the folder. Environment: log on with an armlinux user under RedHat 9.0. The directory tree is as follows: | -- bootloader | -- debug | -- images | -- kernel | -- program | -- rootfiles | -- software | -- source | -- sysapps | -- tmp '-- create a patch under the program folder under tools folder is used as an experiment, then go to the patch folder. 1. patch a single file. 1. create test files test0 and test1 [armlinux @ feng patch] $ cat> test0 < 111111> 111111> 111111> EOF [armlinux @ feng patch] $ more test0 111111 111111 111111 [armlinux @ feng patch] $ cat> test1 < 222222> 111111> 222222> 111111> EOF [armlinux @ feng patch] $ more test1 222222 111111 222222 111111 2. use diff to create a patch test1.patch [armlinux @ feng patch] $ diff-uN test0 test1> test1.patch [note: the-r option is not required because of a single file. There is no relation between the option sequence, that is, it can be-uN or-Nu .] [Armlinux @ feng patch] $ ls test0 test1 test1.patch [armlinux @ feng patch] $ more test1.patch ******************** **************************************** the patch file's structure patch header contains two lines starting with ---/++, indicates the file to be patched. --- The beginning indicates the old file, and the beginning of ++ indicates the new file. One patch file contains multiple patches. one patch file may contain many sections starting with ---/++. each section is used for a patch. Therefore, a patch file can contain many patches. A block is the part to be modified in the patch. It usually starts and ends with something that does not need to be modified. They are only used to indicate the location to be modified. They usually start with @ and end with another block or a new patch header. The indention block of the block is reduced into a column, which indicates whether to add or delete the row. The first column + number of the block indicates that this row is to be added. -Indicates that this row is to be deleted. There is no plus sign or minus sign, indicating that this is just referenced and does not need to be modified. * ************************ Diff commands will record the first creation of these two files in the patch file time, *** --- test0 09:12:01. 000000000 + 0800 ++ test1 09:13:09. 000000000 + 0800 @-222222 + 111111 @ + 111111 222222-111111 + [armlinux @ feng patch] $ patch-p0 <test1.patch patching file test0 [armlinux @ feng patch] $ ls test0 test1 test1.patch [armlinux @ feng patch] $ cat test0 222222 111111 222222 111111 3. patches can be removed, recover the old version [armlinux @ feng patch] $ patch-RE-p0 <test1.patch patching file test0 [armlinux @ feng patch] $ ls test0 test1 test1.patch [armlinux @ feng patch] $ cat test0 111111 111111 2. install patches for multiple files 1. create a test folder [armlinux @ feng patch] $ mkdir prj0 [armlinux @ feng patch] $ cp test0 prj0 [armlinux @ feng patch] $ ls prj0 test0 test1 test1.patch [armlinux @ feng patch] $ cd prj0/[armlinux @ feng prj0] $ ls test0 [armlinux @ feng prj0] $ cat> prj0name < --------> Prj0/strong> --------> EOF [armlinux @ feng prj0] $ ls prj0name test0 [armlinux @ feng prj0] $ cat =-------- prj0/prj0name -------- [armlinux @ feng prj0] $ cd .. [armlinux @ feng patch] $ mkdir prj1 [armlinux @ feng patch] $ cp test1 prj1 [armlinux @ feng patch] $ cd prj1 [armlinux @ feng prj1] $ cat> prj1name < ---------> Prj1/prj1name> ---------> EOF [armlinux @ feng prj1] $ cat prj1name --------- prj1/prj1name --------- [armlinux @ feng prj1] $ cd .. 2. create a patch [armlinux @ feng patch] $ diff-uNr prj0 prj1> prj1.patch [armlinux @ feng patch] $ more prj1.patch diff-uNr prj0/prj0name prj1/prj0name --- prj0/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 + [armlinux @ feng patch] $ ls prj0 prj1 prj1.patch test0 test1 test1.patch [armlinux @ feng patch] $ cp prj1.patch. /prj0 [armlinux @ feng patch] $ cd prj0 [armlinux @ feng prj0] $ patch-p1 <prj1.patch patching file prj0name patching file prj1name patching file test0 patching file test1 [armlinux @ feng prj0] $ ls prj1name prj1.patch test1 [armlinux @ feng prj0] $ patch-R-p1 <prj1.patch patching file prj0name patching file prj1name patching file test0 patching file test1 [armlinux @ feng prj0] $ prj0name prj1.patch test0 ------------------- summary: single file diff-uN from-file to-file> to-file.patch patch-p0 <to-file.patch patch-RE-p0 <to-file.patch multiple files diff-uNr from-docu to-docu> to-docu.patch patch -p1 <to-docu.patch patch-R-p1
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.