You are not logged in.

#1 2010-02-17 21:52:12

Registered: 2010-02-17
Posts: 3

How to correctly create a patch file?


I'm wondering what is the correct way to create a patch file for use in a PKGBUILD build function.

I have tried doing the following:
1) copy the file I want to patch (a Makefile) to Makefile.old in the same directory
2) edit the original Makefile
3) from that directory, run: diff -u Makefile.old Makefile > Makefile.patch
4) move Makefile.patch into the directory containing the PKGBUILD, and add it to sources
5) inside the build function, cd to the directory where the original Makefile is unpacked to ($srcdir/odamex-src-0.4.4), and run: patch -Nup0 < $srcdir/Makefile.patch || return 1
6) run makepkg, and the patch is not applied, giving an error and aborting the build:

Hunk #1 FAILED at 283.
1 out of 1 hunk FAILED -- saving rejects to file Makefile.rej

So, my question is, how do I do this properly?



#2 2010-02-17 23:20:50

Registered: 2007-10-28
Posts: 476

Re: How to correctly create a patch file?

That's pretty much how I would make a patch and use it from a PKGBUILD.
1. Does the diff work if you try to apply it using patch from the command line?
2. That Makefile is indented with tabs.  When editing the file to make the patch, did any tabs get replaced by spaces?


#3 2010-02-18 02:18:34

From: Sacremende
Registered: 2008-12-14
Posts: 438

Re: How to correctly create a patch file?

It sounds to me like you're running makepkg on a dirty srcdir.  Did you delete src/ before running makepkg?

edit: although now that I think about it, that's probably not it because I think the error would be "patch previously applied" or something.

Last edited by tdy (2010-02-18 02:24:31)

dots (or just the awesomewm config)

$ whatis this?
this?: nothing appropriate.


#4 2010-02-18 03:57:15

From: Croatia
Registered: 2008-03-22
Posts: 833

Re: How to correctly create a patch file?

Example for individual file

$ diff -Naur filename.ext.old filename.ext > filename-patchname.diff

cd "${srcdir}/${pkgname}-${pkgver}"
patch -uN filename.ext ../filename-patchname.diff || return 1

Example for multiple files

$ diff -Naur package-ver.old package-ver > package-patchname.diff

cd "${srcdir}/${pkgname}-${pkgver}"
patch -uNp1 -i ../${pkgname}-patchname.diff || return 1

Last edited by anrxc (2010-02-18 03:57:29)

You need to install an RTFM interface.


Board footer

Powered by FluxBB