#!/bin/bash

# Author: Ben Wing <ben@xemacs.org>

modpatches=/e/download/installers/emacs/moddiff
origpatches=/e/download/installers/emacs
emacsroot=/src/emacs

# Generate all the remaining Emacs 19.x versions by applying the patches
# and copying the dirs as we go along.

# NOTE: This is a rather difficult and error-prone process.  Applying
# patches backward does not in general work because of added and deleted
# files.  I modified the patches as best I could, but you still get lots of
# complaints from `patch' and have to skip and deal as well as you can.
# Unfortunately, there do not appear to be complete versions of any of the
# versions of GNU Emacs on the net before 19.28 except 19.22 -- and no
# patch from 19.22 to 19.23 exists so we cannot even generate the versions
# from 19.23 to 19.27 by moving forward.

cd $emacsorigroot

make-one-dir-back ()
{
echo "cp -a emacs-19.$2 emacs-19.$1"
cp -a emacs-19.$2 emacs-19.$1
cd emacs-19.$1
echo "sh $modpatches/emacs-19.$1-19.$2.diff"
sh $modpatches/emacs-19.$1-19.$2.diff
cd ..
}

make-one-dir-forward ()
{
echo "cp -a emacs-19.$1 emacs-19.$2"
cp -a emacs-19.$1 emacs-19.$2
cd emacs-19.$2
echo "sh $origpatches/emacs-19.$1-19.$2.diff"
sh $origpatches/emacs-19.$1-19.$2.diff
cd ..
}

# make-one-dir-back 20 21
# make-one-dir-back 19 20
# make-one-dir-back 18 19
# make-one-dir-back 17 18
# make-one-dir-back 16 17
# make-one-dir-back 15 16
# make-one-dir-back 14 15
# make-one-dir-back 13 14
# make-one-dir-back 12 13
# make-one-dir-back 11 12
# make-one-dir-back 10 11
# make-one-dir-back 9 10
# make-one-dir-back 8 9
# make-one-dir-back 7 8

# make-one-dir-back 27 28
# make-one-dir-back 26 27
# make-one-dir-back 25 26
# make-one-dir-back 24 25
# make-one-dir-back 23 24

make-one-dir-forward 31 32
make-one-dir-forward 32 33
