OpenWrt Forum Archive

Topic: how to create a patch for a ported application

The content of this topic has been archived on 19 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

My question is in general on how to create a "successfull" patch for the OpenWrt.
Particularly, this question is related to snort

I am using a ported version of snort from the svn repository.
I want to add a new preprocessor.
For people, not familier with "preprocessor", basically add new functionality through addition of a new source files and modifying existing header and make files.

I did a untar of the existing ported packages from dl directory into tmp.  Made another copy.  In the copy, added the new "preprocessor" files and changed some Makefile/header file.  Then generated a patch using "diff -ruN directory.orig directory > patch".  Now, I copied this patch file as 100-xxx.patch to the package/400-snort-xxx folder.  when I run "make clean && make compile" from the parent folder i.e., "OpenWrt-SDK-Linux-i686-1"...the compilation process stops in the middle and asks me which file to patch ? once I entered the pathname it patches correctly.  However, I need it to create two new files in the tree, which it doesn't.  Note, there are two other patches that came with package which goes through without asking any questions.

As a work-around.  I generated a tarball of the new sourcetree and placed it in the "dl" directory and adjusted the md5sum checksum in the package/400-snort-xxx/Makefile but this time while compiling my patch works fine but the patches that came with the software stops and asks question !

I know I am missing something trivial here...
Any help is much appreciated.

thanks,
Krishnan

You generated your patch from the wrong directory.

The patch should look like this:

--- snort.orig/src/file.c       1970-01-01 01:00:00.000000000 +0100
+++ snort/src/file.c            1970-01-01 01:00:00.000000000 +0100

We use the command "patch -p1", which means that it will ignore the first part of the path (the "snort.orig/" or "snort/") and will attempt to find "src/file.c" relative to the current directory (when patch is run you'll be within the snort directory).

The discussion might have continued from here.