From 29044d8d5770bfde6ca7f4ed331d093bebb5ab92 Mon Sep 17 00:00:00 2001 From: gulle Date: Sat, 6 Feb 2016 19:58:04 +0200 Subject: [PATCH] gutenprint --- hardware/printer/gutenprint/actions.py | 41 + hardware/printer/gutenprint/comar/package.py | 7 + .../files/fedora/cups-genppdupdate.py.in | 1058 +++++++++++++++++ .../files/fedora/gutenprint-O6.patch | 281 +++++ .../files/fedora/gutenprint-build.patch | 22 + .../files/fedora/gutenprint-device-ids.patch | 149 +++ .../files/fedora/gutenprint-foomaticppdupdate | 136 +++ .../files/fedora/gutenprint-menu.patch | 11 + .../fedora/gutenprint-postscriptdriver.patch | 99 ++ hardware/printer/gutenprint/pspec.xml | 136 +++ hardware/printer/gutenprint/translations.xml | 13 + 11 files changed, 1953 insertions(+) create mode 100644 hardware/printer/gutenprint/actions.py create mode 100644 hardware/printer/gutenprint/comar/package.py create mode 100644 hardware/printer/gutenprint/files/fedora/cups-genppdupdate.py.in create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-O6.patch create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-build.patch create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-device-ids.patch create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-foomaticppdupdate create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-menu.patch create mode 100644 hardware/printer/gutenprint/files/fedora/gutenprint-postscriptdriver.patch create mode 100644 hardware/printer/gutenprint/pspec.xml create mode 100644 hardware/printer/gutenprint/translations.xml diff --git a/hardware/printer/gutenprint/actions.py b/hardware/printer/gutenprint/actions.py new file mode 100644 index 0000000000..181843c829 --- /dev/null +++ b/hardware/printer/gutenprint/actions.py @@ -0,0 +1,41 @@ +#!/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 + +def setup(): + shelltools.system("sed -i 's:cups_sbindir=\"\/usr\/sbin\":cups_sbindir=\"\/usr\/bin\":g' m4/stp_cups.m4") + shelltools.system("sed -i 's:cups_sbindir=\"\${cups_prefix}\/sbin\":cups_sbindir=\"\${cups_prefix}\/bin\":' m4/stp_cups.m4") + shelltools.system("sed -i 's:m4local:m4extra:' Makefile.am") + autotools.autoreconf("-fi") + autotools.configure("--prefix=/usr \ + --sbindir=/usr/bin \ + --enable-samples \ + --enable-cups-ppds \ + --enable-cups-ppds-at-top-level \ + --disable-translated-cups-ppds \ + --disable-globalized-cups-ppds \ + --disable-static \ + --disable-static-genppd") + +def build(): + autotools.make() + +def install(): + autotools.rawInstall("DESTDIR=%s install" % get.installDIR()) + + #pisitools.dohtml("%s/usr/share/gutenprint/doc/reference-html/*" % get.installDIR()) + + #pisitools.removeDir("/usr/share/gutenprint/doc/") + #pisitools.removeDir("/usr/include/gutenprintui2") + + # FIXME: Remove command.types, check if any other file exists + #pisitools.removeDir("/etc/") + + #pisitools.remove("/usr/share/foomatic/kitload.log") diff --git a/hardware/printer/gutenprint/comar/package.py b/hardware/printer/gutenprint/comar/package.py new file mode 100644 index 0000000000..517d698d8e --- /dev/null +++ b/hardware/printer/gutenprint/comar/package.py @@ -0,0 +1,7 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import os + +def postInstall(fromVersion, fromRelease, toVersion, toRelease): + os.system("/usr/sbin/cups-genppdupdate") diff --git a/hardware/printer/gutenprint/files/fedora/cups-genppdupdate.py.in b/hardware/printer/gutenprint/files/fedora/cups-genppdupdate.py.in new file mode 100644 index 0000000000..d0d6e92d12 --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/cups-genppdupdate.py.in @@ -0,0 +1,1058 @@ +#!/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) diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-O6.patch b/hardware/printer/gutenprint/files/fedora/gutenprint-O6.patch new file mode 100644 index 0000000000..0c1084b66d --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-O6.patch @@ -0,0 +1,281 @@ +diff -up gutenprint-5.2.7/configure.ac.O6 gutenprint-5.2.7/configure.ac +--- gutenprint-5.2.7/configure.ac.O6 2011-05-02 03:20:49.000000000 +0200 ++++ gutenprint-5.2.7/configure.ac 2011-05-05 12:40:29.000000000 +0200 +@@ -625,27 +625,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([-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.7/configure.O6 gutenprint-5.2.7/configure +--- gutenprint-5.2.7/configure.O6 2011-05-02 03:32:21.000000000 +0200 ++++ gutenprint-5.2.7/configure 2011-05-05 12:52:09.000000000 +0200 +@@ -16589,246 +16589,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 -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 diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-build.patch b/hardware/printer/gutenprint/files/fedora/gutenprint-build.patch new file mode 100644 index 0000000000..6b17a40296 --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-build.patch @@ -0,0 +1,22 @@ +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 + #include ++#include + #include + + +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 + #include ++#include + #include + #include + diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-device-ids.patch b/hardware/printer/gutenprint/files/fedora/gutenprint-device-ids.patch new file mode 100644 index 0000000000..30a1f190f5 --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-device-ids.patch @@ -0,0 +1,149 @@ +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 @@ + + + +- ++ + + + + +- ++ + + + +- ++ + + + +@@ -188,7 +188,7 @@ + + + +- ++ + + + +@@ -200,7 +200,7 @@ + + + +- ++ + + + +@@ -407,6 +407,7 @@ + + + ++ + + + +@@ -425,7 +426,7 @@ + + + +- ++ + + + +@@ -487,7 +488,7 @@ + + + +- ++ + + + +@@ -521,7 +522,7 @@ + + + +- ++ + + + +@@ -625,6 +626,7 @@ + + + ++ + + + +@@ -903,7 +905,7 @@ + + + +- ++ + + + +@@ -1036,9 +1038,9 @@ + + + +- ++ + +- ++ + + + +@@ -1208,19 +1210,19 @@ + + + +- +- ++ ++ + + + + + +- ++ + +- ++ + + +- ++ + + + +@@ -1228,15 +1230,15 @@ + + + +- +- ++ ++ + + + + + + +- ++ + + + diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-foomaticppdupdate b/hardware/printer/gutenprint/files/fedora/gutenprint-foomaticppdupdate new file mode 100644 index 0000000000..47958b8e75 --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-foomaticppdupdate @@ -0,0 +1,136 @@ +#!/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 " + 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) diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-menu.patch b/hardware/printer/gutenprint/files/fedora/gutenprint-menu.patch new file mode 100644 index 0000000000..2c76a41581 --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-menu.patch @@ -0,0 +1,11 @@ +--- 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 "" */ +- (BAD_CONST_CHAR) N_("/File/Print..."), ++ (BAD_CONST_CHAR) N_("/File/Send/Print..."), + (BAD_CONST_CHAR) types, + GIMP_PLUGIN, + n_args, 0, diff --git a/hardware/printer/gutenprint/files/fedora/gutenprint-postscriptdriver.patch b/hardware/printer/gutenprint/files/fedora/gutenprint-postscriptdriver.patch new file mode 100644 index 0000000000..ac7f920f0a --- /dev/null +++ b/hardware/printer/gutenprint/files/fedora/gutenprint-postscriptdriver.patch @@ -0,0 +1,99 @@ +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 + These macros extract size information from a `struct dirent *'. + They may evaluate their argument multiple times, so it must not diff --git a/hardware/printer/gutenprint/pspec.xml b/hardware/printer/gutenprint/pspec.xml new file mode 100644 index 0000000000..0998a66793 --- /dev/null +++ b/hardware/printer/gutenprint/pspec.xml @@ -0,0 +1,136 @@ + + + + + gutenprint + http://gimp-print.sourceforge.net/ + + Pisi Linux Admins + admins@pisilinux.org + + GPLv2 + data + High quality printer drivers + gutenprint contains drivers for Canon, Epson, Lexmark, Sony, Olympus, and PCL printers for use with Ghostscript, CUPS, Foomatic, and the Gimp. + mirrors://sourceforge/gimp-print/gutenprint-5.2/5.2.11/gutenprint-5.2.11.tar.bz2 + + fedora/cups-genppdupdate.py.in + + + cups-devel + foomatic-db + ghostscript-devel + cups + + + python-cups + ghostscript + atk-devel + gtk2-devel + zlib-devel + cairo-devel + glib2-devel + pango-devel + libusb-devel + + + fedora/gutenprint-build.patch + + fedora/gutenprint-menu.patch + fedora/gutenprint-O6.patch + fedora/gutenprint-postscriptdriver.patch + + + + + gutenprint + + cups + + + ghostscript + atk + gtk2 + zlib + cairo + glib2 + pango + libusb + ncurses + freetype + fontconfig + gdk-pixbuf + + + /usr/lib/cups + /usr/bin + /usr/sbin + /usr/lib + /usr/share/doc + /usr/share/man/ + /usr/share/cups + /usr/share/foomatic + /usr/share/gutenprint + /usr/share/locale + /usr/include/gutenprintui2/ + /etc/cups/command.types + + + fedora/gutenprint-foomaticppdupdate + + + System.Package + + + + + gutenprint-devel + Development files for gutenprint + + gutenprint + + + /usr/include/gutenprint + /usr/lib/pkgconfig + /usr/share/man/man3 + + + + + + 2016-01-07 + 5.2.11 + Version bump. + Ali Algul + alialgul@pisilinux.org + + + 2014-07-07 + 5.2.10 + Version bump. + Vedat Demir + vedat@pisilinux.org + + + 2014-02-26 + 5.2.9 + Rebuild + Osman Erkan + osman.erkan@pisilinux.org + + + 2013-07-01 + 5.2.9 + Remove ijs from dependencies, ijs is provided by ghostscript package + Osman Erkan + osman.erkan@pisilinux.org + + + 2012-11-20 + 5.2.9 + First release + Osman Erkan + osman.erkan@pisilinux.org + + + diff --git a/hardware/printer/gutenprint/translations.xml b/hardware/printer/gutenprint/translations.xml new file mode 100644 index 0000000000..92593a7d65 --- /dev/null +++ b/hardware/printer/gutenprint/translations.xml @@ -0,0 +1,13 @@ + + + + gutenprint + Yüksek kaliteli yazıcı sürücüleri + Canon, Epson, Lexmark, Sony, Olympus ve PCL türü yazıcılar için Gimp, CUPS, Foomatic yazıcı sürücüleri + + + + gutenprint-devel + gutenprint için geliştirme dosyaları + +