[comp.emacs] How are diff files used to update the distribution ?

SKAPUR@sbccmail.BITNET (Sanjay Kapur) (01/18/87)

I copied version 18.33 of Gnu-emacs last month.
I now also have the diff file diff-18.33-18.35.

How can I use the diff file to update the 18.33 version to 18.35 ?

Sanjay Kapur

skapur@sbccmail.bitnet
or
skapur%sbccmail.bitnet@wiscvm.arpa

karl@cbrma.att.com (Karl Kleinpaste) (01/21/87)

SKAPUR@sbccmail.BITNET writes:
>I copied version 18.33 of Gnu-emacs last month.
>I now also have the diff file diff-18.33-18.35.
>How can I use the diff file to update the 18.33 version to 18.35 ?

It requires that you get a copy of Larry Wall's patch program, which
reads diff files and applies the identified changes automatically to
your local copies of the files referenced.  Check your neighborhood
mod.sources archive for the latest patch.
-- 
Karl

montnaro@sprite.UUCP (01/21/87)

In article <8701192041.AA01426@EDDIE.MIT.EDU> SKAPUR@sbccmail.BITNET (Sanjay Kapur) writes:
>I copied version 18.33 of Gnu-emacs last month.
>I now also have the diff file diff-18.33-18.35.
>How can I use the diff file to update the 18.33 version to 18.35 ?

1. cd to the directory containing the GNU Emacs "dist" directory.

2. create the following symbolic links:

	ln -s dist dist-18.33
	ln -s dist dist-18.35

3. Check the beginning of diff-18.33-18.35 for any instructions. Create any
new files given (they will be at the beginning of the diff file). Trim the
instructions and any new files from the beginning of the diff file. You
don't strictly have to do this, but it speeds up patch's first patch
enormously.

4. execute

	patch -p < diff-18.33-18.35

Patch will spit out lots of messages. You will want to keep an eye on things
for "Hunk failed" messages. In particular, unless the constant emacs-version
in dist/lisp/version.el is "18.33.0" that particular patch will fail. No big
deal, just edit version.el and set emacs-version to "18.35.0".

Other failed hunks will turn up in whatever-file.type.rej (i.e.,
version.el.rej) for the previous example. If you have made local changes it
is possible that they will conflict with the distributed changes. At any
rate, you will have to compare the source file with the diff output in the
.rej file manually and figure out what the problem is. There are usually few
problems.

When a file is successfully patched, the original will be moved to
whatever-file.type.orig and the new one placed in whatever-file.type.

5. Remake emacs.


Skip Montanaro

ARPA: montanaro%desdemona.tcpip@ge-crd.arpa
UUCP: seismo!rochester!steinmetz!desdemona!montanaro
GE DECnet: csbvax::mrgate!montanaro@desdemona@smtp@tcpgateway

wohler@sri-spam.istc.sri.com (Bill Wohler) (01/22/87)

  the following is an excerpt from a README.local file that i maintain
  in my emacs directory in case i die tomorrow and someone should have
  to maintain emacs here.

  it describes the method that use to get patch to work as
  automatically as possible with the minimum amount of editing of the
  diff file.

  i'll welcome any improvements in wording or design to this method.
  
							--bw

NOTE: the example given in this README file was that we were upgrading
from dist-18.33 to dist-18.35.

* Incorporate the diff file.
** Edit the diff file.  
*** Write the "new file" portions to their respective files.  
*** Remove any diff references to non-existent files.  For instance, I
    do not maintain cpp or shortnames directories.
** Run patch on the diff file.
*** First, move the diff file into the same directory that contains
    the emacs directory.  Make a symbolic link from a file called
    dist-18.33 to the emacs directory.  The actual name of this file
    is taken from the diff file.  Pick either the old or new
    distribution name for the symbolic link.  
*** Then run "patch -p < diff-18.33-18.35" (or whatever your patch
    file is) and watch the fun.  The symbolic link can then be
    removed.  You may have to manually edit some files if the patch
    fails--this is where you get to be creative.
** Remove the .rej and .orig files created by patch once you feel that
   everything is right.

earle@smeagol.UUCP (01/28/87)

