Index: packaging/cups.spec.in
===================================================================
--- packaging/cups.spec.in	(revision 7661)
+++ packaging/cups.spec.in	(working copy)
@@ -157,8 +157,6 @@
 %config(noreplace) /etc/cups/*.conf
 /etc/cups/cupsd.conf.default
 %dir /etc/cups/interfaces
-/etc/cups/mime.types
-/etc/cups/mime.convs
 %dir /etc/cups/ppd
 %attr(0700,root,root) %dir /etc/cups/ssl
 
@@ -237,6 +235,8 @@
 /usr/share/cups/drv/*
 %dir /usr/share/cups/fonts
 /usr/share/cups/fonts/*
+%dir /usr/share/cups/mime
+/usr/share/cups/mime/*
 %dir /usr/share/cups/model
 %dir /usr/share/cups/ppdc
 /usr/share/cups/ppdc/*
Index: packaging/cups.list.in
===================================================================
--- packaging/cups.list.in	(revision 7661)
+++ packaging/cups.list.in	(working copy)
@@ -467,6 +467,10 @@
 f 0644 root sys $DATADIR/fonts fonts/Courier*
 f 0644 root sys $DATADIR/fonts/Symbol fonts/Symbol
 
+d 0755 root sys $DATADIR/mime -
+f 0644 root sys $DATADIR/mime/mime.convs conf/mime.convs
+f 0644 root sys $DATADIR/mime/mime.types conf/mime.types
+
 d 0755 root sys $DATADIR/model -
 
 d 0755 root sys $DATADIR/ppdc -
@@ -514,8 +518,6 @@
 d 0700 root $CUPS_GROUP $SERVERROOT/ssl -
 c $CUPS_PERM root $CUPS_GROUP $SERVERROOT conf/*.conf
 f $CUPS_PERM root $CUPS_GROUP $SERVERROOT/cupsd.conf.default conf/cupsd.conf
-f 0644 root $CUPS_GROUP $SERVERROOT/mime.convs conf/mime.convs
-f 0644 root $CUPS_GROUP $SERVERROOT/mime.types conf/mime.types
 
 %if PAMDIR
 d 0755 root sys $PAMDIR -
Index: conf/mime.types
===================================================================
--- conf/mime.types	(revision 7661)
+++ conf/mime.types	(working copy)
@@ -7,7 +7,7 @@
 #   VERSIONS OF CUPS.  Instead, create a "local.types" file that
 #   reflects your local configuration changes.
 #
-#   Copyright 2007 by Apple Inc.
+#   Copyright 2007-2008 by Apple Inc.
 #   Copyright 1997-2007 by Easy Software Products.
 #
 #   These coded instructions, statements, and computer programs are the
@@ -33,6 +33,8 @@
 #   extension				Pattern match on "*.extension"
 #   ascii(offset,length)		True if bytes are valid printable ASCII
 #					(CR, NL, TAB, BS, 32-126)
+#   priority(number)                    Sets priority of type (0=lowest,
+#                                       100=default, 200=highest)
 #   printable(offset,length)		True if bytes are printable 8-bit chars
 #					(CR, NL, TAB, BS, 32-126, 128-254)
 #   string(offset,"string")		True if bytes are identical to string
Index: conf/Makefile
===================================================================
--- conf/Makefile	(revision 7661)
+++ conf/Makefile	(working copy)
@@ -75,11 +75,15 @@
 	done
 	$(INSTALL_CONFIG) cupsd.conf $(SERVERROOT)/cupsd.conf.default
 	-chgrp $(CUPS_GROUP) $(SERVERROOT)/cupsd.conf.default
+	$(INSTALL_DIR) -m 755 $(DATADIR)/mime
 	for file in $(REPLACE); do \
+		if test -r $(DATADIR)/mime/$$file ; then \
+			$(MV) $(DATADIR)/mime/$$file $(DATADIR)/mime/$$file.O ; \
+		fi ; \
 		if test -r $(SERVERROOT)/$$file ; then \
-			$(MV) $(SERVERROOT)/$$file $(SERVERROOT)/$$file.O ; \
+			$(MV) $(SERVERROOT)/$$file $(DATADIR)/mime/$$file.O ; \
 		fi ; \
-		$(INSTALL_DATA) $$file $(SERVERROOT) ; \
+		$(INSTALL_DATA) $$file $(DATADIR)/mime ; \
 	done
 	-if test x$(PAMDIR) != x; then \
 		$(INSTALL_DIR) -m 755 $(BUILDROOT)$(PAMDIR); \
@@ -121,6 +125,10 @@
 		$(RM) $(SERVERROOT)/$$file; \
 	done
 	-$(RMDIR) $(SERVERROOT)
+	for file in $(REPLACE); do \
+		$(RM) $(DATADIR)/mime/$$file; \
+	done
+	-$(RMDIR) $(DATADIR)/mime
 	-if test x$(PAMDIR) != x; then \
 		$(RM) $(BUILDROOT)$(PAMDIR)/cups; \
 		$(RMDIR) $(BUILDROOT)$(PAMDIR); \
Index: man/mime.types.man
===================================================================
--- man/mime.types.man	(revision 7661)
+++ man/mime.types.man	(working copy)
@@ -3,7 +3,7 @@
 .\"
 .\"   mime.types man page 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.
 .\"
 .\"   These coded instructions, statements, and computer programs are the
@@ -12,7 +12,7 @@
 .\"   which should have been included with this file.  If this file is
 .\"   file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH mime.types 5 "Common UNIX Printing System" "12 February 2006" "Apple Inc."
+.TH mime.types 5 "Common UNIX Printing System" "17 June 2008" "Apple Inc."
 .SH NAME
 mime.types \- mime type description file for cups
 .SH DESCRIPTION
@@ -51,6 +51,11 @@
 .br
 True if bytes are printable 8-bit chars (CR, NL, TAB, BS, 32-126, 128-254)
 .TP 5
+priority(number)
+.br
+Specifies the relative priority of this MIME type. The default priority is 100.
+Larger values have higher priority while smaller values have lower priority.
+.TP 5
 string(offset,"string")
 .br
 True if bytes are identical to string
@@ -88,7 +93,7 @@
 .br
 http://localhost:631/help
 .SH COPYRIGHT
-Copyright 2007 by Apple Inc.
+Copyright 2007-2008 by Apple Inc.
 .\"
 .\" End of "$Id$".
 .\"
Index: CHANGES.txt
===================================================================
--- CHANGES.txt	(revision 7668)
+++ CHANGES.txt	(working copy)
@@ -3,6 +3,9 @@
 
 CHANGES IN CUPS V1.4b1
 
+	- MIME types now support a priority() attribute (STR #2719)
+	- The standard MIME types are now installed in
+	  DataDir/mime (STR #2719)
 	- The lpoptions command now describes custom options and
 	  the necessary parameters (STR #2660)
 	- The ppdmerge program did not support Simplified Chinese
Index: scheduler/cupsfilter.c
===================================================================
--- scheduler/cupsfilter.c	(revision 7661)
+++ scheduler/cupsfilter.c	(working copy)
@@ -110,6 +110,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 */
@@ -360,6 +361,10 @@
     return (1);
   }
 
