From d0a3aea8fa04864d8c65a79fe5dd0adf353e05e9 Mon Sep 17 00:00:00 2001 From: Yingjie Wang Date: Thu, 6 Jun 2024 17:48:33 -0400 Subject: [PATCH] feat: add src_check and src_install, exit if src_check fails --- leaf | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/leaf b/leaf index 3049870..865db3a 100755 --- a/leaf +++ b/leaf @@ -41,7 +41,7 @@ main() { else local _item case $1 in - prepare|build|install|remove|pack) + prepare|build|install|force-install|remove|pack) leaf_check_permission for _item in "${@:2}"; do leaf_find_pkgbuild "${_item}" @@ -335,6 +335,16 @@ leaf_prepare_package() { leaf_build_package() { leaf_prepare_package src_build + + if ! src_check; then + if [ "${FORCE_INSTALL}" == "1" ]; then + echo -e "${RED_COLOR}* Tests failed, but is in force-install mode.${CLEAR_COLOR}" + else + leaf_error "Tests failed, please check. Aborting installation." + fi + fi + + src_install local _option for _option in $(echo ${!BUILD_OPTIONS[*]}); do if [[ x"${_option}" == x"strip" ]] && [[ x"${BUILD_OPTIONS[$_option]}" == x"1" ]]; then @@ -363,6 +373,11 @@ leaf_install_package() { echo -e "${GREEN_COLOR}* Package ${PKG_PREFIX}/${PKG_NAME} has been installed${CLEAR_COLOR}\n" } +leaf_force-install_package(){ + FORCE_INSTALL=1 + leaf_install_package +} + leaf_remove_package() { [ -n "$(grep "${PKG_PREFIX}/${PKG_NAME}" ${INSTALLED_PACKAGES})" ] || { leaf_error "Package ${PKG_PREFIX}/${PKG_NAME} is NOT installed"