Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: "What is a Patch?" (was: install a patch)
From: BlueChip (cs_bluechip_at_webtribe.net)
Date: 2004-06-28


>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
   (and/or)
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" ...so 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 ...so
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 (@@) 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
@@ -219,7 +219,7 @@
  #define DEFAULT_FF_REWIND_ACCEL_SETTING 3

  /* repeat mode options */
-enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
+enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, AB_REPEAT, NUM_REPEAT_MODES };

  /* dir filter options */
  enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST,
NUM_FILTER_MODES };
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
@@ -41,6 +41,8 @@
  static bool plug_state;
  static bool battery_state;

+int ABR_step=0;
+
  struct status_info {
      int battlevel;
      int volume;
@@ -62,6 +64,9 @@
  void status_set_playmode(enum playmode mode)
  {
      current_mode = mode;
+ if (mode==STATUS_STOP)
+ ABR_step=0;
+
      status_draw(false);
  }
-------------- >-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,

BlueChip

2
apps/settings.h & apps/status.c
13:16 & 16:14
3
"#define DEFAULT_FF_REWIND_ACCEL_SETTING 3"
...note no space on the start or end!!!
219
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
>Failed")
>If you can program in C, this is relatively easy.
>If you are not a programmer, give up before you send yourself insane
>;)
>
>BC
>
>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
>Windows
> >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
>the
> >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

_______________________________________________
http://cool.haxx.se/mailman/listinfo/rockbox



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa