about summary refs log tree commit diff
path: root/pkgs/misc/cups
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2015-10-03 13:33:13 +0200
committerVladimír Čunát <vcunat@gmail.com>2015-10-03 13:33:37 +0200
commit5227fb1dd53fcb5918b9342dff4868f4ad68427e (patch)
treed6cd521e3f67944031216a27f740f28f22b73b41 /pkgs/misc/cups
parentd6dd3b8bd1eaeeb21dfdb5051cd4732c748ce5d7 (diff)
parent33373d939a19f465228ddede6d38ce9032b5916b (diff)
downloadnixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.gz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.bz2
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.lz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.xz
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.tar.zst
nixlib-5227fb1dd53fcb5918b9342dff4868f4ad68427e.zip
Merge commit staging+systemd into closure-size
Many non-conflict problems weren't (fully) resolved in this commit yet.
Diffstat (limited to 'pkgs/misc/cups')
-rw-r--r--pkgs/misc/cups/default.nix59
-rw-r--r--pkgs/misc/cups/drivers/canon/default.nix220
-rw-r--r--pkgs/misc/cups/drivers/canon/preload.c81
-rw-r--r--pkgs/misc/cups/filters.nix31
-rw-r--r--pkgs/misc/cups/longer-shell-path.patch13
5 files changed, 360 insertions, 44 deletions
diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix
index f91d53c81a53..3d335a01d9ba 100644
--- a/pkgs/misc/cups/default.nix
+++ b/pkgs/misc/cups/default.nix
@@ -1,8 +1,11 @@
-{ stdenv, fetchurl, pkgconfig, zlib, libjpeg, libpng, libtiff, pam, openssl
-, dbus, libusb, acl, gmp }:
+{ stdenv, fetchurl, pkgconfig, zlib, libjpeg, libpng, libtiff, pam
+, dbus, acl, gmp
+, libusb ? null, gnutls ? null, avahi ? null, libpaper ? null
+}:
 
-let version = "1.7.5"; in
+let version = "2.0.4"; in
 
