Dimitri PISSARENKO 26.08.04 21:30

dimitri.pissarenko@gmx.net

















How to create patches
























Dimitri Pissarenko

dimitri.pissarenko@gmx.net





Purpose of the document

How to show differences between directories?

WinDiff


This tool can be downloaded from Petri (2004).

diff -r dir1 dir2

The command


diff -r dir1 dir2


shows all the differences between the directories dir1 and dir2. It produces a text output, which is rather unsuitable for humans.

How to create a patch?

This section is based upon Compaq Servers And Linux (2003).


In order to create a patch, which updates olddir to newdir, following command should be invoked


diff -Naur olddir newdir > new-patch



How to apply a patch?

Invoke the command


patch -d directoryToPatch -p1 -i ../patch-file


where directoryToPatch is the directory to be patched and patch-file is the patch to be applied.

Practical example

In the directory examples you'll find directories demetrix-0.0.10 and demetrix-0.0.11, using which you can experiment with diff and path.


Let's create a patch, which updates demetrix-0.0.10 to demetrix-0.0.11 and then actually apply this patch to see the effect.

Step 1: Verify that demetrix-0.0.10 and demetrix-0.0.11 are different

Use WinDiff for this.

Step 1: Creating a patch

cd into the examples directory. Then, enter the following command


diff -Naur demetrix-0.0.10 demetrix-0.0.11 > patch-2004-05-04-demetrix-0.0.10

Step 2: Copy old directory

Now copy demetrix-0.0.10 to a new directory demetrix-0.0.10-2 by means of the command


cp -r demetrix-0.0.10 demetrix-0.0.10-2


We will use out patch to update demetrix-0.0.10-2 to demetrix-0.0.11.

Step 3: Verify that demetrix-0.0.10-2 and demetrix-0.0.10 are equal

Use WinDiff for this.

Step 4: Apply patch to demetrix-0.0.10-2

Invoke


patch -d demetrix-0.0.10-2 -p1 -i ../patch-2004-04-05-demetrix-0.0.10

Conventions

The name of the path should include following three pieces of information:


References

Petri (2004)

Daniel Petri, 2004, Where can I download the Windows 2000 Resource Kit tools?, http://www.petri.co.il/download_free_reskit_tools.htm (URL accessed on May 4, 2004)

Compaq Servers And Linux (2003)

Compaq Servers And Linux, 2003, How to create and use a patch in Linux, http://www.cpqlinux.com/patch.html (URL accessed on May 4, 2004)


4/4