The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Things look quiet here. But I've been doing a lot of blogging at dan.langille.org because I prefer WordPress now. Not all my posts there are FreeBSD related. I am in the midst of migrating The FreeBSD Diary over to WordPress (and you can read about that here). Once the migration is completed, I'll move the FreeBSD posts into the new FreeBSD Diary website.

Creating patch files 4 August 1999
Need more help on this topic? Click here
This article has no comments
Show me similar articles
A patch file contains the difference between two files.  A patch file is created using diff.

This article shows you how I created some diff files to upgrade the www.freebsd.org website to refer to http://www.freebsddiary.org instead of .com.  I happen to run the New Zealand www mirror, so I had the HTML on hand.

Creating copies of the originals
First I created some mirror images of the files I was about to amend.  I created a temp directory and directories herein which matched what I waa about to modify.  Note that I should have done these patches to the SGML, not the HTML.  See below for details.
# mkdir temp
# mkdir temp/news/
# mkdir temp/ja
# mkdir temp/projects
# cp docs.html temp
# cp news/newsflash.html temp/news/newsflash.html
# cp news/news.html temp/news/news.html
# cp ja/docs.html temp/ja/docs.html
# cp projects/index.html temp/projects/index.html
# cp projects/projects.html temp/projects/projects.html
Modify the copies
Then I modified the copies I made above.
# cd temp
# ee docs.html
# ee news/newsflash.html
# ee news/news.html
# ee ja/docs.html
# ee projects/index.html
# ee projects/projects.html
Create the patches
To create the patches, I used the diff command as described above.  The "-C 5" gives you 5 lines of context and allows the patch program to apply the diffs.
# diff -C 5 ../docs.html docs.html  > patch.diary
# diff -C 5 ../news/newsflash.html news/newsflash.html >> patch.diary
# diff -C 5 ../news/news.html news/news.html >> patch.diary
# diff -C 5 ../ja/docs.html ja/docs.html >> patch.diary
# diff -C 5 ../projects/index.html projects/index.html >> patch.diary
# diff -C 5 ../projects/projects.html projects/projects.html 
                                                       >> patch.diary

I then included this patch file when I submitted the PR.  If you want to look at the resulting patch file.

Apply the patches
The last step was to apply the patches to make sure the patches will work.  You'll see that one of the patches did not apply correctly.  That was the ../ja/docs.html patch.  I suspect this was because of the kanji, but I'm not sure.
# cd ..
# patch < patch.diary 
Hmm...  Looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../docs.html       Sat Jul 31 11:07:45 1999
|--- docs.html  Wed Aug  4 21:01:06 1999
--------------------------
Patching file docs.html using Plan A...
Hunk #1 succeeded at 250.
Hmm...  The next patch looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../news/newsflash.html     Mon Jul 26 11:03:00 1999
|--- news/newsflash.html        Wed Aug  4 21:09:19 1999
--------------------------
Patching file news/newsflash.html using Plan A...
Hunk #1 succeeded at 95.
Hmm...  The next patch looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../news/news.html  Thu Jun 17 11:01:51 1999
|--- news/news.html     Wed Aug  4 21:09:41 1999
--------------------------
Patching file news/news.html using Plan A...
Hunk #1 succeeded at 43.
Hmm...  The next patch looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../ja/docs.html    Sat Jun 26 11:05:58 1999
|--- ja/docs.html       Wed Aug  4 21:09:55 1999
--------------------------
Patching file docs.html using Plan A...
Hunk #1 failed at 242.
1 out of 1 hunks failed--saving rejects to docs.html.rej
Hmm...  The next patch looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../projects/index.html     Wed Aug  4 21:22:31 1999
|--- projects/index.html        Wed Aug  4 21:20:12 1999
--------------------------
Patching file index.html using Plan A...
Hunk #1 failed at 76.
1 out of 1 hunks failed--saving rejects to index.html.rej
Hmm...  The next patch looks like a new-style context diff to me...
The text leading up to this was:
--------------------------
|*** ../projects/projects.html  Wed Aug  4 21:22:31 1999
|--- projects/projects.html     Wed Aug  4 21:24:11 1999
--------------------------
Patching file projects/projects.html using Plan A...
Hunk #1 succeeded at 76.
done
Right after I submitted the above PR, I was told that it would be better if I'd done the changes against the SGML instead of the HTML.  The HTML for the website is generated from the SGML.  You can find these files at:

ftp://ftp.freebsd.org/pub/FreeBSD/branches/-current/www/

SGML is Standard Generalized Markup Language.  The following extract is from the Free Online Dictionary of Computing (FOLDOC) at http://nightflight.com/cgi-bin/foldoc.cgi?query=SGML

SGML is an International Standard that describes the relationship between a document's content and its structure. SGML allows document-based information to be shared and re-used across applications and computer platforms in an open, vendor-neutral format.


Share
Need more help on this topic? Click here
This article has no comments
Show me similar articles