code:
#!/usr/bin/python
# $Id$
# Update CUPS PPDs for Gutenprint queues.
# Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org)
# Copyright (C) 2009, 2011 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

import getopt
import glob
import os
import re
import stat
import subprocess
import sys

global optargs
global debug
global verbose
global interactive
global quiet
global no_action
global reset_defaults
global version
global micro_version
global use_static_ppd
global file_version

global ppd_dir
global ppd_root_dir
global ppd_base_dir
global ppd_out_dir
global gzext
global updated_ppd_count
global skipped_ppd_count
global failed_ppd_count
global exit_after_parse_args
global languages

global serverdir
global driver_bin
global driver_version
global server_multicat
global server_multicat_initialized

global ppd_files
global languagemappings

def help():
    print """
Usage: %s [OPTION]... [PPD_FILE]...
Update CUPS+Gutenprint PPD files.

  -d flags    Enable debugging
  -h          Display this help text
  -n          No-action.  Don't overwrite any PPD files.
  -q          Quiet mode.  No messages except errors.
  -s ppd_dir  Use ppd_dir as the source PPD directory.
  -p ppd_dir  Update PPD files in ppd_dir.
  -P driver   Use the specified driver binary to generate PPD files.
  -v          Verbose messages.
  -N          Reset options to defaults.
  -o out_dir  Output PPD files to out_dir.
  -r version  Use PPD files for Gutenprint major.minor version.
  -f          Ignore new PPD file safety checks.
  -i          Prompt (interactively) for each PPD file.
  -l language Language choice (Gutenprint 5.1 or below).
              Choices: %s
              Or -loriginal to preserve original language
                 with Gutenprint 5.2 or above
""" % (sys.argv[0],
       reduce (lambda x,y: "%s %s" % (x,y), languages))
    sys.exit (0)

def die_if_not_directory (dir):
    try:
        st = os.stat (dir)
        if not st.S_ISDIR (st.st_mode):
            os.chdir (dir)
    except OSError, (e, s):
        print "%s: invalid directory: %s" % (dir, s)
        sys.exit (1)

def get_driver_version():
    global server_multicat
    global driver_version

    def run_with_arg (arg):
        try:
            p = subprocess.Popen ([driver_bin, arg],
                                  stdin=file("/dev/null"),
                                  stdout=subprocess.PIPE,
                                  stderr=file("/dev/null", "w"),
                                  shell=False)
            (stdout, stderr) = p.communicate ()
        except OSError:
            return None

        return stdout

    stdout = run_with_arg ("org.gutenprint.extensions")
    if stdout == None:
        return
    for line in stdout.split ("\n"):
        if line == "org.gutenprint.multicat":
            server_multicat = 1
            break

    stdout = run_with_arg ("VERSION")
    if stdout == None:
        return

    driver_version = stdout.strip ()

def parse_options():
    try:
        opts, args = getopt.getopt (sys.argv[1:], "d:hnqs:vNo:p:P:r:ifl:")
    except getopt.GetoptError:
        help ()

    global optargs
    global debug
    global verbose
    global interactive
    global quiet
    global no_action
    global reset_defaults
    global version
    global micro_version
    global use_static_ppd
    global file_version
    global ppd_dir
    global ppd_out_dir
    global ppd_base_dir
    global ppd_root_dir
    global serverdir
    global driver_bin
    global driver_version
    global server_multicat
    global languages
    optargs = dict()
    for opt, optarg in opts:
        optargs[opt[1]] = optarg

    if optargs.has_key ('n'):
        no_action = 1

    if optargs.has_key ('d'):
        try:
            debug = int (optargs['d'])
        except ValueError:
            d = 0

    if optargs.has_key ('v'):
        verbose = 1
        quiet = 0

    if optargs.has_key ('q'):
        verbose = 0
        quiet = 1

    if optargs.has_key ('N'):
        reset_defaults = 1

    if optargs.has_key ('o'):
        opt_o = optargs['o']
        die_if_not_directory (opt_o)
        ppd_out_dir = opt_o

    if optargs.has_key ('r'):
        opt_r = optargs['r']
        if version != opt_r:
            version = opt_r
            if optargs.has_key ('s'):
                opt_s = optargs['s']
                die_if_not_directory (opt_s)
                ppd_base_dir = opt_s
                driver_bin = ""
                server_multicat = 0
                use_static_ppd = "yes"
            else:
                ppd_base_dir = ppd_root_dir + "/gutenprint/" + version
                driver_bin = serverdir + "/driver/gutenprint." + version

            driver_version = ""
            # If user specifies version, we're not going to be able to check
            # for an exact match.
            file_version = '"' + version
            if os.access (driver_bin, os.X_OK):
                get_driver_version ()
                use_static_ppd = "no"
                file_version = "\"%s\"$" % driver_version
            else:
                print "Gutenprint %s does not appear to be installed!" % version
                sys.exit (1)

    if optargs.has_key ('s'):
        opt_s = optargs['s']
        die_if_not_directory (opt_s)
        ppd_base_dir = opt_s
        driver_bin = ""
        server_multicat = 0
        driver_version = ""
        use_static_ppd = "yes"

    if optargs.has_key ('p'):
        opt_p = optargs['p']
        die_if_not_directory (opt_p)
        ppd_dir = opt_p

    if optargs.has_key ('P'):
        opt_P = optargs['P']
        if os.access (opt_P, os.X_OK):
            driver_bin = opt_P
            get_driver_version ()
            use_static_ppd = "no"
        else:
            print "%s: invalid executable" % opt_P

    if optargs.has_key ('h'):
        help ()

    if (optargs.has_key ('l') and
        optargs['l'].lower () != "original" and
        optargs['l'].lower () not in languages):
        print >>sys.stderr, "Unknown language '%s'" % optargs['l']

    if optargs.has_key ('i'):
        interactive = 1

    if exit_after_parse_args:
        sys.exit (0)

    if verbose and driver_version != "":
        print "Updating PPD files from Gutenprint %s" % driver_version

    return args

