1#!/bin/bash -ex
2# This is a historical record of how we did the merge between our
3# fork of glib 1.2.8 and the vendor update to 1.2.11
4# It may be of use when we sync up with a future vendor update.
5# It should not be expected to work without being modified!
6rm -fr zlib
7rm -fr zlib.old
8rm -fr zlib.new
9git checkout -- zlib
10# I manually found all the files we modified after the zlib
11# 1.2.8 release with "diff -r".
12# I then did three way compares between zlib 1.2.8, our code,
13# and zlib 1.2.11.
14# We had modified 7 files.  For the 5 below I wanted to preserve
15# our changes so I generate patches to apply to zlib 1.2.11.
16# The other 2 were gzlib.c and inflate.c.
17# In the case of gzlib.c we had a patch to fix a seek issue.
18# This was reported to the zlib creators with a test case.
19# 1.2.11 did not incorporate our patch, but the issue was fixed
20# in another manner.  Therfore we accept 1.2.11 gzlib.c without
21# our changes.
22# Both the test case we submitted to zlib and our gpsbabel
23# testcase were recreated to verify the failure in 1.2.8 and
24# verify that it was fixed in 1.2.11.
25# The last case was inflate.c.  In that case both zlib 1.2.11
26# and ourselves had the same change.  Therefore we accept 1.2.11
27# inflate.c without our changes.
28#
29# generate patches between 1.2.8 and our current zlib
30diff -u ../zlib-1.2.8/contrib/minizip/ioapi.c zlib/contrib/minizip 1> ioapi.c.patch || true
31diff -u ../zlib-1.2.8/contrib/minizip/ioapi.h zlib/contrib/minizip 1> ioapi.h.patch || true
32diff -u ../zlib-1.2.8/contrib/minizip/zip.c zlib/contrib/minizip 1> zip.c.patch || true
33diff -u ../zlib-1.2.8/contrib/minizip/zip.h zlib/contrib/minizip 1> zip.h.patch || true
34diff -u ../zlib-1.2.8/zconf.h zlib 1> zconf.h.patch || true
35
36mv zlib zlib.old
37
38tar -xzvf ../../Downloads/zlib-1.2.11.tar.gz
39mv zlib-1.2.11 zlib
40cd zlib
41
42mv doc/algorithm.txt .
43
44rm -fr amiga
45rm -fr doc
46rm -fr examples
47rm -fr msdos
48rm -fr nintendods
49rm -fr old
50rm -fr os400
51rm -fr qnx
52rm -fr test
53rm -fr watcom
54rm -fr win32
55rm -f configure
56rm -f CMakeLists.txt
57rm -f INDEX
58rm -f Makefile
59rm -f make_vms.com
60rm -f treebuild.xml
61rm -f zlib2ansi
62rm -f zconf.h.cmakein
63rm -f zlib.3.pdf
64rm -f zlib.map
65rm -f zlib.pc.cmakein
66rm -f zlib.pc.in
67rm -fr contrib/ada
68rm -fr contrib/amd64
69rm -fr contrib/asm686
70rm -fr contrib/blast
71rm -fr contrib/delphi
72rm -fr contrib/dotzlib
73rm -fr contrib/gcc_gvmat64
74rm -fr contrib/infback9
75rm -fr contrib/inflate86
76rm -fr contrib/iostream
77rm -fr contrib/iostream2
78rm -fr contrib/iostream3
79rm -fr contrib/masmx64
80rm -fr contrib/masmx86
81rm -fr contrib/pascal
82rm -fr contrib/puff
83rm -fr contrib/README.contrib
84rm -fr contrib/testzlib
85rm -fr contrib/untgz
86rm -fr contrib/vstudio
87# rename .in files to protect them from auto tools.
88mv zconf.h.in  zconf.in.h
89mv -f Makefile.in Makefile.in.zlib
90
91# copy our unique files
92cp -p ../zlib.old/README.gpsbabel .
93cp -p ../zlib.old/.gitignore .
94cp -p ../zlib.old/empty.in .
95
96# we don't neet this anymore, but it makes the diff line up
97# it will be deleted below.
98cp -p ../zlib.old/gzlib.patch .
99cd ..
100find zlib | sort > zlib.new.list
101find zlib.old | sort > zlib.old.list
102
103# move patches
104mv ioapi.c.patch zlib/contrib/minizip
105mv ioapi.h.patch zlib/contrib/minizip
106mv zip.c.patch zlib/contrib/minizip
107mv zip.h.patch zlib/contrib/minizip
108mv zconf.h.patch zlib
109
110# apply patches
111cd zlib/contrib/minizip
112patch < ioapi.c.patch
113patch < ioapi.h.patch
114patch < zip.c.patch
115patch < zip.h.patch
116cd ../..
117patch < zconf.h.patch
118
119cd ..
120cp resync_zlib zlib
121
122echo "see $0 for git commands to run manually"
123# this patch is obsolete
124#git rm zlib/gzlib.patch
125# and these are new files
126#git add zlib/contrib/minizip/ioapi.c.patch
127#git add zlib/contrib/minizip/ioapi.h.patch
128#git add zlib/contrib/minizip/zip.c.patch
129#git add zlib/contrib/minizip/zip.h.patch
130#git add zlib/zconf.h.patch
131#git add zlib/resync_zlib
132
133echo "you must manually edit README.gpsbabel"
134echo "Done"
135