Projects
home:Eustace:branches:Eulaceura:Factory
sysmonitor
_service:obs_scm:add-install-section-in-src-CMa...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:add-install-section-in-src-CMakeList.txt-and-module-Makefile.patch of Package sysmonitor
From 5f14b328ea78ea7b375c775d894dd987ce707fdb Mon Sep 17 00:00:00 2001 From: wangxiaomeng <wangxiaomeng@kylinos.cn> 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
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2