def update_ppd (ppd_source_filename):
    global ppd_dest_filename
    global ppd_out_dir
    global optargs
    global languagemappings
    global interactive
    global server_multicat
    global no_action
    global quiet, verbose
    global reset_defaults

    ppd_dest_filename = ppd_source_filename
    if ppd_out_dir:
        ppd_dest_filename = "%s/%s" % (ppd_out_dir,
                                       os.path.basename (ppd_dest_filename))

    orig = file (ppd_source_filename)
    orig_metadata = os.fstat (orig.fileno ())
    if debug & 1:
        print "Source Filename: %s" % ppd_source_filename

    filename = ""
    driver = ""
    gutenprintdriver = ""
    locale = ""
    lingo = ""
    region = ""
    valid = 0
    orig_locale = ""
    for line in orig.readlines ():
        line.rstrip ()
        if line.find ("*StpLocale:") != -1:
            match = re.search ("\*StpLocale:\s*\"(.*)\"$", line)
            if match:
                groups = match.groups ()
                if len (groups) >= 1:
                    locale = groups[0]
                    orig_locale = locale
                    valid = 1
        elif line.startswith ("*LanguageVersion"):
            match = re.search ("^\*LanguageVersion:\s*(.*)$", line)
            if match:
                groups = match.groups ()
                if len (groups) >= 1:
                    lingo = groups[0]
        elif line.startswith ("*StpDriverName:"):
            match = re.search ("^\*StpDriverName:\s*\"(.*)\"$", line)
            if match:
                groups = match.groups ()
                if len (groups) >= 1:
                    driver = groups[0]
                    valid = 1
        elif line.find ("*%End of ") != -1 and driver == "":
            match = re.search ("^\*%End of\s*(.*).ppd$", line)
            if match:
                groups = match.groups ()
                if len (groups) >= 1:
                    driver = groups[0]
        elif line.startswith ("*StpPPDLocation:"):
            match = re.search ("^\*StpPPDLocation:\s*\"(.*)\"$", line)
            if match:
                groups = match.groups ()
                if len (groups) >= 1:
                    filename = groups[0]
                    valid = 1
        elif line.startswith ("*%Gutenprint Filename:"):
            valid = 1

        if filename and driver and lingo and locale:
            break

        if not valid and line.startswith ("*OpenUI"):
            break

    if not valid:
        #print >>sys.stderr, ("Skipping %s: not a Gutenprint PPD file" %
        #                     ppd_source_filename)
        return -1

    if (optargs.has_key ('l') and
        optargs['l'] != "" and
        optargs['l'].lower () != "original"):
        locale = optargs['l']
        orig_locale = locale

    if debug & 2:
        print "Gutenprint Filename: %s" % filename
        if optargs.has_key ('l'):
            print "Locale: %s (from -l)" % locale
        else:
            print "Locale: %s" % locale

        print "Language: %s" % lingo
        print "Driver: %s" % driver

    if locale:
        # Split into the language and territory.
        s = locale.split ("_", 1)
        locale = s[0]
        try:
            region = s[1]
        except IndexError:
            region = ""
    else:
        # Split into the language and territory.
        s = lingo.split ("_", 1)
        locale = s[0]
        try:
            region = s[1]
        except IndexError:
            region = ""

        # Convert language into language code.
        locale = languagemappings.get (lingo.lower (), "C")

    if debug & 2:
        print "Base Locale: %s" % locale
        print "Region: %s" % region

    # Read in the new PPD, decompressing it if needed...
    (new_ppd_filename, source_fd) = get_ppd_fh (ppd_source_filename,
                                                filename,
                                                driver,
                                                locale,
                                                region)
    if source_fd == None:
        print "Unable to retrieve PPD file!"
        return 0

    if interactive:
        inp = raw_input ("Update PPD %s from %s [nyq]? " % ppd_source_filename)
        inp = inp.lower ()
        if inp.startswith ("q"):
            if not server_multicat:
                source_fd.close ()

            print "Skipping all..."
            return -2
        elif not inp.startswith ("y"):
            if not server_multicat:
                source_fd.close ()

            print "Skipping..."
            return -1

    # Extract the default values from the original PPD...

    orig.seek (0)
    (odt, oopt, ores, odef, unused) = get_ppd_data (orig, 1, 0, 1, 1, 0)
    (ndt, nopt, nres, ndef, source_data) = get_ppd_data (source_fd,
                                                         1, 1, 1, 1, 1)

    # Close original and temporary files...

    orig.close ()
    if not server_multicat:
        source_fd.close ()

    orig_default_types = odt
    new_default_types = ndt
    defaults = odef
    new_defaults = ndef
    options = nopt
    resolution_map = nres
    old_resolution_map = dict()
    for key, value in resolution_map.iteritems ():
        old_resolution_map[value] = key

    # Store previous language in the PPD file so that -l original works
    # correctly.

    if orig_locale != "":
        lines = source_data.rstrip ().split ("\n")
        source_data = ""
        for line in lines:
            m = re.search ("(\*StpLocale:\s*\")(.*)(\")", line)
            if m:
                groups = m.groups ()
                line = groups[0] + orig_locale + groups[2]

            source_data += line + "\n"

    if debug & 4:
        print "Options (Old->New Default Type):"
        keys = options.keys ()
        keys.sort ()
        for t in keys:
            old_type = orig_default_types.get (t, "(New)")
            new_type = new_default_types.get (t)
            if old_type != new_type:
                out = "  %s (%s -> %s) :  " % (t, old_type, new_type)
            else:
                out = "  %s (%s) :  " % (t, new_type)

            dft = defaults.get ("Default%s" % t)
            for opt in options.get (t, []):
                if dft != None and dft == opt:
                    out += "*"

                out += "%s " % opt

            print out

        if len (resolution_map.keys ()) > 0:
            print "Resolution Map:"
            keys = resolution_map.keys ()
            keys.sort ()
            for key in keys:
                print "   %s: %s" % (key, resolution_map[key])

        if len (old_resolution_map.keys ()) > 0:
            print "Old Resolution Map:"
            keys = old_resolution_map.keys ()
            keys.sort ()
            for key in keys:
                print "   %s: %s" % (key, old_resolution_map[key])

        print "Non-UI Defaults:"
        keys = defaults.keys ()
        keys.sort ()
        for key in keys:
            xkey = key
            if xkey.startswith ("Default"):
                xkey = xkey[7:]
            if not options.has_key (xkey):
                print "  %s: %s" % (key, defaults[key])

        print "Default Types of dropped options:"
        keys = orig_default_types.keys ()
        keys.sort ()
        for t in keys:
            if not options.has_key (t):
                print "  %s: %s" % (t, orig_default_types[t])

    if no_action:
        if not quiet or verbose:
            if ppd_dest_filename == ppd_source_filename:
                print "Would update %s using %s" % (ppd_source_filename,
                                                    new_ppd_filename)
            else:
                print "Would update %s to %s using %s" % (ppd_source_filename,
                                                          ppd_dest_filename,
                                                          new_ppd_filename)

        return 0

    if not reset_defaults:
        # Update source buffer with old defaults...

        # Loop through each default in turn.
        keys = defaults.keys ()
        keys.sort ()
        for default_option in keys:
            default_option_value = defaults[default_option]
            option = default_option
            if option.startswith ("Default"):
                # Strip off `Default'
                option = option[7:]

            # Check method is valid
            orig_method = orig_default_types.get (option)
            new_method = new_default_types.get (option)
            new_default = new_defaults.get (default_option)
            if (orig_method == None or new_method == None or
                orig_method != new_method):
                continue

            if (new_default != None and
                default_option_value == new_default):
                if verbose:
                    print "%s: Preserve *%s (%s)" % (ppd_source_filename,
                                                     default_option,
                                                     default_option_value)

                continue

            if new_method == "PickOne":
                next_default = False

                # Check the old setting is valid
                for opt in options.get (option, []):
                    def_option = default_option_value
                    odef_option = def_option
                    if (option == "Resolution" and
                        old_resolution_map.has_key (def_option)):
                        if debug & 4:
                            print ("Intermapping old resolution %s to %s" %
                                   def_option, old_resolution_map[def_option])

                        def_option = old_resolution_map[def_option]

                    dopts = [def_option]
                    if def_option != odef_option:
                        dopts.append (odef_option)

                    for dopt in dopts:
                        valid = False
                        if dopt == opt:
                            valid = True
                        elif (option == "Resolution" and
                              resolution_map.has_key (dopt)):
                            dopt = resolution_map[dopt]
                            if dopt == opt:
                                valid = True

                        if valid:
                            # Valid option

                            # Set the option in the new PPD
                            lines = source_data.rstrip ().split ("\n")
                            source_data = ""
                            attr = "*%s" % default_option
                            for line in lines:
                                if line.startswith (attr):
                                    line = "%s:%s" % (attr, dopt)

                                source_data += line + "\n"

                            if verbose:
                                print "%s: Set *%s to %s" % (ppd_source_filename,
                                                             default_option,
                                                             dopt)

                            next_default = True
                            break
                    if next_default:
                        break

                if next_default:
                    continue

                print ("Warning: %s: Invalid option: *%s: %s.  Using default "
                       "setting %s." % (ppd_source_filename, default_option,
                                        defaults[default_option],
                                        new_defaults[default_option]))
                continue

            print ("Warning: %s: PPD OpenUI method %s not understood." %
                   (ppd_source_filename, new_default_types[default_option]))

    # Write new PPD...
    tmpnew = "%s.new" % ppd_dest_filename
    try:
        newppd = file (tmpnew, "w")
    except IOError, (e, s):
        print "Can't create %s: %s" % (tmpnew, s)
        return 0

    newppd.writelines (source_data)
    try:
        newppd.close ()
    except IOError, (e, s):
        print "Can't write to %s: %s" % (tmpnew, s)
        return 0

    chcon = subprocess.Popen (["chcon", "--reference=%s" % ppd_dest_filename,
                               tmpnew], shell=False,
                              stdin=file("/dev/null"),
                              stdout=file("/dev/null", "w"),
                              stderr=subprocess.STDOUT)
    chcon.communicate ()

    try:
        os.rename (tmpnew, ppd_dest_filename)
    except OSError, (e, s):
        print "Can't rename %s to %s: %s" % (tmpnew, ppd_dest_filename, s)
        try:
            os.unlink (tmpnew)
        except OSError:
            pass

        return 0

    try:
        os.chown (ppd_dest_filename,
                  orig_metadata.st_uid,
                  orig_metadata.st_gid)
    except OSError:
        pass

    try:
        os.chmod (ppd_dest_filename,
                  orig_metadata.st_mode & 0777)
    except OSError:
        pass

    if not quiet or verbose:
        if ppd_dest_filename == ppd_source_filename:
            print "Updated %s using %s" % (ppd_source_filename,
                                           new_ppd_filename)
        else:
            print "Updated %s to %s using %s" % (ppd_source_filename,
                                                 ppd_dest_filename,
                                                 new_ppd_filename)

    # All done!
    return 1

def get_ppd_data (fh, types, opts, resolutions, defaults, data):
    options_map = dict()
    defaults_map = dict()
    resolution_map = dict()
    default_types = dict()
    cur_opt = ""
    optionlist = []
    source_data = ""

    if reset_defaults:
        types = 0
        opts = 0
        resolutions = 0
        defaults = 0

    if resolutions or types or opts or defaults or data:
        while True:
            line = fh.readline ()
            if line == '':
                break
            if line == "*%*%EOFEOF\n":
                break
            source_data += line
            line = line.strip ()

            if (types or opts) and line.startswith ("*OpenUI"):
                m = re.search ("^\*OpenUI\s\*(\w+).*:\s(\w+)",
                               line)
                if m:
                    groups = m.groups ()
                    key = groups[0]
                    value = groups[1]
                    default_types[key] = value
                    cur_opt = key
            elif opts and line.startswith ("*CloseUI"):
                if cur_opt != "":
                    options_map[cur_opt] = optionlist
                    cur_opt = ""

                optionlist = []
            elif opts and line.startswith ("*%s" % cur_opt):
                m = re.search ("^\*%s\s*(\w+)[\/:]" % cur_opt, line)
                if m:
                    groups = m.groups()
                    if len (groups) >= 1:
                        value = m.groups ()[0]
                        optionlist.append (value)
            elif resolutions and line.startswith ("*StpResolutionMap:"):
                s = line.split (None, 3)
                if len (s) == 3:
                    new = s[1]
                    old = s[2]
                    resolution_map[old] = new
            elif defaults and line.startswith ("*Default"):
                m = re.search ("^\*(\w+):\s*(\w+)", line)
                if m:
                    groups = m.groups ()
                    key = groups[0]
                    value = groups[1]
                    defaults_map[key] = value

    return (default_types, options_map, resolution_map,
            defaults_map, source_data)

def get_ppd_fh (ppd_source_filename, filename, driver, locale, region):
    global use_static_ppd
    global driver_version
    global optargs
    global driver_bin
    global debug
    global server_multicat, server_multicat_initialized
    global gzext

    if use_static_ppd == "no" and driver_version != "":
        if re.search (".*/([^/]*)(.sim)(.ppd)?(.gz)?$", filename):
            simplified = "simple"
        else:
            simplified = "expert"

        opt_r = optargs.get ('r')
        if opt_r:
            try:
                opt_r = float (opt_r)
            except ValueError:
                opt_r = None

        url_list = []
        if (((opt_r != None and opt_r < 5.2) or
             (optargs.has_key ('l') and optargs['l'] != "")) and
            locale != ""):
            if region:
                url_list.append ("gutenprint.%s://%s/%s/%s_%s" %
                                 version, driver, simplified, locale, region)
            url_list.append ("gutenprint.%s://%s/%s/%s" %
                             version, driver, simplified, locale)

        url_list.append ("gutenprint.%s://%s/%s" % (version, driver,
                                                    simplified))
        for url in url_list:
            new_ppd_filename = url
            if debug & 8:
                if server_multicat:
                    cat = ""
                else:
                    cat = "%s cat " % driver_bin

                print ("Trying %s%s for %s, %s, %s, %s" %
                       (cat, url, driver, simplified, locale, region))

            if server_multicat:
                try:
                    if not server_multicat_initialized:
                        mc_proc = subprocess.Popen ([driver_bin,
                                                     "org.gutenprint.multicat"],
                                                    shell=False,
                                                    stdin=subprocess.PIPE,
                                                    stdout=subprocess.PIPE,
                                                    stderr=file("/dev/null",
                                                                "w"))
                        server_multicat_initialized = mc_proc

                    print >>server_multicat_initialized.stdin, "%s" % url
                    server_multicat_initialized.stdin.flush ()
                    return (new_ppd_filename,
                            server_multicat_initialized.stdout)
                except OSError:
                    pass

            try:
                proc = subprocess.Popen ([driver_bin, "cat", url],
                                         shell=False,
                                         stdin=file("/dev/null"),
                                         stdout=subprocess.PIPE,
                                         stderr=file("/dev/null", "w"))
                return (new_ppd_filename, proc.stdout)
            except OSError:
                pass

        # Otherwise fall through and try to find a static PPD

    # Search for a PPD matching our criteria...

    new_ppd_filename = find_ppd (filename, driver, locale, region)
    if not new_ppd_filename:
        # There wasn't a valid source PPD file, so give up.
        print >>sys.stderr, ("%s: no valid candidate for replacement.  "
                             "Skipping" % ppd_source_filename)
        print >>sys.stderr, ("%s: please upgrade this PPD manually" %
                             ppd_source_filename)
        return ("", None)

    if debug & 1:
        print "Candidate PPD: %s" % new_ppd_filename

    suffix = "\\" + gzext # Add '\' so the regexp matches the '.'
    if new_ppd_filename.endswith (".gz"):
        # Decompress input buffer
        try:
            proc = subprocess.Popen (['gunzip', '-c', new_ppd_filename],
                                     shell=False,
                                     stdin=file("/dev/null"),
                                     stdout=subprocess.PIPE,
                                     stderr=file("/dev/null", "w"))
        except OSError, (e, s):
            print "can't open for decompression: %s" % s
            sys.exit (1)

        return (new_ppd_filename, proc.stdout)
    else:
        return (new_ppd_filename, file (new_ppd_filename))

