Merge pull request #336670 from museoa/cronie

Cronie: a new cron
This commit is contained in:
Thiago Kenji Okada 2024-08-23 20:13:17 +01:00 committed by GitHub
commit 48614c893c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 158 additions and 50 deletions

View File

@ -0,0 +1,41 @@
{
lib,
autoreconfHook,
fetchFromGitHub,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "cronie";
version = "1.7.2";
src = fetchFromGitHub {
owner = "cronie-crond";
repo = "cronie";
rev = "cronie-${finalAttrs.version}";
hash = "sha256-WrzdpE9t7vWpc8QFoFs+S/HgHwsidRNmfcHp7ltSWQw=";
};
nativeBuildInputs = [ autoreconfHook ];
outputs = [
"out"
"man"
];
strictDeps = true;
meta = {
homepage = "https://github.com/cronie-crond/cronie";
description = "Cron replacement, based on vixie-cron";
changelog = "https://github.com/cronie-crond/cronie/blob/master/ChangeLog";
license = with lib.licenses; [
gpl2Plus
isc
lgpl21Plus
];
mainProgram = "crond";
maintainers = with lib.maintainers; [ AndersonTorres ];
platforms = lib.platforms.all;
};
})

View File

@ -0,0 +1,45 @@
diff -Naur cron-old/externs.h cron-new/externs.h
--- cron-old/externs.h 2024-08-23 09:04:25.525752797 -0300
+++ cron-new/externs.h 2024-08-23 10:12:05.304311078 -0300
@@ -121,3 +121,14 @@
#ifndef WCOREDUMP
# define WCOREDUMP(st) (((st) & 0200) != 0)
#endif
+
+/* Nixpkgs-specific patch begin */
+
+/*
+ Implicit saved UIDs do not work here due to way NixOS uses setuid wrappers
+ See https://github.com/NixOS/nixpkgs/issues/16518
+ */
+
+#undef HAVE_SAVED_UIDS
+
+/* Nixpkgs-specific patch end */
diff -Naur cron-old/pathnames.h cron-new/pathnames.h
--- cron-old/pathnames.h 2024-08-23 09:04:25.524752791 -0300
+++ cron-new/pathnames.h 2024-08-23 10:11:33.186749198 -0300
@@ -105,4 +105,23 @@
# define _PATH_DEVNULL "/dev/null"
#endif
+/* Nixpkgs-specific patch begin */
+
+/*
+ We want to ignore the $glibc/include/paths.h definition of sendmail path.
+ Further, set a usable default PATH
+ See https://github.com/NixOS/nixpkgs/issues/16518
+ */
+
+#undef _PATH_SENDMAIL
+#define _PATH_SENDMAIL "@sendmailPath@"
+
+#undef _PATH_VI
+#define _PATH_VI "@VIPATH@"
+
+#undef _PATH_DEFPATH
+#define _PATH_DEFPATH "@DEFPATH@"
+
+/* Nixpkgs-specific patch end */
+
#endif /* _PATHNAMES_H_ */

View File

@ -0,0 +1,71 @@
{
lib,
fetchurl,
stdenv,
substituteAll,
vim,
sendmailPath ? "/usr/sbin/sendmail",
}:
stdenv.mkDerivation (finalAttrs: {
pname = "cron";
version = "4.1";
src = fetchurl {
url = "ftp://ftp.isc.org/isc/cron/cron_${finalAttrs.version}.shar";
hash = "sha256-xEWDd1b7mI8slduNxV15N9FLygzfopLegTIsolVuw5o=";
};
patches = [
(substituteAll {
src = ./0000-nixpkgs-specific.diff;
inherit sendmailPath;
VIPATH = lib.getExe' vim "vim";
DEFPATH = lib.concatStringsSep ":" [
"/run/wrappers/bin"
"/nix/var/nix/profiles/default/bin"
"/run/current-system/sw/bin"
"/usr/bin"
"/bin"
];
})
];
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
"DESTROOT=$(out)"
];
hardeningEnable = [ "pie" ];
unpackCmd = ''
mkdir cron
pushd cron
sh $curSrc
popd
'';
# do not set sticky bit in /nix/store
# further, do not strip during install since it breaks on cross-compilation
# and we will do this ourselves as needed
postPatch = ''
substituteInPlace Makefile \
--replace ' -o root' ' ' \
--replace 111 755 \
--replace 4755 0755 \
--replace ' -s cron' ' cron'
'';
preInstall = ''
mkdir -p $out/{{,s}bin,share/man/man{1,5,8}}
'';
meta = {
homepage = "https://ftp.isc.org/isc/cron/";
description = "Daemon for running commands at specific times";
license = lib.licenses.bsd0;
mainProgram = "cron";
maintainers = with lib.maintainers; [ AndersonTorres ];
platforms = lib.platforms.unix;
};
})

View File

@ -1,49 +0,0 @@
{lib, stdenv, fetchurl, vim, sendmailPath ? "/usr/sbin/sendmail"}:
stdenv.mkDerivation rec {
pname = "cron";
version = "4.1";
src = fetchurl {
url = "ftp://ftp.isc.org/isc/cron/cron_${version}.shar";
sha256 = "16n3dras4b1jh7g958nz1k54pl9pg5fwb3fvjln8z67varvq6if4";
};
unpackCmd = "(mkdir cron && cd cron && sh $curSrc)";
hardeningEnable = [ "pie" ];
preBuild = ''
# do not set sticky bit in /nix/store
substituteInPlace Makefile --replace ' -o root' ' ' --replace 111 755 --replace 4755 0755
# do not strip during install, broken on cross and we'll do ourselves as needed
substituteInPlace Makefile --replace ' -s cron' ' cron'
makeFlags="DESTROOT=$out CC=$CC"
# We want to ignore the $glibc/include/paths.h definition of
# sendmail path.
# Also set a usable default PATH (#16518).
cat >> pathnames.h <<__EOT__
#undef _PATH_SENDMAIL
#define _PATH_SENDMAIL "${sendmailPath}"
#undef _PATH_VI
#define _PATH_VI "${vim}/bin/vim"
#undef _PATH_DEFPATH
#define _PATH_DEFPATH "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin"
__EOT__
# Implicit saved uids do not work here due to way NixOS uses setuid wrappers
# (#16518).
echo "#undef HAVE_SAVED_UIDS" >> externs.h
'';
preInstall = "mkdir -p $out/bin $out/sbin $out/share/man/man1 $out/share/man/man5 $out/share/man/man8";
meta = with lib; {
description = "Daemon for running commands at specific times (Vixie Cron)";
license = licenses.bsd0;
platforms = with platforms; linux ++ darwin;
};
}

View File

@ -6897,7 +6897,7 @@ with pkgs;
cromfs = callPackage ../tools/archivers/cromfs { };
cron = callPackage ../tools/system/cron { };
cron = isc-cron;
ctlptl = callPackage ../development/tools/ctlptl { };