rpms/deltarpm/F-10 deltarpm-system-zlib.patch, NONE, 1.1 deltarpm.spec, 1.13, 1.14

Toshio くらとみ toshio at fedoraproject.org
Thu Oct 1 06:25:55 UTC 2009


Author: toshio

Update of /cvs/pkgs/rpms/deltarpm/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13543

Modified Files:
	deltarpm.spec 
Added Files:
	deltarpm-system-zlib.patch 
Log Message:

* Wed Sep 30 2009 Toshio Kuratomi <toshio at fedoraproject.org> - 3.4-11.1
- Build against the system zlib, not the bundled library.  This remedies the
  fact that the included zlib is affected by CAN-2005-1849.
- Fix cfile_detect_rsync() to detect rsync even if we don't have a zlib capable
  of making rsync-friendly compressed files.


deltarpm-system-zlib.patch:
 Makefile |   21 ++++++++++++---------
 cfile.c  |   60 ++++++++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 60 insertions(+), 21 deletions(-)

--- NEW FILE deltarpm-system-zlib.patch ---
Index: deltarpm-3.4/Makefile
===================================================================
--- deltarpm-3.4.orig/Makefile
+++ deltarpm-3.4/Makefile
@@ -3,29 +3,32 @@ bindir=$(prefix)/bin
 mandir=$(prefix)/man
 rpmdumpheader=$(bindir)/rpmdumpheader
 zlibdir=zlib-1.2.2.f-rsyncable
+zlibbundled=$(zlibdir)/libz.a
+zlibldflags=$(zlibbundled)
+zlibcppflags=-I$(zlibdir)
 CFLAGS = -O2 -Wall -g
-CPPFLAGS = -DDELTARPM_64BIT -DBSDIFF_NO_SUF -DRPMDUMPHEADER=\"$(rpmdumpheader)\" -I$(zlibdir)
-LDLIBS = -lbz2 $(zlibdir)/libz.a
+CPPFLAGS = -DDELTARPM_64BIT -DBSDIFF_NO_SUF -DRPMDUMPHEADER=\"$(rpmdumpheader)\" $(zlibcppflags)
+LDLIBS = -lbz2 $(zlibldflags)
 LDFLAGS =
 
 all: makedeltarpm applydeltarpm rpmdumpheader makedeltaiso applydeltaiso combinedeltarpm fragiso
 
-makedeltarpm: makedeltarpm.o writedeltarpm.o md5.o util.o rpml.o rpmhead.o cpio.o delta.o cfile.o $(zlibdir)/libz.a
+makedeltarpm: makedeltarpm.o writedeltarpm.o md5.o util.o rpml.o rpmhead.o cpio.o delta.o cfile.o $(zlibbundled)
 
-applydeltarpm: applydeltarpm.o readdeltarpm.o md5.o util.o rpmhead.o cpio.o cfile.o prelink.o $(zlibdir)/libz.a
+applydeltarpm: applydeltarpm.o readdeltarpm.o md5.o util.o rpmhead.o cpio.o cfile.o prelink.o $(zlibbundled)
 
-combinedeltarpm: combinedeltarpm.o md5.o util.o rpmhead.o cfile.o readdeltarpm.o writedeltarpm.o $(zlibdir)/libz.a
+combinedeltarpm: combinedeltarpm.o md5.o util.o rpmhead.o cfile.o readdeltarpm.o writedeltarpm.o $(zlibbundled)
 
 rpmdumpheader: rpmdumpheader.o
 	$(CC) $(LDFLAGS) $^ -lrpm -o $@
 
-makedeltaiso: makedeltaiso.o delta.o rpmoffs.o util.o md5.o cfile.o $(zlibdir)/libz.a
+makedeltaiso: makedeltaiso.o delta.o rpmoffs.o util.o md5.o cfile.o $(zlibbundled)
 
-applydeltaiso: applydeltaiso.o util.o md5.o cfile.o $(zlibdir)/libz.a
+applydeltaiso: applydeltaiso.o util.o md5.o cfile.o $(zlibbundled)
 