def find_ppd (gutenprintfilename, drivername, lang, region):
    global file_version
    global optargs
    global ppd_base_dir
    global ppd_root_dir
    global debug

    key = '^\\*FileVersion:[ 	]*' + file_version
    match = re.search (".*/([^/]+\.[0-9]+\.[0-9]+)(\.sim)?(\.ppd)?(\.gz)?$",
                       gutenprintfilename)
    if not match:
        return None

    stored_name = match.groups ()[0]
    if re.search (".*/([^/]*)(\.sim)(\.ppd)?(\.gz)?$", gutenprintfilename):
        simplified = ".sim"
    else:
        simplified = ""

    stored_dir = os.path.dirname (gutenprintfilename)

    current_best_file = ""
    current_best_time = 0
    if optargs.has_key ('s'):
        basedirs = [optargs['s']]
    else:
        basedirs = [ppd_base_dir, stored_dir, ppd_root_dir]

    lingos = []
    if region != "":
        lingos.append ("%s_%s/" % (lang, region))

    lingos.append ("%s/" % lang)
    if lang != "C":
        lingos.append ("C/")

    lingos.append ("en/")
    lingos.append ("")
    lingos.append ("Global/")
    bases = ["stp-%s.%s%s" % (drivername, version, simplified),
             "%s.%s%s" % (drivername, version, simplified)]
    if stored_name not in bases:
        bases.append (stored_name)

    bases.append (drivername)

    # All possible candidates, in order of usefulness and gzippedness
    for lingo in lingos:
        for suffix in (".ppd%s" % gzext,
                       ".ppd"):
            for base in bases:
                for basedir in basedirs:
                    if basedir == "" or base == "":
                        continue

                    fn = "%s/%s%s%s" % (basedir, lingo, base, suffix)
                    if debug & 8:
                        print ("Trying %s for %s, %s, %s" %
                               (fn, gutenprintfilename, lang, region))

                    try:
                        st = os.stat (fn)
                    except OSError:
                        continue

                    if (optargs.has_key ('f') or
                        (stat.S_ISREG (st.st_mode) and
                         st.st_uid == 0)):
                        # Check that the file is a valid Gutenprint PPD file
                        # of the correct version.
                        if fn.endswith (".gz"):
                            cmdline = "gunzip -c '%s' | grep '%s'" % (fn, key)
                        else:
                            cmdline = "cat '%s' | grep '%s'" % (fn, key)

                        try:
                            p = subprocess.Popen (cmdline,
                                                  stdin=file("/dev/null"),
                                                  stdout=subprocess.PIPE,
                                                  stderr=file("/dev/null", "w"))
                        except OSError:
                            new_file_version = ""
                        else:
                            (stdin, stderr) = p.communicate ()
                            new_file_version = stdin.rstrip ()

                        if new_file_version != "":
                            if debug & 8:
                                print ("   Format valid: time %s best %s "
                                       "prev %s cur %s!" %
                                       (st.st_mtime, current_best_time,
                                        current_best_file, fn))

                            if st.st_mtime > current_best_time:
                                current_best_time = st.st_mtime
                                current_best_file = fn
                                if debug & 8:
                                    print >>sys.stderr, ("***current_best_file "
                                                         " is %s" % fn)
                        elif debug & 8:
                            print "   Format invalid"
                    else:
                        if (not stat.S_ISDIR (st.st_mode) and
                            not fn.endswith ("/")):
                            print >>sys.stderr, ("%s: not a regular file, "
                                                 "or insecure ownership and "
                                                 "permissions.  Skipped" % fn)

    if current_best_file:
        return current_best_file

    # Yikes!  Cannot find a valid PPD file!
    return None

debug=0
verbose=0
interactive=0
quiet=0
no_action=0
reset_defaults=0
version="@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@"
micro_version="@GUTENPRINT_VERSION@"
use_static_ppd="@BUILD_CUPS_PPDS@"
file_version='"@VERSION@"$'

ppd_dir = "@cups_conf_serverroot@/ppd"
ppd_root_dir = "@cups_conf_datadir@/model";
ppd_base_dir = ppd_root_dir + "/gutenprint/" + version
ppd_out_dir = ""
gzext = ".gz"
updated_ppd_count = 0
skipped_ppd_count = 0
failed_ppd_count = 0
exit_after_parse_args = 0
languages=["Global", "C"] + "@ALL_LINGUAS@".split (' ')

serverdir = "@cups_conf_serverbin@"
driver_bin = serverdir + "/driver/gutenprint." + version
driver_version = ""
server_multicat = 0
server_multicat_initialized = 0

if os.access (driver_bin, os.X_OK):
    get_driver_version ()

ppd_files = []
languagemappings = { "chinese": "cn",
                     "danish": "da",
                     "dutch": "nl",
                     "english": "en",
                     "finnish": "fi",
                     "french": "fr",
                     "german": "de",
                     "greek": "el",
                     "hungarian": "hu",
                     "italian": "it",
                     "japanese": "jp",
                     "norwegian": "no",
                     "polish": "pl",
                     "portuguese": "pt",
                     "russian": "ru",
                     "slovak": "sk",
                     "spanish": "es",
                     "swedish": "sv",
                     "turkish": "tr" }

# Check command-line options...
args = parse_options()

# Set a secure umask...
os.umask (0177)

# Find all in-use Gutenprint PPD files...
# For case-insensitive filesystems, use only one of .ppd and .PPD
# (bug 1929738)

for f in args:
    if (os.access (f, os.F_OK) and
        (f.lower ().endswith (".ppd") or
         f.find ("/") != -1)):
        ppd_files.append (f)
    elif os.access ("%s/%s" % (ppd_dir, f), os.F_OK):
        ppd_files.append ("%s/%s" % (ppd_dir, f))
    elif os.access ("%s/%s.ppd" % (ppd_dir, f), os.F_OK):
        ppd_files.append ("%s/%s.ppd" % (ppd_dir, f))
    elif os.access ("%s/%s.PPD" % (ppd_dir, f), os.F_OK):
        ppd_files.append ("%s/%s.PPD" % (ppd_dir, f))
    else:
        print >>sys.stderr, ("Cannot find file %s/%s, %s/%s.ppd, or %s/%s.PPD" %
                             ppd_dir, f, ppd_dir, f, ppd_dir, f)

if len (args) == 0:
    ppdtmp = glob.glob ("%s/*.ppd" % ppd_dir)
    ppdtmp += glob.glob ("%s/*.PPD" % ppd_dir)
    ppd_map = dict()
    for each in ppdtmp:
        ppd_map[each] = 1

    for f in ppdtmp:
        if f.endswith (".PPD"):
            g = f[:-4] + ".ppd"
            if not ppd_map.has_key (g):
                ppd_files.append (f)
        else:
            ppd_files.append (f)

# Update each of the Gutenprint PPDs, where possible...

for ppd_file in ppd_files:
    status = update_ppd (ppd_file)
    if status == -2:
        break
    elif status == 0:
        failed_ppd_count += 1
    elif status == 1:
        updated_ppd_count += 1
    elif status == -1:
        skipped_ppd_count += 1

if (not quiet) or verbose:
    if len (ppd_files) == 0:
        print "No Gutenprint PPD files to update."
    elif updated_ppd_count > 0:
        plural = ""
        if updated_ppd_count != 1:
            plural = "s"

        print "Updated %d PPD file%s" % (updated_ppd_count, plural)
        if ((not optargs.has_key ('o')) or
            optargs['o'] != ""):
            print "Restart cupsd for the changes to take effect."
    else:
        if failed_ppd_count > 0:
            print "Failed to update any PPD files"
        else:
            print "Did not update any PPD files"

sys.exit (failed_ppd_count > 0)


code:
diff -up gutenprint-5.2.12-pre3/configure.ac.O6 gutenprint-5.2.12-pre3/configure.ac
--- gutenprint-5.2.12-pre3/configure.ac.O6	2016-10-14 10:41:54.290398824 +0200
+++ gutenprint-5.2.12-pre3/configure.ac	2016-10-14 10:44:04.921328215 +0200
@@ -638,27 +638,6 @@ AH_TEMPLATE(PKGMODULEDIR,, [Package modu
 PKGMODULEDIR="${PACKAGE_LIB_DIR}/${GUTENPRINT_RELEASE_VERSION}/modules"
 AC_DEFINE_UNQUOTED(PKGMODULEDIR, ["$PKGMODULEDIR"])

-dnl Compiler flags
-if test x$ac_compiler_gnu = "xyes"; then
-  STP_ADD_COMPILER_ARGS([-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wwrite-strings -Werror-implicit-function-declaration -Winline -Wformat=2 -finline-limit=131072],, [GNUCFLAGS])
-  if test x${USE_MAINTAINER_MODE} = xyes ; then
-    STP_ADD_COMPILER_ARGS([-D_POSIX_C_SOURCE=200809L -std=c99 -pedantic -Waggregate-return -Wcast-qual -Wshadow -Wredundant-decls],, [GNUCFLAGS])
-  fi
-  if test x$ENABLE_DEBUG = xyes ; then
-    STP_ADD_COMPILER_ARG([-g])
-  else
-    STP_ADD_FIRST_COMPILER_ARG([-O6 -O3 -O2 -O1 -O])
-  fi
-else
-  if test x$ENABLE_DEBUG = xyes ; then
-    STP_ADD_COMPILER_ARG([-g])
-  else
-    STP_ADD_FIRST_COMPILER_ARG([-O])
-  fi
-fi
-if test x$ENABLE_PROFILE = xyes ; then
-  STP_ADD_COMPILER_ARG([-pg])
-fi
 AC_SUBST(GNUCFLAGS)

 AH_TEMPLATE([HAVE_GCC_ATTRIBUTES],
diff -up gutenprint-5.2.12-pre3/configure.O6 gutenprint-5.2.12-pre3/configure
--- gutenprint-5.2.12-pre3/configure.O6	2016-10-14 10:41:54.293398800 +0200
+++ gutenprint-5.2.12-pre3/configure	2016-10-14 10:53:25.392709079 +0200
@@ -17651,246 +17651,6 @@ cat >>confdefs.h <<_ACEOF
 #define PKGMODULEDIR "$PKGMODULEDIR"
 _ACEOF

-
-if test x$ac_compiler_gnu = "xyes"; then
-
-  for stp_ac_arg in -Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wwrite-strings -Werror-implicit-function-declaration -Winline -Wformat=2 -finline-limit=131072 ; do
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports ${stp_ac_arg}" >&5
-$as_echo_n "checking if ${CC} supports ${stp_ac_arg}... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${GNUCFLAGS} ${stp_ac_arg}"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  GNUCFLAGS="${stp_newCFLAGS}"
-
-  done
-
-  if test x${USE_MAINTAINER_MODE} = xyes ; then
-
-  for stp_ac_arg in -D_POSIX_C_SOURCE=200809L -std=c99 -pedantic -Waggregate-return -Wcast-qual -Wshadow -Wredundant-decls ; do
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports ${stp_ac_arg}" >&5
-$as_echo_n "checking if ${CC} supports ${stp_ac_arg}... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${GNUCFLAGS} ${stp_ac_arg}"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  GNUCFLAGS="${stp_newCFLAGS}"
-
-  done
-
-  fi
-  if test x$ENABLE_DEBUG = xyes ; then
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports -g" >&5
-$as_echo_n "checking if ${CC} supports -g... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${CFLAGS} -g"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  CFLAGS="${stp_newCFLAGS}"
-
-  else
-
-  for stp_ac_arg in -O6 -O3 -O2 -O1 -O ; do
-    stp_ac_save_CFLAGS="${CFLAGS}"
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports ${stp_ac_arg}" >&5
-$as_echo_n "checking if ${CC} supports ${stp_ac_arg}... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${CFLAGS} ${stp_ac_arg}"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  CFLAGS="${stp_newCFLAGS}"
-
-    test "${stp_ac_save_CFLAGS}" != "${CFLAGS}" && break
-  done
-
-  fi
-else
-  if test x$ENABLE_DEBUG = xyes ; then
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports -g" >&5
-$as_echo_n "checking if ${CC} supports -g... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${CFLAGS} -g"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  CFLAGS="${stp_newCFLAGS}"
-
-  else
-
-  for stp_ac_arg in -O ; do
-    stp_ac_save_CFLAGS="${CFLAGS}"
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports ${stp_ac_arg}" >&5
-$as_echo_n "checking if ${CC} supports ${stp_ac_arg}... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${CFLAGS} ${stp_ac_arg}"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  CFLAGS="${stp_newCFLAGS}"
-
-    test "${stp_ac_save_CFLAGS}" != "${CFLAGS}" && break
-  done
-
-  fi
-fi
-if test x$ENABLE_PROFILE = xyes ; then
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ${CC} supports -pg" >&5
-$as_echo_n "checking if ${CC} supports -pg... " >&6; }
-  stp_acOLDCFLAGS="${CFLAGS}"
-  CFLAGS="${CFLAGS} -pg"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; };
-        stp_newCFLAGS="$CFLAGS"
-else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; };
-	stp_newCFLAGS="$stp_acOLDCFLAGS"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  CFLAGS="$stp_acOLDCFLAGS"
-  CFLAGS="${stp_newCFLAGS}"
-
-fi
-
-
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports __attribute__ syntax" >&5
 $as_echo_n "checking if $CC supports __attribute__ syntax... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext

