From fec8d429653459ada403c4eb7146162ac5e633ca Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Tue, 21 Sep 2010 04:29:10 +0000
Subject: ghostscript: arch sync

---
 abs/core-testing/ghostscript/PKGBUILD              | 65 ++++++++++----
 .../ghostscript/ghostscript-fPIC.patch             |  8 +-
 .../ghostscript/ghostscript-pdf2dsc.patch          | 12 +++
 .../ghostscript/ghostscript-system-jasper.patch    | 26 ++++++
 abs/core-testing/ghostscript/ghostscript.install   | 14 ---
 abs/core-testing/ghostscript/libpng14.patch        | 24 ++++++
 abs/core-testing/ghostscript/svn_r10890.patch      | 99 ++++++++++++++++++++++
 7 files changed, 212 insertions(+), 36 deletions(-)
 create mode 100644 abs/core-testing/ghostscript/ghostscript-pdf2dsc.patch
 create mode 100644 abs/core-testing/ghostscript/ghostscript-system-jasper.patch
 delete mode 100644 abs/core-testing/ghostscript/ghostscript.install
 create mode 100644 abs/core-testing/ghostscript/libpng14.patch
 create mode 100644 abs/core-testing/ghostscript/svn_r10890.patch

diff --git a/abs/core-testing/ghostscript/PKGBUILD b/abs/core-testing/ghostscript/PKGBUILD
index 5a7aa2a..f4139ff 100644
--- a/abs/core-testing/ghostscript/PKGBUILD
+++ b/abs/core-testing/ghostscript/PKGBUILD
@@ -1,27 +1,51 @@
-# $Id: PKGBUILD 20527 2008-12-05 14:17:31Z allan $
+# $Id: PKGBUILD 73021 2010-03-21 21:20:23Z andyrtr $
 # Maintainer: AndyRTR <andyrtr@archlinux.org>
 
 pkgname=ghostscript
-pkgver=8.63
-pkgrel=5
+pkgver=8.71
+pkgrel=3
 pkgdesc="An interpreter for the PostScript language"
-arch=(i686 x86_64)
-license=('GPL' 'custom')
-depends=('libjpeg' 'libxext' 'libxt' 'libcups>=1.3.8-2' 'fontconfig>=2.6.0' 'gtk2>=2.12.11' 'gnutls>=2.4.1')
-makedepends=('automake' 'autoconf')
-optdepends=('texlive-core: dvipdf')
+arch=('i686' 'x86_64')
+license=('GPL3' 'custom')
+depends=('libxext' 'libxt' 'libcups>=1.4.2-3' 'fontconfig>=2.8.0' 'gnutls>=2.8.5' 'cairo>=1.8.8-2'
+          'jasper>=1.900.1-4' 'zlib' 'libpng>=1.4.0' 'libjpeg>=8')
+makedepends=('automake' 'autoconf' 'gtk2>=2.18.6')
+optdepends=('texlive-core:	dvipdf'
+            'gtk2:		gsx')
 replaces=('ghostscript-lrpng')
 provides=('ghostscript-lprng')
-url="http://www.cs.wisc.edu/~ghost/"
-source=(http://ghostscript.com/releases/ghostscript-${pkgver}.tar.bz2
-	#ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs863/ghostscript-${pkgver}.tar.bz2
-	ghostscript-fPIC.patch)
+url="http://www.ghostscript.com/"
+source=(http://ghostscript.com/releases/ghostscript-${pkgver}.tar.xz
+	ghostscript-fPIC.patch
+	ghostscript-system-jasper.patch
+	libpng14.patch
+	ghostscript-pdf2dsc.patch
+	svn_r10890.patch)
 options=('!libtool' '!makeflags')
