[widelands] Fix building with libpng-1.5

Hans de Goede jwrdegoede at fedoraproject.org
Tue Dec 6 14:11:29 UTC 2011


commit f201031d85c47e9e74036b5345e62c7aaab2c15d
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Dec 6 15:12:10 2011 +0100

    Fix building with libpng-1.5

 widelands-build16-src-libpng15.patch |   68 ++++++++++++++++++++++++++++++++++
 widelands.spec                       |   22 +++++++----
 2 files changed, 82 insertions(+), 8 deletions(-)
---
diff --git a/widelands-build16-src-libpng15.patch b/widelands-build16-src-libpng15.patch
new file mode 100644
index 0000000..13fbcb9
--- /dev/null
+++ b/widelands-build16-src-libpng15.patch
@@ -0,0 +1,68 @@
+diff -ur widelands-build16-src/src/graphic/SDL_mng.cc widelands-build16-src.new/src/graphic/SDL_mng.cc
+--- widelands-build16-src/src/graphic/SDL_mng.cc	2011-04-15 20:40:26.000000000 +0200
++++ widelands-build16-src.new/src/graphic/SDL_mng.cc	2011-12-06 14:55:36.196284293 +0100
+@@ -276,7 +276,11 @@
+ 	 * the normal method of doing things with libpng).  REQUIRED unless you
+ 	 * set up your own error handlers in png_create_read_struct() earlier.
+ 	 */
++#ifndef LIBPNG_VERSION_12
++	if (setjmp(png_jmpbuf(png_ptr))) {
++#else
+ 	if (setjmp(png_ptr->jmpbuf)) {
++#endif
+ 		SDL_SetError("Error reading the PNG file.");
+ 		goto done;
+ 	}
+@@ -360,9 +360,12 @@
+ 			Rmask = 0x000000FF;
+ 			Gmask = 0x0000FF00;
+ 			Bmask = 0x00FF0000;
+-			Amask = (info_ptr->channels == 4) ? 0xFF000000 : 0;
++			Amask = (png_get_channels(png_ptr, info_ptr) == 4) ?
++				0xFF000000 : 0;
+ 		} else {
+-			int const s = (info_ptr->channels == 4) ? 0 : 8;
++			int const s =
++				(png_get_channels(png_ptr, info_ptr) == 4) ?
++				0 : 8;
+ 			Rmask = 0xFF000000 >> s;
+ 			Gmask = 0x00FF0000 >> s;
+ 			Bmask = 0x0000FF00 >> s;
+@@ -373,7 +376,7 @@
+ 		SDL_AllocSurface
+ 			(SDL_SWSURFACE,
+ 			 width, height,
+-			 bit_depth * info_ptr->channels,
++			 bit_depth * png_get_channels(png_ptr, info_ptr),
+ 			 Rmask, Gmask, Bmask, Amask);
+ 	if (not surface) {
+ 		SDL_SetError("Out of memory");
+@@ -413,6 +416,9 @@
+ 
+ 	/* Load the palette, if any */
+ 	if ((palette = surface->format->palette)) {
++		int png_num_palette;
++		png_colorp png_palette;
++		png_get_PLTE(png_ptr, info_ptr, &png_palette, &png_num_palette);
+ 		if (color_type == PNG_COLOR_TYPE_GRAY) {
+ 			palette->ncolors = 256;
+ 			for (uint16_t i = 0; i < 256; ++i) {
+@@ -420,12 +426,12 @@
+ 				palette->colors[i].g = i;
+ 				palette->colors[i].b = i;
+ 			}
+-		} else if (info_ptr->num_palette > 0) {
+-			palette->ncolors = info_ptr->num_palette;
+-			for (uint32_t i = 0; i < info_ptr->num_palette; ++i) {
+-				palette->colors[i].b = info_ptr->palette[i].blue;
+-				palette->colors[i].g = info_ptr->palette[i].green;
+-				palette->colors[i].r = info_ptr->palette[i].red;
++		} else if (png_num_palette > 0) {
++			palette->ncolors = png_num_palette;
++			for (uint32_t i = 0; i < png_num_palette; ++i) {
++				palette->colors[i].b = png_palette[i].blue;
++				palette->colors[i].g = png_palette[i].green;
++				palette->colors[i].r = png_palette[i].red;
+ 			}
+ 		}
+ 	}
diff --git a/widelands.spec b/widelands.spec
index c57fad3..5382773 100644
--- a/widelands.spec
+++ b/widelands.spec
@@ -1,7 +1,7 @@
 %define build_id build16
 Name:           widelands
 Version:        0
-Release:        0.27.%{build_id}%{?dist}
+Release:        0.28.%{build_id}%{?dist}
 Summary:        Open source realtime-strategy game
 
 Group:          Amusements/Games
@@ -9,6 +9,7 @@ License:        GPLv2+
 URL:            http://www.widelands.org
 Source0:        http://launchpad.net/widelands/%{build_id}/%{build_id}/+download/widelands-%{build_id}-src.tar.bz2
 Patch0:         widelands-build16-src-crash-on-messagebox.patch
+Patch1:         widelands-build16-src-libpng15.patch
 
 BuildRequires: SDL_mixer-devel SDL_image-devel SDL_net-devel SDL_ttf-devel
 BuildRequires: SDL_gfx-devel boost-devel ggz-base-libs-devel libpng-devel
@@ -27,6 +28,7 @@ perhaps will have a thought, what Widelands is all about.
 %prep
 %setup -q -n widelands-%{build_id}-src
 %patch0 -p1
+%patch1 -p1
 
 
 %build
@@ -98,18 +100,19 @@ Two frontiers
 War of the Valleys
 EOF
 
+
 %post
-touch --no-create %{_datadir}/icons/hicolor || :
-if [ -x %{_bindir}/gtk-update-icon-cache ]; then
-   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
-fi
+touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
 
 %postun
-touch --no-create %{_datadir}/icons/hicolor || :
-if [ -x %{_bindir}/gtk-update-icon-cache ]; then
-   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
+if [ $1 -eq 0 ] ; then
+    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 fi
 
+%posttrans
+gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+
 
 %files -f %{name}.files
 %defattr(-,root,root,-)
@@ -122,6 +125,9 @@ fi
 
 
 %changelog
+* Tue Dec 06 2011 Hans de Goede <hdegoede at redhat.com> - 0-0.28.build16
+- Fix building with libpng-1.5
+
 * Tue Dec 06 2011 Adam Jackson <ajax at redhat.com> - 0-0.27.build16
 - Rebuild for new libpng
 


More information about the scm-commits mailing list