repo_name: ayhanyalcinsoy/main


code:
diff -up gutenprint-5.2.7/src/cups/commandtocanon.c.build gutenprint-5.2.7/src/cups/commandtocanon.c
--- gutenprint-5.2.7/src/cups/commandtocanon.c.build	2011-06-07 13:32:37.372042304 +0100
+++ gutenprint-5.2.7/src/cups/commandtocanon.c	2011-06-07 13:32:41.270970750 +0100
@@ -13,6 +13,7 @@

 #include <cups/cups.h>
 #include <ctype.h>
+#include <stdio.h>
 #include <stdlib.h>

diff -up gutenprint-5.2.7/src/cups/commandtoepson.c.build gutenprint-5.2.7/src/cups/commandtoepson.c
--- gutenprint-5.2.7/src/cups/commandtoepson.c.build	2007-12-24 17:19:20.000000000 +0000
+++ gutenprint-5.2.7/src/cups/commandtoepson.c	2011-06-07 13:32:35.656073794 +0100
@@ -30,6 +30,7 @@

 #include <cups/cups.h>
 #include <ctype.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>


code:
diff -up gutenprint-5.2.8/src/xml/printers.xml.device-ids gutenprint-5.2.8/src/xml/printers.xml
--- gutenprint-5.2.8/src/xml/printers.xml.device-ids	2012-05-31 02:57:53.000000000 +0200
+++ gutenprint-5.2.8/src/xml/printers.xml	2012-06-12 10:03:16.344274655 +0200
@@ -149,16 +149,16 @@
       <printer translate="name" name="Canon PIXMA iP100" driver="bjc-PIXMA-iP100" manufacturer="Canon" model="3000100" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP100" />
       <printer translate="name" name="Canon PIXMA iP2000" driver="bjc-PIXMA-iP2000" manufacturer="Canon" model="3002000" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP2000" />
       <printer translate="name" name="Canon PIXMA iP2700" driver="bjc-PIXMA-iP2700" manufacturer="Canon" model="3002700" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP2700" />
-      <printer translate="name" name="Canon PIXMA iP3000" driver="bjc-PIXMA-iP3000" manufacturer="Canon" model="3003000" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3000" />
+      <printer translate="name" name="Canon PIXMA iP3000" deviceid="MFG:Canon;MDL:iP3000;DES:Canon iP3000;CMD:BJL,BJRaster3,BSCCe;" driver="bjc-PIXMA-iP3000" manufacturer="Canon" model="3003000" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3000" />
       <printer translate="name" name="Canon PIXMA iP3100" driver="bjc-PIXMA-iP3100" manufacturer="Canon" model="3003100" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3100" />
       <printer translate="name" name="Canon PIXMA iP3300" driver="bjc-PIXMA-iP3300" manufacturer="Canon" model="3003300" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3300" />
       <printer translate="name" name="Canon PIXMA iP3500" driver="bjc-PIXMA-iP3500" manufacturer="Canon" model="3003500" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3500" />
       <printer translate="name" name="Canon PIXMA iP3600" driver="bjc-PIXMA-iP3600" manufacturer="Canon" model="3003600" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP3600" />
-      <printer translate="name" name="Canon PIXMA iP4000" driver="bjc-iP4000" manufacturer="Canon" model="3004000" parameters="PIXMA_iP4000_params" foomaticid="Canon-iP4000" />
+      <printer translate="name" name="Canon PIXMA iP4000" deviceid="MFG:Canon;MDL:iP4000;CMD:BJL,BJRaster3,BSCCe;" driver="bjc-iP4000" manufacturer="Canon" model="3004000" parameters="PIXMA_iP4000_params" foomaticid="Canon-iP4000" />
       <printer translate="name" name="Canon PIXMA iP4000R" driver="bjc-PIXMA-iP4000R" manufacturer="Canon" model="3004000" parameters="PIXMA_iP4000_params" foomaticid="Canon-iP4000R" />
       <printer translate="name" name="Canon PIXMA iP4100" driver="bjc-PIXMA-iP4100" manufacturer="Canon" model="3004100" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP4100" />
       <printer translate="name" name="Canon PIXMA iP4100R" driver="bjc-PIXMA-iP4100R" manufacturer="Canon" model="3004100" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-iP4100R" />
-      <printer translate="name" name="Canon PIXMA iP4200" driver="bjc-PIXMA-iP4200" manufacturer="Canon" model="3004200" parameters="PIXMA_iP4200_params" foomaticid="Canon-PIXMA-iP4200" />
+      <printer translate="name" name="Canon PIXMA iP4200" deviceid="MFG:Canon;MDL:iP4200;CMD:BJL,BJRaster3,BSCCe;" driver="bjc-PIXMA-iP4200" manufacturer="Canon" model="3004200" parameters="PIXMA_iP4200_params" foomaticid="Canon-PIXMA-iP4200" />
       <printer translate="name" name="Canon PIXMA iP4300" driver="bjc-PIXMA-iP4300" manufacturer="Canon" model="3004300" parameters="PIXMA_iP4300_params" foomaticid="Canon-PIXMA-iP4300" />
       <printer translate="name" name="Canon PIXMA iP4500" driver="bjc-PIXMA-iP4500" manufacturer="Canon" model="3004500" parameters="PIXMA_iP4300_params" foomaticid="Canon-PIXMA-iP4500" />
       <printer translate="name" name="Canon PIXMA iP4600" driver="bjc-PIXMA-iP4600" manufacturer="Canon" model="3004600" parameters="PIXMA_iP4300_params" foomaticid="Canon-PIXMA-iP4600" />
@@ -188,7 +188,7 @@
       <printer translate="name" name="Canon PIXMA iX6500" driver="bjc-PIXMA-iX6500" manufacturer="Canon" model="4006500" parameters="PIXMA_iX5000_params" foomaticid="Canon-PIXMA-iX6500" />
       <printer translate="name" name="Canon PIXMA iX7000" driver="bjc-PIXMA-iX7000" manufacturer="Canon" model="4007000" parameters="PIXMA_iX5000_params" foomaticid="Canon-PIXMA-iX7000" />
       <printer translate="name" name="Canon PIXMA Pro9000" driver="bjc-PIXMA-Pro9000" manufacturer="Canon" model="7009000" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-Pro9000" />
-      <printer translate="name" name="Canon PIXMA Pro9000mk2" driver="bjc-PIXMA-Pro9000mk2" manufacturer="Canon" model="7009002" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-Pro9000-Mk2" />
+      <printer translate="name" name="Canon PIXMA Pro9000mk2" deviceid="MFG:Canon;MDL:Pro9000II series;CMD:BJL,BJRaster3,BSCCe,PLI;"  driver="bjc-PIXMA-Pro9000mk2" manufacturer="Canon" model="7009002" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-Pro9000-Mk2" />
       <printer translate="name" name="Canon PIXMA Pro9500" driver="bjc-PIXMA-Pro9500" manufacturer="Canon" model="7009500" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-Pro9500" />
       <printer translate="name" name="Canon PIXMA Pro9500mk2" driver="bjc-PIXMA-Pro9500mk2" manufacturer="Canon" model="7009502" parameters="PIXMA_iP4000_params" foomaticid="Canon-PIXMA-Pro9500-Mk2" />
       <printer translate="name" name="Canon PIXMA MP140" driver="bjc-MULTIPASS-MP140" manufacturer="Canon" model="5000150" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP140" />
@@ -200,7 +200,7 @@
       <printer translate="name" name="Canon PIXMA MP210" driver="bjc-MULTIPASS-MP210" manufacturer="Canon" model="5000210" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP210" />
       <printer translate="name" name="Canon PIXMA MP220" driver="bjc-MULTIPASS-MP220" manufacturer="Canon" model="5000210" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP220" />
       <printer translate="name" name="Canon PIXMA MP240" driver="bjc-MULTIPASS-MP240" manufacturer="Canon" model="5000240" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP240" />
-      <printer translate="name" name="Canon PIXMA MP250" driver="bjc-MULTIPASS-MP250" manufacturer="Canon" model="5000250" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP250" />
+      <printer translate="name" name="Canon PIXMA MP250" deviceid="MFG:Canon;CMD:BJL,BJRaster3,BSCCe,IVEC,IVECPLI;MDL:MP250 series;DES:Canon MP250 series;"  driver="bjc-MULTIPASS-MP250" manufacturer="Canon" model="5000250" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP250" />
       <printer translate="name" name="Canon PIXMA MP260" driver="bjc-MULTIPASS-MP260" manufacturer="Canon" model="5000240" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP260" />
       <printer translate="name" name="Canon PIXMA MP270" driver="bjc-MULTIPASS-MP270" manufacturer="Canon" model="5000270" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP270" />
       <printer translate="name" name="Canon PIXMA MP280" driver="bjc-MULTIPASS-MP280" manufacturer="Canon" model="5000280" parameters="PIXMA_iP4000_params" foomaticid="Canon-MULTIPASS-MP280" />
@@ -407,6 +407,7 @@
       <printer translate="name" name="Epson Stylus C86" deviceid="MFG:EPSON;MDL:Stylus C86;DES:EPSON Stylus C86;CMD:ESCPL2,BDC,D4;" driver="escp2-c86" manufacturer="Epson" model="69" parameters="standard_params" foomaticid="Epson-Stylus_C86" />
       <printer translate="name" name="Epson Stylus C87" driver="escp2-c87" manufacturer="Epson" model="69" parameters="standard_params" foomaticid="Epson-Stylus_C87" />
       <printer translate="name" name="Epson Stylus C88" deviceid="MFG:EPSON;MDL:Stylus C88;DES:EPSON Stylus C88;CMD:ESCPL2,BDC,D4;" driver="escp2-c88" manufacturer="Epson" model="69" parameters="standard_params" foomaticid="Epson-Stylus_C88" />
