[Pkg-cups-devel] r812 - in cupsys/trunk/debian: . patches

Till Kamppeter till-guest at alioth.debian.org
Thu Aug 7 14:42:28 UTC 2008


Author: till-guest
Date: Thu Aug  7 14:42:28 2008
New Revision: 812

Log:
Make the package building under pbuilder and the PDF printing workflow actually working.


Modified:
   cupsys/trunk/debian/changelog
   cupsys/trunk/debian/control
   cupsys/trunk/debian/copyright
   cupsys/trunk/debian/patches/pdftopdf-libpoppler3-api.dpatch
   cupsys/trunk/debian/patches/search_mime_files_in_usr_share.dpatch
   cupsys/trunk/debian/rules

Modified: cupsys/trunk/debian/changelog
==============================================================================
--- cupsys/trunk/debian/changelog	(original)
+++ cupsys/trunk/debian/changelog	Thu Aug  7 14:42:28 2008
@@ -16,6 +16,15 @@
     accepted in the debian/ directory as they are binary files. In addition,
     pdftopdf needs a patch because of a small change in the Poppler API
     (debian/patches/pdftopdf-libpoppler3-api.dpatch).
+  * debian/patches/search_mime_files_in_usr_share.dpatch: Replaced by the
+    changes which were done for this purpose in CUPS 1.4. In addition to
+    the introduction of /usr/share/cups/mime for installing file detection and
+    conversion rules as non-conffiles it also changes the reading order to
+    all *.types files and the all *.convs files (instead of all in
+    /usr/share/cups/mime and then all in /etc/cups). This way
+    /usr/share/cups/mime can contain conversion rules based on file types
+    defined by files in /etc/cups (CUPS STR #2719, CUPS SVN revs #7670 and 
+    #7694).
     
   [ Martin Pitt ]
   * Add missing CVE and more verbose descriptions to security fixes to 1.3.6-1

Modified: cupsys/trunk/debian/control
==============================================================================
--- cupsys/trunk/debian/control	(original)
+++ cupsys/trunk/debian/control	Thu Aug  7 14:42:28 2008
@@ -8,7 +8,7 @@
  debhelper (>= 5.0), po-debconf, cdbs (>= 0.4.27), sharutils, 
  dpatch (>= 1.11), libdbus-1-dev, libkrb5-dev | heimdal-dev,
  libavahi-compat-libdnssd-dev, libpoppler-dev, poppler-utils | xpdf-utils,
- lsb-release, po4a (>= 0.31)
+ lsb-release, po4a (>= 0.31), autotools-dev, autoconf, automake, libtool
 Uploaders: Kenshi Muto <kmuto at debian.org>, 
  Martin Pitt <mpitt at debian.org>, Roger Leigh <rleigh at debian.org>, 
  Martin-Éric Racine <q-funk at iki.fi>, Masayuki Hatta (mhatta) <mhatta at debian.org>,

Modified: cupsys/trunk/debian/copyright
==============================================================================
--- cupsys/trunk/debian/copyright	(original)
+++ cupsys/trunk/debian/copyright	Thu Aug  7 14:42:28 2008
@@ -208,7 +208,7 @@
 
 /*
  * Image file to PDF filter for the Common UNIX Printing System (CUPS).
- * developped by BBR Inc. 2006-2007
+ * developed by BBR Inc. 2006-2007
 
  * This is based on imagetops.c
  * imagetops.c copyright notice is follows

Modified: cupsys/trunk/debian/patches/pdftopdf-libpoppler3-api.dpatch
==============================================================================
--- cupsys/trunk/debian/patches/pdftopdf-libpoppler3-api.dpatch	(original)
+++ cupsys/trunk/debian/patches/pdftopdf-libpoppler3-api.dpatch	Thu Aug  7 14:42:28 2008
@@ -5,38 +5,65 @@
 ## DP: No description.
 
 @DPATCH@
+diff -urNad cups-1.3.8~/debian/local/filters/pdftopdf/configure.ac cups-1.3.8/debian/local/filters/pdftopdf/configure.ac
+--- cups-1.3.8~/debian/local/filters/pdftopdf/configure.ac	2008-08-06 13:08:33.000000000 +0200
++++ cups-1.3.8/debian/local/filters/pdftopdf/configure.ac	2008-08-07 16:10:45.000000000 +0200
+@@ -131,5 +131,11 @@
+     AC_DEFINE([HAVE_UGOOSTRING_H],,[Have UGooString.g])
+ ,)
+ 
++dnl check CharCodeToUnicode::mapToUnicode interface
++CPPFLAGS="$CPPFLAGS -I$POPPLER_SRCDIR/poppler"
++if grep "mapToUnicode(.*Unicode[ ][ ]*\*u" $POPPLER_SRCDIR/poppler/CharCodeToUnicode.h >/dev/null ;then
++    AC_DEFINE([OLD_MAPTOUNICODE],,[Old CharCodeToUnicode::mapToUnicode])
++fi
++
+ AC_CONFIG_FILES([Makefile src/Makefile conf/Makefile man/Makefile])
+ AC_OUTPUT
 diff -urNad cups-1.3.8~/debian/local/filters/pdftopdf/src/P2PFont.cc cups-1.3.8/debian/local/filters/pdftopdf/src/P2PFont.cc
 --- cups-1.3.8~/debian/local/filters/pdftopdf/src/P2PFont.cc	2008-08-06 13:08:33.000000000 +0200
-+++ cups-1.3.8/debian/local/filters/pdftopdf/src/P2PFont.cc	2008-08-06 16:54:11.000000000 +0200
-@@ -386,10 +386,10 @@
++++ cups-1.3.8/debian/local/filters/pdftopdf/src/P2PFont.cc	2008-08-07 16:10:45.000000000 +0200
+@@ -386,10 +386,17 @@
  	CharCode cid;
  	for (cid = 0;cid <= maxRefCID ;cid++) {
  	  int len;
--	  Unicode ucode;
-+	  Unicode *ucode = NULL;
++#ifdef OLD_MAPTOUNICODE
+ 	  Unicode ucode;
  
--	  len = octu->mapToUnicode(cid,&ucode,1);
--	  humap[cid*N_UCS_CANDIDATES] = ucode;
+ 	  len = octu->mapToUnicode(cid,&ucode,1);
+ 	  humap[cid*N_UCS_CANDIDATES] = ucode;
++#else
++	  Unicode *ucode = NULL;
++
 +	  len = octu->mapToUnicode(cid,&ucode);
 +	  humap[cid*N_UCS_CANDIDATES] = *ucode;
++#endif
  	  for (i = 1;i < N_UCS_CANDIDATES;i++) {
  	    humap[cid*N_UCS_CANDIDATES+i] = 0;
  	  }
-@@ -1109,7 +1109,7 @@
+@@ -1109,7 +1116,11 @@
    char *p;
    int len;
    int n;
--  Unicode u[8];
++#ifdef OLD_MAPTOUNICODE
+   Unicode u[8];
++#else
 +  Unicode *u = NULL;
++#endif
    CharCode code;
    int uLen;
    double dx,dy,originX,originY;
-@@ -1120,7 +1120,7 @@
+@@ -1120,8 +1131,13 @@
    p = s->getCString();
    len = s->getLength();
    while (len > 0) {
--    n = font->getNextChar(p,len,&code,u,(sizeof(u)/sizeof(Unicode)),&uLen,
-+    n = font->getNextChar(p,len,&code,&u,&uLen,
++#ifdef OLD_MAPTOUNICODE
+     n = font->getNextChar(p,len,&code,u,(sizeof(u)/sizeof(Unicode)),&uLen,
           &dx,&dy,&originX,&originY);
++#else
++    n = font->getNextChar(p,len,&code,&u,&uLen,
++         &dx,&dy,&originX,&originY);
++#endif
      code &= (CIDTOGID_SIZE-1); /* mask */
      fontFile->refChar(code);
+     p += n;

Modified: cupsys/trunk/debian/patches/search_mime_files_in_usr_share.dpatch
==============================================================================
--- cupsys/trunk/debian/patches/search_mime_files_in_usr_share.dpatch	(original)
+++ cupsys/trunk/debian/patches/search_mime_files_in_usr_share.dpatch	Thu Aug  7 14:42:28 2008
@@ -1,41 +1,578 @@
 #! /bin/sh /usr/share/dpatch/dpatch-run
-## search_mime_files_in_usr_share.dpatch by  <martin.pitt at ubuntu.com>
+## search_mime_files_in_usr_share.dpatch by  <till.kamppeter at gmail.com>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
 ## DP: http://www.cups.org/str.php?L2719
 
 @DPATCH@
-diff -urNad trunk~/scheduler/conf.c trunk/scheduler/conf.c
---- trunk~/scheduler/conf.c	2008-03-16 14:22:22.000000000 +0100
-+++ trunk/scheduler/conf.c	2008-03-16 14:23:33.000000000 +0100
+diff -urNad cups-1.3.8~/scheduler/conf.c cups-1.3.8/scheduler/conf.c
+--- cups-1.3.8~/scheduler/conf.c	2008-08-06 22:31:38.000000000 +0200
++++ cups-1.3.8/scheduler/conf.c	2008-08-06 22:32:28.000000000 +0200
 @@ -342,6 +342,7 @@
    cups_file_t	*fp;			/* Configuration file */
    int		status;			/* Return status */
    char		temp[1024],		/* Temporary buffer */
-+		temp2[1024],		/* Temporary buffer */
++		mimedir[1024],		/* MIME directory */
  		*slash;			/* Directory separator */
    cups_lang_t	*language;		/* Language */
    struct passwd	*user;			/* Default user */
-@@ -1073,11 +1074,21 @@
- 
-    /*
-     * Read the MIME type and conversion database...
-+    * Files are read from DataDir/mime by default, and can be overridden in
-+    * ServerRoot.
+@@ -1100,20 +1101,25 @@
      */
  
      snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
++    snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
  
 -    MimeDatabase = mimeLoad(ServerRoot, temp);
-+    snprintf(temp2, sizeof(temp2), "%s/mime", DataDir);
-+    MimeDatabase = mimeLoad(temp2, temp);
-+    if (!MimeDatabase)
++    MimeDatabase = mimeLoadTypes(NULL, mimedir);
++    MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
++    MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
++    MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
+ 
+     if (!MimeDatabase)
+     {
+       cupsdLogMessage(CUPSD_LOG_EMERG,
+-                      "Unable to load MIME database from \'%s\'!", ServerRoot);
++                      "Unable to load MIME database from \"%s\" or \"%s\"!",
++		      mimedir, ServerRoot);
+       exit(errno);
+     }
+ 
+     cupsdLogMessage(CUPSD_LOG_INFO,
+-                    "Loaded MIME database from \'%s\': %d types, %d filters...",
+-                    ServerRoot, mimeNumTypes(MimeDatabase),
+-		    mimeNumFilters(MimeDatabase));
++                    "Loaded MIME database from \"%s\" and \"%s\": %d types, "
++		    "%d filters...", mimedir, ServerRoot,
++		    mimeNumTypes(MimeDatabase), mimeNumFilters(MimeDatabase));
+ 
+    /*
+     * Create a list of MIME types for the document-format-supported
+--- cups-1.3.8~/scheduler/cupsfilter.c	2008-01-16 23:20:33.000000000 +0100
++++ cups-1.3.8/scheduler/cupsfilter.c	2008-08-06 22:32:38.000000000 +0200
+@@ -103,6 +103,7 @@
+   int		compression;		/* Compression of file */
+   int		cost;			/* Cost of filters */
+   mime_t	*mime;			/* MIME database */
++  char		mimedir[1024];		/* MIME directory */
+   char		*infile,		/* File to filter */
+ 		*outfile;		/* File to create */
+   char		cupsdconf[1024];	/* cupsd.conf file */
+@@ -331,11 +332,19 @@
+   if (read_cupsd_conf(cupsdconf))
+     return (1);
+ 
+-  if ((mime = mimeLoad(ServerRoot, Path)) == NULL)
++  snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
++
++  mime = mimeLoadTypes(NULL, mimedir);
++  mime = mimeLoadTypes(mime, ServerRoot);
++  mime = mimeLoadFilters(mime, mimedir, Path);
++  mime = mimeLoadFilters(mime, ServerRoot, Path);
++
++  if (!mime)
+   {
+     _cupsLangPrintf(stderr,
+-                    _("%s: Unable to read MIME database from \"%s\"!\n"),
+-		    command, ServerRoot);
++                    _("%s: Unable to read MIME database from \"%s\" or "
++		      "\"%s\"!\n"),
++		    command, mimedir, ServerRoot);
+     return (1);
+   }
+ 
+--- cups-1.3.8~/scheduler/mime.c	2008-01-17 00:42:35.000000000 +0100
++++ cups-1.3.8/scheduler/mime.c	2008-08-06 22:32:48.000000000 +0200
+@@ -72,6 +72,7 @@
+ 		           const char *filterpath,
+ 			   cups_array_t *filtercache);
+ static void	load_types(mime_t *mime, const char *filename);
++static mime_t	*mime_new(void);
+ 
+ 
+ /*
+@@ -192,73 +193,50 @@
+ 
+ /*
+  * 'mimeLoad()' - Create a new MIME database from disk.
++ *
++ * This function uses @link mimeLoadFilters@ and @link mimeLoadTypes@ to
++ * create a MIME database from a single directory.
+  */
+ 
+ mime_t *				/* O - New MIME database */
+ mimeLoad(const char *pathname,		/* I - Directory to load */
+          const char *filterpath)	/* I - Directory to load */
+ {
+-  return (mimeMerge(NULL, pathname, filterpath));
++  return (mimeLoadFilters(mimeLoadTypes(NULL, pathname), pathname, filterpath));
+ }
+ 
+ 
+ /*
+- * 'mimeMerge()' - Merge a MIME database from disk with the current one.
++ * 'mimeLoadFilters()' - Load filter definitions from disk.
++ *
++ * This function loads all of the .convs files from the specified directory.
++ * Use @link mimeLoadTypes@ to load all types before you load the filters.
+  */
+ 
+-mime_t *				/* O - Updated MIME database */
+-mimeMerge(mime_t     *mime,		/* I - MIME database to add to */
+-          const char *pathname,		/* I - Directory to load */
+-          const char *filterpath)	/* I - Directory to load */
++mime_t *				/* O - MIME database */
++mimeLoadFilters(mime_t     *mime,	/* I - MIME database */
++                const char *pathname,	/* I - Directory to load from */
++                const char *filterpath)	/* I - Default filter program directory */
+ {
+   cups_dir_t	*dir;			/* Directory */
+   cups_dentry_t	*dent;			/* Directory entry */
+-  char		filename[1024];		/* Full filename of types/converts file */
++  char		filename[1024];		/* Full filename of .convs file */
+   cups_array_t	*filtercache;		/* Filter cache */
+ 
+ 
+  /*
+-  * First open the directory specified by pathname...  Return NULL if nothing
+-  * was read or if the pathname is NULL...
+-  */
+-
+-  if (!pathname)
+-    return (NULL);
+-
+-  if ((dir = cupsDirOpen(pathname)) == NULL)
+-    return (NULL);
+-
+- /*
+-  * If "mime" is NULL, make a new, blank database...
++  * Range check input...
+   */
+ 
+-  if (!mime)
+-    mime = mimeNew();
+-  if (!mime)
+-  {
+-    cupsDirClose(dir);
+-    return (NULL);
+-  }
++  if (!mime || !pathname || !filterpath)
++    return (mime);
+ 
+  /*
+-  * Read all the .types files...
++  * Then open the directory specified by pathname...
+   */
+ 
+-  while ((dent = cupsDirRead(dir)) != NULL)
+-  {
+-    if (strlen(dent->filename) > 6 &&
+-        !strcmp(dent->filename + strlen(dent->filename) - 6, ".types"))
+-    {
+-     /*
+-      * Load a mime.types file...
+-      */
+-
+-      snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
+-      load_types(mime, filename);
+-    }
+-  }
+-
+-  cupsDirRewind(dir);
++  if ((dir = cupsDirOpen(pathname)) == NULL)
++    return (mime);
+ 
+  /*
+   * Read all the .convs files...
+@@ -289,13 +267,62 @@
+ 
+ 
+ /*
+- * 'mimeNew()' - Create a new, empty MIME database.
++ * 'mimeLoadTypes()' - Load type definitions from disk.
++ *
++ * This function loads all of the .types files from the specified directory.
++ * Use @link mimeLoadFilters@ to load all filters after you load the types.
+  */
+ 
+ mime_t *				/* O - MIME database */
+-mimeNew(void)
++mimeLoadTypes(mime_t     *mime,		/* I - MIME database or @code NULL@ to create a new one */
++              const char *pathname)	/* I - Directory to load from */
+ {
+-  return ((mime_t *)calloc(1, sizeof(mime_t)));
++  cups_dir_t	*dir;			/* Directory */
++  cups_dentry_t	*dent;			/* Directory entry */
++  char		filename[1024];		/* Full filename of .types file */
++
++
++ /*
++  * First open the directory specified by pathname...
++  */
++
++  if ((dir = cupsDirOpen(pathname)) == NULL)
++    return (mime);
++
++ /*
++  * If "mime" is NULL, make a new, empty database...
++  */
++
++  if (!mime)
++    mime = mime_new();
++
++  if (!mime)
++  {
++    cupsDirClose(dir);
++    return (NULL);
++  }
++
++ /*
++  * Read all the .types files...
++  */
++
++  while ((dent = cupsDirRead(dir)) != NULL)
++  {
++    if (strlen(dent->filename) > 6 &&
++        !strcmp(dent->filename + strlen(dent->filename) - 6, ".types"))
 +    {
-+      cupsdLogMessage(CUPSD_LOG_INFO,
-+                      "Unable to load MIME database from \'%s\'!", temp2);
++     /*
++      * Load a mime.types file...
++      */
++
++      snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
++      load_types(mime, filename);
 +    }
++  }
++
++  cupsDirClose(dir);
 +
-+    MimeDatabase = mimeMerge(MimeDatabase, ServerRoot, temp);
++  return (mime);
+ }
  
-     if (!MimeDatabase)
+ 
+@@ -474,6 +501,10 @@
+   int		cost;			/* Cost of filter */
+ 
+ 
++  DEBUG_printf(("load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", "
++                "filtercache=%p)\n", mime, filename, filterpath, filtercache));
++
++
+  /*
+   * First try to open the file...
+   */
+@@ -481,8 +512,6 @@
+   if ((fp = cupsFileOpen(filename, "r")) == NULL)
+     return;
+ 
+-  DEBUG_printf(("\"%s\":\n", filename));
+-
+  /*
+   * Then read each line from the file, skipping any comments in the file...
+   */
+@@ -493,8 +522,6 @@
+     * Skip blank lines and lines starting with a #...
+     */
+ 
+-    DEBUG_puts(line);
+-
+     if (!line[0] || line[0] == '#')
+       continue;
+ 
+@@ -544,7 +571,8 @@
+ 
+     if ((dsttype = mimeType(mime, super, type)) == NULL)
      {
+-      DEBUG_printf(("    Destination type %s/%s not found!\n", super, type));
++      DEBUG_printf(("load_convs: Destination type %s/%s not found!\n",
++                    super, type));
+       continue;
+     }
+ 
+@@ -578,7 +606,8 @@
+ 
+       if (!add_fcache(filtercache, filter, filterpath))
+       {
+-        DEBUG_printf(("    Filter %s not found in %s!\n", filter, filterpath)); 
++        DEBUG_printf(("load_convs: Filter %s not found in %s!\n", filter,
++	              filterpath)); 
+         continue;
+       }
+     }
+@@ -653,6 +682,8 @@
+   mime_type_t	*typeptr;		/* New MIME type */
+ 
+ 
++  DEBUG_printf(("load_types(mime=%p, filename=\"%s\")\n", mime, filename));
++
+  /*
+   * First try to open the file...
+   */
+@@ -660,8 +691,6 @@
+   if ((fp = cupsFileOpen(filename, "r")) == NULL)
+     return;
+ 
+-  DEBUG_printf(("\"%s\":\n", filename));
+-
+  /*
+   * Then read each line from the file, skipping any comments in the file...
+   */
+@@ -672,8 +701,6 @@
+     * Skip blank lines and lines starting with a #...
+     */
+ 
+-    DEBUG_puts(line);
+-
+     if (!line[0] || line[0] == '#')
+       continue;
+ 
+@@ -732,5 +759,16 @@
+ 
+ 
+ /*
++ * 'mime_new()' - Create a new, empty MIME database.
++ */
++
++static mime_t *				/* O - MIME database */
++mime_new(void)
++{
++  return ((mime_t *)calloc(1, sizeof(mime_t)));
++}
++
++
++/*
+  * End of "$Id: mime.c 7224 2008-01-16 23:42:35Z mike $".
+  */
+--- cups-1.3.8~/scheduler/mime.h	2007-07-11 23:46:42.000000000 +0200
++++ cups-1.3.8/scheduler/mime.h	2008-08-06 22:32:51.000000000 +0200
+@@ -3,7 +3,7 @@
+  *
+  *   MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
+  *
+- *   Copyright 2007 by Apple Inc.
++ *   Copyright 2007-2008 by Apple Inc.
+  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+  *
+  *   These coded instructions, statements, and computer programs are the
+@@ -86,6 +86,7 @@
+ typedef struct _mime_type_s		/**** MIME Type Data ****/
+ {
+   mime_magic_t	*rules;			/* Rules used to detect this type */
++  int		priority;		/* Priority of this type */
+   char		super[MIME_MAX_SUPER],	/* Super-type name ("image", "application", etc.) */
+ 		type[MIME_MAX_TYPE];	/* Type name ("png", "postscript", etc.) */
+ } mime_type_t;
+@@ -112,9 +113,9 @@
+ 
+ extern void		mimeDelete(mime_t *mime);
+ extern mime_t		*mimeLoad(const char *pathname, const char *filterpath);
+-extern mime_t		*mimeMerge(mime_t *mime, const char *pathname,
+-			           const char *filterpath);
+-extern mime_t		*mimeNew(void);
++extern mime_t		*mimeLoadFilters(mime_t *mime, const char *pathname,
++			                 const char *filterpath);
++extern mime_t		*mimeLoadTypes(mime_t *mime, const char *pathname);
+ 
+ extern mime_type_t	*mimeAddType(mime_t *mime, const char *super,
+ 			             const char *type);
+--- cups-1.3.8~/scheduler/type.c	2008-07-12 00:48:49.000000000 +0200
++++ cups-1.3.8/scheduler/type.c	2008-08-06 22:33:06.000000000 +0200
+@@ -3,7 +3,7 @@
+  *
+  *   MIME typing routines for the Common UNIX Printing System (CUPS).
+  *
+- *   Copyright 2007 by Apple Inc.
++ *   Copyright 2007-2008 by Apple Inc.
+  *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+  *
+  *   These coded instructions, statements, and computer programs are the
+@@ -102,6 +102,7 @@
+ 
+   strlcpy(temp->super, super, sizeof(temp->super));
+   strcpy(temp->type, type);		/* Safe: temp->type is allocated */
++  temp->priority = 100;
+ 
+   cupsArrayAdd(mime->types, temp);
+ 
+@@ -156,7 +157,7 @@
+   logic  = MIME_MAGIC_NOP;
+   invert = 0;
+ 
+-  DEBUG_printf(("%s/%s: %s\n", mt->super, mt->type, rule));
++  DEBUG_printf(("mimeAddTypeRule: %s/%s: %s\n", mt->super, mt->type, rule));
+ 
+   while (*rule != '\0')
+   {
+@@ -165,13 +166,13 @@
+ 
+     if (*rule == '(')
+     {
+-      DEBUG_puts("new parenthesis group");
++      DEBUG_puts("mimeAddTypeRule: New parenthesis group");
+       logic = MIME_MAGIC_NOP;
+       rule ++;
+     }
+     else if (*rule == ')')
+     {
+-      DEBUG_puts("close paren...");
++      DEBUG_puts("mimeAddTypeRule: Close paren...");
+       if (current == NULL || current->parent == NULL)
+         return (-1);
+ 
+@@ -207,11 +208,12 @@
+         current->prev   = NULL;
+ 	current->parent = temp;
+ 
+-        DEBUG_printf(("creating new AND group %p...\n", temp));
++        DEBUG_printf(("mimeAddTypeRule: Creating new AND group %p...\n", temp));
+       }
+       else
+       {
+-        DEBUG_printf(("setting group %p op to AND...\n", current->parent));
++        DEBUG_printf(("mimeAddTypeRule: Setting group %p op to AND...\n",
++	              current->parent));
+         current->parent->op = MIME_MAGIC_AND;
+       }
+ 
+@@ -237,7 +239,8 @@
+ 	  if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
+ 	    return (-1);
+ 
+-          DEBUG_printf(("creating new AND group %p inside OR group\n", temp));
++          DEBUG_printf(("mimeAddTypeRule: Creating new AND group %p inside OR "
++	                "group\n", temp));
+ 
+           while (current->prev != NULL)
+ 	  {
+@@ -257,7 +260,7 @@
+ 	  * This isn't the top rule, so go up one level...
+ 	  */
+ 
+-          DEBUG_puts("going up one level");
++          DEBUG_puts("mimeAddTypeRule: Going up one level");
+ 	  current = current->parent;
+ 	}
+       }
+@@ -267,7 +270,7 @@
+     }
+     else if (*rule == '!')
+     {
+-      DEBUG_puts("NOT");
++      DEBUG_puts("mimeAddTypeRule: NOT");
+       invert = 1;
+       rule ++;
+     }
+@@ -395,6 +398,11 @@
+ 	  op = MIME_MAGIC_LOCALE;
+ 	else if (!strcmp(name, "contains"))
+ 	  op = MIME_MAGIC_CONTAINS;
++	else if (!strcmp(name, "priority") && num_values == 1)
++	{
++	  mt->priority = atoi(value[0]);
++	  continue;
++	}
+ 	else
+ 	  return (-1);
+       }
+@@ -433,7 +441,8 @@
+         * Add parenthetical grouping...
+ 	*/
+ 
+-        DEBUG_printf(("making new OR group %p for parenthesis...\n", temp));
++        DEBUG_printf(("mimeAddTypeRule: Making new OR group %p for "
++	              "parenthesis...\n", temp));
+ 
+         temp->op = MIME_MAGIC_OR;
+ 
+@@ -446,8 +455,8 @@
+         logic = MIME_MAGIC_OR;
+       }
+ 
+-      DEBUG_printf(("adding %p: %s, op = %d, logic = %d, invert = %d\n",
+-                    temp, name, op, logic, invert));
++      DEBUG_printf(("mimeAddTypeRule: adding %p: %s, op=%d, logic=%d, "
++                    "invert=%d\n", temp, name, op, logic, invert));
+ 
+      /*
+       * Fill in data for the rule...
+@@ -530,14 +539,12 @@
+ {
+   _mime_filebuf_t	fb;		/* File buffer */
+   const char		*base;		/* Base filename of file */
+-  mime_type_t		*type;		/* File type */
++  mime_type_t		*type,		/* File type */
++			*best;		/* Best match */
+ 
+ 
+   DEBUG_printf(("mimeFileType(mime=%p, pathname=\"%s\", filename=\"%s\", "
+-                "compression=%p)\n",
+-                mime, pathname ? pathname : "(nil)",
+-		filename ? filename : "(nil)",
+-		compression));
++                "compression=%p)\n", mime, pathname, filename, compression));
+ 
+  /*
+   * Range check input parameters...
+@@ -576,11 +583,14 @@
+   * Then check it against all known types...
+   */
+ 
+-  for (type = (mime_type_t *)cupsArrayFirst(mime->types);
++  for (type = (mime_type_t *)cupsArrayFirst(mime->types), best = NULL;
+        type;
+        type = (mime_type_t *)cupsArrayNext(mime->types))
+     if (checkrules(base, &fb, type->rules))
+-      break;
++    {
++      if (!best || type->priority > best->priority)
++        best = type;
++    }
+ 
+  /*
+   * Finally, close the file and return a match (if any)...
+@@ -591,7 +601,7 @@
+ 
+   cupsFileClose(fb.fp);
+ 
+-  return (type);
++  return (best);
+ }
+ 
+ 
+@@ -791,7 +801,7 @@
+ 	  break;
+ 
+       case MIME_MAGIC_STRING :
+-          DEBUG_printf(("    string(%d, \"%s\")\n", rules->offset,
++          DEBUG_printf(("checkrules: string(%d, \"%s\")\n", rules->offset,
+ 	                rules->value.stringv));
+ 
+          /*
+@@ -810,7 +820,7 @@
+ 	                              sizeof(fb->buffer));
+ 	    fb->offset = rules->offset;
+ 
+-            DEBUG_printf(("        loaded %d byte fb->buffer at %d, starts "
++            DEBUG_printf(("checkrules: loaded %d byte fb->buffer at %d, starts "
+ 	                  "with \"%c%c%c%c\"...\n",
+ 	                  fb->length, fb->offset, fb->buffer[0], fb->buffer[1],
+ 			  fb->buffer[2], fb->buffer[3]));
+@@ -826,7 +836,7 @@
+ 	  else
+             result = (memcmp(fb->buffer + rules->offset - fb->offset,
+ 	                     rules->value.stringv, rules->length) == 0);
+-          DEBUG_printf(("    result=%d\n", result));
++          DEBUG_printf(("checkrules: result=%d\n", result));
+ 	  break;
+ 
+       case MIME_MAGIC_ISTRING :
+@@ -1027,8 +1037,8 @@
+     * the the rule set is false...
+     */
+ 
+-    DEBUG_printf(("    result of test %p (MIME_MAGIC_%s) is %d\n", rules,
+-                  debug_tests[rules->op], result));
++    DEBUG_printf(("checkrules: result of test %p (MIME_MAGIC_%s) is %d\n",
++                  rules, debug_tests[rules->op], result));
+ 
+     if ((result && logic == MIME_MAGIC_OR) ||
+         (!result && logic == MIME_MAGIC_AND))

Modified: cupsys/trunk/debian/rules
==============================================================================
--- cupsys/trunk/debian/rules	(original)
+++ cupsys/trunk/debian/rules	Thu Aug  7 14:42:28 2008
@@ -38,27 +38,22 @@
 endif
 LDFLAGS := -Wl,--as-needed
 
-common-configure-impl::
-	# Prepare building of extra filters for PDF printing workflow
-	export CFLAGS="$CFLAGS -I`pwd`"
-	export LDFLAGS="$LDFLAGS -L`pwd`/cups/"
-	# We have removed README.jp from all source trees, as it caused
-	# packaging problems. So do not try to install these files.
-	(cd debian/local/filters; perl -p -i -e 's/README.jp//g' */Makefile*)
-	(cd debian/local/filters/imagetopdf;autoreconf --install;./configure --prefix=/usr --sysconfdir=/etc)
-	(cd debian/local/filters/pdftopdf;autoreconf --install;./configure --prefix=/usr --sysconfdir=/etc)
-	(cd debian/local/filters/pdftoraster;autoreconf --install;./configure --prefix=/usr --sysconfdir=/etc)
-
 common-post-build-arch::
 	# Fix permissions of filters/backends installed from debian/local/
 	chmod 755 debian/local/filters/*
 	chmod 755 debian/local/backends/*
 	# Build extra filters for PDF printing workflow
-	export CFLAGS="$CFLAGS -I`pwd`"
-	export LDFLAGS="$LDFLAGS -L`pwd`/cups/"
-	(cd debian/local/filters/imagetopdf;$(MAKE) imagetopdf_CFLAGS="")
-	(cd debian/local/filters/pdftopdf;$(MAKE))
-	(cd debian/local/filters/pdftoraster;$(MAKE))
+	# We have removed README.jp from all source trees, as it caused
+	# packaging problems. So do not try to install these files.
+	(cd debian/local/filters; perl -p -i -e 's/README.jp//g' */Makefile*)
+	# Link CUPS headers so that filter build process finds them
+	[ -r $(CURDIR)/cups/raster.h ] || \
+		ln -s $(CURDIR)/filter/raster.h $(CURDIR)/cups/
+	[ -r $(CURDIR)/cups/image.h ] || \
+		ln -s $(CURDIR)/filter/image.h $(CURDIR)/cups/
+	(cd debian/local/filters/imagetopdf; export CFLAGS="$$CFLAGS -I$(CURDIR)"; export CXXFLAGS="$$CFLAGS -I$(CURDIR)"; export LDFLAGS="$$LDFLAGS -L$(CURDIR)/cups/ -L$(CURDIR)/filter/"; touch NEWS AUTHORS ChangeLog; autoreconf --install; ./configure --prefix=/usr --sysconfdir=/etc; $(MAKE) imagetopdf_CFLAGS="")
+	(cd debian/local/filters/pdftopdf; export CFLAGS="$$CFLAGS -I$(CURDIR)"; export CXXFLAGS="$$CFLAGS -I$(CURDIR)"; export LDFLAGS="$$LDFLAGS -L$(CURDIR)/cups/ -L$(CURDIR)/filter/"; touch NEWS AUTHORS ChangeLog; autoreconf --install; ./configure --prefix=/usr --sysconfdir=/etc; $(MAKE))
+	(cd debian/local/filters/pdftoraster; export CFLAGS="$$CFLAGS -I$(CURDIR)"; export CXXFLAGS="$$CFLAGS -I$(CURDIR)"; export LDFLAGS="$$LDFLAGS -L$(CURDIR)/cups/ -L$(CURDIR)/filter/"; touch NEWS AUTHORS ChangeLog; autoreconf --install; ./configure --prefix=/usr --sysconfdir=/etc; $(MAKE))
 
 clean::
 	rm -f man/client.conf.man packaging/cups.list
