compile cmake-source to debian deb packages
Hi,
I would like to always install the newest CMake on my Debian or Ubuntu PC.
Looking here...
https://cmake.org/download/#latest
... I only see a download for tar.gz
.
But I want a deb package: that I can easily install and (important!) cleanly uninstall.
So I guess I'm asking: would it be possible to provide a deb on the download-page as well?
I've written a script to create a deb from the source-code:
click-me to fold-out section and show script to compile source and generate deb (get_deb_with_bootstrap.sh)
#!/usr/bin/env bash
set -eE
GIT_REPO_URL=https://gitlab.kitware.com/cmake/cmake.git
CPACK_SET_DESTDIR=0
CPACK_GENERATOR="DEB"
SCRIPT_PATH="$(readlink -e "$BASH_SOURCE")"
SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
NUMJOBS="$(grep -c ^processor /proc/cpuinfo)"
if ls -1d ~/Qt*/[0-9]*/gcc_64 &>/dev/null; then
# Qt is installed in e.g. ~/Qt5.11.1/5.11.1/gcc_64/
Qt_in_home_dir="$(readlink -e "$(ls -1d ~/Qt* | sort -V | tail -1)"/[0-9]*/gcc_64 )"
export CMAKE_PREFIX_PATH="$Qt_in_home_dir"
export LD_LIBRARY_PATH="$Qt_in_home_dir/lib:$LD_LIBRARY_PATH"
fi
tags="$(git ls-remote --tags $GIT_REPO_URL | awk '{print $2}' | sed -E 's|^refs/tags/(.*)$|\1|g' | grep -v '\^{}$')"
# ~~~~~~~~~~ -> does not end with ^{}
version_tags="$(echo "$tags" | grep -v '[-]rc[0-9]*$')"
# ~~~~~~~~~~~~~~~~ -> does not end with -rc1 etc.
latest_version_tag="$(echo "$version_tags" | sort -V | tail -1 )"
echo $latest_version_tag
cd $SCRIPT_DIR
rm -rf cmake
git clone -b $latest_version_tag --depth 1 --recurse-submodules $GIT_REPO_URL cmake
cd $SCRIPT_DIR/cmake
BOOTSTRAP_PARALLEL="--parallel=$NUMJOBS"
BUILD_DATE="$(LC_ALL=C date -u "+%B %d, %Y")"
rm -rf Build && mkdir -p Build && cd Build
echo 'set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip rpath" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_USE_RELATIVE_PATHS ON CACHE BOOL "Use relative paths" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose build" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)' >> build-flags.cmake
# see https://salsa.debian.org/cmake-team/cmake/tree/master/debian
#echo 'set(CMAKE_C_FLAGS "-g -O2 -fdebug-prefix-map=/home/albert/projects/cmake_deb/debian/cmake=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C flags" FORCE)' >> build-flags.cmake
#echo 'set(CMAKE_CXX_FLAGS "-g -O2 -fdebug-prefix-map=/home/albert/projects/cmake_deb/debian/cmake=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2" CACHE STRING "C++ flags" FORCE)' >> build-flags.cmake
echo 'set(CMAKE_SKIP_BOOTSTRAP_TEST ON CACHE BOOL "Skip BootstrapTest" FORCE)' >> build-flags.cmake
echo 'set(BUILD_CursesDialog ON CACHE BOOL "Build curses GUI" FORCE)' >> build-flags.cmake
echo 'set(BUILD_QtDialog ON CACHE BOOL "Build Qt GUI" FORCE)' >> build-flags.cmake
if [[ -n "$Qt_in_home_dir" ]]; then
echo "set(CMAKE_PREFIX_PATH $CMAKE_PREFIX_PATH CACHE STRING \"\" FORCE)" >> build-flags.cmake
fi
echo 'set(CPACK_GENERATOR DEB CACHE STRING "" FORCE)' >> build-flags.cmake
echo 'set(CPACK_DEB_COMPONENT_INSTALL ON CACHE BOOL "" FORCE)' >> build-flags.cmake
echo 'set(CMake_INSTALL_COMPONENTS ON CACHE BOOL "" FORCE)' >> build-flags.cmake
echo 'set(CPACK_BINARY_DEB ON CACHE BOOL "" FORCE)' >> build-flags.cmake
../bootstrap --prefix=/usr --docdir=/share/doc/cmake --mandir=/share/man \
--init=build-flags.cmake `#--system-libs` \
--sphinx-man --sphinx-html --sphinx-flags="-D today=\"$BUILD_DATE\"" \
$BOOTSTRAP_PARALLEL --verbose -- -DCMAKE_BUILD_TYPE=Release
make -j$NUMJOBS
make package
The script above will clone into a folder cmake
, create a build-directory cmake/Build
and end up with this deb-file cmake/Build/cmake-3.13.2-Linux-x86_64.deb
.
I tried hard to get multiple debs here (via CMake_OPTIONAL_COMPONENT
):
cmake-developer-reference-html
cmake-developer-reference-qthelp
sphinx-info
sphinx-man
sphinx-html
sphinx-singlehtml
sphinx-qthelp
ccmake
But it does not work. I only get the single deb mentioned above (cmake/Build/cmake-3.13.2-Linux-x86_64.deb
).
Why? (Note that I am setting set(CPACK_DEB_COMPONENT_INSTALL ON)
)
Thanks.