Applying patches in Drupal modules from MAC OS X

By
César Álvarez's picture
César Álvarez
· 17/11/2014

The software required to apply patches onto any Drupal module comes by default on every version of Mac OS X. It is the patch command which must be launched from the command line through the Terminal.app
  
Applying patches through Terminal.app

The first thing to do is a backup of the patch to be applied (i.e. ejemploparche.patch) and copy it over to the same folder where the .module file lives.

Once this is done, check that the patch to be applied and the module are the same version by opening both files with a text editor and double-checking the review numbers. Review numbers look like this:

diff -u -r1.51 example.module

This command will search for version 1.51 of the example module.

If the version number is different than the expected one, several error messages will be displayed in the command line and you will cry in front of your Mac.

If the version number coincides, we can proceed.

Open the Terminal.app (Application/Utilities). A window will popup with something like this:

Last login: Fri Nov 14 08:56:19 on console Ordenador-de-pepe:~ admin$
Using the cd command (change directory) browse to the folder where both the module and the patch live in (i.e. "cd ~/Users/Sites/Misitiodrupal/sites/all/modules/example_module/")


Tip: you can drag & drop a file or folder from Finder to the terminal window and the path will auto complete. Basically you only need to type “cd” (with a final space) and drop the folder where the module & patch live and then press Enter.

Once you are in the correct folder, run the following command but replacing the name of the patch with the name of your patch:

$ patch < ejemploparche.patch

(NB: do not type the $ sign, this is only to show you how the command will look like I the command line)

That’s it! The original module is patched and ready to be used.

Share 
How can we help?Get in touch