From b87b4d1310d61c91ff6ab823ef25a9306f82ea94 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Fri, 19 Jul 2024 14:14:51 +0800 Subject: [PATCH] add install section in src/CMakeList.txt and module/Makefile --- ...rc-CMakeList.txt-and-module-Makefile.patch | 103 ++++++++++++++++++ sysmonitor-kmod.spec | 8 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch diff --git a/add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch b/add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch new file mode 100644 index 0000000..7d7f577 --- /dev/null +++ b/add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch @@ -0,0 +1,103 @@ +From 5f14b328ea78ea7b375c775d894dd987ce707fdb Mon Sep 17 00:00:00 2001 +From: wangxiaomeng +Date: Thu, 23 May 2024 14:57:12 +0800 +Subject: [PATCH] add install section in src/CMakeList.txt and module/Makefile + +--- + module/Makefile | 30 ++++++++++++++++++++++++------ + src/CMakeLists.txt | 27 +++++++++++++++++++++++++++ + 2 files changed, 51 insertions(+), 6 deletions(-) + +diff --git a/module/Makefile b/module/Makefile +index 8030152..0ca0f86 100644 +--- a/module/Makefile ++++ b/module/Makefile +@@ -3,19 +3,37 @@ + # Author: xuchunmei + # Create: 2018-12-15 + ++KERNELVER?=$(shell uname -r) ++ + obj-m += sysmonitor.o + sysmonitor-objs := sysmonitor_main.o signo_catch.o fdstat.o monitor_netdev.o +-KERNELDIR ?= /lib/modules/$(shell uname -r)/build ++KERNELDIR ?= /lib/modules/$(KERNELVER)/build + PWD := $(shell pwd) + EXTRA_CFLAGS += -Wall -Werror + +-modules: ++default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +-modules_install: +- $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install +- + clean: + $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) clean ++ rm -f *.ko *.o *.mod.o *.mod.c *.symvers *.order .sysmonitor* .mo* .Module* .signo* sysmonitor.mod .fdstat.* ++ ++install: ++ install -d -m 750 /lib/modules/sysmonitor ++ install -m 640 sysmonitor.ko /lib/modules/sysmonitor ++ lsmod | grep -qw sysmonitor && modprobe -r sysmonitor || true ++ if [ -e "/lib/modules/sysmonitor/sysmonitor.ko" ];then \ ++ /sbin/depmod -aeF /boot/System.map-$(KERNELVER) $(KERNELVER) > /dev/null;\ ++ insmod /lib/modules/sysmonitor/sysmonitor.ko 2>/dev/null 1>/dev/null;\ ++ if [ $$? -ne 0 ];then { echo "sysmonitor.ko modprobe is failed.";exit 0;} fi;\ ++ else\ ++ echo "The /lib/modules/sysmonitor/sysmonitor.ko file does not exist in the sysmonitor rpm package";\ ++ exit 0; \ ++ fi + +-.PHONY: modules modules_install clean ++uninstall: ++ if [ $(id -u) -ne 0 ]; then { echo "root permission is required to uninstall sysmonitor";exit 0;} fi ++ ps h -C sysmonitor -o pid && killall sysmonitor || true ++ lsmod | grep -qw sysmonitor && modprobe -r sysmonitor || true ++ rm -rf /lib/modules/sysmonitor ++ /sbin/depmod -aeF /boot/System.map-$(KERNELVER) $(KERNELVER) > /dev/null +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index e5af612..4943c8f 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -6,6 +6,12 @@ + project(sysmonitor) + + set(CMAKE_C_FLAGS "-Wall -Werror -D_FORTIFY_SOURCE=2 -O2 -fPIE -fstack-protector-strong -g") ++set(CMAKE_INSTALL_SYSCONFDIR "/etc") ++set(CMAKE_INSTALL_LIBEXECDIR "/usr/libexec") ++set(CMAKE_INSTALL_SYSLOGDIR "/etc/rsyslog.d") ++set(CMAKE_INSTALL_SBINDIR "/usr/sbin") ++set(CMAKE_INSTALL_BINDIR "/usr/bin") ++set(SYSTEMD_SERVICEDIR "/usr/lib/systemd/system/") + + if (VERSION) + add_compile_options(-D ${VERSION}) +@@ -18,3 +24,24 @@ endif(CUSTOM) + add_executable(sysmonitor common.c custom.c disk.c fsmonitor.c filemonitor.c process.c sys_resources.c sys_event.c sysmonitor.c zombie.c monitor_thread.c) + set_target_properties(sysmonitor PROPERTIES LINK_FLAGS "-Wl,-z,relro -Wl,-z,noexecstack -Wl,-z,now -Wtrampolines -pie") + target_link_libraries(sysmonitor boundscheck pthread) ++install(TARGETS sysmonitor DESTINATION ${CMAKE_INSTALL_BINDIR}) ++install(DIRECTORY ../conf/ DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysmonitor PATTERN "rsyslog.d " EXCLUDE PATTERN "clock_transition" EXCLUDE PATTERN "io_monitor" EXCLUDE PATTERN "logind_monitor" EXCLUDE PATTERN "sysmonitor" EXCLUDE PATTERN "io_monitor" EXCLUDE) ++install(FILES ../conf/rsyslog.d/sysmonitor.conf DESTINATION ${CMAKE_INSTALL_SYSLOGDIR}) ++install(FILES ../conf/logrotate.d/sysmonitor-logrotate DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/sysmonitor) ++install(FILES ../conf/clock_transition DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysmonitor.d) ++install(FILES ../conf/io_monitor DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysmonitor.d) ++install(FILES ../conf/logind_monitor DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysmonitor.d) ++install(FILES ../conf/sysmonitor DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysconfig) ++ ++install(DIRECTORY ../script/ DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/sysmonitor PATTERN "iomonitor_daemon" EXCLUDE) ++install(PROGRAMS ../script/iomonitor_daemon DESTINATION ${CMAKE_INSTALL_SBINDIR}) ++install(FILES ../conf/io_monitor DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/sysmonitor.d) ++install(FILES ../service/sysmonitor.service DESTINATION ${SYSTEMD_SERVICEDIR}) ++ ++add_custom_target(uninstall ++ COMMAND rm -rf /etc/sysmonitor /usr/libexec/sysmonitor /etc/rsyslog.d/sysmonitor.conf /etc/sysmonitor.d/ ++ COMMAND rm -rf /usr/lib/systemd/system/sysmonitor.service ++ COMMAND rm -rf /usr/sbin/iomonitor_daemon /usr/bin/sysmonitor ++ COMMENT "Uninstall sysmonitor" ++ VERBATIM ++) +-- +2.43.0 + diff --git a/sysmonitor-kmod.spec b/sysmonitor-kmod.spec index b157b64..f1620cb 100644 --- a/sysmonitor-kmod.spec +++ b/sysmonitor-kmod.spec @@ -7,7 +7,7 @@ %define kmod_name sysmonitor %define version 1.3.2 -%define releaseversion 1.5 +%define releaseversion 1.6 Summary: System Monitor Daemon Name: %{kmod_name}-kmod Version: %{version} @@ -38,6 +38,7 @@ Provides: sysmonitor Patch1: bugfix-fix-signal-monitor-err.patch Patch2: bugfix-fix-fd-path-failed-to-open.patch Patch3: update-support-loongarch-fix-compilation-errors.patch +Patch4: add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch %description System Monitor Daemon @@ -172,6 +173,11 @@ systemctl daemon-reload 2>/dev/null 1>/dev/null /usr/lib/systemd/system/multi-user.target.wants/sysmonitor.service %changelog +* Thu May 23 2024 wangxiaomeng - 1.3.2-1.6 +- Type:bugfix +- CVE:NA +- DESC:add install section + * Mon Jun 03 2024 yueyuankun - 1.3.2-1.5 - Type:update - CVE:NA -- Gitee