Initial commit
This commit is contained in:
47
cmake/DnfInstall.cmake
Normal file
47
cmake/DnfInstall.cmake
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# dnf/yum 系统包安装通用模块
|
||||
#
|
||||
|
||||
# 函数:DNF 安装系统包
|
||||
# 参数:PKG_NAME - 包名
|
||||
function(DnfInstall PKG_NAME)
|
||||
CHECK_ROOT()
|
||||
DEPLOY_MSG ("Start install system package: ${PKG_NAME}")
|
||||
|
||||
if(ENABLE_DEBUG)
|
||||
execute_process(
|
||||
COMMAND dnf install -y ${PKG_NAME}
|
||||
RESULT_VARIABLE DNF_RET
|
||||
OUTPUT_VARIABLE DNF_OUT
|
||||
ERROR_VARIABLE DNF_ERR
|
||||
)
|
||||
message(STATUS "[Debug] Output: ${DNF_OUT}")
|
||||
message(STATUS "[Debug] Errors: ${DNF_ERR}")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND dnf install -y ${PKG_NAME}
|
||||
RESULT_VARIABLE DNF_RET
|
||||
OUTPUT_VARIABLE DNF_OUT
|
||||
ERROR_VARIABLE DNF_ERR
|
||||
)
|
||||
set(DNF_ERR "")
|
||||
endif()
|
||||
|
||||
if(NOT DNF_RET EQUAL 0)
|
||||
message(FATAL_ERROR "Install ${PKG_NAME} failed: ${DNF_ERR}")
|
||||
endif()
|
||||
DEPLOY_MSG ("Install ${PKG_NAME} success")
|
||||
endfunction()
|
||||
|
||||
# 函数:DNF 卸载系统包
|
||||
function(DnfRemove PKG_NAME)
|
||||
CHECK_ROOT()
|
||||
DEPLOY_MSG ("Start remove system package: ${PKG_NAME}")
|
||||
execute_process(
|
||||
COMMAND dnf remove -y ${PKG_NAME}
|
||||
RESULT_VARIABLE DNF_RET
|
||||
)
|
||||
if(NOT DNF_RET EQUAL 0)
|
||||
message(WARNING "Remove ${PKG_NAME} failed")
|
||||
endif()
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user