From 462fa8bbaf9c6db560c7803e9dfa7dd985b43c2e Mon Sep 17 00:00:00 2001 From: Pavel Goran Date: Sat, 29 Feb 2020 10:19:01 +0000 Subject: [PATCH 1/2] pykms: replace logging patch The logging "sed-patch" that was introduced for version 20190611 worked poorly: it was too intrusive (breaking the --logfile option), and it didn't prevent using in-store file for logging by default. The new logging patch (an actual "diff-patch") is less intrusive: it just changes the default log file's location to be the current directory instead of the executable's directory. --- pkgs/tools/networking/pykms/default.nix | 8 +++----- .../log-to-current-directory-by-default.patch | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 pkgs/tools/networking/pykms/log-to-current-directory-by-default.patch diff --git a/pkgs/tools/networking/pykms/default.nix b/pkgs/tools/networking/pykms/default.nix index e1a13b73120e..345999c00bcd 100644 --- a/pkgs/tools/networking/pykms/default.nix +++ b/pkgs/tools/networking/pykms/default.nix @@ -44,16 +44,14 @@ in buildPythonApplication rec { propagatedBuildInputs = [ systemd pytz tzlocal ]; + # Fix https://github.com/SystemRage/py-kms/issues/64 : + patches = [ ./log-to-current-directory-by-default.patch ]; + postPatch = '' siteDir=$out/${python3.sitePackages} substituteInPlace pykms_DB2Dict.py \ --replace "'KmsDataBase.xml'" "'$siteDir/KmsDataBase.xml'" - - # we are logging to journal - sed -i pykms_Misc.py \ - -e '6ifrom systemd import journal' \ - -e 's/log_obj.addHandler(log_handler)/log_obj.addHandler(journal.JournalHandler())/' ''; format = "other"; diff --git a/pkgs/tools/networking/pykms/log-to-current-directory-by-default.patch b/pkgs/tools/networking/pykms/log-to-current-directory-by-default.patch new file mode 100644 index 000000000000..7c8c65b63a2a --- /dev/null +++ b/pkgs/tools/networking/pykms/log-to-current-directory-by-default.patch @@ -0,0 +1,20 @@ +# By default, create log files in current directory, instead of the script directory. +--- ../original/py-kms/pykms_Client.py ++++ py-kms/pykms_Client.py +@@ -48,5 +48,5 @@ + 'choi' : ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "MINI"]}, + 'lfile' : {'help' : 'Use this option to set an output log file. The default is \"pykms_logclient.log\" or type \"STDOUT\" to view log info on stdout.', +- 'def' : os.path.dirname(os.path.abspath( __file__ )) + "/pykms_logclient.log", 'des' : "logfile"}, ++ 'def' : "pykms_logclient.log", 'des' : "logfile"}, + 'lsize' : {'help' : 'Use this flag to set a maximum size (in MB) to the output log file. Desactivated by default.', 'def' : 0, 'des': "logsize"}, + } +--- ../original/py-kms/pykms_Server.py ++++ py-kms/pykms_Server.py +@@ -85,5 +85,5 @@ + 'choi' : ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "MINI"]}, + 'lfile' : {'help' : 'Use this option to set or not an output log file. The default is \"pykms_logserver.log\" or type \"STDOUT\" to view log info on stdout.', +- 'def' : os.path.dirname(os.path.abspath( __file__ )) + "/pykms_logserver.log", 'des' : "logfile"}, ++ 'def' : "pykms_logserver.log", 'des' : "logfile"}, + 'lsize' : {'help' : 'Use this flag to set a maximum size (in MB) to the output log file. Desactivated by default.', 'def' : 0, 'des': "logsize"}, + } + ''); From c678d68cdb98cfbaca4abb9b53991ee86ebe89a7 Mon Sep 17 00:00:00 2001 From: Pavel Goran Date: Sat, 29 Feb 2020 11:14:17 +0000 Subject: [PATCH 2/2] nixos/pykms: add SyslogIdentifier --- nixos/modules/services/misc/pykms.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/misc/pykms.nix b/nixos/modules/services/misc/pykms.nix index 25aa27ae7673..d6aeae48ccb6 100644 --- a/nixos/modules/services/misc/pykms.nix +++ b/nixos/modules/services/misc/pykms.nix @@ -82,6 +82,7 @@ in { ]); ProtectHome = "tmpfs"; WorkingDirectory = libDir; + SyslogIdentifier = "pykms"; Restart = "on-failure"; MemoryLimit = cfg.memoryLimit; };