简体   繁体   中英

How to patch source files

I am trying to patch dmenu with the files provided here: http://aur.archlinux.org/packages.php?ID=27334

I do not know how to do it, I've read that I should do patch file-to-patch the-patch , but in the patch provided there is more than one file involved. I've tried patching manually but I failed, it will not compile.

Actually, it's patch < the_patch or cat the_patch | patch cat the_patch | patch .

You may need to use the -p<n> option which is used to strip off segments of the pathnames stored in the patch. For example, if the patch was created from one level above the source tree (like you were diffing one tree against another) and you want to apply the patch from within the source tree, you would need -p .

Another useful option is --dry-run . That will act like it's applying the patch, but won't modify any files. It's a good thing to use to test if you have the -p option correct and to see if the patch will apply cleanly.

What I normally do is change to the root of the source tree and then run cat <file> | patch -p1 --dry-run cat <file> | patch -p1 --dry-run . If I get errors about files not being found, I'll switch to -p0 . Once either of those works, I remove the --dry-run and do it for real.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM