canon-cups-ufr2: 3.70 -> 5.40 (#155685)

This commit is contained in:
dmayle 2022-01-20 08:55:47 -08:00 committed by GitHub
parent 8bfa76f8a3
commit b4797eaffc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 106 additions and 251 deletions

View file

@ -4,9 +4,15 @@
, unzip
, autoconf
, automake
, libtool
, libtool_1_5
, makeWrapper
, cups
, jbigkit
, glib
, gtk3
, pkg-config
, gnome2
, libxml2
, ghostscript
, pkgsi686Linux
, zlib
@ -15,16 +21,14 @@
let
i686_NIX_GCC = pkgsi686Linux.callPackage ({ gcc }: gcc) { };
i686_libxml2 = pkgsi686Linux.callPackage ({ libxml2 }: libxml2) { };
commonVer = "4.10";
version = "3.70";
dl = "4/0100010264/01";
version = "5.40";
dl = "6/0100009236/10";
versionNoDots = builtins.replaceStrings [ "." ] [ "" ] version;
src_canon = fetchurl {
url = "http://gdlp01.c-wss.com/gds/${dl}/linux-UFRII-drv-v${versionNoDots}-uken-07.tar.gz";
sha256 = "01nxpg3h1c64p5skxv904fg5c4sblmif486vkij2v62wwn6l65pz";
url = "http://gdlp01.c-wss.com/gds/${dl}/linux-UFRII-drv-v${versionNoDots}-usen-20.tar.gz";
sha256 = "sha256:069z6ijmql62mcdyxnzc9mf0dxa6z1107cd0ab4i1adk8kr3d75k";
};
in
@ -36,190 +40,122 @@ stdenv.mkDerivation {
src = src_canon;
postUnpack = ''
(cd $sourceRoot; tar -xzf Sources/cndrvcups-common-${commonVer}-1.tar.gz)
(cd $sourceRoot; tar -xzf Sources/cndrvcups-lb-${version}-1.tar.gz)
(cd $sourceRoot; tar -xzf Sources/cnrdrvcups-lb-${version}-1.tar.gz)
(cd $sourceRoot; sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-common-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-common-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@_bindir=/usr/bin@_libdir=$out/bin@" cnrdrvcups-common-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@etc/cngplp@$out/etc/cngplp@" cnrdrvcups-common-${version}/cngplp/Makefile.am)
(cd $sourceRoot; sed -ie "s@usr/share/cngplp@$out/usr/share/cngplp@" cnrdrvcups-common-${version}/cngplp/src/Makefile.am)
(cd $sourceRoot; patchShebangs cnrdrvcups-common-${version})
(cd $sourceRoot; sed -ie "s@_prefix=/usr@_prefix=$out@" cnrdrvcups-lb-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@_libdir=/usr/lib@_libdir=$out/lib@" cnrdrvcups-lb-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@_bindir=/usr/bin@_libdir=$out/bin@" cnrdrvcups-lb-${version}/allgen.sh)
(cd $sourceRoot; sed -ie '/^cd \.\.\/cngplp/,/^cd files/{/^cd files/!{d}}' cnrdrvcups-lb-${version}/allgen.sh)
(cd $sourceRoot; sed -ie "s@cd \.\./pdftocpca@cd pdftocpca@" cnrdrvcups-lb-${version}/allgen.sh)
(cd $sourceRoot; sed -i "/CNGPLPDIR/d" cnrdrvcups-lb-${version}/Makefile)
(cd $sourceRoot; patchShebangs cnrdrvcups-lb-${version})
'';
nativeBuildInputs = [ makeWrapper unzip autoconf automake libtool ];
nativeBuildInputs = [ makeWrapper unzip autoconf automake libtool_1_5 ];
buildInputs = [ cups zlib ];
buildInputs = [ cups zlib jbigkit glib gtk3 pkg-config gnome2.libglade libxml2 ];
installPhase = ''
runHook preInstall
##
## cndrvcups-common buildPhase
##
( cd cndrvcups-common-${commonVer}/buftool
autoreconf -fi
./autogen.sh --prefix=$out --enable-progpath=$out/bin --libdir=$out/lib --disable-shared --enable-static
make
)
( cd cndrvcups-common-${commonVer}/backend
./autogen.sh --prefix=$out --libdir=$out/lib
make
)
( cd cndrvcups-common-${commonVer}/c3plmod_ipc
make
)
##
## cndrvcups-common installPhase
##
( cd cndrvcups-common-${commonVer}/buftool
(
cd cnrdrvcups-common-${version}
./allgen.sh
make install
)
( cd cndrvcups-common-${commonVer}/backend
make install
)
( cd cndrvcups-common-${commonVer}/c3plmod_ipc
make install DESTDIR=$out/lib
)
( cd cndrvcups-common-${commonVer}/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.1.0.0 $out/lib32
cp libcanon_slim.so.1.0.0 $out/lib32
cp c3pldrv $out/bin
)
(cd cndrvcups-common-${commonVer}/Rule
(
cd cnrdrvcups-common-${version}/Rule
mkdir -p $out/share/usb
chmod 644 *.usb-quirks $out/share/usb
install -m 644 *.usb-quirks $out/share/usb
)
(cd cndrvcups-common-${commonVer}/data
chmod 644 *.ICC
mkdir -p $out/share/caepcm
cp *.ICC $out/share/caepcm
cp *.icc $out/share/caepcm
cp *.PRF $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.1.0.0 libColorGearC.so.1
ln -sf libColorGearC.so.1.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.1.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-${version}/buftool
./autogen.sh --prefix=$out --libdir=$out/lib --enable-progpath=$out/bin --enable-static
make
)
( cd cndrvcups-lb-${version}/pstoufr2cpca
./autogen.sh --prefix=$out --libdir=$out/lib
make
)
##
## cndrvcups-lb installPhase
##
( cd cndrvcups-lb-${version}/pstoufr2cpca
(
cd cnrdrvcups-lb-${version}
./allgen.sh
make install
)
( cd cndrvcups-lb-${version}/libs
chmod 755 *
(
cd lib
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
install -m 755 libs32/intel/libColorGearCufr2.so.2.0.0 $out/lib32
install -m 755 libs32/intel/libcaepcmufr2.so.1.0 $out/lib32
install -m 755 libs32/intel/libcaiocnpkbidir.so.1.0.0 $out/lib32
install -m 755 libs32/intel/libcaiousb.so.1.0.0 $out/lib32
install -m 755 libs32/intel/libcaiowrapufr2.so.1.0.0 $out/lib32
install -m 755 libs32/intel/libcanon_slimufr2.so.1.0.0 $out/lib32
install -m 755 libs32/intel/libcanonufr2r.so.1.0.0 $out/lib32
install -m 755 libs32/intel/libcnaccm.so.1.0 $out/lib32
install -m 755 libs32/intel/libcnlbcmr.so.1.0 $out/lib32
install -m 755 libs32/intel/libcnncapcmr.so.1.0 $out/lib32
install -m 755 libs32/intel/libufr2filterr.so.1.0.0 $out/lib32
cp cnpkmoduleufr2 $out/bin #maybe needs setuid 4755
cp cnpkbidi $out/bin
)
mkdir -p $out/lib
install -m 755 libs64/intel/libColorGearCufr2.so.2.0.0 $out/lib
install -m 755 libs64/intel/libcaepcmufr2.so.1.0 $out/lib
install -m 755 libs64/intel/libcaiocnpkbidir.so.1.0.0 $out/lib
install -m 755 libs64/intel/libcaiousb.so.1.0.0 $out/lib
install -m 755 libs64/intel/libcaiowrapufr2.so.1.0.0 $out/lib
install -m 755 libs64/intel/libcanon_slimufr2.so.1.0.0 $out/lib
install -m 755 libs64/intel/libcanonufr2r.so.1.0.0 $out/lib
install -m 755 libs64/intel/libcnaccm.so.1.0 $out/lib
install -m 755 libs64/intel/libcnlbcmr.so.1.0 $out/lib
install -m 755 libs64/intel/libcnncapcmr.so.1.0 $out/lib
install -m 755 libs64/intel/libufr2filterr.so.1.0.0 $out/lib
( 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
)
install -m 755 libs64/intel/cnpdfdrv $out/bin
install -m 755 libs64/intel/cnpkbidir $out/bin
install -m 755 libs64/intel/cnpkmoduleufr2r $out/bin
install -m 755 libs64/intel/cnrsdrvufr2 $out/bin
install -m 755 libs64/intel/cnsetuputil2 $out/bin
mkdir -p $out/share/cnpkbidir
install -m 644 libs64/intel/cnpkbidir_info* $out/share/cnpkbidir
( cd cndrvcups-lb-${version}
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
install -m 644 libs64/intel/ThLB* $out/share/ufr2filter
)
(
cd $out/lib32
ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so
ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so
ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so.1
ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so
ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so.1
ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so
ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so.1
)
(
cd $out/lib
ln -sf libcaepcmufr2.so.1.0 libcaepcmufr2.so
ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so
ln -sf libcaiowrapufr2.so.1.0.0 libcaiowrapufr2.so.1
ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so
ln -sf libcanon_slimufr2.so.1.0.0 libcanon_slimufr2.so.1
ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so
ln -sf libufr2filterr.so.1.0.0 libufr2filterr.so.1
)
# Perhaps patch the lib64 version as well???
patchelf --set-rpath "$(cat ${i686_NIX_GCC}/nix-support/orig-cc)/lib" $out/lib32/libColorGearCufr2.so.2.0.0
(
cd lib/data/ufr2
mkdir -p $out/share/caepcm
install -m 644 *.ICC $out/share/caepcm
install -m 644 *.icc $out/share/caepcm
install -m 644 *.PRF $out/share/caepcm
install -m 644 CnLB* $out/share/caepcm
)
mkdir -p $out/share/cups/model
install -c -m 644 cndrvcups-lb-${version}/ppd/CN*.ppd $out/share/cups/model/
patchelf --set-rpath "$out/lib32:${i686_libxml2.out}/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.out}/lib" $out/bin/cnpkbidi
install -m 644 cnrdrvcups-lb-${version}/ppd/*.ppd $out/share/cups/model/
makeWrapper "${ghostscript}/bin/gs" "$out/bin/gs" \
--prefix LD_LIBRARY_PATH ":" "$out/lib" \

View file

@ -1,81 +0,0 @@
/*
* 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);
}