From 40ff865489fbbd4ea5688b4cfa4d0a8b0ed5aaca Mon Sep 17 00:00:00 2001 From: Username404 Date: Wed, 24 Mar 2021 13:18:17 +0100 Subject: [PATCH] Use the /usr directory instead of /opt. --- CMakeLists.txt | 9 +++++---- scripts/TestYbcon | 2 +- scripts/postinst | 3 +-- scripts/ybcon | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0731e86..857314f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,12 +78,13 @@ target_compile_definitions(ybcon PRIVATE YBCON_VERSION="${CODENAME} ${PROJECT_VE set(PNAME ${PROJECT_NAME}-${CODENAME}-${TIME}) if (UNIX AND NOT MINGW) include(GNUInstallDirs) - set(CMAKE_INSTALL_PREFIX "/opt") + set(CMAKE_INSTALL_PREFIX "/usr") set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") set(CPACK_PACKAGE_FILE_NAME "${PNAME}_lpkg") set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE) - set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst") - set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinst" "processed/postinst" @ONLY) + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/processed/postinst") + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.14), libstdc++6 (>= 9)") set(CPACK_DEBIAN_COMPRESSION_TYPE lzma) set(CPACK_RPM_COMPRESSION_TYPE lzma) @@ -110,7 +111,7 @@ if (UNIX AND NOT MINGW) DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/completions DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ybcon.d) install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ybcon - DESTINATION yerbacon/${CMAKE_INSTALL_BINDIR}) + DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() elseif(MINGW OR MSVC) set(CMAKE_INSTALL_PREFIX "C:\\progs\\${PROJECT_NAME}") diff --git a/scripts/TestYbcon b/scripts/TestYbcon index 0ba59b8..42c763b 100644 --- a/scripts/TestYbcon +++ b/scripts/TestYbcon @@ -1 +1 @@ -cd ./cmake-build-release/ && clear && ./ybcon -printresult ../examples/HelloWorld.ybcon +cd ./cmake-build-release/ && clear && ./ybcon --printresult ../examples/HelloWorld.ybcon diff --git a/scripts/postinst b/scripts/postinst index 0278ef2..fc4aa72 100644 --- a/scripts/postinst +++ b/scripts/postinst @@ -2,8 +2,7 @@ # Post install ybcon script -ybconDir="/opt/share/ybcon.d" -ln -sf "/opt/yerbacon/bin/ybcon" "/usr/bin/ybcon" +ybconDir="@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATAROOTDIR@/ybcon.d" fishLoc="/usr/share/fish/vendor_completions.d" bashcompleteLoc="/etc/bash_completion.d" zshLoc="/etc/zsh_completion.d" diff --git a/scripts/ybcon b/scripts/ybcon index 5e69360..4b32cce 100755 --- a/scripts/ybcon +++ b/scripts/ybcon @@ -4,8 +4,10 @@ EXENAME=ybcon -# Default location of the executable -defaultBinLocation=/opt/libexec/ybcon +scriptDir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) + +# Location of the executable +defaultBinLocation="$scriptDir/../libexec/ybcon" usage() { if [ "$1" = false ]; then echo "Invalid arguments, usage:"; fi