User Tools

Site Tools


patching

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
patching [2009/03/14 19:45]
darkaudax created Tutorial: How To Patch Drivers
patching [2018/10/05 22:57]
mister_x [Introduction] Updated link to patching
Line 1: Line 1:
 ====== Tutorial: How To Patch Drivers ====== ====== Tutorial: How To Patch Drivers ======
-Version: 1.00 March 14, 2009\\+Version: 1.01 March 15, 2009\\
 By: darkAudax By: darkAudax
  
Line 16: Line 16:
 Patches are easy to apply, once you understand a few simple concepts: Patches are easy to apply, once you understand a few simple concepts:
  
-    * Patches are usually for a specific versions of the source code.  This means old patches may not work with newer versions of the source code.  Sometimes they do, sometimes they don't.  As well, a patch may or may not work on older versions of the source code.   All things being equal, use a patch specifically written for your version of the source code.+    * Patches are usually for a specific version of the source code.  This means old patches may not work with newer versions of the source code.  Sometimes they do, sometimes they don't.  As well, a patch may or may not work on older versions of the source code.   All things being equal, use a patch specifically written for your version of the source code.
     * Patches are generally built from 'clean' unpatched program sources. So, one patch may make a change that causes other patches to fail.     * Patches are generally built from 'clean' unpatched program sources. So, one patch may make a change that causes other patches to fail.
     * Patches are not part of the released source code, thus do not be surprised it they don't work. Always keep a backup of your original program source!      * Patches are not part of the released source code, thus do not be surprised it they don't work. Always keep a backup of your original program source! 
  
-There is always the questions of+Other common questions:
  
   * What patches do I need?   * What patches do I need?
   * Where do I get the patch?   * Where do I get the patch?
    
-The [[http://aircrack-ng.org/doku.php|aircrack-ng wiki]] typically indicates which patches are required for particular drivers.  And the appropriate pages contain detailed installation and patching instructions.  See the [[drivers|drivers page]] for links to the various detailed pages.+The [[http://aircrack-ng.org/doku.php|aircrack-ng wiki]] typically indicates which patches are required for particular drivers.  And the appropriate pages contain detailed installation and patching instructions.  See the [[install_drivers|drivers installation page]] for links to the various detailed pages
 + 
 +You can obtain the patch in a variety of ways.  The wiki page normally provides a download link.  As well, patches are included in the aircrack-ng source package in the "patches" directory.  Many times patches are under development and you can find links to them on the [[http://forum.aircrack-ng.org|Forum]].
  
-You can obtain the patch in a variety of ways.  The wiki page normally provides a download link.  As well, patches are included in the aircrack-ng source package in the "patches" directory.  Many times patches are under development and you can find links to them on the [[http://forum.tinyshell.be|Forum]]. 
  
  
Line 42: Line 43:
    wget http://patches.aircrack-ng.org/rtl8187_2.6.24v3.patch    wget http://patches.aircrack-ng.org/rtl8187_2.6.24v3.patch
  
-Then you need to move the patch to the appropriate directory using the "mv" command.  The question arises as to which is the "appropriate directory"?  There is no right answer to the question.  It depends on what you are patching and how the patch was created.   You might need to try a few locations.  Here are some typical locations:+Then you need to move the patch to the appropriate directory using the "mv" command.  The question arises as to which is the "appropriate directory"?  There is no correct answer to the question.  It depends on what you are patching and how the patch was created.   Looking at the directories referenced in the patch itself usually gives you a good indication of where it should go.  You might need to try a few locations.  Here are some typical locations:
  
   * Same directory as the file(s) to be patched   * Same directory as the file(s) to be patched
Line 60: Line 61:
 If you want to test applying the patch: If you want to test applying the patch:
  
-   patch -Np0 --dryrun --verbose -i <name of the patch file>+   patch -Np0 --dry-run --verbose -i <name of the patch file>
  
-NOTE: There is double dash in front of "dryrun" and "verbose".+NOTE: There is double dash in front of "dry-run" and "verbose".
  
-It is always a good idea to perform at test prior to applying it for real.  This way you can avoid problems.+It is always a good idea to perform test prior to applying it for real.  This way you can avoid problems.
  
-Once the patch is install then you need to recompile the program.  This is typically done via:+Once the patch is installed then you need to recompile the program.  This is typically done via:
  
    make    make
Line 84: Line 85:
 ===== Troubleshooting Tips ===== ===== Troubleshooting Tips =====
  
-==== can't find file to patch at input line ====+==== Can't find file to patch at input line ====
  
 You get an error message similar to the following: You get an error message similar to the following:
Line 100: Line 101:
 There are a few possible solutions depending on the root cause of the problem: There are a few possible solutions depending on the root cause of the problem:
  
-  * Make sure the file you are trying to patch really exists on your system.  In the example above, verify that "ieee80211_crypt.h" really exists.  If if does not then install the source code which contains the file.  As well, most times you need the kernel headers and/or kernel source installed.  The version of the kernel headers/source MUST match the version of the kernel you are running.  "uname -r" will show you which kernel version you are running.  As well, Fedora requires the kernel-devel rpm to be installed. +  * Make sure the file you are trying to patch really exists on your system.  In the example above, verify that "ieee80211_crypt.h" really exists.  If if does notthen install the source code which contains the file.  As well, most times you need the kernel headers and/or kernel source installed.  The version of the kernel headers/source MUST match the version of the kernel you are running.  "uname -r" will show you which kernel version you are running.  As well, Fedora requires the kernel-devel rpm to be installed. 
-  * You have the patch located in the wrong directory.  Re-read the section in the Introduction section above regarding where to place the patch.  Sometimes you can get clues about where to place the patch by looking at patch itself.  The directory paths specified in the patch should give you an indication of where it should be placed.+  * You have the patch located in the wrong directory.  Re-read the section in the Introduction section above regarding where to place the patch.  Sometimes you can get clues about where to place the patch by looking at the patch itself.  The directory paths specified in the patch should give you an indication of where it should be placed.
   * Play with the "-pX" value.  This allows you to strip directories off of the referenced files in the patch.  Try -p0, -p1, -p2, etc.   * Play with the "-pX" value.  This allows you to strip directories off of the referenced files in the patch.  Try -p0, -p1, -p2, etc.
   * The version of the patch may be wrong for your kernel version.  Check to ensure that the patch you are using is known to work properly against the kernel you are running.   * The version of the patch may be wrong for your kernel version.  Check to ensure that the patch you are using is known to work properly against the kernel you are running.
 +
  
  
Line 125: Line 127:
   * In some rare cases, a few failures may still be ignored.   You can try compiling the program and see if it works.  Not a high probability but worth a try.   * In some rare cases, a few failures may still be ignored.   You can try compiling the program and see if it works.  Not a high probability but worth a try.
   * The version of the patch may be wrong for your kernel version.  Check to ensure that the patch you are using is known to work properly against the kernel you are running.  Most likely, you need an older or new version of the patch.   * The version of the patch may be wrong for your kernel version.  Check to ensure that the patch you are using is known to work properly against the kernel you are running.  Most likely, you need an older or new version of the patch.
 +  * If all hunks fail: The patch may be whitespace-damaged. Try adding the -l option to the patch command line.
 +  * Try applying the patch with the "fuzz" option: add "-F3" to the patch command line. (The number specifies the maximal fuzz allowed - 3 is a value that works well.)
   * If all else fails, you can try manually updating the source code by reviewing the patch and applying the changes by hand.   * If all else fails, you can try manually updating the source code by reviewing the patch and applying the changes by hand.
  
patching.txt · Last modified: 2018/10/05 22:57 by mister_x