+      <printer translate="name" name="Epson Stylus C92" deviceid="MFG:EPSON;MDL:Stylus C92;DES:EPSON Stylus C92;CMD:ESCPL2,BDC,D4,D4PX;" driver="escp2-c68" manufacturer="Epson" model="66" parameters="standard_params" foomaticid="Epson-Stylus_C92" />
       <printer translate="name" name="Epson Stylus C110" driver="escp2-c110" manufacturer="Epson" model="85" parameters="standard_params" foomaticid="Epson-Stylus_C110" />
       <printer translate="name" name="Epson Stylus C120" driver="escp2-c120" manufacturer="Epson" model="85" parameters="standard_params" foomaticid="Epson-Stylus_C120" />
       <printer translate="name" name="Epson Stylus Color" driver="escp2" manufacturer="Epson" model="0" parameters="standard_params" foomaticid="Epson-Stylus_Color" />
@@ -425,7 +426,7 @@
       <printer translate="name" name="Epson Stylus Color 640" driver="escp2-640" manufacturer="Epson" model="11" parameters="standard_params" foomaticid="Epson-Stylus_Color_640" />
       <printer translate="name" name="Epson Stylus Color 660" driver="escp2-660" manufacturer="Epson" model="18" parameters="standard_params" foomaticid="Epson-Stylus_Color_660" />
       <printer translate="name" name="Epson Stylus Color 670" deviceid="MFG:EPSON;MDL:Stylus COLOR 670;DES:EPSON Stylus COLOR 670;CMD:ESCPL2,BDC,D4;" driver="escp2-670" manufacturer="Epson" model="25" parameters="standard_params" foomaticid="Epson-Stylus_Color_670" />
-      <printer translate="name" name="Epson Stylus Color 680" driver="escp2-680" manufacturer="Epson" model="32" parameters="standard_params" foomaticid="Epson-Stylus_Color_680" />
+      <printer translate="name" name="Epson Stylus Color 680" deviceid="MFG:EPSON;MDL:Stylus COLOR 680;DES:EPSON Stylus COLOR 680;CMD:ESCPL2,BDC,D4;" driver="escp2-680" manufacturer="Epson" model="32" parameters="standard_params" foomaticid="Epson-Stylus_Color_680" />
       <printer translate="name" name="Epson Stylus Color 740" deviceid="MFG:EPSON;MDL:Stylus COLOR 740;DES:EPSON Stylus COLOR 740;CMD:ESCPL2,BDC,D4;" driver="escp2-740" manufacturer="Epson" model="12" parameters="standard_params" foomaticid="Epson-Stylus_Color_740" />
       <printer translate="name" name="Epson Stylus Color 760" deviceid="MFG:EPSON;MDL:Stylus COLOR 760;DES:EPSON Stylus COLOR 760;CMD:ESCPL2,BDC,D4;" driver="escp2-760" manufacturer="Epson" model="19" parameters="standard_params" foomaticid="Epson-Stylus_Color_760" />
       <printer translate="name" name="Epson Stylus Color 777" deviceid="MFG:EPSON;MDL:Stylus COLOR 777;DES:EPSON Stylus COLOR 777;CMD:ESCPL2,BDC,D4;" driver="escp2-777" manufacturer="Epson" model="32" parameters="standard_params" foomaticid="Epson-Stylus_Color_777" />
@@ -487,7 +488,7 @@
       <printer translate="name" name="Epson Stylus Photo 950" driver="escp2-950" manufacturer="Epson" model="46" parameters="standard_params" foomaticid="Epson-Stylus_Photo_950" />
       <printer translate="name" name="Epson Stylus Photo 960" driver="escp2-960" manufacturer="Epson" model="46" parameters="standard_params" foomaticid="Epson-Stylus_Photo_960" />
       <printer translate="name" name="Epson Stylus Photo 1200" driver="escp2-1200" manufacturer="Epson" model="15" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1200" />
-      <printer translate="name" name="Epson Stylus Photo 1270" driver="escp2-1270" manufacturer="Epson" model="23" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1270" />
+      <printer translate="name" name="Epson Stylus Photo 1270" deviceid="MFG:EPSON;MDL:Stylus Photo 1270;DES:EPSON Stylus Photo 1270;CMD:ESCPL2,BDC,D4;" driver="escp2-1270" manufacturer="Epson" model="23" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1270" />
       <printer translate="name" name="Epson Stylus Photo 1280" driver="escp2-1280" manufacturer="Epson" model="37" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1280" />
       <printer translate="name" name="Epson Stylus Photo 1290" driver="escp2-1290" manufacturer="Epson" model="37" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1290" />
       <printer translate="name" name="Epson Stylus Photo 1290s" driver="escp2-1290s" manufacturer="Epson" model="37" parameters="standard_params" foomaticid="Epson-Stylus_Photo_1290s" />
@@ -521,7 +522,7 @@
       <printer translate="name" name="Epson Stylus Photo R1800" driver="escp2-r1800" manufacturer="Epson" model="67" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R1800" />
       <printer translate="name" name="Epson Stylus Photo R1900" driver="escp2-r1900" manufacturer="Epson" model="91" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R1900" />
       <printer translate="name" name="Epson Stylus Photo R2000" driver="escp2-r2000" manufacturer="Epson" model="91" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R2000" />
-      <printer translate="name" name="Epson Stylus Photo R2400" driver="escp2-r2400" manufacturer="Epson" model="71" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R2400" />
+      <printer translate="name" name="Epson Stylus Photo R2400" deviceid="MFG:EPSON;MDL:Stylus Photo R2400;DES:EPSON Stylus Photo R2400;CMD:ESCPL2,BDC,D4;" driver="escp2-r2400" manufacturer="Epson" model="71" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R2400" />
       <printer translate="name" name="Epson Stylus Photo R2880" driver="escp2-r2880" manufacturer="Epson" model="98" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R2880" />
       <printer translate="name" name="Epson Stylus Photo R3000" driver="escp2-r3000" manufacturer="Epson" model="115" parameters="standard_params" foomaticid="Epson-Stylus_Photo_R3000" />
       <printer translate="name" name="Epson Stylus Photo RX400" deviceid="MFG:EPSON;MDL:Stylus Photo RX400;DES:EPSON Stylus Photo RX400;CMD:ESCPL2,BDC,D4;" driver="escp2-rx400" manufacturer="Epson" model="84" parameters="standard_params" foomaticid="Epson-Stylus_Photo_RX400" />
@@ -625,6 +626,7 @@
       <printer translate="name" name="Epson Stylus CX9400F" driver="escp2-cx9400f" manufacturer="Epson" model="65" parameters="cx3500_params" foomaticid="Epson-Stylus_CX9400F" />
       <printer translate="name" name="Epson Stylus CX9475F" driver="escp2-cx9475f" manufacturer="Epson" model="65" parameters="cx3500_params" foomaticid="Epson-Stylus_CX9475F" />
       <printer translate="name" name="Epson Stylus D68" deviceid="MFG:EPSON;MDL:Stylus D68;DES:EPSON Stylus D68;CMD:ESCPL2,BDC,D4;" driver="escp2-d68" manufacturer="Epson" model="66" parameters="standard_params" foomaticid="Epson-Stylus_D68" />
+      <printer translate="name" name="Epson Stylus D78" deviceid="MFG:EPSON;MDL:Stylus D78;DES:EPSON Stylus D78;CMD:ESCPL2,BDC,D4,D4PX;" driver="escp2-d68" manufacturer="Epson" model="66" parameters="standard_params" foomaticid="Epson-Stylus_D78" />
       <printer translate="name" name="Epson Stylus D88" deviceid="MFG:EPSON;MDL:Stylus D88;DES:EPSON Stylus D88;CMD:ESCPL2,BDC,D4;" driver="escp2-d88" manufacturer="Epson" model="69" parameters="standard_params" foomaticid="Epson-Stylus_D88" />
       <printer translate="name" name="Epson Stylus D92" deviceid="MFG:EPSON;CMD:ESCPL2,BDC,D4,D4PX;MDL:Stylus D92;DES:EPSON Stylus D92;" driver="escp2-d92" manufacturer="Epson" model="66" parameters="standard_params" foomaticid="Epson-Stylus_D92" />
       <printer translate="name" name="Epson Stylus D120" driver="escp2-d120" manufacturer="Epson" model="85" parameters="standard_params" foomaticid="Epson-Stylus_D120" />
@@ -903,7 +905,7 @@
       <printer translate="name" name="Brother HL-1850" driver="brother-hl-1850" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-1850" />
       <printer translate="name" name="Brother HL-1870N" driver="brother-hl-1870n" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-1870N" />
       <printer translate="name" name="Brother HL-2030" driver="brother-hl-2030" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2030" />
-      <printer translate="name" name="Brother HL-2035" driver="brother-hl-2035" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2035" />
+      <printer translate="name" name="Brother HL-2035" deviceid="MFG:Brother;MDL:HL-2030 series;CMD:PJL,HBP;" driver="brother-hl-2035" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2035" />
       <printer translate="name" name="Brother HL-2060" driver="brother-hl-2060" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2060" />
       <printer translate="name" name="Brother HL-2460" deviceid="MFG:Brother;MDL:Brother HL-2460 series;" driver="brother-hl-2460" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2460" />
       <printer translate="name" name="Brother HL-2460N" driver="brother-hl-2460n" manufacturer="Brother" model="6" parameters="pcl_laser_params" foomaticid="Brother-HL-2460N" />
@@ -1036,9 +1038,9 @@
       <printer translate="name" name="HP Business Inkjet 2280" deviceid="MFG:HEWLETT-PACKARD;MDL:HP BUSINESS INKJET 2280;DES:Hewlett-Packard Business Inkjet 2280;CMD:MLC,PML,PJL,PCL5,POSTSCRIPT;" driver="hp-bij_2280" manufacturer="HP" model="900" parameters="pcl_inkjet_params" foomaticid="HP-Business_Inkjet_2280" />
       <printer translate="name" name="HP Color Inkjet Printer CP1160" driver="hp-cij_cp1160" manufacturer="HP" model="900" parameters="pcl_inkjet_params" foomaticid="HP-Color_Inkjet_Printer_CP1160" />
       <printer translate="name" name="HP Color Inkjet Printer CP1700" deviceid="MFG:HEWLETT-PACKARD;MDL:HP Color Inkjet CP1700;DES:HP Color Inkjet CP1700;" driver="hp-cij_cp1700" manufacturer="HP" model="901" parameters="pcl_inkjet_params" foomaticid="HP-Color_Inkjet_Printer_CP1700" />
-      <printer translate="name" name="HP Color LaserJet 2500" driver="hp-clj_2500" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_2500" />
+      <printer translate="name" name="HP Color LaserJet 2500" deviceid="MFG:Hewlett-Packard;MDL:hp color LaserJet 2500;CMD:PJL,MLC,BIDI-ECP,POSTSCRIPT,PJL,PCLXL,PCL;" driver="hp-clj_2500" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_2500" />
       <printer translate="name" name="HP Color LaserJet 4500" deviceid="MFG:Hewlett-Packard;MDL:LaserJet Color 4500;" driver="hp-clj_4500" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_4500" />
