Commit 8a5b09c1 authored by Sylvain Fargier's avatar Sylvain Fargier 🐾
Browse files

📦 update packaging receipe

parent 02e5f222
Pipeline #1682223 canceled with stages
......@@ -32,6 +32,9 @@ package:
# Install deps
- yum install -y cmake3 make gcc-c++ git boost-devel rpm-build pugixml-devel
# Won't package on a shallow clone
- git fetch --unshallow
# rpm-build debuginfo workarround, srcdir must be longer than debuginfo path
- git clone . rpmbuild && cd rpmbuild
......
# Create a git badge
if(NOT CMAKE_SCRIPT_MODE_FILE)
add_custom_target(git-badge DEPENDS ${CMAKE_BINARY_DIR}/git_badge.svg)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/git_badge.svg
COMMAND ${CMAKE_COMMAND} -DGIT_EXE="${GIT_EXE}"
-DGIT_WORKDIR="${GIT_WORKDIR}" -P "${CMAKE_CURRENT_LIST_FILE}"
DEPENDS ${CMAKE_SOURCE_DIR}/.git)
else()
execute_process(
COMMAND ${GIT_EXE} "describe" "--tags" "--always" "HEAD"
WORKING_DIRECTORY "${GIT_WORKDIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE GIT_DESCRIBE)
message(STATUS "Git describe: ${GIT_DESCRIBE}")
string(REPLACE "-" "--" GIT_BADGE "${GIT_DESCRIBE}")
file(DOWNLOAD "https://img.shields.io/badge/version-${GIT_BADGE}-informational.svg" "${CMAKE_CURRENT_BINARY_DIR}/git_badge.svg")
message(STATUS "Git badge generated !")
endif()
......@@ -19,17 +19,25 @@ if(NOT CMAKE_SCRIPT_MODE_FILE)
OUTPUT ${CMAKE_BINARY_DIR}/.git_version
COMMAND ${CMAKE_COMMAND} -DGIT_WORKDIR="${GIT_WORKDIR}" -P "${CMAKE_CURRENT_LIST_FILE}"
DEPENDS ${CMAKE_SOURCE_DIR}/.git)
include(GitBadge)
endif(NOT CMAKE_SCRIPT_MODE_FILE)
execute_process(
COMMAND ${GIT_EXE} "log" "--pretty=format:"
WORKING_DIRECTORY "${GIT_WORKDIR}"
ERROR_FILE "${CMAKE_BINARY_DIR}/.git_error.log"
OUTPUT_FILE ${CMAKE_BINARY_DIR}/.git_version)
file(READ ${CMAKE_BINARY_DIR}/.git_version GIT_COUNT)
string(LENGTH "${GIT_COUNT}" GIT_COUNT)
file(WRITE ${CMAKE_BINARY_DIR}/.git_version ${GIT_COUNT})
message(STATUS "Count commits: ${GIT_COUNT}")
if (EXISTS "${CMAKE_SOURCE_DIR}/.git/shallow")
# Use git fetch --unshallow to count commits
message(STATUS "Count commits: shallow clone")
set(GIT_COUNT "0")
else()
execute_process(
COMMAND ${GIT_EXE} "log" "--pretty=format:"
WORKING_DIRECTORY "${GIT_WORKDIR}"
ERROR_FILE "${CMAKE_BINARY_DIR}/.git_error.log"
OUTPUT_FILE ${CMAKE_BINARY_DIR}/.git_version)
file(READ ${CMAKE_BINARY_DIR}/.git_version GIT_COUNT)
string(LENGTH "${GIT_COUNT}" GIT_COUNT)
file(WRITE ${CMAKE_BINARY_DIR}/.git_version ${GIT_COUNT})
message(STATUS "Count commits: ${GIT_COUNT}")
endif()
execute_process(
COMMAND ${GIT_EXE} "rev-parse" "--short" "HEAD"
......@@ -44,3 +52,4 @@ if(GIT_DIRTY)
message(STATUS "Git tree is dirty")
set(GIT_DIRTY "+")
endif(GIT_DIRTY)
......@@ -13,6 +13,7 @@ set(CPACK_PACKAGE_CONTACT "Sylvain Fargier <sylvain.fargier@cern.ch>")
# Generate debug package
set(CPACK_RPM_DEBUGINFO_PACKAGE ON)
set(CPACK_RPM_PACKAGE_AUTOREQ 1)
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/cmake/PackConfig.cmake")
add_custom_target(rpm-package COMMAND ${CMAKE_CPACK_COMMAND} -G RPM)
......
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/../.git/shallow")
message(SEND_ERROR "Not generating package on shallow clone, use \"git fetch --unshallow\"")
endif ()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment