dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: "What is a Patch?" (was: install a patch)

"What is a Patch?" (was: install a patch)

From: BlueChip <>
Date: Mon, 28 Jun 2004 03:32:33 +0100

>Are patches incorporated into the daily builds of Rockbox?

No, you download them from sourceforge (and/or wherever-else)

I could confuse you by telling you all about cvs and how it works like
patches; But perhaps you would rather spend your time contemplating
something more relevant first...

A .patch/.pat/.dif/.diff is a plain text file which says:
o Look at [such] file
o Near line number [N],
o Find the text [blah1] and [blah2]
o Now, Just after [blah1] ...and before [blah2]
o Remove (-) [this] line of text
o Add (+) [that] line of text

That's it!

If the patch says "look for text [blah]" and that text is no longer in the
file*, then it will fail.

If it says "remove [this] line" and some other patch/hacker has already
fixed that bug, then it will fail.

*Even if someone does so much as add a space to the end of the line
  ...That is enough for "[blah]" to no longer exist (it is now "[blah] ")

Each new feature is likely to require many small modifications to several
different files, so the process is logically divided down ...each little
modification is called a "Hunk" now you know what "Hunk [X] failed"
means :) (...modification number [X] - couldn't find [blah] or [-remove_line])

There is some clever heuristics in there. So if, for example, someone just
re-orders the functions in a file, it will often track what happened and
manage to make the change anyway.

However, this is far from common ...especially with the older patches
much has changed in the last few weeks, let alone since March 2003.

My suggestion ...if you've got two brain cells to rub together, an aptitude
for logic problems, SOME PATIENCE (you may not get it right first time),
and a text editor:
o Open the patch file
o Count down the list (_at__at_) until you find the "Hunk" that failed
o Try to work out what the author was trying to do with the problem faile/hunk

There are 15 dozen hundred or two different styles of patch file. But they
are all the same where it matters. Here is your test:

Below is a portion of a patch ...Look; Contemplate; and then answer the
questions that follow ...if you get the right answers, you're possibly now
armed with enough information to try applying patch files by hand.

-------------- >-8 ----------------- >-8 ----------------- >-8 ---------------
diff -urN rockbox-old/apps/settings.h rockbox-new/apps/settings.h
--- rockbox-old/apps/settings.h 2003-07-15 12:04:20.000000000 +0200
+++ rockbox-new/apps/settings.h 2003-08-28 13:16:14.000000000 +0200
_at__at_ -219,7 +219,7 _at__at_

  /* repeat mode options */

  /* dir filter options */
diff -urN rockbox-old/apps/status.c rockbox-new/apps/status.c
--- rockbox-old/apps/status.c 2003-06-05 06:00:22.000000000 +0200
+++ rockbox-new/apps/status.c 2003-08-28 16:14:53.000000000 +0200
_at__at_ -41,6 +41,8 _at__at_
  static bool plug_state;
  static bool battery_state;

+int ABR_step=0;
  struct status_info {
      int battlevel;
      int volume;
_at__at_ -62,6 +64,9 _at__at_
  void status_set_playmode(enum playmode mode)
      current_mode = mode;
+ if (mode==STATUS_STOP)
+ ABR_step=0;
-------------- >-8 ----------------- >-8 ----------------- >-8 ---------------

How many files are edited:
Name the file(s) which are edited:
At what time of day did the hacker edit the file(s):
How many "Hunks" are there in the above patch in total:
The first hunk is identified by [this] text:
What line number do we expect to find [this] text on/near:
How many lines are REMOVED in the SECOND Hunk:
How many lines are ADDED in the FIRST Hunk:

Answers are a couple of PgDn's away

Good Luck,


apps/settings.h & apps/status.c
13:16 & 16:14
...note no space on the start or end!!!
0 (sorry)
1, well technically 1 line is CHANGED
...that is,we -remove the old line and +add the new line

>Applying patches is not an easy task :(
>If they are shiny new patches it should be almost as simple as typing
>"patch" in the DevKit.
>If they are old patches you will need to apply them by hand ("Hunk
>If you can program in C, this is relatively easy.
>If you are not a programmer, give up before you send yourself insane
>At 19:39 27/06/04, you wrote:
> >If you have to ask, it's probably not for you. Sorry :)
> >
> >However, what you need to do is download the source code and the
> >devkit (unless you're running Linux or OSX).
> >
> >Then you need to apply the patch to the source code and compile.
> >
> >If that sounds like something you're capable of, I'm sure the rest of
> >lsit will give you more detailed instructions, as I've never actually
> >attempted it myself.
> >
> >Joe
> >
> >fanus wrote:
> >>Hi Listers
> >>Can someone please explain how does one install a rockbox patch?
> >>Thanks
> >>Fanus

Received on 2004-06-28

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy