atop: fix packaging .service files, add option to build with atopgpu
This commit is contained in:
parent
2703a7999a
commit
327dcea4cc
13
pkgs/os-specific/linux/atop/atop-pm.sh.patch
Normal file
13
pkgs/os-specific/linux/atop/atop-pm.sh.patch
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
--- a/atop-pm.sh
|
||||||
|
+++ b/atop-pm.sh
|
||||||
|
@@ -2,8 +2,8 @@
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
- pre) /usr/bin/systemctl stop atop
|
||||||
|
+ pre) @systemd@/bin/systemctl stop atop
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
- post) /usr/bin/systemctl start atop
|
||||||
|
+ post) @systemd@/bin/systemctl start atop
|
||||||
|
exit 0
|
||||||
|
;;
|
7
pkgs/os-specific/linux/atop/atop-rotate.service.patch
Normal file
7
pkgs/os-specific/linux/atop/atop-rotate.service.patch
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
--- a/atop-rotate.service
|
||||||
|
+++ b/atop-rotate.service
|
||||||
|
@@ -4,3 +4,3 @@
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
-ExecStart=/usr/bin/systemctl try-restart atop.service
|
||||||
|
+ExecStart=@systemd@/bin/systemctl try-restart atop.service
|
14
pkgs/os-specific/linux/atop/atop.service.patch
Normal file
14
pkgs/os-specific/linux/atop/atop.service.patch
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
--- a/atop.service
|
||||||
|
+++ b/atop.service
|
||||||
|
@@ -9,7 +9,8 @@
|
||||||
|
Environment=LOGPATH=/var/log/atop
|
||||||
|
-EnvironmentFile=/etc/default/atop
|
||||||
|
+EnvironmentFile=-/etc/default/atop
|
||||||
|
ExecStartPre=/bin/sh -c 'test -n "$LOGINTERVAL" -a "$LOGINTERVAL" -eq "$LOGINTERVAL"'
|
||||||
|
ExecStartPre=/bin/sh -c 'test -n "$LOGGENERATIONS" -a "$LOGGENERATIONS" -eq "$LOGGENERATIONS"'
|
||||||
|
-ExecStart=/bin/sh -c 'exec /usr/bin/atop ${LOGOPTS} -w "${LOGPATH}/atop_$(date +%%Y%%m%%d)" ${LOGINTERVAL}'
|
||||||
|
-ExecStartPost=/usr/bin/find "${LOGPATH}" -name "atop_*" -mtime +${LOGGENERATIONS} -exec rm -v {} \;
|
||||||
|
+ExecStartPre=/bin/sh -c 'mkdir -p "${LOGPATH}"'
|
||||||
|
+ExecStart=/bin/sh -c 'exec @out@/bin/atop ${LOGOPTS} -w "${LOGPATH}/atop_$(date +%%Y%%m%%d)" ${LOGINTERVAL}'
|
||||||
|
+ExecStartPost=@findutils@/bin/find "${LOGPATH}" -name "atop_*" -mtime +${LOGGENERATIONS} -exec rm -v {} \;
|
||||||
|
KillSignal=SIGUSR2
|
11
pkgs/os-specific/linux/atop/atopacct.service.patch
Normal file
11
pkgs/os-specific/linux/atop/atopacct.service.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--- a/atopacct.service
|
||||||
|
+++ b/atopacct.service
|
||||||
|
@@ -8,6 +8,6 @@
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
-PIDFile=/var/run/atopacctd.pid
|
||||||
|
-ExecStart=/usr/sbin/atopacctd
|
||||||
|
+PIDFile=/run/atopacctd.pid
|
||||||
|
+ExecStart=@out@/bin/atopacctd
|
||||||
|
|
||||||
|
[Install]
|
9
pkgs/os-specific/linux/atop/atopgpu.service.patch
Normal file
9
pkgs/os-specific/linux/atop/atopgpu.service.patch
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
--- a/atopgpu.service
|
||||||
|
+++ b/atopgpu.service
|
||||||
|
@@ -6,5 +6,5 @@
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
-ExecStart=/usr/sbin/atopgpud
|
||||||
|
+ExecStart=@out@/bin/atopgpud
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
@ -1,4 +1,14 @@
|
|||||||
{lib, stdenv, fetchurl, zlib, ncurses}:
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, fetchurl
|
||||||
|
, zlib
|
||||||
|
, ncurses
|
||||||
|
, findutils
|
||||||
|
, systemd
|
||||||
|
, python3
|
||||||
|
# makes the package unfree via pynvml
|
||||||
|
, withAtopgpu ? false
|
||||||
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "atop";
|
pname = "atop";
|
||||||
@ -9,31 +19,52 @@ stdenv.mkDerivation rec {
|
|||||||
sha256 = "nsLKOlcWkvfvqglfmaUQZDK8txzCLNbElZfvBIEFj3I=";
|
sha256 = "nsLKOlcWkvfvqglfmaUQZDK8txzCLNbElZfvBIEFj3I=";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [zlib ncurses];
|
nativeBuildInputs = if withAtopgpu then [ python3.pkgs.wrapPython ] else [ ];
|
||||||
|
buildInputs = [ zlib ncurses ] ++ (if withAtopgpu then [ python3 ] else [ ]);
|
||||||
|
pythonPath = if withAtopgpu then [ python3.pkgs.pynvml ] else [ ];
|
||||||
|
|
||||||
makeFlags = [
|
makeFlags = [
|
||||||
"SCRPATH=$out/etc/atop"
|
"DESTDIR=$(out)"
|
||||||
"LOGPATH=/var/log/atop"
|
"BINPATH=/bin"
|
||||||
"INIPATH=$out/etc/rc.d/init.d"
|
"SBINPATH=/bin"
|
||||||
"SYSDPATH=$out/lib/systemd/system"
|
"MAN1PATH=/share/man/man1"
|
||||||
"CRNPATH=$out/etc/cron.d"
|
"MAN5PATH=/share/man/man5"
|
||||||
"DEFPATH=$out/etc/default"
|
"MAN8PATH=/share/man/man8"
|
||||||
"ROTPATH=$out/etc/logrotate.d"
|
"SYSDPATH=/lib/systemd/system"
|
||||||
|
"PMPATHD=/lib/systemd/system-sleep"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./atop-pm.sh.patch
|
||||||
|
./atop-rotate.service.patch
|
||||||
|
./atop.service.patch
|
||||||
|
./atopacct.service.patch
|
||||||
|
] ++ (if withAtopgpu then [ ./atopgpu.service.patch ] else [ ]);
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
sed -e "s@/usr/@$out/@g" -i $(find . -type f )
|
for f in *.{sh,service}; do
|
||||||
sed -e "/mkdir.*LOGPATH/s@mkdir@echo missing dir @" -i Makefile
|
findutils=${findutils} systemd=${systemd} substituteAllInPlace "$f"
|
||||||
sed -e "/touch.*LOGPATH/s@touch@echo should have created @" -i Makefile
|
done
|
||||||
|
|
||||||
sed -e 's/chown/true/g' -i Makefile
|
sed -e 's/chown/true/g' -i Makefile
|
||||||
sed -e '/chkconfig/d' -i Makefile
|
|
||||||
sed -e 's/chmod 04711/chmod 0711/g' -i Makefile
|
sed -e 's/chmod 04711/chmod 0711/g' -i Makefile
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installTargets = [ "systemdinstall" ];
|
installTargets = [ "systemdinstall" ];
|
||||||
preInstall = ''
|
preInstall = ''
|
||||||
mkdir -p "$out"/{bin,sbin}
|
mkdir -p $out/bin
|
||||||
'';
|
'';
|
||||||
|
postInstall = ''
|
||||||
|
# remove extra files we don't need
|
||||||
|
rm -rf $out/{var,etc}
|
||||||
|
rm -rf $out/bin/atop{sar,}-${version}
|
||||||
|
'' + (if withAtopgpu then ''
|
||||||
|
wrapPythonPrograms
|
||||||
|
'' else ''
|
||||||
|
rm $out/lib/systemd/system/atopgpu.service
|
||||||
|
rm $out/bin/atopgpud
|
||||||
|
rm $out/share/man/man8/atopgpud.8
|
||||||
|
'');
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
platforms = platforms.linux;
|
platforms = platforms.linux;
|
||||||
|
14
pkgs/os-specific/linux/netatop/netatop.service.patch
Normal file
14
pkgs/os-specific/linux/netatop/netatop.service.patch
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
--- a/netatop.service
|
||||||
|
+++ b/netatop.service
|
||||||
|
@@ -7,8 +7,8 @@
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
-ExecStartPre=/sbin/modprobe netatop
|
||||||
|
-ExecStart=/usr/sbin/netatopd
|
||||||
|
-ExecStopPost=/sbin/rmmod netatop
|
||||||
|
-PIDFile=/var/run/netatop.pid
|
||||||
|
+ExecStartPre=@kmod@/bin/modprobe netatop
|
||||||
|
+ExecStart=@out@/bin/netatopd
|
||||||
|
+ExecStopPost=@kmod@/bin/rmmod netatop
|
||||||
|
+PIDFile=/run/netatop.pid
|
||||||
|
RemainAfterExit=yes
|
Loading…
x
Reference in New Issue
Block a user