@@ -0,0 +1,150 @@
1+{ stdenv, lib, fetchzip,
2+ autoconf, automake, libtool,
3+ cups, popt, libtiff, libpng,
4+ ghostscript, glib, libusb, libxml2 }:
5+
6+/* this derivation is basically just a transcription of the rpm .spec
7+ file included in the tarball */
8+
9+let arch =
10+ if stdenv.system == "x86_64-linux" then "64"
11+ else if stdenv.system == "i686-linux" then "32"
12+ else abort "Unsupported architecture";
13+
14+in stdenv.mkDerivation rec {
15+ name = "cnijfilter-${version}";
16+
17+ /* important note about versions: cnijfilter packages seem to use
18+ versions in a non-standard way. the version indicates which
19+ printers are supported in the package. so this package should
20+ not be "upgraded" in the usual way.
21+
22+ instead, if you want to include another version supporting your
23+ printer, you should try to abstract out the common things (which
24+ should be pretty much everything except the version and the 'pr'
25+ and 'pr_id' values to loop over). */
26+ version = "4.00";
27+
28+ src = fetchzip {
29+ url = "http://gdlp01.c-wss.com/gds/5/0100005515/01/cnijfilter-source-4.00-1.tar.gz";
30+ sha256 = "1f6vpx1z3qa88590i5m0s49j9n90vpk81xmw6pvj0nfd3qbvzkya";
31+ };
32+
33+ buildInputs = [ autoconf libtool automake
34+ cups popt libtiff libpng
35+ ghostscript glib libusb libxml2 ];
36+
37+ # patches from https://github.com/tokiclover/bar-overlay/tree/master/net-print/cnijfilter
38+ patches = [
39+ ./patches/cnijfilter-3.80-1-cups-1.6.patch
40+ ./patches/cnijfilter-3.80-6-cups-1.6.patch
41+ ./patches/cnijfilter-4.00-4-ppd.patch
42+ ./patches/cnijfilter-4.00-5-abi_x86_32.patch
43+ ./patches/cnijfilter-4.00-6-headers.patch
44+ ];
45+
46+ postPatch = ''
47+ sed -i "s|/usr/lib/cups/backend|$out/lib/cups/backend|" backend/src/Makefile.am;
48+ sed -i "s|/usr/lib/cups/backend|$out/lib/cups/backend|" backendnet/backend/Makefile.am;
49+ sed -i "s|/usr/lib/cups/backend|$out/lib/cups/backend|" cnijbe/src/Makefile.am;
50+ sed -i "s|/usr|$out|" backend/src/cnij_backend_common.c;
51+ sed -i "s|/usr/bin|${ghostscript}/bin|" pstocanonij/filter/pstocanonij.c;
52+ '';
53+
54+ configurePhase = ''
55+ cd libs
56+ ./autogen.sh --prefix=$out
57+
58+ cd ../bscc2sts
59+ ./autogen.sh
60+
61+ cd ../cnijnpr
62+ ./autogen.sh --prefix=$out --enable-libpath=$out/lib/bjlib
63+
64+ cd ../cngpij
65+ ./autogen.sh --prefix=$out --enable-progpath=$out/bin
66+
67+ cd ../cngpijmnt
68+ ./autogen.sh --prefix=$out --enable-progpath=$out/bin
69+
70+ cd ../pstocanonij
71+ ./autogen.sh --prefix=$out --enable-progpath=$out/bin
72+
73+ cd ../backend
74+ ./autogen.sh --prefix=$out
75+
76+ cd ../backendnet
77+ ./autogen.sh --prefix=$out --enable-libpath=$out/lib/bjlib --enable-progpath=$out/bin
78+
79+ cd ../cmdtocanonij
80+ ./autogen.sh --prefix=$out --datadir=$out/share
81+
82+ cd ../cnijbe
83+ ./autogen.sh --prefix=$out --enable-progpath=$out/bin
84+
85+ cd ../lgmon2
86+ substituteInPlace src/Makefile.am \
87+ --replace /usr/include/libusb-1.0 \
88+ ${libusb.dev}/include/libusb-1.0
89+ ./autogen.sh --prefix=$out --enable-libpath=$out/lib/bjlib --enable-progpath=$out/bin
90+
91+ cd ..;
92+
93+ sed -e "s,cnijlgmon2_LDADD =,cnijlgmon2_LDADD = -L../../com/libs_bin${arch}," \
94+ -i lgmon2/src/Makefile.am || die
95+ '';
96+
97+ preInstall = ''
98+ mkdir -p $out/bin $out/lib/cups/filter $out/share/cups/model;
99+ '';
100+
101+ postInstall = ''
102+ set -o xtrace
103+ for pr in mg2400 mg2500 mg3500 mg5500 mg6400 mg6500 mg7100 p200; do
104+ cd ppd;
105+ ./autogen.sh --prefix=$out --program-suffix=$pr
106+ make clean;
107+ make;
108+ make install;
109+
110+ cd ../cnijfilter;
111+ ./autogen.sh --prefix=$out --program-suffix=$pr --enable-libpath=/var/lib/cups/path/lib/bjlib --enable-binpath=$out/bin;
112+ make clean;
113+ make;
114+ make install;
115+
116+ cd ..;
117+ done;
118+
119+ mkdir -p $out/lib/bjlib;
120+ for pr_id in 423 424 425 426 427 428 429 430; do
121+ install -c -m 755 $pr_id/database/* $out/lib/bjlib;
122+ install -c -s -m 755 $pr_id/libs_bin${arch}/*.so.* $out/lib;
123+ done;
124+
125+ pushd $out/lib;
126+ for so_file in *.so.*; do
127+ ln -s $so_file ''${so_file/.so.*/}.so;
128+ patchelf --set-rpath $out/lib $so_file;
129+ done;
130+ popd;
131+ '';
132+
133+ /* the tarball includes some pre-built shared libraries. we run
134+ 'patchelf --set-rpath' on them just a few lines above, so that
135+ they can find each other. but that's not quite enough. some of
136+ those libraries load each other in non-standard ways -- they
137+ don't list each other in the DT_NEEDED section. so, if the
138+ standard 'patchelf --shrink-rpath' (from
139+ pkgs/development/tools/misc/patchelf/setup-hook.sh) is run on
140+ them, it undoes the --set-rpath. this prevents that. */
141+ dontPatchELF = true;
142+
143+ meta = with lib; {
144+ description = "Canon InkJet printer drivers for the MG2400 MG2500 MG3500 MG5500 MG6400 MG6500 MG7100 and P200 series.";
145+ homepage = https://www.canon-europe.com/support/consumer_products/products/fax__multifunctionals/inkjet/pixma_mg_series/pixma_mg5550.aspx?type=drivers&driverdetailid=tcm:13-1094072;
146+ license = licenses.unfree;
147+ platforms = platforms.linux;
148+ maintainers = with maintainers; [ chpatrick ];
149+ };
150+}