about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/hylafaxplus
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/hylafaxplus')
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/config.site20
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/default.nix127
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/libtiff-4.patch12
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/post-install-check.sh7
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/post-install.sh24
-rw-r--r--nixpkgs/pkgs/servers/hylafaxplus/post-patch.sh18
6 files changed, 208 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/config.site b/nixpkgs/pkgs/servers/hylafaxplus/config.site
new file mode 100644
index 000000000000..7c8014449216
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/config.site
@@ -0,0 +1,20 @@
+@config_maxgid@
+DIR_BIN="@out_@/bin"
+DIR_FONTMAP="@out_@/share/ghostscript/@ghostscript_version@"
+DIR_LIB="@out_@/lib"
+DIR_LIBDATA="@out_@/spool/etc"
+DIR_LIBEXEC="@out_@/spool/bin"
+DIR_LOCKS=/var/lock
+DIR_MAN="@out_@/share/man"
+DIR_SBIN="@out_@/spool/bin"
+DIR_SPOOL="@out_@/spool"
+FONTMAP="@ghostscript@/share/ghostscript/@ghostscript_version@"
+PATH_AFM="@ghostscript@/share/ghostscript/fonts"
+PATH_DPSRIP="@out_@/spool/bin/ps2fax"
+PATH_EGETTY="@coreutils@/bin/false"
+PATH_GSRIP="@ghostscript@/bin/gs"
+PATH_IMPRIP="@coreutils@/bin/false"
+PATH_SENDMAIL="@coreutils@/bin/false"
+PATH_VGETTY="@coreutils@/bin/false"
+SYSVINIT=no
+TIFFBIN="@libtiff@/bin"
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/default.nix b/nixpkgs/pkgs/servers/hylafaxplus/default.nix
new file mode 100644
index 000000000000..278f0b4c5260
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/default.nix
@@ -0,0 +1,127 @@
+{ stdenv
+, lib
+, fakeroot
+, fetchurl
+, libfaketime
+, substituteAll
+## runtime dependencies
+, coreutils
+, file
+, findutils
+, gawk
+, ghostscript
+, gnugrep
+, gnused
+, libtiff
+, libxcrypt
+, openssl
+, psmisc
+, sharutils
+, util-linux
+, zlib
+## optional packages (using `null` disables some functionality)
+, jbigkit ? null
+, lcms2 ? null  # for colored faxes
+, openldap ? null
+, pam ? null
+## system-dependent settings that have to be hardcoded
+, maxgid ? 65534  # null -> try to auto-detect (bad on linux)
+, maxuid ? 65534  # null -> hardcoded value 60002
+}:
+
+let
+
+  pname = "hylafaxplus";
+  version = "7.0.7";
+  hash = "sha512-nUvt+M0HBYN+MsGskuuDt1j0nI5Dk8MbfK/OVxP2FCDby3eiDg0eDtcpIxlOe4o0klko07zDRIb06zqh8ABuKA==";
+
+  configSite = substituteAll {
+    name = "${pname}-config.site";
+    src = ./config.site;
+    config_maxgid = lib.optionalString (maxgid!=null) ''CONFIG_MAXGID=${builtins.toString maxgid}'';
+    ghostscript_version = ghostscript.version;
+    out_ = "@out@";  # "out" will be resolved in post-install.sh
+    inherit coreutils ghostscript libtiff;
+  };
+
+  postPatch = substituteAll {
+    name = "${pname}-post-patch.sh";
+    src = ./post-patch.sh;
+    inherit configSite;
+    maxuid = lib.optionalString (maxuid!=null) (builtins.toString maxuid);
+    faxcover_binpath = lib.makeBinPath
+      [stdenv.shellPackage coreutils];
+    faxsetup_binpath = lib.makeBinPath
+      [stdenv.shellPackage coreutils findutils gnused gnugrep gawk];
+  };
+
+  postInstall = substituteAll {
+    name = "${pname}-post-install.sh";
+    src = ./post-install.sh;
+    inherit fakeroot libfaketime;
+  };
+
+in
+
+stdenv.mkDerivation {
+  inherit pname version;
+  src = fetchurl {
+    url = "mirror://sourceforge/hylafax/hylafax-${version}.tar.gz";
+    inherit hash;
+  };
+  patches = [
+    # adjust configure check to work with libtiff > 4.1
+    ./libtiff-4.patch
+  ];
+  # Note that `configure` (and maybe `faxsetup`) are looking
+  # for a couple of standard binaries in the `PATH` and
+  # hardcode their absolute paths in the new package.
+  buildInputs = [
+    file  # for `file` command
+    ghostscript
+    libtiff
+    libxcrypt
+    openssl
+    psmisc  # for `fuser` command
+    sharutils  # for `uuencode` command
+    util-linux  # for `agetty` command
+    zlib
+    jbigkit  # optional
+    lcms2  # optional
+    openldap  # optional
+    pam  # optional
+  ];
+  # Disable parallel build, errors:
+  #  *** No rule to make target '../util/libfaxutil.so.7.0.4', needed by 'faxmsg'.  Stop.
+  enableParallelBuilding = false;
+
+  postPatch = ". ${postPatch}";
+  dontAddPrefix = true;
+  postInstall = ". ${postInstall}";
+  postInstallCheck = ". ${./post-install-check.sh}";
+  meta = {
+    changelog = "https://hylafax.sourceforge.io/news/${version}.php";
+    description = "enterprise-class system for sending and receiving facsimiles";
+    downloadPage = "https://hylafax.sourceforge.io/download.php";
+    homepage = "https://hylafax.sourceforge.io";
+    license = lib.licenses.bsd3;
+    maintainers = [ lib.maintainers.yarny ];
+    platforms = lib.platforms.linux;
+    longDescription = ''
+      HylaFAX is a scalable and time-proven solution
+      for sending and receiving facsimiles via modem(s).
+      It is based on a client-server architecture,
+      loosely comparable to CUPS:
+      A client connects to a server to issue outbound jobs,
+      the server then chooses a modem to
+      connect to the receiving fax machine.
+      The server notifies users about their
+      outbound jobs as well as about inbound jobs.
+      HylaFAX+ is a fork of HylaFAX that -- in general --
+      contains a superset of the features of
+      HylaFAX and produces releases more often.
+      This package contains the client
+      and the server parts of HylaFAX+.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/libtiff-4.patch b/nixpkgs/pkgs/servers/hylafaxplus/libtiff-4.patch
new file mode 100644
index 000000000000..e00d94b5a979
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/libtiff-4.patch
@@ -0,0 +1,12 @@
+https://bugs.gentoo.org/706154
+--- a/configure
++++ b/configure
+@@ -2583,7 +2583,7 @@ EOF
+ 				echo '#define TIFFSTRIPBYTECOUNTS uint32_t'
+ 				echo '#define TIFFVERSION TIFF_VERSION'
+ 				echo '#define TIFFHEADER TIFFHeader';;
+-		4.[012345])	tiff_runlen_t="uint32_t"
++		4.[0-9])	tiff_runlen_t="uint32_t"
+ 				tiff_offset_t="uint64_t"
+ 				echo '#define TIFFSTRIPBYTECOUNTS uint64_t'
+ 				echo '#define TIFFVERSION TIFF_VERSION_CLASSIC'
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/post-install-check.sh b/nixpkgs/pkgs/servers/hylafaxplus/post-install-check.sh
new file mode 100644
index 000000000000..2850738edccc
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/post-install-check.sh
@@ -0,0 +1,7 @@
+# check if the package contains all the files needed
+for x in faxq faxquit hfaxd faxcron faxqclean faxgetty
+do
+  test -x "$out/spool/bin/$x"
+done
+test -d "$out/spool/config"
+test -f "$out/spool/etc/setup.cache"
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/post-install.sh b/nixpkgs/pkgs/servers/hylafaxplus/post-install.sh
new file mode 100644
index 000000000000..ddc7c3f85eda
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/post-install.sh
@@ -0,0 +1,24 @@
+# Parts of the `install` make target don't
+# dare to set file modes (or owners), but put the
+# needed commands in a new file called `root.sh`.
+# We execute the `chmod` commands of
+# this script to set execute bits.
+sed '/chown/d;/chgrp/d' --in-place root.sh
+. root.sh
+
+# We run `faxsetup` to prepare some config files
+# that the admin would have to create otherwise.
+# Since `faxsetup` is quite picky about its environment,
+# we have to prepare some dummy files.
+# `faxsetup` stores today's date in the output files,
+# so we employ faketime to simulate a deterministic date.
+echo "uucp:x:0" >> "$TMPDIR/passwd.dummy"  # dummy uucp user
+touch "$out/spool/etc/config.dummy"  # dummy modem config
+mkdir "$TMPDIR/lock.dummy"  # dummy lock dir
+"@libfaketime@/bin/faketime" -f "$(date --utc --date=@$SOURCE_DATE_EPOCH '+%F %T')" \
+  "@fakeroot@/bin/fakeroot" -- \
+  "$out/spool/bin/faxsetup" -with-DIR_LOCKS="$TMPDIR/lock.dummy" -with-PASSWD="$TMPDIR/passwd.dummy"
+rm "$out/spool/etc/config.dummy"
+
+# Ensure all binaries are reachable within the spooling area.
+ln --symbolic --target-directory="$out/spool/bin/" "$out/bin/"*
diff --git a/nixpkgs/pkgs/servers/hylafaxplus/post-patch.sh b/nixpkgs/pkgs/servers/hylafaxplus/post-patch.sh
new file mode 100644
index 000000000000..43ee91d2f62c
--- /dev/null
+++ b/nixpkgs/pkgs/servers/hylafaxplus/post-patch.sh
@@ -0,0 +1,18 @@
+# Replace strange default value for the nobody account.
+if test -n "@maxuid@"
+then
+  for f in util/faxadduser.c hfaxd/manifest.h
+  do
+    substituteInPlace "$f" --replace 60002 "@maxuid@"
+  done
+fi
+
+# Replace hardcoded `PATH` variables with proper paths.
+# Note: `findutils` is needed for `faxcron`.
+substituteInPlace faxcover/edit-faxcover.sh.in \
+  --replace 'PATH=/bin' 'PATH="@faxcover_binpath@"'
+substituteInPlace etc/faxsetup.sh.in \
+  --replace 'PATH=/bin' 'PATH="@faxsetup_binpath@"'
+
+# Create `config.site`
+substitute "@configSite@" config.site --subst-var out