[BusyBox] the patch applet

Glenn McGrath bug1 at optushome.com.au
Sat Jun 21 20:40:37 UTC 2003


Attached is a minimal patch applet to handle unified diff format.

Im pretty sure i have the logic correct, it correctly applies a linux
kernel diff which is a pretty good test.

I thought it would be pretty simple, but it was painfull for a number of
reasons,
 - Unified diff is standard practice as far as ive seen
 - The posix standard for patch doesnt mention the unified diff format.
 - Unified diff is GNU standard, but the source to GNU patch is ugly
enough that its not worth looking at.
 - The patches for the linux kernel use /dev/null when the source or
destination file doesnt exist, but it doesnt do it consistently, the
real filename is still in the diff command. What diff program do they
use ?
 - Why is there even two filenames in the diff format anyway, who cares
what the filename used to be, we just need to know what file it applies
to.

I nearly gave up in frustration. I still have some optimising to do,
this is just the first working version.

Issues
 - Only handles unified diff format.
 - Only option it accepts is -p<num>
 - Doesnt save the .rej files, im not even sure what they are... but it
does save the .orig though if a hunk fails.
 - The patch has to apply cleanly or the hunk will fail, no fuzz factor.
 - non interactive.

I will use it to apply patches before building a proper toolchain in a
linux from scratc htype environment. It would be more usefull with a
diff command as well, then it could be used on dpkg configure files, but
im not in a hurry to do that.

If i dont hear any objections i will apply a slightly improved version
in a few days.


Glenn 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 10805 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20030622/e848d013/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20030622/e848d013/attachment.pgp 


More information about the busybox mailing list