-      <printer translate="name" name="HP Color LaserJet 4550" deviceid="MFG:Hewlett-Packard;MDL:HP Color LaserJet 4550;DES:Hewlett-Packard Color LaserJet 4550;CMD:PJL,MLC,PCL,POSTSCRIPT,PCLXL,PJL;" driver="hp-clj_4550" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_4550" />
+      <printer translate="name" name="HP Color LaserJet 4550" deviceid="MFG:Hewlett-Packard;MDL:HP Color LaserJet 4550 ;DES:Hewlett-Packard Color LaserJet 4550;CMD:PJL,MLC,PCL,POSTSCRIPT,PCLXL,PJL;" driver="hp-clj_4550" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_4550" />
       <printer translate="name" name="HP Color LaserJet 4600" deviceid="MFG:Hewlett-Packard;MDL:hp color LaserJet 4600;DES:Hewlett-Packard color LaserJet 4600;" driver="hp-clj_4600" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_4600" />
       <printer translate="name" name="HP Color LaserJet 5" driver="hp-clj_5" manufacturer="HP" model="3" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_5" />
       <printer translate="name" name="HP Color LaserJet 5000" driver="hp-clj_5000" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Color_LaserJet_5000" />
@@ -1208,19 +1210,19 @@
       <printer translate="name" name="HP LaserJet 3390" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 3390;DES:Hewlett-Packard LaserJet 3390;CMD:PJL,MLC,PCL,POSTSCRIPT,PCLXL;" driver="hp-lj_3390" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_3390" />
       <printer translate="name" name="HP LaserJet 3392" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 3390;DES:Hewlett-Packard LaserJet 3390;CMD:PJL,MLC,PCL,POSTSCRIPT,PCLXL;" driver="hp-lj_3392" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_3392" />
       <printer translate="name" name="HP LaserJet 4000" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 4000 Series;DES:Hewlett-Packard LaserJet 4000 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_4000" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4000" />
-      <printer translate="name" name="HP LaserJet 4050" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 4050 Series;DES:Hewlett-Packard LaserJet 4050 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_4050" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4050" />
-      <printer translate="name" name="HP LaserJet 4100" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 4100 Series;DES:Hewlett-Packard LaserJet 4100 Series;CMD:PJL,MLC,PCL,POSTSCRIPT,PCLXL,PJL;" driver="hp-lj_4100" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4100" />
+      <printer translate="name" name="HP LaserJet 4050" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 4050 Series ;DES:Hewlett-Packard LaserJet 4050 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_4050" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4050" />
+      <printer translate="name" name="HP LaserJet 4100" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 4100 Series ;DES:Hewlett-Packard LaserJet 4100 Series;CMD:PJL,MLC,POSTSCRIPT,PCLXL,PJL,PCL;" driver="hp-lj_4100" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4100" />
       <printer translate="name" name="HP LaserJet 4200" deviceid="MFG:Hewlett-Packard;MDL:hp LaserJet 4200;DES:Hewlett-Packard LaserJet 4200;CMD:PJL,MLC,POSTSCRIPT,PJL,PCLXL,PCL;" driver="hp-lj_4200" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4200" />
       <printer translate="name" name="HP LaserJet 4240" driver="hp-lj_4240" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4240" />
       <printer translate="name" name="HP LaserJet 4250" deviceid="MFG:Hewlett-Packard;MDL:hp LaserJet 4250;DES:Hewlett-Packard LaserJet 4250;CMD:PJL,MLC,PCLXL,PCL,PJL,POSTSCRIPT;" driver="hp-lj_4250" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4250" />
       <printer translate="name" name="HP LaserJet 4300" deviceid="MFG:Hewlett-Packard;MDL:hp LaserJet 4300;CMD:PJL,MLC,POSTSCRIPT,PJL,PCLXL,PCL;" driver="hp-lj_4300" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4300" />
       <printer translate="name" name="HP LaserJet 4345 mfp" driver="hp-lj_4345_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4345_mfp" />
-      <printer translate="name" name="HP LaserJet 4350" deviceid="MFG:HP;MDL:hp LaserJet 4350L;" driver="hp-lj_4350" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4350" />
+      <printer translate="name" name="HP LaserJet 4350" deviceid="MFG:Hewlett-Packard;MDL:hp LaserJet 4350;CMD:PJL,MLC,PCLXL,PCL,PJL,POSTSCRIPT,PDF;" driver="hp-lj_4350" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_4350" />
       <printer translate="name" name="HP LaserJet 5000" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 5000 Series;DES:Hewlett-Packard LaserJet 5000 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_5000" manufacturer="HP" model="63" parameters="pcl_laser_params" foomaticid="HP-LaserJet_5000" />
-      <printer translate="name" name="HP LaserJet 5100" driver="hp-lj_5100" manufacturer="HP" model="63" parameters="pcl_laser_params" foomaticid="HP-LaserJet_5100" />
+      <printer translate="name" name="HP LaserJet 5100" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 5100 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_5100" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_5100" />
       <printer translate="name" name="HP LaserJet 5200" driver="hp-lj_5200" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_5200" />
       <printer translate="name" name="HP LaserJet 5200L" driver="hp-lj_5200l" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_5200L" />
-      <printer translate="name" name="HP LaserJet 8000" driver="hp-lj_8000" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_8000" />
+      <printer translate="name" name="HP LaserJet 8000" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8000 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_8000" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_8000" />
       <printer translate="name" name="HP LaserJet 8100" driver="hp-lj_8100" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_8100" />
       <printer translate="name" name="HP LaserJet 8150" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_8150" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_8150" />
       <printer translate="name" name="HP LaserJet 9000" driver="hp-lj_9000" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_9000" />
@@ -1228,15 +1230,15 @@
       <printer translate="name" name="HP LaserJet 9040 MFP" driver="hp-lj_9040_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_9040_MFP" />
       <printer translate="name" name="HP LaserJet 9050" driver="hp-lj_9050" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_9050" />
       <printer translate="name" name="HP LaserJet 9050 MFP" driver="hp-lj_9050_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_9050_MFP" />
-      <printer translate="name" name="HP LaserJet M3027 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_m3027_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M3027_MFP" />
-      <printer translate="name" name="HP LaserJet M3035 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_m3035_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M3035_MFP" />
+      <printer translate="name" name="HP LaserJet M3027 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet M3027 MFP;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,BIDI-ECP,PCLXL,PCL,PDF,PJL,POSTSCRIPT;" driver="hp-lj_m3027_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M3027_MFP" />
+      <printer translate="name" name="HP LaserJet M3035 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet M3035 MFP;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,BIDI-ECP,PJL,PCLXL,PCL,PDF,POSTSCRIPT;" driver="hp-lj_m3035_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M3035_MFP" />
       <printer translate="name" name="HP LaserJet M4345 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_m4345_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M4345_MFP" />
       <printer translate="name" name="HP LaserJet M5025 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_m5025_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M5025_MFP" />
       <printer translate="name" name="HP LaserJet M5035 MFP" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet 8150 Series;DES:Hewlett-Packard LaserJet 8150 Series;CMD:PJL,MLC,PCL,PCLXL,POSTSCRIPT;" driver="hp-lj_m5035_mfp" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_M5035_MFP" />
       <printer translate="name" name="HP LaserJet P2010" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet P2010 series;DES:Hewlett-Packard LaserJet P2010 series;CMD:PJL,MLC,BIDI-ECP,PCL,DW-PCL;" driver="hp-lj_p2010" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_P2010" />
       <printer translate="name" name="HP LaserJet P2015" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet P2015 Series;DES:Hewlett-Packard LaserJet P2015 series;CMD:PJL,MLC,BIDI-ECP,PCL,POSTSCRIPT,PCLXL;" driver="hp-lj_p2015" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_P2015" />
       <printer translate="name" name="HP LaserJet P3004" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet P3004 Series;DES:Hewlett-Packard LaserJet P3004 Series;CMD:PJL,MLC,BIDI-ECP,PCL,POSTSCRIPT,PCLXL;" driver="hp-lj_p3004" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_P3004" />
-      <printer translate="name" name="HP LaserJet P3005" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet P3005 Series;DES:Hewlett-Packard LaserJet P3005 Series;CMD:PJL,MLC,BIDI-ECP,PCL,POSTSCRIPT,PCLXL;" driver="hp-lj_p3005" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_P3005" />
+      <printer translate="name" name="HP LaserJet P3005" deviceid="MFG:Hewlett-Packard;MDL:HP LaserJet P3005;DES:Hewlett-Packard LaserJet P3005 Series;CMD:PJL,MLC,BIDI-ECP,POSTSCRIPT,PJL,PCLXL,PCL;" driver="hp-lj_p3005" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-LaserJet_P3005" />
       <printer translate="name" name="HP Mopier 240" driver="hp-mopier_240" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Mopier_240" />
       <printer translate="name" name="HP Mopier 320" driver="hp-mopier_320" manufacturer="HP" model="6" parameters="pcl_laser_params" foomaticid="HP-Mopier_320" />
       <printer translate="name" name="HP OfficeJet 300" deviceid="MFG:Hewlett-Packard;MDL:OfficeJet Series 300;DES:Hewlett-Packard OfficeJet Series 300;CMD:MLC,PCL,PML;" driver="hp-oj_300" manufacturer="HP" model="500" parameters="pcl_inkjet_params" foomaticid="HP-OfficeJet_300" />


code:
#!/usr/bin/python

## gutenprint-foomaticppdupdate

## A utility for updating foomatic-generated PPDs so that they work with
## a newly-installed gutenprint package.

## Copyright (C) 2007, 2009 Red Hat, Inc.
## Copyright (C) 2007, 2009 Tim Waugh <twaugh@redhat.com

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import sys
import glob
import os
import subprocess
import tempfile

import cups

if len (sys.argv) < 2 or sys.argv[1] == "--help":
    print "Usage: gutenprint-foomaticppdupdate <version>"
    sys.exit (1)

gutenprint_version = sys.argv[1]
dry_run = True

def generate_ppd (ppdfile, printer, driver):
    p = subprocess.Popen (["foomatic-ppdfile", "-p", printer, "-d", driver],
                          stdin=file ("/dev/null"),
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE)
    (ppd, stderr) = p.communicate ()
    fname = ppdfile + ".tmp"
    try:
        file(fname, "w").write (ppd)
    except IOError, e:
        print e
        raise

    ppdobj = cups.PPD (fname)
    os.remove (fname)
    return ppdobj