-fragiso: fragiso.o util.o md5.o rpmhead.o cfile.o $(zlibdir)/libz.a
+fragiso: fragiso.o util.o md5.o rpmhead.o cfile.o $(zlibbundled)
 
-$(zlibdir)/libz.a:
+$(zlibbundled):
 	cd $(zlibdir) ; make CFLAGS="$(CFLAGS)" libz.a
 
 clean:
Index: deltarpm-3.4/cfile.c
===================================================================
--- deltarpm-3.4.orig/cfile.c
+++ deltarpm-3.4/cfile.c
@@ -712,8 +712,6 @@ crunread_un(struct cfile *f, void *buf, 
 }
 
 
-#ifdef Z_RSYNCABLE
-
 int
 cfile_detect_rsync(struct cfile *f)
 {
@@ -743,10 +741,22 @@ cfile_detect_rsync(struct cfile *f)
     }
   for (i = 0; i < 2; i++)
     {
+#ifndef Z_RSYNCABLE
+      /* Rsync friendly zlib not available, don't set up a compressor for it
+       * */
+      if (i)
+	{
+	  break;
+	}
+#endif
       cstrm[i].zalloc = 0;
       cstrm[i].zfree = 0;
       cstrm[i].opaque = 0;
+#ifdef Z_RSYNCABLE
       if (deflateInit2(&cstrm[i], Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY | (i == 1 ? Z_RSYNCABLE : 0)) != Z_OK)
+#else
+      if (deflateInit2(&cstrm[i], Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK)
+#endif
 	{
 	  if (i)
 	    deflateEnd(&cstrm[0]);
@@ -788,6 +798,23 @@ cfile_detect_rsync(struct cfile *f)
 		{
 		  for (i = 0; i < 2 && !done; i++)
 		    {
+#ifndef Z_RSYNCABLE
+		      /* No rsync friendly zlib so we can only test against
+		       * COMP_GZ.  This is suboptimal as it's only when we
+		       * run into an error that we can cut to the end.  So
+		       * we're forced to uncompress and recompress the whole
+		       * output.  Need to determine if we can determine that
+		       * we used the other algorithm is being used after
+		       * decompressing a certain amount of blocks.  Perhaps
+		       * after RSYNC_WIN or MAX_DIST blocks have been
+		       * decompressed we can know whether COMP_GZ_RSYNC was
+		       * used?
+		       */
+		      if (i)
+			{
+			    break;
+			}
+#endif
 		      cstrm[i].avail_in = sizeof(dbuf) - dstrm.avail_out;
 		      cstrm[i].next_in = dbuf;
 		      while (cstrm[i].avail_in)
@@ -795,14 +822,23 @@ cfile_detect_rsync(struct cfile *f)
 			  cstrm[i].avail_out = sizeof(cbuf);
 			  cstrm[i].next_out = cbuf;
 			  ret = deflate(&cstrm[i], dret == Z_STREAM_END ? Z_FINISH : Z_NO_FLUSH);
+			  /* Any errors in compressing, set to the other
+			   * compression algorithm
+			   */
 			  if (ret != Z_OK && ret != Z_STREAM_END)
 			    {
 			      comp = i ? CFILE_COMP_GZ: CFILE_COMP_GZ_RSYNC;
 			      done = 1;
 			      break;
 			    }
+			  /* if compression yielded something
+			   */
 			  if (cstrm[i].avail_out != sizeof(cbuf))
 			    {
+			      /* If the newly compressed block is not equal to
+			       * the original compressed payload, set to the
+			       * opposite compression algorithm
+			       */
 			      if (memcmp(b + p[i], cbuf, sizeof(cbuf) - cstrm[i].avail_out))
 				{
 				  comp = i ? CFILE_COMP_GZ: CFILE_COMP_GZ_RSYNC;
@@ -811,6 +847,14 @@ cfile_detect_rsync(struct cfile *f)
 				}
 			      p[i] += sizeof(cbuf) - cstrm[i].avail_out;
 			    }
+			  /* If the input stream is not empty but the
+			   * compressor says that the stream is empty we have
+			   * an error.  Set to the opposite compression
+			   * algorithm.
+			   *
+			   * Note -- This code looks wrong:
+			   * Should be Z_STREAM_END, not BZ_STREAM_END
+			   */
 			  if (cstrm[i].avail_in && ret == BZ_STREAM_END)
 			    {
 			      comp = i ? CFILE_COMP_GZ: CFILE_COMP_GZ_RSYNC;
@@ -835,7 +879,9 @@ cfile_detect_rsync(struct cfile *f)
       b = b2;
     }
   deflateEnd(&cstrm[0]);
+#ifdef Z_RSYNCABLE
   deflateEnd(&cstrm[1]);
+#endif
   inflateEnd(&dstrm);
   f->bufN = -1;
   f->strm.gz.avail_in = 0;
@@ -877,16 +923,6 @@ cfile_detect_rsync(struct cfile *f)
   return comp == -1 ? -1 : 0;
 }
 
-#else
-
-int
-cfile_detect_rsync(struct cfile *f)
-{
-  return -1;
-}
-
-#endif
-
 /*****************************************************************
  *  our open function
  */


Index: deltarpm.spec
===================================================================
RCS file: /cvs/pkgs/rpms/deltarpm/F-10/deltarpm.spec,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- deltarpm.spec	14 Jul 2008 04:02:25 -0000	1.13
+++ deltarpm.spec	1 Oct 2009 06:25:55 -0000	1.14
@@ -1,7 +1,7 @@
 Summary: Create deltas between rpms
 Name: deltarpm
 Version: 3.4
-Release: 11%{?dist}
+Release: 11%{?dist}.1
 License: BSD
 Group: System Environment/Base
 URL: http://www.novell.com/products/linuxpackages/professional/deltarpm.html
@@ -10,11 +10,14 @@ Source: ftp://ftp.suse.com/pub/projects/
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: bzip2-devel, rpm-devel, popt-devel
+BuildRequires: zlib-devel
 
 Patch0: deltarpm-3.4-multilib-workaround.patch
 Patch1: deltarpm-3.4-multilib-include-colored.patch
 Patch2: deltarpm-3.4-prelink-bugfix.patch
 Patch3: deltarpm-3.4-skipmd5.patch
+# Build with system zlib
+Patch5: deltarpm-system-zlib.patch
 
 %description
 A deltarpm contains the difference between an old
@@ -29,10 +32,13 @@ deltarpms can also work with installed r
 %patch1 -p1 -b .multicolor
 %patch2 -p1 -b .prelink
 %patch3 -p1 -b .skipmd5
+# Build with system zlib
+%patch5 -p1 -b .zlib
 
 %build
 %{__make} %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" \
-    bindir=%{_bindir} mandir=%{_mandir} prefix=%{_prefix}
+    bindir=%{_bindir} libdir=%{_libdir} mandir=%{_mandir} prefix=%{_prefix} \
+    zlibbundled='' zlibldflags='-lz' zlibcppflags=''
 
 %install
 %{__rm} -rf %{buildroot}
@@ -55,6 +61,12 @@ deltarpms can also work with installed r
 %{_bindir}/rpmdumpheader
 
 %changelog
+* Wed Sep 30 2009 Toshio Kuratomi <toshio at fedoraproject.org> - 3.4-11.1
+- Build against the system zlib, not the bundled library.  This remedies the
+  fact that the included zlib is affected by CAN-2005-1849.
+- Fix cfile_detect_rsync() to detect rsync even if we don't have a zlib capable
+  of making rsync-friendly compressed files.
+
 * Sun Jul 13 2008 Jonathan Dieter <jdieter at gmail.com> - 3.4-11
 - Rebuild for rpm 4.6
 




More information about the fedora-extras-commits mailing list