+  snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
+  if (!access(mimedir, 0))
+    mime = mimeMerge(mime, mimedir, Path);
+
  /*
   * Get the source and destination types...
   */
Index: scheduler/type.c
===================================================================
--- scheduler/type.c	(revision 7661)
+++ scheduler/type.c	(working copy)
@@ -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);
 
@@ -396,6 +397,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);
       }
@@ -532,7 +538,8 @@
 {
   _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\", "
@@ -578,11 +585,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)...
@@ -593,7 +603,7 @@
 
   cupsFileClose(fb.fp);
 
-  return (type);
+  return (best);
 }
 
 
Index: scheduler/conf.c
===================================================================
--- scheduler/conf.c	(revision 7661)
+++ scheduler/conf.c	(working copy)
@@ -346,6 +346,7 @@
   cups_file_t	*fp;			/* Configuration file */
   int		status;			/* Return status */
   char		temp[1024],		/* Temporary buffer */
+		mimedir[1024],		/* MIME directory */
 		*slash;			/* Directory separator */
   cups_lang_t	*language;		/* Language */
   struct passwd	*user;			/* Default user */
@@ -1113,6 +1114,7 @@
     */
 
     snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
+    snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
 
     MimeDatabase = mimeLoad(ServerRoot, temp);
 
@@ -1123,6 +1125,9 @@
       exit(errno);
     }
 
+    if (!access(mimedir, 0))
+      MimeDatabase = mimeMerge(MimeDatabase, mimedir, temp);
+
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Loaded MIME database from \'%s\': %d types, %d filters...",
                     ServerRoot, mimeNumTypes(MimeDatabase),
Index: scheduler/testmime.c
===================================================================
--- scheduler/testmime.c	(revision 7661)
+++ scheduler/testmime.c	(working copy)
@@ -3,7 +3,7 @@
  *
  *   MIME test program 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
Index: scheduler/mime.h
===================================================================
--- scheduler/mime.h	(revision 7661)
+++ scheduler/mime.h	(working copy)
@@ -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;