@@ -67,6 +62,8 @@
 	-(cd debian/local/filters/imagetopdf;$(MAKE) distclean)
 	-(cd debian/local/filters/pdftopdf;$(MAKE) distclean)
 	-(cd debian/local/filters/pdftoraster;$(MAKE) distclean)
+	# Remove all auxiliary files created by this rules file 
+	rm -f cups/raster.h cups/image.h
 
 common-install-prehook-impl::
 	(cd fonts && $(MAKE) install BUILDROOT=$(DEB_DESTDIR))
@@ -95,19 +92,18 @@
 	fi
 
 	# Install extra filters for PDF printing workflow
-	(cd debian/local/filters/imagetopdf;make install DESTDIR=$(DEB_DESTDIR))
-	(cd debian/local/filters/pdftopdf;make install DESTDIR=$(DEB_DESTDIR))
-	(cd debian/local/filters/pdftoraster;make install DESTDIR=$(DEB_DESTDIR))
-	mv $(DEB_DESTDIR)/usr/share/doc/imagetopdf $(DEB_DESTDIR)/../cups/usr/share/doc/cups
-	mv $(DEB_DESTDIR)/usr/share/doc/pdftopdf $(DEB_DESTDIR)/../cups/usr/share/doc/cups
-	mv $(DEB_DESTDIR)/usr/share/doc/pdftoraster $(DEB_DESTDIR)/../cups/usr/share/doc/cups
+	(cd debian/local/filters/imagetopdf;make install DESTDIR=$(DEB_DESTDIR)/../cups)
+	(cd debian/local/filters/pdftopdf;make install DESTDIR=$(DEB_DESTDIR)/../cups)
+	(cd debian/local/filters/pdftoraster;make install DESTDIR=$(DEB_DESTDIR)/../cups)
+	mv $(DEB_DESTDIR)/../cups/usr/share/doc/imagetopdf $(DEB_DESTDIR)/../cups/usr/share/doc/cups
+	mv $(DEB_DESTDIR)/../cups/usr/share/doc/pdftopdf $(DEB_DESTDIR)/../cups/usr/share/doc/cups
+	mv $(DEB_DESTDIR)/../cups/usr/share/doc/pdftoraster $(DEB_DESTDIR)/../cups/usr/share/doc/cups
 	# Move file detection and conversion rules to /usr/share/cups/mime/ so
 	# that the package manager does not consider them conffiles
 	install -d $(DEB_DESTDIR)/../cups/usr/share/cups/mime
-	( cd $(DEB_DESTDIR)/../tmp/etc/cups; mv imagetopdf.* pdftopdf.* pdftoraster.* pdf.* $(DEB_DESTDIR)/../cups/usr/share/cups/mime/ )
+	( cd $(DEB_DESTDIR)/../cups/etc/cups; mv imagetopdf.* pdftopdf.* pdftoraster.* pdf.* $(DEB_DESTDIR)/../cups/usr/share/cups/mime/ )
 	# Simple Ghostscript-based PostScript-to-PDF filter
-	install -m 0755 filters/pstopdf $(DEB_DESTDIR)/../cups/usr/lib/cups/filter
-	install -m 0644 local/pstopdf.convs $(DEB_DESTDIR)/../cups/usr/share/cups/mime/
+	install -m 0755 debian/filters/pstopdf $(DEB_DESTDIR)/../cups/usr/lib/cups/filter
 
 binary-post-install/libcupsimage2-dev::
 	rm -r debian/libcupsimage2-dev/usr/share/doc/libcupsimage2-dev



More information about the Pkg-cups-devel mailing list