def update_ppdfile (ppdfile):
    try:
        ppd = cups.PPD (ppdfile)
    except RuntimeError:
        # Invalid PPD in some way.
        return

    attr = ppd.findAttr ("FoomaticIDs")
    if not attr:
        return

    IDs = attr.value.split (" ")
    if len (IDs) != 2:
        print "Don't understand FoomaticIDs: %s" % IDs
        return

    if not IDs[1].startswith ("gutenprint"):
        return

    attr = ppd.findAttr ("FoomaticRIPCommandLine")
    if not attr:
        return

    cmdline = attr.value
    STP_VERSION="STP_VERSION="
    i = cmdline.find (STP_VERSION)
    if i == -1:
        return

    i += len (STP_VERSION)
    j = i + 1
    end = len (cmdline)
    while j < end:
        ch = cmdline[j]
        if ch != '.' and not ch.isdigit ():
            break
        j += 1

    version = cmdline[i:j]
    if gutenprint_version == version:
        return

    # Needs updating.
    firstdot = gutenprint_version.find ('.')
    seconddot = firstdot + 1 + gutenprint_version[1 + firstdot:].find ('.')
    major = gutenprint_version[:seconddot]

    driver = IDs[1]
    dot = driver.find ('.')
    driver = driver[:dot] + "." + major
    try:
        genppd = generate_ppd (ppdfile, IDs[0], driver)
    except:
        return

    os.environ['FILE'] = ppdfile
    os.system ('cp -af "$FILE" "$FILE".bak')

    def update_options (options, newppd, origppd):
        for newopt in options:
            origopt = origppd.findOption (newopt.keyword)
            if origopt:
                newppd.markOption (newopt.keyword, origopt.defchoice)

    genppd.markDefaults ()
    for group in genppd.optionGroups:
        update_options (group.options, genppd, ppd)
        for subgroup in group.subgroups:
            update_options (subgroup.options, genppd, ppd)

    ps = genppd.findOption ("PageSize")
    if ps:
        update_options ([ps], genppd, ppd)

    f = file (ppdfile, "w")
    genppd.writeFd (f.fileno ())
    print "Updated PPD file %s" % ppdfile

for ppdfile in glob.glob ("/etc/cups/ppd/*.ppd"):
    update_ppdfile (ppdfile)


code:
--- gutenprint-5.0.0/src/gimp2/print-print.c.menu	2007-03-02 17:08:51.000000000 +0000
+++ gutenprint-5.0.0/src/gimp2/print-print.c	2007-03-02 17:09:10.000000000 +0000
@@ -43,7 +43,7 @@
 			  (BAD_CONST_CHAR) copy,
 			  (BAD_CONST_CHAR) VERSION " - " RELEASE_DATE,
 			  /* Do not translate the prefix "<Image>" */
-			  (BAD_CONST_CHAR) N_("<Image>/File/Print..."),
+			  (BAD_CONST_CHAR) N_("<Image>/File/Send/Print..."),
 			  (BAD_CONST_CHAR) types,
 			  GIMP_PLUGIN,
 			  n_args, 0,


code:
diff -up gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver gutenprint-5.2.6/src/main/gutenprint-internal.h
--- gutenprint-5.2.6/src/main/gutenprint-internal.h.postscriptdriver	2010-08-04 02:33:56.000000000 +0200
+++ gutenprint-5.2.6/src/main/gutenprint-internal.h	2010-08-11 16:11:19.000000000 +0200
@@ -56,6 +56,8 @@ extern void stpi_init_printer(void);
 #define BUFFER_FLAG_FLIP_X	0x1
 #define BUFFER_FLAG_FLIP_Y	0x2
 extern stp_image_t* stpi_buffer_image(stp_image_t* image, unsigned int flags);
+extern stp_list_t *stp_paths_copy_with_prefix(stp_list_t* list,
+					      const char *prefix);

 #define STPI_ASSERT(x,v)						\
 do									\
diff -up gutenprint-5.2.6/src/main/module.c.postscriptdriver gutenprint-5.2.6/src/main/module.c
--- gutenprint-5.2.6/src/main/module.c.postscriptdriver	2006-09-30 17:02:59.000000000 +0200
+++ gutenprint-5.2.6/src/main/module.c	2010-08-11 16:13:43.000000000 +0200
@@ -151,12 +151,20 @@ int stp_module_load(void)
     }
   else
     {
+      const char *prefix = getenv("DESTDIR");
 #ifdef USE_LTDL
       stp_path_split(dir_list, getenv("LTDL_LIBRARY_PATH"));
       stp_path_split(dir_list, lt_dlgetsearchpath());
 #else
       stp_path_split(dir_list, PKGMODULEDIR);
 #endif
+      if (prefix)
+	{
+	  stp_list_t *prefix_list;
+	  prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
+	  stp_list_destroy(dir_list);
+	  dir_list = prefix_list;
+	}
     }
 #ifdef USE_LTDL
   file_list = stp_path_search(dir_list, ".la");
diff -up gutenprint-5.2.6/src/main/path.c.postscriptdriver gutenprint-5.2.6/src/main/path.c
--- gutenprint-5.2.6/src/main/path.c.postscriptdriver	2008-06-01 16:41:18.000000000 +0200
+++ gutenprint-5.2.6/src/main/path.c	2010-08-11 16:13:43.000000000 +0200
@@ -158,7 +158,17 @@ stpi_data_path(void)
   if (getenv("STP_DATA_PATH"))
     stp_path_split(dir_list, getenv("STP_DATA_PATH"));
   else
-    stp_path_split(dir_list, PKGXMLDATADIR);
+    {
+      const char *prefix = getenv("DESTDIR");
+      stp_path_split(dir_list, PKGXMLDATADIR);
+      if (prefix)
+	{
+	  stp_list_t *prefix_list;
+	  prefix_list = stp_paths_copy_with_prefix(dir_list, prefix);
+	  stp_list_destroy(dir_list);
+	  dir_list = prefix_list;
+	}
+    }
   return dir_list;
 }