+with stdenv.lib;
 stdenv.mkDerivation {
   name = "cups-${version}";
 
@@ -10,18 +13,30 @@ stdenv.mkDerivation {
 
   src = fetchurl {
     url = "https://www.cups.org/software/${version}/cups-${version}-source.tar.bz2";
-    sha256 = "00mx4rpiqw9cwx46bd3hd5lcgmcxy63zfnmkr02smanv8xl4rjqq";
+    sha256 = "1gaakz24k6x5nc09rmpiq0xq20j1qdjc3szag8qwmyi4ky6ydmg1";
   };
 
   # FIXME: Split off the cups client library.
   outputs = [ "dev" "out" "doc" "man" ];
 
-  buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb ]
-    ++ stdenv.lib.optionals stdenv.isLinux [ pam dbus.libs acl ] ;
+  buildInputs = [ pkgconfig zlib libjpeg libpng libtiff libusb gnutls avahi libpaper ]
+    ++ optionals stdenv.isLinux [ pam dbus.libs acl ];
 
-  propagatedBuildInputs = [ openssl gmp ];
+  propagatedBuildInputs = [ gmp ];
 
-  configureFlags = "--localstatedir=/var --sysconfdir=/etc --enable-dbus"; # --with-dbusdir
+  configureFlags = [
+    "--localstatedir=/var"
+    "--sysconfdir=/etc"
+    "--with-systemd=\${out}/lib/systemd/system"
+    "--enable-raw-printing"
+    "--enable-threads"
+  ] ++ optionals stdenv.isLinux [
+    "--enable-dbus"
+    "--enable-pam"
+  ] ++ optional (libusb != null) "--enable-libusb"
+    ++ optional (gnutls != null) "--enable-ssl"
+    ++ optional (avahi != null) "--enable-avahi"
+    ++ optional (libpaper != null) "--enable-libpaper";
 
   installFlags =
     [ # Don't try to write in /var at build time.
@@ -42,20 +57,36 @@ stdenv.mkDerivation {
       "CUPS_PRIMARY_SYSTEM_GROUP=root"
     ];
 
-  postInstall =
-    ''
+  postInstall = ''
       # Delete obsolete stuff that conflicts with cups-filters.
       rm -rf $out/share/cups/banners $out/share/cups/data/testprint
 
       mkdir $dev/bin
       mv $out/bin/cups-config $dev/bin/
+
+      # Rename systemd files provided by CUPS
+      for f in $out/lib/systemd/system/*; do
+        substituteInPlace "$f" \
+          --replace "org.cups.cupsd" "cups" \
+          --replace "org.cups." ""
+
+        if [[ "$f" =~ .*cupsd\..* ]]; then
+          mv "$f" "''${f/org\.cups\.cupsd/cups}"
+        else
+          mv "$f" "''${f/org\.cups\./}"
+        fi
+      done
+    '' + optionalString stdenv.isLinux ''
+      # Use xdg-open when on Linux
+      substituteInPlace $out/share/applications/cups.desktop \
+        --replace "Exec=htmlview" "Exec=xdg-open"
     '';
 
   meta = {
-    homepage = "http://www.cups.org/";
+    homepage = https://cups.org/;
     description = "A standards-based printing system for UNIX";
-    license = stdenv.lib.licenses.gpl2; # actually LGPL for the library and GPL for the rest
-    maintainers = [ stdenv.lib.maintainers.urkud stdenv.lib.maintainers.simons ];
-    platforms = stdenv.lib.platforms.linux;
+    license = licenses.gpl2; # actually LGPL for the library and GPL for the rest
+    maintainers = with maintainers; [ urkud simons jgeerds ];
+    platforms = platforms.linux;
   };
 }
diff --git a/pkgs/misc/cups/drivers/canon/default.nix b/pkgs/misc/cups/drivers/canon/default.nix
new file mode 100644
index 000000000000..4c31e8d37d25
--- /dev/null
+++ b/pkgs/misc/cups/drivers/canon/default.nix
@@ -0,0 +1,220 @@
+{stdenv, fetchurl, unzip, autoreconfHook, libtool, makeWrapper, cups, ghostscript, callPackage_i686 }:
+
+let
+
+  i686_NIX_GCC = callPackage_i686 ({gcc}: gcc) {};
+  i686_libxml2 = callPackage_i686 ({libxml2}: libxml2) {};
+  i686_glibc = callPackage_i686 ({glibc}: glibc) {};
+
+  src_canon = fetchurl {
+    url = "http://files.canon-europe.com/files/soft45378/software/o147jen_linuxufrII_0290.zip";
+    sha256 = "1qpdmaaw42gm5fi21rp4lf05skffkq42ka5c8xkw8rckzb13sy9j";
+  };
+
+in
+
+
+stdenv.mkDerivation rec {
+  name = "canon-cups-ufr2-2.90";
+  src = src_canon;
+
+  phases = [ "unpackPhase" "installPhase" ];
+
+  postUnpack = ''
+    (cd $sourceRoot; tar -xzf Sources/cndrvcups-common-2.90-1.tar.gz)
+    (cd $sourceRoot; tar -xzf Sources/cndrvcups-lb-2.90-1.tar.gz)
+  '';
+
+  nativeBuildInputs = [ makeWrapper unzip autoreconfHook libtool ];
+
+  buildInputs = [ cups ];
+
+  installPhase = ''
+    ##
+    ## cndrvcups-common buildPhase
+    ##
+    ( cd cndrvcups-common-2.90/buftool
+      autoreconf -fi
+      ./autogen.sh --prefix=$out --enable-progpath=$out/bin --libdir=$out/lib --disable-shared --enable-static
+      make
+    )
+
+    ( cd cndrvcups-common-2.90/backend
+      ./autogen.sh --prefix=$out --libdir=$out/lib
+      make
+    )
+
+    ( cd cndrvcups-common-2.90/c3plmod_ipc
+      make
+    )
+
+    ##
+    ## cndrvcups-common installPhase
+    ##
+
+    ( cd cndrvcups-common-2.90/buftool
+      make install
+    )
+
+    ( cd cndrvcups-common-2.90/backend
+      make install
+    )
+
+    ( cd cndrvcups-common-2.90/c3plmod_ipc
+      make install DESTDIR=$out/lib
+    )
+
+    ( cd cndrvcups-common-2.90/libs
+      chmod 755 *
+      mkdir -p $out/lib32
+      mkdir -p $out/bin
+      cp libcaiowrap.so.1.0.0 $out/lib32
+      cp libcaiousb.so.1.0.0 $out/lib32
+      cp libc3pl.so.0.0.1 $out/lib32
+      cp libcaepcm.so.1.0 $out/lib32
+      cp libColorGear.so.0.0.0 $out/lib32
+      cp libColorGearC.so.0.0.0 $out/lib32
+      cp libcanon_slim.so.1.0.0 $out/lib32
+      cp c3pldrv $out/bin
+    )
+
+    (cd cndrvcups-common-2.90/data
+      chmod 644 *.ICC
+      mkdir -p $out/share/caepcm
+      cp *.ICC $out/share/caepcm
+    )
+
+    (cd $out/lib32
+      ln -sf libc3pl.so.0.0.1 libc3pl.so.0
+      ln -sf libc3pl.so.0.0.1 libc3pl.so
+      ln -sf libcaepcm.so.1.0 libcaepcm.so.1
+      ln -sf libcaepcm.so.1.0 libcaepcm.so
+      ln -sf libcaiowrap.so.1.0.0 libcaiowrap.so.1
+      ln -sf libcaiowrap.so.1.0.0 libcaiowrap.so
+      ln -sf libcaiousb.so.1.0.0 libcaiousb.so.1
+      ln -sf libcaiousb.so.1.0.0 libcaiousb.so
+      ln -sf libcanon_slim.so.1.0.0 libcanon_slim.so.1
+      ln -sf libcanon_slim.so.1.0.0 libcanon_slim.so
+      ln -sf libColorGear.so.0.0.0 libColorGear.so.0
+      ln -sf libColorGear.so.0.0.0 libColorGear.so
+      ln -sf libColorGearC.so.0.0.0 libColorGearC.so.0
+      ln -sf libColorGearC.so.0.0.0 libColorGearC.so
+    )
+
+    (cd $out/lib
+      ln -sf libcanonc3pl.so.1.0.0 libcanonc3pl.so
+      ln -sf libcanonc3pl.so.1.0.0 libcanonc3pl.so.1
+    )
+
+    patchelf --set-rpath "$(cat ${i686_NIX_GCC}/nix-support/orig-cc)/lib" $out/lib32/libColorGear.so.0.0.0
+    patchelf --set-rpath "$(cat ${i686_NIX_GCC}/nix-support/orig-cc)/lib" $out/lib32/libColorGearC.so.0.0.0
+
+    patchelf --interpreter "$(cat ${i686_NIX_GCC}/nix-support/dynamic-linker)" --set-rpath "$out/lib32" $out/bin/c3pldrv
+
+    # c3pldrv is programmed with fixed paths that point to "/usr/{bin,lib.share}/..."
+    # preload32 wrappes all necessary function calls to redirect the fixed paths
+    # into $out.
+    mkdir -p $out/libexec
+    preload32=$out/libexec/libpreload32.so
+    ${i686_NIX_GCC}/bin/gcc -shared ${./preload.c} -o $preload32 -ldl -DOUT=\"$out\" -fPIC
+    wrapProgram "$out/bin/c3pldrv" \
+      --set PRELOAD_DEBUG 1 \
+      --set LD_PRELOAD $preload32 \
+      --prefix LD_LIBRARY_PATH : "$out/lib32"
+
+
+
+    ##
+    ## cndrvcups-lb buildPhase
+    ##
+
+    ( cd cndrvcups-lb-2.90/ppd
+      ./autogen.sh --prefix=$out
+      make
+    )
+
+    ( cd cndrvcups-lb-2.90/pstoufr2cpca
+      CPPFLAGS="-I$out/include" LDFLAGS=" -L$out/lib" ./autogen.sh --prefix=$out --enable-progpath=$out/bin
+      make
+    )
+
+    ( cd cndrvcups-lb-2.90/cpca
+      CPPFLAGS="-I$out/include" LDFLAGS=" -L$out/lib" ./autogen.sh --prefix=$out --enable-progpath=$out/bin  --enable-static
+      make
+    )
+
+    ##
+    ## cndrvcups-lb installPhase
+    ##
+
+    ( cd cndrvcups-lb-2.90/ppd
+      make install
+    )
+
+    ( cd cndrvcups-lb-2.90/pstoufr2cpca
+      make install
+    )
+
+    ( cd cndrvcups-lb-2.90/cpca
+      make install
+    )
+
+    ( cd cndrvcups-lb-2.90/libs
+      chmod 755 *
+      mkdir -p $out/lib32
+      mkdir -p $out/bin
+      cp libcanonufr2.la $out/lib32
+      cp libcanonufr2.so.1.0.0 $out/lib32
+      cp libufr2filter.so.1.0.0 $out/lib32
+      cp libEnoJBIG.so.1.0.0 $out/lib32
+      cp libEnoJPEG.so.1.0.0 $out/lib32
+      cp libcaiocnpkbidi.so.1.0.0 $out/lib32
+      cp libcnlbcm.so.1.0 $out/lib32
+
+      cp cnpkmoduleufr2 $out/bin #maybe needs setuid 4755
+      cp cnpkbidi $out/bin
+    )
+
+    ( cd $out/lib32
+      ln -sf libcanonufr2.so.1.0.0 libcanonufr2.so
+      ln -sf libcanonufr2.so.1.0.0 libcanonufr2.so.1
+      ln -sf libufr2filter.so.1.0.0 libufr2filter.so
+      ln -sf libufr2filter.so.1.0.0 libufr2filter.so.1
+      ln -sf libEnoJBIG.so.1.0.0 libEnoJBIG.so
+      ln -sf libEnoJBIG.so.1.0.0 libEnoJBIG.so.1
+      ln -sf libEnoJPEG.so.1.0.0 libEnoJPEG.so
+      ln -sf libEnoJPEG.so.1.0.0 libEnoJPEG.so.1
+      ln -sf libcaiocnpkbidi.so.1.0.0 libcaiocnpkbidi.so
+      ln -sf libcaiocnpkbidi.so.1.0.0 libcaiocnpkbidi.so.1
+      ln -sf libcnlbcm.so.1.0 libcnlbcm.so.1
+      ln -sf libcnlbcm.so.1.0 libcnlbcm.so
+    )
+
+    ( cd cndrvcups-lb-2.90
+      chmod 644 data/CnLB*
+      chmod 644 libs/cnpkbidi_info*
+      chmod 644 libs/ThLB*
+      mkdir -p $out/share/caepcm
+      mkdir -p $out/share/cnpkbidi
+      mkdir -p $out/share/ufr2filter
+      cp data/CnLB* $out/share/caepcm
+      cp libs/cnpkbidi_info* $out/share/cnpkbidi
+      cp libs/ThLB* $out/share/ufr2filter
+    )
+
+    patchelf --set-rpath "$out/lib32:${i686_libxml2}/lib" $out/lib32/libcanonufr2.so.1.0.0
+
+    patchelf --interpreter "$(cat ${i686_NIX_GCC}/nix-support/dynamic-linker)" --set-rpath "$out/lib32" $out/bin/cnpkmoduleufr2
+    patchelf --interpreter "$(cat ${i686_NIX_GCC}/nix-support/dynamic-linker)" --set-rpath "$out/lib32:${i686_libxml2}/lib" $out/bin/cnpkbidi
+
+    makeWrapper "${ghostscript}/bin/gs" "$out/bin/gs" \
+      --prefix LD_LIBRARY_PATH ":" "$out/lib" \
+      --prefix PATH ":" "$out/bin"
+    '';
+
+  meta = {
+    description = "CUPS Linux drivers for Canon printers";
+    homepage = "http://www.canon.com/";
+    license = stdenv.lib.licenses.unfree;
+  };
+}
diff --git a/pkgs/misc/cups/drivers/canon/preload.c b/pkgs/misc/cups/drivers/canon/preload.c
new file mode 100644
index 000000000000..f3a30063a6e3
--- /dev/null
+++ b/pkgs/misc/cups/drivers/canon/preload.c
@@ -0,0 +1,81 @@
+/*
+ * LD_PRELOAD trick to make c3pldrv handle the absolute path to /usr/{bin,lib,share)}.
+ * As c3pldrv is a 32 bit executable, /lib will be rewritten to /lib32.
+ *
+ * Usage:
+ *   gcc -shared -fPIC -DOUT="$out" preload.c -o preload.so -ldl
+ *   LD_PRELOAD=$PWD/preload.so ./c3pldrv
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <limits.h>
+
+#ifndef OUT
+#error Missing OUT define - path to the installation directory.
+#endif
+
+typedef void *(*dlopen_func_t)(const char *filename, int flag);
+typedef int (*open_func_t)(const char *pathname, int flags, ...);
+typedef int (*execv_func_t)(const char *path, char *const argv[]);
+
+
+void *dlopen(const char *filename, int flag)
+{
+	dlopen_func_t orig_dlopen;
+	const char *new_filename;
+	char buffer[PATH_MAX];
+
+	orig_dlopen = (dlopen_func_t)dlsym(RTLD_NEXT, "dlopen");
+
+	new_filename = filename;
+	if (strncmp("/usr/lib", filename, 8) == 0) {
+		snprintf(buffer, PATH_MAX, OUT "/lib32%s", filename+8);
+		buffer[PATH_MAX-1] = '\0';
+		new_filename = buffer;
+	}
+	
+	return orig_dlopen(new_filename, flag);
+}
+
+int open(const char *pathname, int flags, ...)
+{
+	open_func_t orig_open;
+	const char *new_pathname;
+	char buffer[PATH_MAX];
+
+	orig_open = (open_func_t)dlsym(RTLD_NEXT, "open");
+
+	new_pathname = pathname;
+	if (strncmp("/usr/share", pathname, 10) == 0) {
+		snprintf(buffer, PATH_MAX, OUT "%s", pathname+4);
+		buffer[PATH_MAX-1] = '\0';
+		new_pathname = buffer;
+	}
+	
+	return orig_open(new_pathname, flags);
+}
+
+int execv(const char *path, char *const argv[])
+{
+	execv_func_t orig_execv;
+	const char *new_path;
+	char buffer[PATH_MAX];
+
+	orig_execv = (execv_func_t)dlsym(RTLD_NEXT, "execv");
+
+	new_path = path;
+	if (strncmp("/usr/bin", path, 8) == 0) {
+		snprintf(buffer, PATH_MAX, OUT "%s", path+4);
+		buffer[PATH_MAX-1] = '\0';
+		new_path = buffer;
+	}
+	
+	return orig_execv(new_path, argv);
+}
+
diff --git a/pkgs/misc/cups/filters.nix b/pkgs/misc/cups/filters.nix
index 8043cbb1506e..a860273e9eb5 100644
--- a/pkgs/misc/cups/filters.nix
+++ b/pkgs/misc/cups/filters.nix
@@ -1,35 +1,32 @@
-{ stdenv, fetchurl, pkgconfig, cups, poppler, poppler_utils, fontconfig
+{ stdenv, fetchurl, fetchpatch, pkgconfig, cups, poppler, poppler_utils, fontconfig
 , libjpeg, libpng, perl, ijs, qpdf, dbus, substituteAll, bash, avahi }:
 
 stdenv.mkDerivation rec {
   name = "cups-filters-${version}";
-  version = "1.0.61";
+  version = "1.0.71";
 
   src = fetchurl {
     url = "http://openprinting.org/download/cups-filters/${name}.tar.xz";
-    sha256 = "1bq48nnrarlbf6qc93bz1n5wlh6j420gppbck3r45sinwhz5wa7m";
+    sha256 = "07wwlqcykfjfqcwj1bxk60ggahyaw7wcx32n5s104d1qkhham01i";
   };
 
-  patches = [
-    (substituteAll {
-      src = ./longer-shell-path.patch;
-      bash = "${bash}/bin/bash";
-    })
-
-    # Fix build with poppler-0.31.0
-    (fetchurl {
-      url = "https://bugs.linuxfoundation.org/attachment.cgi?id=476";
-      name = "cups-filters-poppler-0.31.0.patch";
-      sha256 = "016pzksz4nl1sv3p5ahlnbmb7c899yrvlzq8jxic0gvdrzwd5bl4";
-    })
-  ];
+  patches = [(fetchpatch { # drop on update
+    name = "poppler-0.34.patch";
+    url = "https://bugs.linuxfoundation.org/attachment.cgi?id=493";
+    sha256 = "18za83q0b0n4hpvvw76jsv0hm89zmijvps2z5kg1srickqlxj891";
+  })];
 
   buildInputs = [
     pkgconfig cups poppler poppler_utils fontconfig libjpeg libpng perl
     ijs qpdf dbus avahi
   ];
 
-  configureFlags = "--with-pdftops=pdftops --enable-imagefilters --with-rcdir=no";
+  configureFlags = [
+    "--with-pdftops=pdftops"
+    "--enable-imagefilters"
+    "--with-rcdir=no"
+    "--with-shell=${stdenv.shell}"
+  ];
 
   makeFlags = "CUPS_SERVERBIN=$(out)/lib/cups CUPS_DATADIR=$(out)/share/cups CUPS_SERVERROOT=$(out)/etc/cups";
 
diff --git a/pkgs/misc/cups/longer-shell-path.patch b/pkgs/misc/cups/longer-shell-path.patch
deleted file mode 100644
index a15fd4832258..000000000000
--- a/pkgs/misc/cups/longer-shell-path.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c
-index 1c019aa..431d2f9 100644
---- a/filter/foomatic-rip/foomaticrip.c
-+++ b/filter/foomatic-rip/foomaticrip.c
-@@ -174,7 +174,7 @@ char cupsfilterpath[PATH_MAX] = "/usr/local/lib/cups/filter:"
-                                 "/opt/cups/filter:"
-                                 "/usr/lib/cups/filter";
- 
--char modern_shell[64] = "/bin/bash";
-+char modern_shell[128] = "@bash@";
- 
- void config_set_option(const char *key, const char *value)
- {