[Buildroot] Generating patches against packages source code

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Sat Dec 29 16:15:40 UTC 2012


Dear Stefan Fröberg,

On Sat, 29 Dec 2012 16:56:51 +0200, Stefan Fröberg wrote:

> That's what I meant. Those *inside* Signed-off tags.
> How should I add those inside Signed-off tags to individual patches
> (either my own make or 3rd party)
> applied to mesa3d ?
> 
> Does git diff command do that ? It does not have -s switch like commit does.

Ah, ok, I know understand your problem better. You're wondering how to
nicely generate patches against the package you're working on.

However, one thing you don't seem to realize is that the Signed-off-by
line is just pure text. There's nothing special about this line, so if
you have a patch sitting here in your directory, just open your
favorite text editor, and add the Signed-off-by line, that's it. You
don't need the '-s' option of Git to add the Signed-off-by line.

So basically, you have three choices (ordered below from the poorest to
the nicest, in my opinion).

1. Use the raw diff tool

We will use the raw diff tool only. So first, extract one copy of
mesa3d source code (outside of Buildroot), and rename the directory:

	tar xf mesa3d-8.0.5.tar.bz2
	mv mesa3d-8.0.5 mesa3d-8.0.5.orig

Extract another copy:

	tar xf mesa3d-8.0.5.tar.bz2

Then, do your modifications in the mesa3d-8.0.5/ directory. The
mesa3d-8.0.5.orig/ must be kept unchanged. Once you're done doing your
modifications, do:

	diff -ruN mesa3d-8.0.5.orig/ mesa3d-8.0.5/ > mesa3d-01-something.patch

And then, edit mesa3d-01-something.patch with your text editor to add
the patch description and the Signed-off-by line.

This method is really poor mainly because it is hard to handle multiple
patches with it. I do not recommend it.

2. Use quilt

quilt is a tool that allows to generate a stack of patches. I typically
use quilt as follows in the context of Buildroot. I start building a
package, and realize it doesn't work. So the package source code has
already been extracted in output/build/mesa3d-8.0.5/.

What I do is:

	cd output/build/mesa3d-8.0.5/
	mkdir patches
	quilt new mesa3d-01-something.patch
	quilt edit configure.ac
	# Do my changes in configure.ac

Then, I can test to build the package against (of course, don't do a
make clean, or remove the package directory, or you would loose your
patches). You can continue editing more files using "quilt edit
<filename>".

You can also add more patches:

	quilt new mesa3d-02-something-else.patch
	quilt edit ...

At any point, to refresh (i.e generate) the current patch in the
patches/ directory, run "quilt refresh". You can move forward and
backward through your patches using quilt pop and quilt push.

When you're on a particular patch, you can edit its description using
'quilt header -e'. There, write your patch description and
Signed-off-by line.

Once you're happy with your patches, make sure to refresh them all, and
then do:

	cp patches/*.patch ${your_buildroot_src}/package/mesa3d/

And that's its.

That's typically the method I use when I have only a few minor
modification to make to a package. It is practical because it can be
done directly within the build directory of a package.

3. Use Git

To use Git, the easiest way is to fetch the original source code of the
package by cloning the official repository of the project, and do the
modification here. So, something like:

	git clone git://somewhere.org/mesa3d.git
	cd mesa3d/
	# identify the tag that corresponds to the official release
	# you're working on, i.e 8.0.5. I'll assume it's called v8.0.5
	git branch buildroot-work v8.0.5
	git checkout buildroot-work

	# Do your work as usual with Git.

	# Then, to generate your patches:
	git format-patch master

	# All patches are named 000x-<something>.patch, so you'll have
	# to rename them. Typically, I do:
	for i in *.patch; do cp $i ${buildroot_src_dir}/package/mesa3d/mesa3d-$i ; done

Hope this helps,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


More information about the buildroot mailing list