How to install patch packages

Source: Internet
Author: User

If you already know how to use the diff/patch command, but you still don't know how to use it, we recommend that you review "Diff/patch usage and directory relationship" first"

1. Make a patch

Generate patches for a single file. Most of these patches are sufficient:

Srctree = linux-2.6
Myfile = Drivers/NET/mydriver. c
CD $ srctree
CP $ myfile. orig
VI $ myfile # Make your change
CD ..
Diff-runa $ srctree/$ myfile. orig $ srctree/$ myfile>/tmp/patch #/tmp/patch but you can specify it as needed.

To generate patches for multiple files, extract an original kernel (vanilla) or an unmodified kernel source code tree to correspond to your own source code tree and generate a diff. For example:
Tar xvfz linux-2.6.12.tar.gz

// Note: the original file and the file you modified must be consistent with the code you modified. Otherwise, other differences will be reflected in the patch package, for example, you do not need to find a compiled source code and a patch that has just been decompressed and not compiled. You should copy the source code and modify it in one of them, then, use the diff command in the parent directory of the two source codes to make the patch package. As shown below:
CP linux-2.6.12 linux-2.6.12-vanilla

// Modify your code in linux-2.6.12.

// Use the following command in the parent directory of the linux-2.6.12 and linux-2.6.12-vanilla after modification
Diff-runa linux-2.6.12-vanilla linux-2.6.12> XXX. Patch

 

2. Install the patch package (incomplete version)

If you do the patch yourself, you don't need to use the patch command, Because you directly modify your own kernel source code and compile the modified source code kernel directly.

If the downloaded patch is used, perform the following operations:

A patch is a text document that contains changes between two different versions of the source code tree.
Patches are created through the diff application.
In order to install a patch correctly, you need to know which base version the patch is generated and the patch will
The new version of the current source code tree. This information may appear in the original data of the patch file, or possibly
It can be inferred from the file name.
How to install and uninstall patches:
The patches in the Linux kernel are generated relative to the parent directory that saves the kernel source code directory.
This means that the file path in the patch file contains the name of the kernel source file directory it is based on (or such as "A/" and "B /"
And so on ).
This may not match the name of the kernel source code directory on your local machine.
Based on the kernel version is very useful ). You should switch to your kernel source code directory and remove the patch when patching.
(The-P1 parameter of the patch command can complete this task ).
To uninstall a previously installed patch, use the-R parameter.
Therefore, if you use the following command to install patches:
Patch-P1 <XXX. Patch # finding the correct directory is the key. It is recommended that you refer to my article "Diff/patch usage and directory relationship", which is intuitive.

// For example, the XXX. patch you mentioned above is done under the parent directory of the linux-2.6.12, it should be used in your linux-2.6.12 directory with this patch Oh
If you regret it, You can uninstall the patch:
Patch-r-P1 # Never tried

After the patch is installed, recompile your kernel.

// Compile the kernel should be done in the source directory, the above is the linux-2.6.12 directory to do the following operations

# Back up the. config file in the main directory of your kernel source code

Make mrproper

# Copy the. config file back to the source code home directory

Make

Make modules_install

Make install

// Then, test your kernel image file under/boot and restart the system.

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.