May 2007

patch is a open source tool used to apply bug fix, and diff is a tool for generating patch files.


When you do open source project ,after you made some bug fix ,you need to submit patch file:

1. prepare the original and the modified source code directory, say project.orig/ and project.mod/
2. make clean to remove the binaries
3. apply diff command at the root level of directory, and pipe them into a patch fileFor example:

diff -ru -xCVS -x’.#*’ -x’*.so’ -x’*~’ -x’*conf*’ -x’*.P*’ -x’Makefile*’ project.orig/ project.mod/ > project.patch

if you see unwanted diff of configure or binary files, add prefix -x to exclude those files as in the example.


To apply patches, copy the patch file to the source code root directory . (e.g. put project.patch to project.orig folder), then patch the source

patch -p1 < project.patch

to reverse the patch,add -R option

patch -Rp1 < project.patch

This problem has been troubling me until recently. When I use the vi editor as user “root”, the vi syntax is not working. However, the vi syntax works perfectly fine when you log on as other user.

The solution is simple, use vim instead of vi.

The cause of this lies in in /etc/profile.d/vim.* . vi only aliases to vim for user id greater than 100. User “root” is lower than 100 so it isn’t not aliased.

I believe the syntax files may not be available during boot level 1(single user mode), so vim is only used for other users.


If you don’t even have syntax color for normal users, make sure you have vim-full installed
$ apt-get install vim-full

then in vi, turn it on by : syntax on
or edit /etc/vim/vimrc and turn it on by default