Please provide instructions to apply patch.

Asked by Allan W. Macdonald

Hello community.

I want to build the source files for zoneminder on my (sort of headless) Lucid system (which is a desktop sitting in my garage and I am working from a laptop in my living room). I need instructions as to how to apply the patch that appears alongside the source tarball in this package. I presume the "diff" file is the "patch" which I apply with the "patch" program.

Before you all echo previous posts and recommend I install the precompiled binaries, I have already tried installing the binary package on my "headless" box using apt-get via an ssh terminal session and it fails for some reason (I will ask for help from that only if I can't get the source build to work - and it should, right?). Therefore I want to try to build from source to see if this will be more successful. Besides, I would like to learn a bit about this stuff.

The question I have is this: I can extract the tarball but I am a stupid dummy about how to apply the patch. Diff files are pretty impossible to read and understand (at least to me, anyway) so I am having a bit of trouble understanding what it does.

I tried to compile the "orig" build directory and it fails so maybe the diff file has a fix in it. If, after the patch is applied and I still can't get the build to compile, I'll ask more questions then.

So, in summary, what I need, for now, anyway, is instructions how to apply the patch: i.e. what is the command line I should use, where should the diff file be located and what should be my working directory (relative to the build directory)?

Any help would be greatly appreciated. Thanks in advance.


Question information

English Edit question
Ubuntu zoneminder Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
mycae (mycae) said :

patches can be applied with the "patch" program

for example, you can use it like so:

imagine you have afile called "my-patch.patch"

you can cd to the top level of the folder (this must be the same as when the patch was created) then issue the command

patch < my-patch.patch

assuming my-patch.patch was in the same folder.

This is equivalent to:

cat my-patch.patch | patch

Revision history for this message
Allan W. Macdonald (allan-w-macdonald) said :

Thanks, mycae.

Unfortunately, I don't quite understand yet. I have a couple of more questions:

Question 1: You mentioned a file named "my-patch.patch". I know that this is just an example and my questions sound stupid, but I am wondering why you picked "patch" for the file extension. The file I have is a "diff" file. Is this the same as a "patch"? Are we talking about the same thing?

Question 2:

The "patch" file I want to apply is available here:

The build tarball is here:

However, I am confused as to what to do - the build tarball extracts to a directory named "ZoneMinder-1.24.2". However, the "diff" file references two other directories:




Neither one of these names appear exactly in the tarball (close but Linux is case sensitive and the capitalized directory names don't match any of the directories in the diff file).

When I extract the tarball, should I rename the directory to one referenced in the diff file? If so, which one?

Should I also extract the source tarball again to another directo and rename the directory as well so that I have both named directories?

And then I run the patch command?

Question 3:
Also, some of the files mentioned in the diff file don't actually appear in the source tarball:

For example:

--- zoneminder-1.24.2.orig/config.sub
+++ zoneminder-1.24.2/config.sub

Am I missing something?

In closing:

I tried extracting the source tarball, renaming the directory to one of the directories in the patch, then I extracted the tarball again, renamed that directory too and ran patch from just above the two differently named source directories. The patch did not modify the directories at all - it just dumped some files into the directory from which the patch program was invoked.

I am at a bit of a loss. Please bear with me.



Revision history for this message
Best mycae (mycae) said :

>but I am wondering why you picked "patch" for the file extension.
Force of habit. I could call it anything; the extention is irrelevant, the patch program wont see it, and wouldn't care about it if it could.

The missing directory is probably due to the way the person generated the patch; they probably unzipped the tarball and renamed the directory according to the debian guidelines, which disallow uppercase letters.

You can "strip" these path components off using the -p option of patch, as in

patch -p2 < mypatch.diff

config.sub is an intermediate file generated by ./configure (autoconf); you can ignore this, but patch will probably spit out a few warnings.

You can play around with diff and patch to better understand their operation yourself, as instructed here:

Note that the patches you have will be in the so-called "unified" format.

Revision history for this message
Allan W. Macdonald (allan-w-macdonald) said :

Thanks mycae, that solved my question.