diff --git a/cmake.packaging/CMakeLists.txt b/cmake.packaging/CMakeLists.txt index 940f213acb..584db2b85e 100644 --- a/cmake.packaging/CMakeLists.txt +++ b/cmake.packaging/CMakeLists.txt @@ -70,6 +70,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Unfortunately, you "just need to know" that this has a hidden # dependency on dpkg-shlibdeps whilst using a debian based host. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) + + # Include postinst and prerm scripts for update-alternatives + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + "${CMAKE_CURRENT_LIST_DIR}/postinst" + "${CMAKE_CURRENT_LIST_DIR}/prerm") else() set(CPACK_GENERATOR TGZ) endif() diff --git a/cmake.packaging/postinst b/cmake.packaging/postinst new file mode 100755 index 0000000000..9debcd7cff --- /dev/null +++ b/cmake.packaging/postinst @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +# Register nvim as an alternative for vi and vim, view, editor +update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60 +update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60 +update-alternatives --install /usr/bin/view view /usr/bin/nvim 60 + +exit 0 diff --git a/cmake.packaging/prerm b/cmake.packaging/prerm new file mode 100755 index 0000000000..345e0270dd --- /dev/null +++ b/cmake.packaging/prerm @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +if [ "$1" = "remove" ]; then + update-alternatives --remove vi /usr/bin/nvim + update-alternatives --remove vim /usr/bin/nvim + update-alternatives --remove view /usr/bin/nvim +fi + +exit 0