You are hereHow to apply a patch to a drupal Module from Windows

How to apply a patch to a drupal Module from Windows


By Koder - Posted on 09 January 2009



I recently had to patch my Mollom Module that I have got installed on a Drupal installation. I just wanted to share with other folks as to how you can do this, especially from a Windows machine when you do not have access to a Linux or Unix command prompt to make changes or you do not have access to the patch utility.

In our example below we would try to patch the Mollom module with a patch that is avaialable at http://drupal.org/node/302941 . All this patch does is modify the module file to make it aware of the Guestbook form, so Mollom can spam protect your site's Guestbook as well.

Here are the steps:

- Download the "Patch" utility for Windows from Sourceforge at http://gnuwin32.sourceforge.net/packages/patch.htm

- Run setup.exe and choose all defaults, this would create a C:\Program Files\GnuWin32\bin folder on your machine and a start menu entry as well.

- Connect to your Drupal website using an FTP client, and naviagate to your Mollom module directory (this is usually /sites/all/modules/mollom directory

- From your Mollom module directory above, download the "mollom.module" file to your C:\Program Files\GnuWin32\bin directory

- Download the Mollom Patch from http://drupal.org/node/302941 also to the C:\Program Files\GnuWin32\bin folder

- Open up a Windows command prompt (by clicking Start -> run -> cmd and hit enter)

- Change your directory to the GNU Patch program directory on the command prompt by giving the command cd C:\Program Files\GnuWin32\bin

- Patch the Mollom.module file locally by typing "patch < NameOfThePatchFileYouDownloaded" without quotes

- It would confirm that the file has been patched succesfully, and would also create a backup copy of the file with a file extension of .orig

- Finally, Upload this patched mollom.module file to your web server to the /sites/all/modules/mollom directory, overwtiting the the file that exsists there. For backup purposes, also upload the .orig file that the patch process created.

Mollom should now be patched.

Although this example shows how the Mollom.module was patched, its the same process for patching any other drupal module files as well. The .patch file you download is actually a text file, if you read the file it would tell you exactly which file in your module directory is it patching and what it is doing! Good Luck!

Hi, thanks for this, it is exactly what I'm looking for. However, when I enter command prompt and type the command, i get this error: "patching file realname.module Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354 This application has requested the runtime to terminate it in an unusual way. Please contact the application's support team for more info." Any ideas? Obviously I'm trying to patch the realname module. Thanks
This post says you need --binary to get around that error. http://drupal.org/node/23844#comment-41593

The author for this article is currently away. I am sure you will get a response back as soon as they return, do check back!

Thanks

I have exactly the same problem !
I have used bynary, but it look to not work at the end anyway.. Microsoft Windows XP [Versione 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\matteo>cd ^V La sintassi del nome del file, della directory o del volume รจ incorretta. C:\Documents and Settings\matteo>cd C:\Programmi\GnuWin32\bin C:\Programmi\GnuWin32\bin>patch < 597654-theme.patch patching file domain_theme.admin.inc Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. C:\Programmi\GnuWin32\bin>patch < 597654-theme.patch --binary patching file domain_theme.admin.inc can't find file to patch at input line 42 Perhaps you should have used the -p or --strip option? The text leading up to this was: -------------------------- |Index: domain_theme/domain_theme.module |=================================================================== |RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_theme/domain_ theme.module,v |retrieving revision 1.16 |diff -u -p -r1.16 domain_theme.module |--- domain_theme/domain_theme.module 13 Jun 2009 20:02:40 -0000 1.16 |+++ domain_theme/domain_theme.module 7 Oct 2009 14:31:08 -0000 -------------------------- File to patch: domain_theme.admin.inc patching file domain_theme.admin.inc Hunk #1 FAILED at 238. 1 out of 1 hunk FAILED -- saving rejects to file domain_theme.admin.inc.rej C:\Programmi\GnuWin32\bin>patch < 597654-theme.patch --binary^A

AddThis

Popular content

Last viewed: