Re: How to apply a diff patch

Stanley Hopcroft <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Dear Sir,

I am writing to attempt an answer to your question about applying
patches for Netsaint.

Firstly, I suggest that this is not what you want to do. Please send the
messages that make you think you need to patch - send them to the list
(the patches may not be Netsaint and they may not be 'patches' but fixes
to the OS)

1 I haven't heard of public patches for Netsaint. The developers usually
fix whatever it is and release a new version. 

Generally only developers deal with patches and patching.

2 If you want to proceed then :-

2.1 Have you got a patch file ? You can tell because the content of the
file is text that looks like

--- check_coms.pl       Fri Aug 23 21:25:00 2002
+++ pams_rrd/check_coms_hack    Sat Aug 24 19:02:18 2002
@@ -1,11 +1,8 @@
 #!/usr/bin/perl
 
-# $Id: check_coms.pl,v 1.8 2002-08-23 21:24:13+10 anwsmh Exp anwsmh $
+# $Id: check_coms.pl,v 1.7 2002-08-23 21:20:02+10 anwsmh Exp anwsmh $
 
 # $Log: check_coms.pl,v $
-# Revision 1.8  2002-08-23 21:24:13+10  anwsmh
-# Correct mistaken use of '$delta_s[]' in assignment to $delta_f.
-#
 # Revision 1.7  2002-08-23 21:20:02+10  anwsmh
 # Correct &business_hours (set if conjunction of day __and__ hour).
 #
@@ -63,77 +60,99 @@
 
 # COMS is alive if the last entries are increasing and the time is
normal business hours
 
-my @last = splice(@fetched, 0, scalar(@fetched) -1) ;
+my @rrd = splice(@fetched, 0, scalar(@fetched) -1) ;

# last element of an RRD is always 0.
-my @delta = () ;
-for ( my $i = $#last; $i >= 1; $i-- ) {
-  my $delta_s = ($last[$i]->[1] ? $last[$i]->[1] - $last[$i-1]->[1]
: 0) ;
-  my $delta_f = ($last[$i]->[2] ? $last[$i]->[2] - $last[$i-1]->[2]
: 0) ;
-  push @delta, [ $delta_s, $delta_f ] ;
-}
 
If you don't have such a file, forget patching

2.2 Find out about patching from either

2.2.1 man patch

2.2.2 Greg Leheys excellent book 'Porting Unix software' (ORA)

2.2.3 Some internet web site

Patching is basically an automated way of turning one text file (such as
a C program) into another; it's a reproducible way of applying changes
(expressed as diffs).

If you get it wrong, you can munge your text file.

Be aware that there are all sorts of reasons for the patch to fail.

Here's an  example of applying a patch in p1.p.

tsitc> patch < p1.p 
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- check_coms.pl      Fri Aug 23 21:25:00 2002
|+++ pams_rrd/check_coms_hack   Sat Aug 24 19:02:18 2002
--------------------------
Patching file check_coms.pl using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 60.
Hunk #3 succeeded at 169.
Hunk #4 succeeded at 253.
Hunk #5 succeeded at 274.
done
tsitc> 

A rare site.

After the patch, there is no difference between the two files

tsitc> diff -u check_coms.pl pams_rrd/check_coms_hack

Also note that now there is a backup of the patched file
(check_coms.pl) saved in check_coms.pl.bak

tsitc> ll check_coms.pl*
-rwxr-xr-x  1 anwsmh  anwsmh  8100 Aug 24 19:56 check_coms.pl
-rwxr-xr-x  1 anwsmh  anwsmh  7223 Aug 23 21:25 check_coms.pl.orig
tsitc> 

3 Applying the patch is then a matter of only

prompt> patch < Your_Patch_File

and working out what to do when you 

3.1 are prompted to do things

3.2 the 'hunks' fail.

I suggest that you don't proceed unless you practise a __lot__ before
hand.  

Yours sincerely.


-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.