From WebOS Internals
Revision as of 21:59, 20 July 2009 by FreeTim (talk | contribs) (Initial rough draft - FreeTim)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using Diff

Using Diff to Determine changes when you have two files

Let's say you need to know the differences between a new patch file and your existing file.

Here is the command:

diff --unified --recursive --new-file firstfile secondfile  > differencesfile
diff -urn first second differences
  • Example:
diff -urn /usr/var/palm/somefile.pl  /usr/home/mine/somenewfile.pl > /usr/var/mine/differences.txt

Using Diff to Patch An Existing File

Let's say you have downloaded a patch file for your Pre and you want to apply them. Here is the procedure

  1. Make a backup of the file to your own folder on the pre
  2. Take the file you need to apply (the patch) and place it onto the pre (more detail needed here)---- I'll add later
  3. Now you can change the production copy

Apply a Patch

A destination file is the file you will be overwriting/ patching into. The patch is the file that contains the changes and is in your /usr/home folder.

To apply a patch to a single file,

  1. Make the file system read-write instead of read-only, then
  2. Use WinSCP to transfer the patch to your Pre, put it in the /usr/home or some similar folder (I use /usr/home/FreeTim/somepatch )
  3. Change to the directory where the DESTINATION system file is located using cd command
  4. Make a backup copy of the file somewhere safe (I copy it to my home directory) using cp command then finally,
  5. call patch command:

The command is

patch --strip=1 --remove-empty-files < /usr/home/somepatchfile.pl || echo "failures!"

In this example, change the /usr/home/somepatchfile.pl to the folder of the file you have on the Pre you want to apply as a patch.

If this works (nothing is returned) then you can check for differences after the patch, if you like. But if nothing is returned, then it worked.

To apply a patch to a single file, change to the directory where the file is located and call patch:

cd /usr/var/palm/something
patch --strip=1 --remove-empty-files < /usr/home/somepatchfile.pl  || echo "failures!"
  • No response indicates success

Check for Differences after the Patch

Let's say you want to just make sure the patch took effect.

Here is an example command.

diff --unified --recursive --new-file newfile existingfile
  • If there is no diff between "newfile" and "existingfile", you'll just be put back at your command prompt, showing that there are no differences - success!
  • Otherwise differences will be displayed.

If Differences Exist

Your choices here are

  • Use 'vi' and other commands to fix the files or
  • Just copy your (previously saved) original back into place.

This Wiki page

This document is a rough initial draft-- FreeTim3