Merge pull request #4857 from abbradar/cups2

[WIP] Improve printing experience and update related packages
This commit is contained in:
Michael Raskin 2014-11-15 15:18:35 +03:00
commit a7c8d00b27
15 changed files with 282 additions and 167 deletions

View File

@ -175,7 +175,7 @@ in
};
services.printing.drivers =
[ pkgs.cups pkgs.cups_pdf_filter pkgs.ghostscript additionalBackends
[ pkgs.cups pkgs.cups-filters pkgs.ghostscript additionalBackends
pkgs.perl pkgs.coreutils pkgs.gnused pkgs.bc pkgs.gawk pkgs.gnugrep
];

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, pkgconfig, gtk, poppler }:
{ stdenv, fetchurl, fetchpatch, pkgconfig, gtk, poppler }:
stdenv.mkDerivation rec {
name = "epdfview-0.1.8";
src = fetchurl {
@ -6,7 +6,17 @@ stdenv.mkDerivation rec {
sha256 = "1w7qybh8ssl4dffi5qfajq8mndw7ipsd92vkim03nywxgjp4i1ll";
};
buildInputs = [ pkgconfig gtk poppler ];
patches = [ ./glib-top-level-header.patch ];
patches = [ (fetchpatch {
name = "epdfview-0.1.8-glib2-headers.patch";
url = "https://projects.archlinux.org/svntogit/community.git/plain/trunk/epdfview-0.1.8-glib2-headers.patch?h=packages/epdfview&id=40ba115c860bdec31d03a30fa594a7ec2864d634";
sha256 = "13ha8l3ysw065wr1gpi33dr3r23pv2w51iczzkx6pnxsqk9cda4f";
})
(fetchpatch {
name = "epdfview-0.1.8-modern-cups.patch";
url = "https://projects.archlinux.org/svntogit/community.git/plain/trunk/epdfview-0.1.8-modern-cups.patch?h=packages/epdfview&id=40ba115c860bdec31d03a30fa594a7ec2864d634";
sha256 = "15pjriq0ppnjgmr26r9zj9smv301w8szwps6n87sshm0yiw9sli7";
})
];
meta = {
homepage = http://trac.emma-soft.com/epdfview/;
description = "A lightweight PDF document viewer using Poppler and GTK+";

View File

@ -1,12 +0,0 @@
diff -Naur epdfview-0.1.8-orig/src/gtk/StockIcons.h epdfview-0.1.8/src/gtk/StockIcons.h
--- epdfview-0.1.8-orig/src/gtk/StockIcons.h 2011-05-28 06:24:57.000000000 -0400
+++ epdfview-0.1.8/src/gtk/StockIcons.h 2012-07-15 11:02:43.946339253 -0400
@@ -18,7 +18,7 @@
#if !defined (__STOCK_ICONS_H__)
#define __STOCK_ICONS_H__
-#include <glib/gmacros.h>
+#include <glib.h>
G_BEGIN_DECLS

View File

@ -0,0 +1,30 @@
{ stdenv, fetchurl, autoreconfHook }:
let version = "9.15";
in
stdenv.mkDerivation {
name = "ijs-${version}";
src = fetchurl {
url = "http://downloads.ghostscript.com/public/ghostscript-${version}.tar.bz2";
sha256 = "0p1isp6ssfay141klirn7n9s8b546vcz6paksfmksbwy0ljsypg6";
};
prePatch = "cd ijs";
enableParallelBuilding = true;
nativeBuildInputs = [ autoreconfHook ];
configureFlags = [ "--disable-static" "--enable-shared" ];
meta = with stdenv.lib; {
homepage = https://www.openprinting.org/download/ijs/;
description = "Raster printer driver architecture";
license = licenses.gpl3Plus;
platforms = platforms.all;
maintainers = [ maintainers.abbradar ];
};
}

View File

@ -0,0 +1,34 @@
{ stdenv, fetchurl, pcre, zlib, perl }:
let version = "5.1.2";
in
stdenv.mkDerivation rec {
name = "qpdf-${version}";
src = fetchurl {
url = "mirror://sourceforge/qpdf/qpdf/${version}/${name}.tar.gz";
sha256 = "1zbvhrp0zjzbi6q2bnbxbg6399r47pq5gw3kspzph81j19fqvpg9";
};
nativeBuildInputs = [ perl ];
buildInputs = [ pcre zlib ];
postPatch = ''
patchShebangs qpdf/fix-qdf
'';
preCheck = ''
patchShebangs qtest/bin/qtest-driver
'';
doCheck = true;
meta = with stdenv.lib; {
homepage = http://qpdf.sourceforge.net/;
description = "A C++ library and set of programs that inspect and manipulate the structure of PDF files";
licenses = licenses.artistic2;
maintainers = maintainers.abbradar;
platforms = platforms.all;
};
}

View File

@ -1,13 +1,13 @@
{ stdenv, fetchurl, python, cups }:
let version = "1.9.57"; in
let version = "1.9.68"; in
stdenv.mkDerivation {
name = "pycups-${version}";
src = fetchurl {
url = "http://cyberelk.net/tim/data/pycups/pycups-${version}.tar.bz2";
sha256 = "12m3lh4nmfp6yn6sqlskl9gb1mfiwx42m8dnms6j6xc2nimn5k14";
sha256 = "1i1ph9k1wampa7r6mgc30a99w0zjmxhvcxjxrgjqa5vdknynqd24";
};
installPhase = ''

View File

@ -1,24 +1,27 @@
{ stdenv, fetchurl, pkgconfig, zlib, libjpeg, libpng, libtiff, pam, openssl
{ stdenv, fetchurl, pkgconfig, zlib, pam, openssl
, dbus, libusb, acl }:
let version = "1.5.4"; in
let version = "2.0.0"; in
stdenv.mkDerivation {
stdenv.mkDerivation rec {
name = "cups-${version}";
passthru = { inherit version; };
src = fetchurl {
url = "https://www.cups.org/software/${version}/cups-${version}-source.tar.bz2";
sha256 = "1rfhlv9b37120d6shngvyrcp99vh4a3lwdkrfanv3sjqid7068w0";
url = "https://www.cups.org/software/${version}/${name}-source.tar.bz2";
sha256 = "1qjv1w8m3f9lbrnd9wx8gman4sjbgb75svfypd4jkn649b5vpzc3";
};
buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb ]
buildInputs = [ pkgconfig zlib libusb ]
++ stdenv.lib.optionals stdenv.isLinux [ pam dbus.libs acl ] ;
propagatedBuildInputs = [ openssl ];
configureFlags = "--localstatedir=/var --enable-dbus"; # --with-dbusdir
patches = [ ./use-initgroups.patch ];
configureFlags = [ "--localstatedir=/var" "--enable-dbus"
# Workaround for installing systemd path
"--with-systemd=$out/lib/systemd/system"
];
installFlags =
[ # Don't try to write in /var at build time.

View File

@ -0,0 +1,35 @@
{ stdenv, fetchurl, autoreconfHook, pkgconfig, cups, libjpeg, ghostscript
, dejavu_fonts, libpng, libtiff, glib, lcms, freetype, fontconfig, ijs, poppler
, zlib, qpdf, dbus }:
stdenv.mkDerivation rec {
name = "cups-filters-1.0.61";
src = fetchurl {
url = "https://www.openprinting.org/download/cups-filters/${name}.tar.gz";
sha256 = "0mri36qih4vniycbga8aczmdf0qkiwyyi5hv8x9mg2f6a9wj8ch9";
};
configureFlags = [ "--with-test-font-path=${dejavu_fonts}/share/fonts/truetype/DejaVuSans.ttf"
"--with-cups-domainsocket=/var/run/cups/cups.sock"
"--with-rcdir=no"
];
buildInputs = [ ghostscript cups libjpeg libpng libtiff glib lcms freetype fontconfig
poppler zlib ijs qpdf dbus
];
patches = [ ./fix-cups-path.patch ];
nativeBuildInputs = [ pkgconfig autoreconfHook ];
doCheck = true;
meta = with stdenv.lib; {
homepage = http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters;
description = "Backends, filters, and other software that was once part of the core CUPS distribution";
license = "cups-filters";
maintainers = maintainers.abbradar;
platforms = stdenv.lib.platforms.linux;
};
}

View File

@ -0,0 +1,26 @@
diff -ru3 cups-filters-1.0.61-old/configure.ac cups-filters-1.0.61/configure.ac
--- cups-filters-1.0.61-old/configure.ac 2014-11-04 23:48:35.185515564 +0300
+++ cups-filters-1.0.61/configure.ac 2014-11-05 00:01:57.132038500 +0300
@@ -92,11 +92,11 @@
AC_SUBST(CUPS_CFLAGS)
AC_SUBST(CUPS_LIBS)
-CUPS_DATADIR="`$CUPSCONFIG --datadir`"
+CUPS_DATADIR="$out/share/cups"
AC_DEFINE_UNQUOTED(CUPS_DATADIR, "$CUPS_DATADIR", [CUPS datadir])
AC_SUBST(CUPS_DATADIR)
-CUPS_SERVERROOT="`$CUPSCONFIG --serverroot`"
+CUPS_SERVERROOT="$out/etc/cups"
AC_DEFINE_UNQUOTED(CUPS_SERVERROOT, "$CUPS_SERVERROOT", [CUPS serverroot])
AC_SUBST(CUPS_SERVERROOT)
@@ -104,7 +104,7 @@
AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$CUPS_FONTPATH", [Path to CUPS fonts dir])
AC_SUBST(CUPS_FONTPATH)
-CUPS_SERVERBIN="`$CUPSCONFIG --serverbin`"
+CUPS_SERVERBIN="$out/lib/cups"
AC_DEFINE_UNQUOTED(CUPS_SERVERBIN, "$CUPS_SERVERBIN", [Path to CUPS binaries dir])
AC_SUBST(CUPS_SERVERBIN)

View File

@ -1,39 +0,0 @@
{ stdenv, fetchurl, pkgconfig, cups, poppler }:
stdenv.mkDerivation {
name = "cups-pdf-filter-${cups.version}";
inherit (cups) src;
buildInputs = [ pkgconfig cups poppler ];
preConfigure = ''
sed -e 's@\.\./cups/$(LIBCUPS)@@' -e 's@$(LIBCUPSIMAGE)@@' -i filter/Makefile
'';
NIX_LDFLAGS="-L${cups}/lib";
configureFlags = ''
--localstatedir=/var --enable-dbus
--enable-image --with-pdftops=pdftops'';
buildPhase = ''
cd filter
make pdftops
'';
installPhase = ''
mkdir -pv $out/lib/cups/filter $out/share/cups/mime
cp -v pdftops $out/lib/cups/filter
echo >$out/share/cups/mime/pdftops.convs 'application/pdf application/vnd.cups-postscript 66 pdftops'
'';
meta = {
homepage = http://www.cups.org/;
description = "Image and pdf filters for CUPS";
license = stdenv.lib.licenses.gpl2;
maintainers = [ stdenv.lib.maintainers.urkud ];
platforms = stdenv.lib.platforms.linux;
};
}

View File

@ -0,0 +1,80 @@
diff -ru3 cups-2.0.0-old/scheduler/cups-exec.c cups-2.0.0/scheduler/cups-exec.c
--- cups-2.0.0-old/scheduler/cups-exec.c 2014-11-04 19:55:05.734768315 +0300
+++ cups-2.0.0/scheduler/cups-exec.c 2014-11-04 20:24:15.936670878 +0300
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <grp.h>
+#include <pwd.h>
#include <sys/stat.h>
#ifdef HAVE_SANDBOX_H
# include <sandbox.h>
@@ -55,6 +56,7 @@
uid_t uid = getuid(); /* UID */
gid_t gid = getgid(); /* GID */
int niceval = 0; /* Nice value */
+ struct passwd *pwd; /* User passwd entry */
#ifdef HAVE_SANDBOX_H
char *sandbox_error = NULL; /* Sandbox error, if any */
#endif /* HAVE_SANDBOX_H */
@@ -135,7 +137,15 @@
if (setgid(gid))
exit(errno + 100);
- if (setgroups(1, &gid))
+ if (uid)
+ {
+ if ((pwd = getpwuid(uid)) == NULL)
+ exit(errno + 100);
+
+ if (initgroups(pwd->pw_name, gid))
+ exit(errno + 100);
+ }
+ else if (setgroups(1, &gid))
exit(errno + 100);
if (uid && setuid(uid))
diff -ru3 cups-2.0.0-old/scheduler/process.c cups-2.0.0/scheduler/process.c
--- cups-2.0.0-old/scheduler/process.c 2014-11-04 19:55:05.736768298 +0300
+++ cups-2.0.0/scheduler/process.c 2014-11-04 20:23:55.001850057 +0300
@@ -19,6 +19,7 @@
#include "cupsd.h"
#include <grp.h>
+#include <pwd.h>
#ifdef __APPLE__
# include <libgen.h>
#endif /* __APPLE__ */
@@ -462,6 +463,7 @@
cups_exec[1024]; /* Path to "cups-exec" program */
uid_t user; /* Command UID */
cupsd_proc_t *proc; /* New process record */
+ struct passwd *pwd; /* User passwd entry */
#ifdef HAVE_POSIX_SPAWN
posix_spawn_file_actions_t actions; /* Spawn file actions */
posix_spawnattr_t attrs; /* Spawn attributes */
@@ -716,13 +718,22 @@
nice(FilterNice);
/*
- * Reset group membership to just the main one we belong to.
+ * Reset group membership to the main one we belong to with its
+ * supplementary groups.
*/
if (!RunUser && setgid(Group))
exit(errno + 100);
- if (!RunUser && setgroups(1, &Group))
+ if (!RunUser && user)
+ {
+ if ((pwd = getpwuid(user)) == NULL)
+ exit(errno + 100);
+
+ if (initgroups(pwd->pw_name, Group))
+ exit(errno + 100);
+ }
+ else if (!RunUser && setgroups(1, &Group))
exit(errno + 100);
/*

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, pkgconfig, perl, cups, dbus }:
{ stdenv, fetchurl, pkgconfig, perl, cups, dbus, enscript }:
stdenv.mkDerivation rec {
name = "foomatic-filters-4.0.17";
@ -8,7 +8,7 @@ stdenv.mkDerivation rec {
sha256 = "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2";
};
buildInputs = [ pkgconfig perl cups dbus ];
buildInputs = [ pkgconfig perl cups dbus enscript ];
preConfigure =
''

View File

@ -3,69 +3,18 @@
, libiconvOrEmpty
, x11Support ? false, x11 ? null
, cupsSupport ? false, cups ? null
, gnuFork ? true
}:
assert x11Support -> x11 != null;
assert cupsSupport -> cups != null;
let
meta_common = {
homepage = "http://www.gnu.org/software/ghostscript/";
description = "PostScript interpreter (GNU version)";
stdenv.mkDerivation rec {
name = "ghostscript-9.15";
longDescription = ''
Ghostscript is the name of a set of tools that provides (i) an
interpreter for the PostScript language and the PDF file format,
(ii) a set of C procedures (the Ghostscript library) that
implement the graphics capabilities that appear as primitive
operations in the PostScript language, and (iii) a wide variety
of output drivers for various file formats and printers.
'';
license = stdenv.lib.licenses.gpl3Plus;
platforms = stdenv.lib.platforms.all;
maintainers = [ stdenv.lib.maintainers.viric ];
};
gnuForkSrc = rec {
name = "ghostscript-9.04.1";
src = fetchurl {
url = "mirror://gnu/ghostscript/gnu-${name}.tar.bz2";
sha256 = "0zqa6ggbkdqiszsywgrra4ij0sddlmrfa50bx2mh568qid4ga0a2";
};
meta = meta_common;
patches = [ ./purity.patch ];
};
mainlineSrc = rec {
name = "ghostscript-9.06";
src = fetchurl {
url = "http://downloads.ghostscript.com/public/${name}.tar.bz2";
sha256 = "014f10rxn4ihvcr1frby4szd1jvkrwvmdhnbivpp55c9fssx3b05";
sha256 = "0p1isp6ssfay141klirn7n9s8b546vcz6paksfmksbwy0ljsypg6";
};
meta = meta_common // {
homepage = "http://www.ghostscript.com/";
description = "PostScript interpreter (mainline version)";
};
preConfigure = ''
rm -R libpng jpeg lcms{,2} tiff freetype jbig2dec expat openjpeg
substituteInPlace base/unix-aux.mak --replace "INCLUDE=/usr/include" "INCLUDE=/no-such-path"
sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@" -i base/unix-aux.mak
'';
patches = [];
};
variant = if gnuFork then gnuForkSrc else mainlineSrc;
in
stdenv.mkDerivation rec {
inherit (variant) name src meta;
fonts = [
(fetchurl {
@ -91,34 +40,56 @@ stdenv.mkDerivation rec {
# [] # maybe sometimes jpeg2000 support
;
CFLAGS = "-fPIC";
NIX_LDFLAGS =
"-lz -rpath${ if stdenv.isDarwin then " " else "="}${freetype}/lib";
patches = [ ./urw-font-files.patch ];
patches = variant.patches ++ [ ./urw-font-files.patch ];
preConfigure = ''
# "ijs" is impure: it contains symlinks to /usr/share/automake etc.!
rm -rf ijs/ltmain.sh
# Don't install stuff in the Cups store path.
makeFlagsArray=(CUPSSERVERBIN=$out/lib/cups CUPSSERVERROOT=$out/etc/cups CUPSDATA=$out/share/cups)
'' + stdenv.lib.optionalString (variant ? preConfigure) variant.preConfigure;
makeFlags = [ "cups_serverroot=$(out)" "cups_serverbin=$(out)/lib/cups" ];
configureFlags =
[ "--with-system-libtiff"
[ "--with-system-libtiff" "--disable-sse2"
"--enable-dynamic"
(if x11Support then "--with-x" else "--without-x")
(if cupsSupport then "--enable-cups --with-install-cups" else "--disable-cups")
(if cupsSupport then "--enable-cups" else "--disable-cups")
];
doCheck = true;
installTargets="install soinstall";
# ToDo: web says the fonts should be already included
#CFLAGS = "-fPIC";
#NIX_LDFLAGS =
# "-lz -rpath${ if stdenv.isDarwin then " " else "="}${freetype}/lib";
preConfigure = ''
rm -rf jpeg libpng zlib jasper expat tiff lcms{,2} jbig2dec openjpeg freetype cups/libs
sed "s@if ( test -f \$(INCLUDE)[^ ]* )@if ( true )@; s@INCLUDE=/usr/include@INCLUDE=/no-such-path@" -i base/unix-aux.mak
'';
postInstall = ''
# ToDo: web says the fonts should be already included
for i in $fonts; do
(cd $out/share/ghostscript && tar xvfz $i)
done
rm -rf $out/lib/cups/filter/{gstopxl,gstoraster}
'';
meta = {
homepage = "http://www.ghostscript.com/";
description = "PostScript interpreter (mainline version)";
longDescription = ''
Ghostscript is the name of a set of tools that provides (i) an
interpreter for the PostScript language and the PDF file format,
(ii) a set of C procedures (the Ghostscript library) that
implement the graphics capabilities that appear as primitive
operations in the PostScript language, and (iii) a wide variety
of output drivers for various file formats and printers.
'';
license = stdenv.lib.licenses.gpl3Plus;
platforms = stdenv.lib.platforms.all;
maintainers = [ stdenv.lib.maintainers.viric ];
};
}

View File

@ -1,26 +0,0 @@
Don't look for files under `/usr/include' since we don't have that directory
under NixOS.
--- gnu-ghostscript-8.64.0/base/unix-aux.mak 2009-04-19 19:00:20.000000000 +0200
+++ gnu-ghostscript-8.64.0/base/unix-aux.mak 2009-04-27 11:58:31.000000000 +0200
@@ -103,13 +103,13 @@ $(MKROMFS_XE): $(GLSRC)mkromfs.c $(MKROM
# The "else true;" is required because Ultrix's implementation of sh -e
# terminates execution of a command if any error occurs, even if the command
# traps the error with ||.
-INCLUDE=/usr/include
+INCLUDE=/no-such-path
$(gconfig__h): $(UNIX_AUX_MAK) $(ECHOGS_XE)
$(ECHOGS_XE) -w $(gconfig__h) -x 2f2a -s This file was generated automatically by unix-aux.mak. -s -x 2a2f
- if ( test -f $(INCLUDE)/dirent.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_DIRENT_H; else true; fi
- if ( test -f $(INCLUDE)/ndir.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_NDIR_H; else true; fi
- if ( test -f $(INCLUDE)/sys/dir.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_DIR_H; else true; fi
- if ( test -f $(INCLUDE)/sys/ndir.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_NDIR_H; else true; fi
- if ( test -f $(INCLUDE)/sys/time.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_TIME_H; else true; fi
- if ( test -f $(INCLUDE)/sys/times.h ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_TIMES_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_DIRENT_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_NDIR_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_DIR_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_NDIR_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_TIME_H; else true; fi
+ if ( true ); then $(ECHOGS_XE) -a $(gconfig__h) -x 23 define HAVE_SYS_TIMES_H; else true; fi
if ( test -f $(JSRCDIR)/jmemsys.h); then true; else $(ECHOGS_XE) -a $(gconfig__h) -x 23 define DONT_HAVE_JMEMSYS_H; fi

View File

@ -2173,6 +2173,8 @@ let
qjoypad = callPackage ../tools/misc/qjoypad { };
qpdf = callPackage ../development/libraries/qpdf { };
qscintilla = callPackage ../development/libraries/qscintilla {
qt = qt4;
};
@ -5490,6 +5492,8 @@ let
imlib2 = callPackage ../development/libraries/imlib2 { };
ijs = callPackage ../development/libraries/ijs { };
incrtcl = callPackage ../development/libraries/incrtcl { };
indilib = callPackage ../development/libraries/indilib { };
@ -12273,7 +12277,7 @@ let
cups = callPackage ../misc/cups { libusb = libusb1; };
cups_pdf_filter = callPackage ../misc/cups/pdf-filter.nix { };
cups-filters = callPackage ../misc/cups/drivers/cups-filters { };
crashplan = callPackage ../applications/backup/crashplan { };
@ -12326,7 +12330,6 @@ let
ghostscript = callPackage ../misc/ghostscript {
x11Support = false;
cupsSupport = config.ghostscript.cups or (!stdenv.isDarwin);
gnuFork = config.ghostscript.gnu or false;
};
ghostscriptX = appendToName "with-X" (ghostscript.override {