From 9c273574caea01c1adc975529f4ae857e0872f00 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Mon, 10 Aug 2015 14:21:48 +0000
Subject: gd: update to 2.1.1

---
 abs/extra/gd/PKGBUILD                    | 25 ++++++++++-----------
 abs/extra/gd/color_c_null_pointer.patch  | 18 ----------------
 abs/extra/gd/gd-2.1.1-libvpx-1.4.0.patch | 37 ++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 30 deletions(-)
 delete mode 100644 abs/extra/gd/color_c_null_pointer.patch
 create mode 100644 abs/extra/gd/gd-2.1.1-libvpx-1.4.0.patch

diff --git a/abs/extra/gd/PKGBUILD b/abs/extra/gd/PKGBUILD
index b050624..f3dfcd2 100644
--- a/abs/extra/gd/PKGBUILD
+++ b/abs/extra/gd/PKGBUILD
@@ -1,27 +1,28 @@
 # $Id$
 
 pkgname=gd
-pkgver=2.1.0
-pkgrel=3
+pkgver=2.1.1
+pkgrel=2
 pkgdesc="Library for the dynamic creation of images by programmers"
 arch=('i686' 'x86_64')
 url="http://www.libgd.org/"
 license=('custom')
 depends=('fontconfig' 'libvpx' 'libxpm' 'libtiff')
+makedepends=('git')
 optdepends=('perl: bdftogd script')
-source=("https://bitbucket.org/libgd/gd-libgd/downloads/libgd-${pkgver}.tar.xz"
-        'color_c_null_pointer.patch')
-md5sums=('03588159bf4faab9079849c8d709acc6'
-         '51f5ff073eabbd7809e0ce438d5bb1c2')
+source=("${pkgname}::git+https://github.com/libgd/libgd.git#tag=${pkgname}-${pkgver}"
+        gd-2.1.1-libvpx-1.4.0.patch)
+md5sums=('SKIP'
+         '9114dd8259aaa88b0a09188fe7b19afc')
 
 prepare() {
-  cd libgd-${pkgver}
-  # CVE-2014-2497
-  patch -p1 -i ${srcdir}/color_c_null_pointer.patch
+  cd ${pkgname}
+  ./bootstrap.sh
+  patch -p1 -i "${srcdir}/gd-2.1.1-libvpx-1.4.0.patch"
 }
 
 build() {
-  cd libgd-${pkgver}
+  cd ${pkgname}
   ./configure \
     --prefix=/usr \
     --disable-rpath \
@@ -31,12 +32,12 @@ build() {
 }
 
 check() {
-  cd libgd-${pkgver}
+  cd ${pkgname}
   make check
 }
 
 package() {
-  cd libgd-${pkgver}
+  cd ${pkgname}
   make DESTDIR="${pkgdir}" install
   install -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
 }
diff --git a/abs/extra/gd/color_c_null_pointer.patch b/abs/extra/gd/color_c_null_pointer.patch
deleted file mode 100644
index 95b3eeb..0000000
--- a/abs/extra/gd/color_c_null_pointer.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -up ./src/gdxpm.c.color_c_null_pointer ./src/gdxpm.c
---- ./src/gdxpm.c.color_c_null_pointer	2013-06-25 11:58:23.000000000 +0200
-+++ ./src/gdxpm.c	2014-07-16 16:43:44.000000000 +0200
-@@ -62,6 +62,13 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFro
- 
- 	for(i = 0; i < number; i++) {
- 		char *c_color = image.colorTable[i].c_color;
-+		if (!c_color)
-+		{
-+			/* unsupported color key or color key not defined */
-+			gdImageDestroy(im);
-+			im = 0;
-+			goto done;
-+		}
- 		if(strcmp(c_color, "None") == 0) {
- 			colors[i] = gdImageGetTransparent(im);
- 			if(colors[i] == -1) colors[i] = gdImageColorAllocate(im, 0, 0, 0);
-diff -up ./x.color_c_null_pointer ./x
diff --git a/abs/extra/gd/gd-2.1.1-libvpx-1.4.0.patch b/abs/extra/gd/gd-2.1.1-libvpx-1.4.0.patch
new file mode 100644
index 0000000..c698972
--- /dev/null
+++ b/abs/extra/gd/gd-2.1.1-libvpx-1.4.0.patch
@@ -0,0 +1,37 @@
+From d41eb72cd4545c394578332e5c102dee69e02ee8 Mon Sep 17 00:00:00 2001
+From: Remi Collet <fedora@famillecollet.com>
+Date: Tue, 7 Apr 2015 13:11:03 +0200
+Subject: [PATCH] Fix build with latest libvpx 1.4.0
+
+These new constants exist at least since 1.0.0
+Compatibility ones have been droped in 1.4.0
+---
+ src/webpimg.c | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/src/webpimg.c b/src/webpimg.c
+index cf73d64..e49fcc6 100644
+--- a/src/webpimg.c
++++ b/src/webpimg.c
+@@ -711,14 +711,14 @@ static WebPResult VPXEncode(const uint8* Y,
+     codec_ctl(&enc, VP8E_SET_STATIC_THRESHOLD, 0);
+     codec_ctl(&enc, VP8E_SET_TOKEN_PARTITIONS, 2);
+ 
+-    vpx_img_wrap(&img, IMG_FMT_I420,
++    vpx_img_wrap(&img, VPX_IMG_FMT_I420,
+                  y_width, y_height, 16, (uint8*)(Y));
+-    img.planes[PLANE_Y] = (uint8*)(Y);
+-    img.planes[PLANE_U] = (uint8*)(U);
+-    img.planes[PLANE_V] = (uint8*)(V);
+-    img.stride[PLANE_Y] = y_stride;
+-    img.stride[PLANE_U] = uv_stride;
+-    img.stride[PLANE_V] = uv_stride;
++    img.planes[VPX_PLANE_Y] = (uint8*)(Y);
++    img.planes[VPX_PLANE_U] = (uint8*)(U);
++    img.planes[VPX_PLANE_V] = (uint8*)(V);
++    img.stride[VPX_PLANE_Y] = y_stride;
++    img.stride[VPX_PLANE_U] = uv_stride;
++    img.stride[VPX_PLANE_V] = uv_stride;
+ 
+     res = vpx_codec_encode(&enc, &img, 0, 1, 0, VPX_DL_BEST_QUALITY);
+ 
-- 
cgit v0.12