@@ -226,6 +236,40 @@ stp_path_split(stp_list_t *list, /* List
     }
 }

+/*
+ * Split a PATH-type string (colon-delimited) into separate
+ * directories.
+ */
+stp_list_t *
+stp_paths_copy_with_prefix(stp_list_t *list,   /* List to add prefix to */
+			   const char *prefix) /* Prefix to add */
+{
+  stp_list_t *new_list;
+  stp_list_item_t *item;
+  int prefixlen = strlen (prefix);
+  if (!(new_list = stp_list_create()))
+    return;
+
+  item = stp_list_get_start (list);
+  while (item)
+    {
+      const char *data;
+      char *new_data;
+      int len;
+      data = stp_list_item_get_data (item);
+      len = strlen (data);
+      new_data = (char *) stp_malloc(prefixlen + 1 + len + 1);
+      strncpy(new_data, prefix, prefixlen);
+      new_data[prefixlen] = '/';
+      strcpy(new_data + prefixlen + 1, data);
+      stp_list_item_create(new_list, NULL, new_data);
+
+      item = stp_list_item_next (item);
+    }
+
+  return new_list;
+}
+
 /* Adapted from GNU libc <dirent.h>
    These macros extract size information from a `struct dirent *'.
    They may evaluate their argument multiple times, so it must not


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>gutenprint</Name>
        <Homepage>http://gimp-print.sourceforge.net/</Homepage>
        <Packager>
            <Name>Pisi Linux Admins</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>GPLv2</License>
        <IsA>data</IsA>
        High quality printer drivers
        <Description>gutenprint contains drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with Ghostscript, CUPS, Foomatic, and the Gimp.</Description>
        <Archive sha1sum="b277ae58af0de0f0e9e1884d5dde8f1673528c4f" type="tarbz2">mirrors://sourceforge/gimp-print/gutenprint-5.2/5.2.13/gutenprint-5.2.13.tar.bz2</Archive>
        <AdditionalFiles>
            <AdditionalFile owner="root" permission="0644" target="src/cups/cups-genppdupdate.in">fedora/cups-genppdupdate.py.in</AdditionalFile>
        </AdditionalFiles>
        <BuildDependencies>
            <Dependency>cups-devel</Dependency>
            <Dependency>foomatic-db</Dependency>
            <Dependency>ghostscript-devel</Dependency>
            <Dependency>cups</Dependency>

            <Dependency>python-cups</Dependency>
            <Dependency>atk-devel</Dependency>
            <Dependency>gtk2-devel</Dependency>
            <Dependency>zlib-devel</Dependency>
            <Dependency>cairo-devel</Dependency>
            <Dependency>glib2-devel</Dependency>
            <Dependency>pango-devel</Dependency>
            <Dependency>libusb-devel</Dependency>
        </BuildDependencies>
        <Patches>
            <Patch level="1">fedora/gutenprint-build.patch</Patch>

            <Patch level="1">fedora/gutenprint-menu.patch</Patch>
            <Patch level="1">fedora/gutenprint-O6.patch</Patch>
            <Patch level="1">fedora/gutenprint-postscriptdriver.patch</Patch>
        </Patches>
    </Source>

    <Package>
        <Name>gutenprint</Name>
        <RuntimeDependencies>
            <Dependency>cups</Dependency>

            <Dependency>ghostscript</Dependency>
            <Dependency>gtk2</Dependency>
            <Dependency>zlib</Dependency>
            <Dependency>glib2</Dependency>
            <Dependency>libusb</Dependency>
            <Dependency>ncurses</Dependency>
            <Dependency>freetype</Dependency>
            <Dependency>fontconfig</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/usr/lib/cups</Path>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="executable">/usr/sbin</Path>
            <Path fileType="library">/usr/lib</Path>
            <Path fileType="doc">/usr/share/doc</Path>
            <Path fileType="man">/usr/share/man/</Path>
            <Path fileType="data">/usr/share/cups</Path>
            <Path fileType="data">/usr/share/foomatic</Path>
            <Path fileType="data">/usr/share/gutenprint</Path>
            <Path fileType="localedata">/usr/share/locale</Path>
            <Path fileType="data">/usr/include/gutenprintui2/</Path>
            <Path fileType="data"> /etc/cups/command.types</Path>
        </Files>
        <AdditionalFiles>
            <AdditionalFile owner="root" permission="0755" target="/usr/sbin/gutenprint-foomaticppdupdate">fedora/gutenprint-foomaticppdupdate</AdditionalFile>
        </AdditionalFiles>
        <Provides>
            <COMAR script="package.py">System.Package</COMAR>
        </Provides>
    </Package>

    <Package>
        <Name>gutenprint-devel</Name>
        Development files for gutenprint
        <RuntimeDependencies>
            <Dependency release="current">gutenprint</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="header">/usr/include/gutenprint</Path>
            <Path fileType="data">/usr/lib/pkgconfig</Path>
            <Path fileType="man">/usr/share/man/man3</Path>
        </Files>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-12-15</Date>
            <Version>5.2.13</Version>
            <Comment>Version Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="3">
            <Date>2017-03-02</Date>
            <Version>5.2.12</Version>
            <Comment>Version Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-09</Date>
            <Version>5.2.11</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-02-13</Date>
            <Version>5.2.11</Version>
            <Comment>First release</Comment>
            <Name>Ali Algul</Name>
            <Email>alialgul@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>gutenprint</Name>
        Yüksek kaliteli yazıcı sürücüleri
        <Description xml:lang="tr">Canon, Epson, Lexmark, Sony, Olympus ve PCL türü yazıcılar için Gimp, CUPS, Foomatic yazıcı sürücüleri</Description>
    </Source>

    <Package>
        <Name>gutenprint-devel</Name>
        gutenprint için geliştirme dosyaları
    </Package>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import shelltools
from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import get

import os

def setup():
    # Patch compressed PPDs
    for patch in sorted(os.listdir("ppd-patches")):
        shelltools.system("./patch-ppds ppd-patches/%s" % patch)

    for f in ("NEWS", "INSTALL", "README", "AUTHORS", "ChangeLog"):
        shelltools.touch(f)

    pisitools.dosed("Makefile.am", "^rulesdir = .*$", "rulesdir = /lib/udev/rules.d")

    # Migrate device ids from hpcups drv to hpijs drv
    #shelltools.system("./copy-deviceids prnt/drv/hpcups.drv.in prnt/drv/hpijs.drv.in > hpijs.drv.in.new")
    #shelltools.move("hpijs.drv.in.new", "prnt/drv/hpijs.drv.in")

    # Strip duplex constraints from hpcups
    pisitools.dosed("prnt/drv/hpcups.drv.in", "(UIConstraints.* \*Duplex)", "//\\1")

    # Change python shebang
    shelltools.system("find -name '*.py' -print0 | xargs -0 sed -i 's,^#!/usr/bin/env python,#!/usr/bin/python,'")

    # These are barely the defaults except:
    # --enable-foomatic-drv-install (default=no) (respected by Fedora, enabled by Ubuntu)
    autotools.autoreconf("-fi")
    autotools.configure("--with-cupsbackenddir=/usr/lib/cups/backend \
                         --with-drvdir=/usr/share/cups/drv \
                         --with-hpppddir=/usr/share/cups/model/hplip \
                         --with-docdir=/usr/share/doc/hplip \
                         --with-mimedir=/usr/share/cups/mime \
                         --enable-qt5 \
                         --enable-hpijs-install \
                         --enable-udev-acl-rules \
                         --enable-pp-build \
                         --enable-fax-build \
                         --enable-gui-build \
                         --enable-dbus-build \
                         --enable-scan-build \
                         --enable-network-build \
                         --enable-hpcups-install \
                         --enable-cups-drv-install \
                         --enable-foomatic-drv-install \
                         --disable-qt4 \
                         --disable-qt3 \
                         --disable-policykit \
                         --disable-doc-build \
                         --disable-foomatic-ppd-install \
                         --disable-foomatic-rip-hplip-install")

    # Remove hardcoded rpaths
    pisitools.dosed("libtool", "^hardcode_libdir_flag_spec=.*", "hardcode_libdir_flag_spec=\"\"")
    pisitools.dosed("libtool", "^runpath_var=LD_RUN_PATH", "runpath_var=DIE_RPATH_DIE")

def build():
    autotools.make()

def install():
    autotools.rawInstall("DESTDIR=%s ppddir=/usr/share/cups/model/hplip" % get.installDIR())

    # Create a compatibility symlink for foomatic-rip-hplip
    pisitools.dosym("/usr/lib/cups/filter/foomatic-rip", "/usr/lib/cups/filter/foomatic-rip-hplip")

    # Remove the hal preprobe rules as they were causing breakage (bug #479648).
    # Remove hal directory as well.
    pisitools.removeDir("/usr/share/hal/")

    # Remove unpackaged stuff (Fedora)
    #pisitools.remove("/usr/share/hplip/fax/pstotiff*")
    #pisitools.remove("/usr/share/cups/mime/pstotiff.types")
    #pisitools.remove("/usr/share/hplip/pkservice.py")
    #pisitools.remove("/usr/bin/hp-pkservice")

    # Do not mess with sane, init, foomatic etc.
    pisitools.removeDir("/etc/sane.d")

    # Create empty plugins directory
    pisitools.dodir("/usr/share/hplip/prnt/plugins")

    # This notifies user through libnotify when the printer requires a firmware
    # Should port it to KNotify if possible, argh.
    pisitools.remove("/lib/udev/rules.d/56-hpmud.rules")

    # --disable-doc-build used. It doesn't go to the true directory.
    pisitools.dohtml("doc/*")


code:
#/usr/bin/python

import os

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    # Update hplip queues if any
    os.system("/usr/bin/hpcups-update-ppds")


code:
From b3a7fa4d4a573cfe0073ae50197f679af7e3a0ac Mon Sep 17 00:00:00 2001
From: Till Kamppeter <till.kamppeter@canonical.com>
Date: Sat, 24 Sep 2016 10:37:20 +0200
Subject: Add 'include <cups/ppd.h>' in various places as CUPS 2.2 moved some
 definitions to ppd.h

---
 configure.in               | 2 +-
 prnt/hpcups/HPCupsFilter.h | 2 ++
 prnt/hpijs/hpcupsfax.cpp   | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.in b/configure.in
index d3a1ddb..eabe14a 100755
--- a/configure.in
+++ b/configure.in
@@ -554,7 +554,7 @@ fi

 if test "$hpijs_only_build" = "no" && test "$hpcups_only_build" = "no"; then
    AC_CHECK_LIB([cups], [cupsDoFileRequest], [LIBS="$LIBS"], [AC_MSG_ERROR([cannot find libcups support], 9)])
-   AC_CHECK_HEADERS(cups/cups.h, ,[AC_MSG_ERROR([cannot find cups-devel support], 3)])
+   AC_CHECK_HEADERS(cups/cups.h cups/ppd.h, ,[AC_MSG_ERROR([cannot find cups-devel support], 3)])
    if test "$libusb01_build" = "yes"; then
       AC_CHECK_LIB([usb], [usb_init], [LIBS="$LIBS"], [AC_MSG_ERROR([cannot find libusb support], 2)])
       AC_CHECK_HEADERS(usb.h, ,[AC_MSG_ERROR([cannot find libusb-devel support], 11)])
diff --git a/prnt/hpcups/HPCupsFilter.h b/prnt/hpcups/HPCupsFilter.h
index ff5548e..c517989 100644
--- a/prnt/hpcups/HPCupsFilter.h
+++ b/prnt/hpcups/HPCupsFilter.h
@@ -38,6 +38,8 @@

 #include "dbuscomm.h"

+#include <cups/ppd.h>
+
 #define		DBITMAPFILEHEADER		14
 #define		DBITMAPINFOHEADER		40

diff --git a/prnt/hpijs/hpcupsfax.cpp b/prnt/hpijs/hpcupsfax.cpp
index 8514775..994e50f 100644
--- a/prnt/hpijs/hpcupsfax.cpp
+++ b/prnt/hpijs/hpcupsfax.cpp
@@ -43,6 +43,7 @@
 #include <arpa/inet.h>
 #include <math.h>
 #include <cups/cups.h>
+#include <cups/ppd.h>
 #include <cups/raster.h>
 #include <string>
 #ifdef FALSE


code:
#!/usr/bin/python
import os
import re
import sys
if len (sys.argv) < 3:
    print ("Specify hpcups.drv and hpijs.drv pathnames")
    sys.exit (1)

hpcups_drv = sys.argv[1]
hpijs_drv = sys.argv[2]

# Match e.g.      Model "ModelName"
# and catch 'ModelName' in group 0
mn_re = re.compile ('^\s*ModelName\s+"(.*)"\s*$')

# Match e.g.      Attribute "1284DeviceID" "" "blah"
# and catch everything before 'blah' in group 0, 'blah' in group 1,
# trailing characters in group 2
devid_re = re.compile ('^(\s*Attribute\s+"1284DeviceID"\s+""\s+")(.*)("\s*)$')

# Match e.g.   }
end_re = re.compile ('^\s*}')

devid_by_mn = dict()

hpcups_lines = open (hpcups_drv, "r").readlines ()
current_mn = None
for line in hpcups_lines:
    if current_mn == None:
        match = mn_re.match (line)
        if match == None:
            continue

        current_mn = match.groups ()[0]
    else:
        match = devid_re.match (line)
        if match:
            devid_by_mn[current_mn] = match.groups ()[1]
            continue

    if end_re.match (line):
        current_mn = None

print("%d IEEE 1284 Device IDs loaded from %s" % (len (devid_by_mn),
                                                os.path.basename (hpcups_drv)),
      file=sys.stderr)

replaced = 0
hpijs_lines = open (hpijs_drv, "r").readlines ()
current_mn = None
for line in hpijs_lines:
    if current_mn == None:
        match = mn_re.match (line)
        if match:
            current_mn = match.groups ()[0]
            if current_mn.endswith (" hpijs"):
                current_mn = current_mn[:-6]
    else:
        match = devid_re.match (line)
        if match:
            devid = devid_by_mn.get (current_mn)
            if devid:
                line = (match.groups ()[0] + devid + match.groups ()[2])
                replaced += 1
            else:
                print ("Not matched: %s" % current_mn, file=sys.stderr)

    if end_re.match (line):
        current_mn = None

    print (line.rstrip ("\n"))

print("%d IEEE 1284 Device IDs loaded in %s" % (replaced,
                                                os.path.basename (hpijs_drv)),
      file=sys.stderr)


code:
#!/bin/bash

## Copyright (C) 2010 Red Hat, Inc.
## Authors:
##  Tim Waugh <twaugh@redhat.com>

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

## Purpose: Update hpcups PPDs when necessary.

sock=/var/run/cups/cups.sock
running=$(LC_ALL=C lpstat -h "$sock" -r 2>/dev/null)
if [ "$?" -ne 0 ]
then
    # No lpstat in path
    exit 0
fi

if [ -z "${running##*not*}" ]
then
    # scheduler is not running
    exit 0
fi

trap 'rm -f "$tmpdir"/models; rmdir "$tmpdir"; exit 0' \
    0 HUP INT QUIT ILL ABRT PIPE TERM

debug=true
tmpdir="$(mktemp -d)"
for ppd in /etc/cups/ppd/*.ppd
do
    [ -r "$ppd" ] || continue
    queue="${ppd#/etc/cups/ppd/}"
    queue="${queue%.ppd}"
    lpstat -h "$sock" -p "$queue" &>/dev/null || continue

    # We have PPD associated with a queue.  Find out its NickName
    $debug && echo "Examining $queue"
    nickname="$(grep '^\*NickName:' "$ppd")"
    nickname="${nickname#*\"}" # strip text up to and incl first double quote
    nickname="${nickname%\"*}" # strip final double quote
    $debug && echo "NickName is: $nickname"

    # Is it an hpcups PPD?
    [ -z "${nickname##*, hpcups*}" ] || continue
    $debug && echo "hpcups: true"

    # No: need to regenerate the PPD.
    if [ ! -f "$tmpdir/models" ]
    then
	# Get list of driver URIs and NickNames
	lpinfo -h "$sock" --include-schemes=drv -m 2>/dev/null >"$tmpdir/models"
    fi

    # Strip hpcups version from NickName
    nickname="${nickname%, hpcups*}"
    $debug && echo "Stripped NickName: $nickname"
    while read line
    do
	uri=${line%% *}
	nn="${line#$uri }"
	[ -z "${nn##*, hpcups*}" ] || continue

	nn="${nn%, hpcups*}"
	if [ "$nn" == "$nickname" ]
	then
	    $debug && echo "Match found, URI: $uri"

	    # Unfortunately CUPS will reset the page size when we
	    # change the PPD, due to the weird page size names that
	    # HPLIP uses.  Try to maintain the existing page size.
	    size="$(grep '^\*DefaultPageSize:' "$ppd")"
	    size="${size##* }" # strip until after first ' '
	    size="${size%% *}" # strip after any ' '
	    $debug && echo "PageSize is $size"

	    if [ -z "${size#*Duplex}" ]
	    then
		# Special handling for duplex sizes because HPLIP
		# broke backwards compatibility with *that* too!
		size="${size%Duplex}.Duplex"
	    fi

	    null=/dev/null
	    $debug && null=/dev/stdout
	    lpadmin -h "$sock" -p "$queue" -m "$uri" &>"$null" || :
	    $debug && echo "PPD regenerated"

	    lpadmin -h "$sock" -p "$queue" -o PageSize="$size" &>"$null" || :
	    $debug && echo "PageSize restored to $size"
	    break
	fi
    done <"$tmpdir/models"
done
exit 0