-md5sums=('c770eedfdd846a53e211e3ba5339de21'
-         '29540cd88aad9a3a788d68193523080d')
+md5sums=('5005d68f7395c2bfc4b05c1a60d9b6ba'
+         '1a8fcacf0005214db823225c870f093d'
+         '03e27cd02471ab3b642c344fa06b623e'
+         'be94ee357986f7f63d1b470da5bdc99e'
+         'f88f3764fc11e3ae2a86b17d2502da2f'
+         'fe0888a74d7870af234ad53a2f74380a')
 
 build() {
   cd ${srcdir}/ghostscript-${pkgver}
+  # force it to use system-libs
+  rm -rf jpeg libpng zlib jasper expat
+
+  patch -Np1 -i ${srcdir}/libpng14.patch || return 1
+
+  # fix build with systems jasper
+  patch -Np1 -i ${srcdir}/ghostscript-system-jasper.patch || return 1
+  
+  # fix PDF viewing with gv - from Fedora
+  patch -Np1 -i ${srcdir}/ghostscript-pdf2dsc.patch || return 1
+  
+  # fix segfaults - http://bugs.archlinux.org/task/18339
+  patch -Np1 -i ${srcdir}/svn_r10890.patch || return 1
+
+
   if [ "$CARCH" = "x86_64" ]; then
     patch -Np1 -i ${srcdir}/ghostscript-fPIC.patch || return 1
   fi
@@ -31,17 +55,22 @@ build() {
   ./autogen.sh
   ./configure --prefix=/usr --enable-shared --disable-static
   make || return 1
-  make DESTDIR=${pkgdir} install || return 1
+  make -j1 DESTDIR=${pkgdir} install || return 1
 
   cd ..
-  ./configure --prefix=/usr --enable-dynamic --enable-threads --with-ijs \
+  ./autogen.sh
+  ./configure --prefix=/usr --enable-dynamic --with-ijs \
               --with-jbig2dec --with-omni --with-x --with-drivers=ALL\
-	      --with-fontpath=/usr/share/fonts/Type1:/usr/share/fonts
+	      --with-fontpath=/usr/share/fonts/Type1:/usr/share/fonts \
+	      --disable-compile-inits # needed for linking with system-zlib
   make || return 1
-  make DESTDIR=${pkgdir} \
+  make -j1 DESTDIR=${pkgdir} \
 	cups_serverroot=${pkgdir}/etc/cups \
 	cups_serverbin=${pkgdir}/usr/lib/cups install soinstall
 
+  # install a missing doc files # http://bugs.archlinux.org/task/18023
+  install -m 644 ${srcdir}/ghostscript-${pkgver}/doc/{Ps2ps2.htm,gs-vms.hlp,gsdoc.el,pscet_status.txt} ${pkgdir}/usr/share/ghostscript/$pkgver/doc/
+  
   mkdir -p ${pkgdir}/usr/share/licenses/${pkgname}
   install -m644 LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/
 
diff --git a/abs/core-testing/ghostscript/ghostscript-fPIC.patch b/abs/core-testing/ghostscript/ghostscript-fPIC.patch
index 9b4deb2..f5b1b30 100644
--- a/abs/core-testing/ghostscript/ghostscript-fPIC.patch
+++ b/abs/core-testing/ghostscript/ghostscript-fPIC.patch
@@ -1,5 +1,5 @@
---- ghostscript-8.60-r8112/src/lib.mak.fPIC	2007-07-10 17:03:11.000000000 +0100
-+++ ghostscript-8.60-r8112/src/lib.mak	2007-07-10 17:05:56.000000000 +0100
+--- ghostscript-8.60-r8112/base/lib.mak.fPIC	2007-07-10 17:03:11.000000000 +0100
++++ ghostscript-8.60-r8112/base/lib.mak	2007-07-10 17:05:56.000000000 +0100
 @@ -874,7 +874,7 @@
  $(GLOBJ)gsparamx.$(OBJ) : $(GLSRC)gsparamx.c $(string__h)\
   $(gserror_h) $(gserrors_h) $(gsmemory_h) $(gsparam_h) $(gsparamx_h)\
@@ -18,8 +18,8 @@
  
  ###### Create a pseudo-"feature" for the entire graphics library.
  
---- ghostscript-8.60-r8112/src/devs.mak.fPIC	2007-07-10 17:05:00.000000000 +0100
-+++ ghostscript-8.60-r8112/src/devs.mak	2007-07-10 17:05:07.000000000 +0100
+--- ghostscript-8.60-r8112/base/devs.mak.fPIC	2007-07-10 17:05:00.000000000 +0100
++++ ghostscript-8.60-r8112/base/devs.mak	2007-07-10 17:05:07.000000000 +0100
 @@ -464,7 +464,7 @@
  	$(GLCCSHARED) $(XINCLUDE) $(GLO_)gdevx.$(OBJ) $(C_) $(GLSRC)gdevx.c
  
diff --git a/abs/core-testing/ghostscript/ghostscript-pdf2dsc.patch b/abs/core-testing/ghostscript/ghostscript-pdf2dsc.patch
new file mode 100644
index 0000000..31b6b54
--- /dev/null
+++ b/abs/core-testing/ghostscript/ghostscript-pdf2dsc.patch
@@ -0,0 +1,12 @@
+diff -up ghostscript-8.71/lib/pdf2dsc.ps.pdf2dsc ghostscript-8.71/lib/pdf2dsc.ps
+--- ghostscript-8.71/lib/pdf2dsc.ps.pdf2dsc	2010-02-20 15:50:51.287734970 +0000
++++ ghostscript-8.71/lib/pdf2dsc.ps	2010-02-20 15:51:02.902609964 +0000
+@@ -116,7 +116,7 @@ systemdict /.setsafe known { .setsafe } 
+    DSCfile PDFname write==only
+    ( \(r\) file { DELAYSAFER { .setsafe } if } stopped pop\n) puts
+    ( pdfopen begin\n) puts
+-   ( copy_trailer_attrs\n) puts
++   ( process_trailer_attrs\n) puts
+    (%%EndSetup\n) puts
+ 
+    /.hasPageLabels false def % see "Page Labels" in the PDF Reference
diff --git a/abs/core-testing/ghostscript/ghostscript-system-jasper.patch b/abs/core-testing/ghostscript/ghostscript-system-jasper.patch
new file mode 100644
index 0000000..444b760
--- /dev/null
+++ b/abs/core-testing/ghostscript/ghostscript-system-jasper.patch
@@ -0,0 +1,26 @@
+diff -up ghostscript-8.64/base/sjpx.c.system-jasper ghostscript-8.64/base/sjpx.c
+--- ghostscript-8.64/base/sjpx.c.system-jasper	2008-08-21 00:22:49.000000000 +0100
++++ ghostscript-8.64/base/sjpx.c	2009-02-04 11:35:56.000000000 +0000
+@@ -34,14 +34,6 @@ static void s_jpxd_set_defaults(stream_s
+ private_st_jpxd_state(); /* creates a gc object for our state,
+ 			    defined in sjpx.h */
+ 
+-/* error reporting callback for the jpx library */
+-static void
+-s_jpx_jas_error_cb(jas_error_t err, char *msg)
+-{
+-  dprintf2("jasper (code %d) %s", (int)err, msg);
+-}
+-
+-
+ /* initialize the steam.
+    this involves allocating the stream and image structures, and
+    initializing the decoder.
+@@ -59,7 +51,6 @@ s_jpxd_init(stream_state * ss)
+     }
+ 
+     status = jas_init();
+-    jas_set_error_cb(s_jpx_jas_error_cb);
+ #ifdef JPX_DEBUG
+     /* raise the error reporting threshold from the default (0) */
+     jas_setdbglevel(1);
diff --git a/abs/core-testing/ghostscript/ghostscript.install b/abs/core-testing/ghostscript/ghostscript.install
deleted file mode 100644
index 10d2d7a..0000000
--- a/abs/core-testing/ghostscript/ghostscript.install
+++ /dev/null
@@ -1,14 +0,0 @@
-post_install() {
-cat << EOF
-==> To use dvipdf, you need to install tetex:
-==> # pacman -S tetex
-EOF
-}
-
-post_upgrade() {
-  post_install $1
-}
-
-op=$1
-shift
-$op $*
diff --git a/abs/core-testing/ghostscript/libpng14.patch b/abs/core-testing/ghostscript/libpng14.patch
new file mode 100644
index 0000000..7ee08af
--- /dev/null
+++ b/abs/core-testing/ghostscript/libpng14.patch
@@ -0,0 +1,24 @@
+diff -Nur ghostscript-8.70.orig/base/configure.ac ghostscript-8.70/base/configure.ac
+--- ghostscript-8.70.orig/base/configure.ac	2009-07-27 19:59:50.000000000 +0300
++++ ghostscript-8.70/base/configure.ac	2010-01-17 02:20:52.000000000 +0200
+@@ -402,7 +402,7 @@
+ 	PNGDEVS="$PNGDEVS_ALL"
+ else
+ 	AC_MSG_RESULT([no])
+-	AC_CHECK_LIB(png, png_check_sig, [
++	AC_CHECK_LIB(png, png_sig_cmp, [
+ 	  AC_CHECK_HEADERS(png.h, [
+ 		SHARE_LIBPNG=1
+ 		PNGDEVS="$PNGDEVS_ALL"
+diff -Nur ghostscript-8.70.orig/jbig2dec/configure.ac ghostscript-8.70/jbig2dec/configure.ac
+--- ghostscript-8.70.orig/jbig2dec/configure.ac	2009-05-29 09:48:44.000000000 +0300
++++ ghostscript-8.70/jbig2dec/configure.ac	2010-01-17 02:21:25.000000000 +0200
+@@ -34,7 +34,7 @@
+   fi
+   dnl libpng requires pow() which may be in libm
+   AC_SEARCH_LIBS([pow], [m])
+-  AC_CHECK_LIB([png], [png_check_sig], [
++  AC_CHECK_LIB([png], [png_sig_cmp], [
+     AC_CHECK_LIB([z], [deflate], [
+       AC_DEFINE(HAVE_LIBPNG, 1, [Define if libpng is available (-lpng)])
+       LIBS="-lpng -lz $LIBS"
diff --git a/abs/core-testing/ghostscript/svn_r10890.patch b/abs/core-testing/ghostscript/svn_r10890.patch
new file mode 100644
index 0000000..afcbf47
--- /dev/null
+++ b/abs/core-testing/ghostscript/svn_r10890.patch
@@ -0,0 +1,99 @@
+From 6d26e9b1c38d8c0f0ab4af42c513cb23f3ae1656 Mon Sep 17 00:00:00 2001
+From: till <till@a1074d23-0009-0410-80fe-cf8c14f379e6>
+Date: Tue, 9 Mar 2010 16:35:06 +0000
+Subject: [PATCH] Fixes on CUPS Raster output device:
+ - Fixed memory reallocation on bitmap size change. Reallocation is not only
+   needed when dimendions and margins change, but also when the color depth
+   changes. Fixes bugs #691029 and #691108.
+ - Fixed arrayoption() macro in cups_put_params() function. Array values did
+   not get actually set in cups.header data structure. Bug only showed via
+   a compiler warning.
+ - Silenced compiler warning by presetting c0..c3 in cups_map_cmyk() to zero.
+
+git-svn-id: http://svn.ghostscript.com/ghostscript/trunk/gs@10890 a1074d23-0009-0410-80fe-cf8c14f379e6
+---
+ cups/gdevcups.c |   32 +++++++++++++++++++++++---------
+ 1 files changed, 23 insertions(+), 9 deletions(-)
+
+diff --git a/cups/gdevcups.c b/cups/gdevcups.c
+index 551b806..4000abf 100644
+--- a/cups/gdevcups.c
++++ b/cups/gdevcups.c
+@@ -975,7 +975,8 @@ cups_map_cmyk(gx_device *pdev,		/* I - Device info */
+ 	      frac      k,		/* I - Black value */
+ 	      frac      *out)		/* O - Device colors */
+ {
+-  int	c0, c1, c2, c3;			/* Temporary color values */
++  int	c0 = 0, c1 = 0,
++        c2 = 0, c3 = 0;			/* Temporary color values */
+   float	rr, rg, rb,			/* Real RGB colors */
+ 	ciex, ciey, ciez,		/* CIE XYZ colors */
+ 	ciey_yn,			/* Normalized luminance */
+@@ -2703,9 +2704,13 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
+   int			color_set;	/* Were the color attrs set? */
+   gdev_prn_space_params	sp;		/* Space parameter data */
+   int			width,		/* New width of page */
+-                        height;		/* New height of page */
++                        height,		/* New height of page */
++                        colorspace,     /* New color space */
++                        bitspercolor;   /* New bits per color */
+   static int            width_old = 0,  /* Previous width */
+-                        height_old = 0; /* Previous height */
++                        height_old = 0, /* Previous height */
++                        colorspace_old = 0,/* Previous color space */
++                        bitspercolor_old = 0;/* Previous bits per color */
+   ppd_attr_t            *backside = NULL,
+                         *backsiderequiresflippedmargins = NULL;
+   float                 swap;
+@@ -2800,9 +2805,10 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
+   else if (code == 0) \
+   { \
+     dprintf1("DEBUG: Setting %s to", sname); \
+-    for (i = 0; i < count; i ++) \
+-      dprintf1(" %d", (unsigned)(arrayval.data[i]));	 \
+-      cups->header.name[i] = (unsigned)arrayval.data[i]; \
++    for (i = 0; i < count; i ++) { \
++      dprintf1(" %d", (unsigned)(arrayval.data[i])); \
++      cups->header.name[i] = (unsigned)(arrayval.data[i]); \
++    } \
+     dprintf("...\n"); \
+   }
+ 
+@@ -3243,23 +3249,31 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
+     }
+ #endif /* CUPS_RASTER_SYNCv1 */
+ 
++    colorspace = cups->header.cupsColorSpace;
++    bitspercolor = cups->header.cupsBitsPerColor;
++
+    /*
+     * Don't reallocate memory unless the device has been opened...
+     * Also reallocate only if the size has actually changed...
+     */
+ 
+-    if (pdev->is_open && (width != width_old || height != height_old))
++    if (pdev->is_open &&
++	(width != width_old || height != height_old ||
++	 colorspace != colorspace_old || bitspercolor != bitspercolor_old))
+     {
+ 
+       width_old = width;
+       height_old = height;
++      colorspace_old = colorspace;
++      bitspercolor_old = bitspercolor;
+ 
+      /*
+       * Device is open and size has changed, so reallocate...
+       */
+ 
+-      dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n",
+-	       pdev->MediaSize[0], pdev->MediaSize[1], width, height);
++      dprintf6("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels, color space: %d, bits per color: %d...\n",
++	       pdev->MediaSize[0], pdev->MediaSize[1], width, height,
++	       colorspace, bitspercolor);
+ 
+       sp = ((gx_device_printer *)pdev)->space_params;
+ 
+-- 
+1.6.6.1
+
-- 
cgit v0.12