In article <1128@steinmetz.steinmetz.UUCP>, montnaro@sprite.UUCP writes:
> In article <big#@EDDIE.MIT.EDU> SKAPUR@sbccmail.BITNET (Sanjay Kapur) writes:
>>I copied version 18.33 of Gnu-emacs last month.
>>I now also have the diff file diff-18.33-18.35.
>>How can I use the diff file to update the 18.33 version to 18.35 ?
> 
> 1. cd to the directory containing the GNU Emacs "dist" directory.
> 
> 2. create the following symbolic links:
> 
> 	ln -s dist dist-18.33
> 	ln -s dist dist-18.35

This is not necessary.  Just go to the top level Emacs directory in your
filesystem heirarchy.  See note after #4.

> 3. Check the beginning of diff-18.33-18.35 for any instructions. Create any
> new files given (they will be at the beginning of the diff file). Trim the
> instructions and any new files from the beginning of the diff file. You
> don't strictly have to do this, but it speeds up patch's first patch
> enormously.

An easy way to do this is to search-forward for '=====', since a line of =
divides each new/replacement file.  When you get to the line, either write
down the name of the file or grab it if you have a mouse based system (like
a Sun).  Then delete all the lines in the buffer up to and including the line
you just found with '====='.  Then search for the next occurance of that line;
when it reaches there go back one line and tell the editor to write out all 
lines from 1 to point to the named file that you saved/grabbed.  Repeat this
cycle (get file name, delete from line 1 to line with file name, go find
next line with '=====', write lines 1 to (line-w/-=== - 1)) until you have
reached the beginning of the `diff' section; then you can nuke lines 1 to point
again.  This just leaves the diffs remaining; as Skip says, this helps 
`patch' start up faster.

Note that using `vi' (heresie!) for this kind of "quick-hit" editting *loses*
because `vi' can't handle long lines of input and Emacs can.  This will bite
you on the diffs file for 18.35-18.36!

> 4. execute
> 	patch -p < diff-18.33-18.35

No; if you invoke as 
	patch -c -p1 < diff-file
`patch' will skip past the `dist-18.xx/' in the diffs and get to the pathnames
relative to where you are now.  This makes step 2. unnecessary if you have 
done step 1.

> Patch will spit out lots of messages. You will want to keep an eye on things
> for "Hunk failed" messages. In particular, unless the constant emacs-version
> in dist/lisp/version.el is "18.33.0" that particular patch will fail. No big
> deal, just edit version.el and set emacs-version to "18.35.0".

It is easier to edit `lisp/version.el' *before* running `patch'; since every
`diff' file is between versions, one can guarantee that version.el will be
patched and therefore the patch will always fail if you do not `reset' it to
the original distributed version ahead of time!

> Other failed hunks will turn up in whatever-file.type.rej (i.e.,
> version.el.rej) for the previous example. If you have made local changes it
> is possible that they will conflict with the distributed changes. At any
> rate, you will have to compare the source file with the diff output in the
> .rej file manually and figure out what the problem is. There are usually few
> problems.
> 
> When a file is successfully patched, the original will be moved to
> whatever-file.type.orig and the new one placed in whatever-file.type.
> 
> 5. Remake emacs.

AUUGGH!  No!  
4.5. Run your present Emacs in the `lisp' subdirectory; execute
M-x byte-recompile-directory to make new .elc files from the updated/new
.el files.  

THEN you can rebuild Emacs.  Also, you should remove the .orig
files from {src,lisp,etc,wherever} if all the patches installed correctly.
Before rebuilding Emacs, if you keep versions of the distribution on mag tape
(as I do), you can do a `make clean' in each of the subdirectories to remove
executables and .o files and the like, and then tar/cpio/whathaveyou to tape.
Then you can rebuild Emacs & friends.
-- 
	Greg Earle	UUCP: sdcrdcf!smeagol!earle; attmail!earle
	JPL		ARPA: elroy!smeagol!earle@csvax.caltech.edu
AT&T: +1 818 354 4034	      earle@jplpub1.jpl.nasa.gov (For the daring)
Should I start with the time I SWITCHED personalities with a BEATNIK hair       stylist or my failure to refer five TEENAGERS to a good OCULIST?