cups: fix configure flags

This commit is contained in:
Orivej Desh 2017-12-04 17:52:29 +00:00
parent e5715d9464
commit bf0d121aed

View File

@ -1,5 +1,5 @@
{ stdenv, fetchurl, fetchpatch, pkgconfig, zlib, libjpeg, libpng, libtiff, pam
, dbus, systemd, acl, gmp, darwin
{ stdenv, fetchurl, fetchpatch, pkgconfig, removeReferencesTo
, zlib, libjpeg, libpng, libtiff, pam, dbus, systemd, acl, gmp, darwin
, libusb ? null, gnutls ? null, avahi ? null, libpaper ? null
}:
@ -27,7 +27,7 @@ stdenv.mkDerivation rec {
})
];
nativeBuildInputs = [ pkgconfig ];
nativeBuildInputs = [ pkgconfig removeReferencesTo ];
buildInputs = [ zlib libjpeg libpng libtiff libusb gnutls libpaper ]
++ optionals stdenv.isLinux [ avahi pam dbus systemd acl ]
@ -38,17 +38,9 @@ stdenv.mkDerivation rec {
propagatedBuildInputs = [ gmp ];
configureFlags = [
# Put just lib/* and locale into $lib; this didn't work directly.
# lib/cups is moved back to $out in postInstall.
# Beware: some parts of cups probably don't fully respect these.
"--prefix=$(lib)"
"--datadir=$(out)/share"
"--localedir=$(lib)/share/locale"
"--localstatedir=/var"
"--sysconfdir=/etc"
"--with-rundir=/run"
"--with-systemd=\${out}/lib/systemd/system"
"--enable-raw-printing"
"--enable-threads"
] ++ optionals stdenv.isLinux [
@ -58,10 +50,24 @@ stdenv.mkDerivation rec {
++ optional (gnutls != null) "--enable-ssl"
++ optional (avahi != null) "--enable-avahi"
++ optional (libpaper != null) "--enable-libpaper"
++ optionals stdenv.isDarwin [
"--with-bundledir=$out"
"--disable-launchd"
];
++ optional stdenv.isDarwin "--disable-launchd";
preConfigure = ''
configureFlagsArray+=(
# Put just lib/* and locale into $lib; this didn't work directly.
# lib/cups is moved back to $out in postInstall.
# Beware: some parts of cups probably don't fully respect these.
"--prefix=$lib"
"--datadir=$out/share"
"--localedir=$lib/share/locale"
"--with-systemd=$out/lib/systemd/system"
${optionalString stdenv.isDarwin ''
"--with-bundledir=$out"
''}
)
'';
installFlags =
[ # Don't try to write in /var at build time.
@ -84,21 +90,26 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
postInstall = ''
moveToOutput lib/cups "$out"
libexec=${if stdenv.isDarwin then "libexec/cups" else "lib/cups"}
moveToOutput $libexec "$out"
# $lib contains references to $out/share/cups.
# CUPS is working without them, so they are not vital.
find "$lib" -type f -exec grep -q "$out" {} \; \
-printf "removing references from %p\n" \
-exec remove-references-to -t "$out" {} +
# Delete obsolete stuff that conflicts with cups-filters.
rm -rf $out/share/cups/banners $out/share/cups/data/testprint
# Some outputs in cups-config were unexpanded and some even wrong.
moveToOutput bin/cups-config "$dev"
sed -e "/^cups_serverbin=/s|\$(lib)|$out|" \
-e "s|\$(out)|$out|" \
-e "s|\$(lib)|$lib|" \
sed -e "/^cups_serverbin=/s|$lib|$out|" \
-i "$dev/bin/cups-config"
# Rename systemd files provided by CUPS
for f in "$out"/lib/systemd/system/*; do
substituteInPlace "$f" \
--replace "$lib/$libexec" "$out/$libexec" \
--replace "org.cups.cupsd" "cups" \
--replace "org.cups." ""