create_package.cmake 4.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# CMake script to create debian packages for AMDiS
# ================================================
#
# Usage:
# - If you want to create a new release, specify the ubuntu distribution, e.g. xenial, or bionic
#   and call the cmake script with the -DDISTRIBUTION parameters:
#   ```
#   cmake -DDISTRIBUTION=xenial -P .../create_package.cmake
#   ```
# - Otherwise, if you want to create a Release Candidate, omit the -DDISTRIBUTION parameter.
# - In case there are multiple uploads of the same version, i.e. you have corrected some bugs,
#   you may need to append a sub-version to the version string, i.e. add ppa[1-9]
#   PACKAGE_VERSION=${PACKAGE_VERSION}~ppa[1-9]~${PACKAGE_DISTRIBUTION}
#

16 17 18
set(PACKAGE_SOURCE_NAME   "amdis")
set(PACKAGE_NAME          "libamdis")
set(PACKAGE_SECTION       "libdevel")
19 20 21 22 23 24 25
if (DEFINED DISTRIBUTION)
  set(PACKAGE_DISTRIBUTION  "${DISTRIBUTION}")
  set(IS_RELEASE ON)
else ()
  set(PACKAGE_DISTRIBUTION  "xenial")
  set(IS_RELEASE OFF)
endif ()
26
set(PACKAGE_VERSION_MAJOR "1")
27
set(PACKAGE_VERSION_MINOR "2")
28
set(PACKAGE_VERSION_PATCH "0")
29 30 31 32 33 34 35 36 37 38 39 40 41
set(PACKAGE_RELEASE_CANDIDATE "1")

# construct a package-version string
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")

if (${PACKAGE_VERSION_PATCH} GREATER 0)
  set(PACKAGE_VERSION "${PACKAGE_VERSION}.${PACKAGE_VERSION_PATCH}")
endif ()

if (NOT IS_RELEASE)
  set(PACKAGE_VERSION "${PACKAGE_VERSION}~rc${PACKAGE_RELEASE_CANDIDATE}")
endif ()

Praetorius, Simon's avatar
Praetorius, Simon committed
42
set(PACKAGE_VERSION "${PACKAGE_VERSION}~${PACKAGE_DISTRIBUTION}")
43
set(PACKAGE_VERSION_FULL "${PACKAGE_VERSION}-1")
44 45

set(PACKAGE_CONTACT "Simon Praetorius <simon.praetorius@tu-dresden.de>")
Praetorius, Simon's avatar
Praetorius, Simon committed
46
set(PACKAGE_SOURCE  "<https://gitlab.mn.tu-dresden.de/iwr/amdis.git>")
47 48 49 50 51 52 53 54 55 56

set(PACKAGE_DESCRIPTION_SUMMARY "A C++ library to solve a broad class of PDEs using adaptive finite elements.")
set(PACKAGE_DESCRIPTION_FILE    "${CMAKE_SOURCE_DIR}/README.md")
set(PACKAGE_DESCRIPTION
"Adaptive MultiDimensional Simulations (AMDiS) is a C++ library
 to solve a broad class of partial differential equations (PDEs) using
 adaptive finite elements.")

set(PACKAGE_LICENSE_FILE "${CMAKE_SOURCE_DIR}/LICENSE")
set(PACKAGE_README_FILE  "${CMAKE_SOURCE_DIR}/README.md")
57

58
file(READ ${CMAKE_SOURCE_DIR}/AUTHORS PACKAGE_AUTHORS)
59
string(STRIP "${PACKAGE_AUTHORS}" PACKAGE_AUTHORS)
60
execute_process(COMMAND date OUTPUT_VARIABLE PACKAGE_DATE)
61 62 63 64 65

set(IN_DIR  ${CMAKE_SOURCE_DIR}/tools/packaging/debian)
set(OUT_DIR ${CMAKE_SOURCE_DIR}/debian_package)
file(MAKE_DIRECTORY ${OUT_DIR})

66 67
set(PACKAGE_FILENAME ${PACKAGE_SOURCE_NAME}_${PACKAGE_VERSION})
set(PACKAGE_PREFIX ${PACKAGE_SOURCE_NAME}-${PACKAGE_VERSION})
68 69
set(TGZ_FILENAME ${OUT_DIR}/${PACKAGE_FILENAME}.orig.tar.gz)

70
# create source tar.gz archive using git archive
71
execute_process(COMMAND git archive --format=tar.gz --prefix ${PACKAGE_PREFIX}/ -o ${TGZ_FILENAME} HEAD)
72

73
# extract package generated above
74 75
execute_process(COMMAND tar -xzf ${TGZ_FILENAME} -C ${OUT_DIR})

76
# fill debian source package directory
77
set(DEBIAN_DIR ${OUT_DIR}/${PACKAGE_PREFIX}/debian)
78 79 80 81 82
file(MAKE_DIRECTORY ${DEBIAN_DIR})
file(MAKE_DIRECTORY ${DEBIAN_DIR}/soure)

execute_process(COMMAND date +%F OUTPUT_VARIABLE CURRENT_DATE)
execute_process(COMMAND date +%Y OUTPUT_VARIABLE YEAR)
83 84

if (NOT EXISTS ${CMAKE_SOURCE_DIR}/CHANGELOG)
85
  configure_file(${IN_DIR}/changelog.in ${CMAKE_SOURCE_DIR}/CHANGELOG @ONLY)
86 87 88 89 90
elseif (UPDATE_CHANGELOG)
  execute_process(COMMAND dch -i -M "New release version published at ${CURRENT_DATE}" -c ${CMAKE_SOURCE_DIR}/CHANGELOG)
endif ()
message(STATUS "Changelog must be uploaded to master")

91
configure_file(${CMAKE_SOURCE_DIR}/CHANGELOG ${DEBIAN_DIR}/changelog @ONLY)
92 93 94 95 96
configure_file(${IN_DIR}/copyright.in ${DEBIAN_DIR}/copyright @ONLY)
configure_file(${IN_DIR}/control.in   ${DEBIAN_DIR}/control   @ONLY)
configure_file(${IN_DIR}/rules.in     ${DEBIAN_DIR}/rules     @ONLY)
execute_process(COMMAND chmod +x ${DEBIAN_DIR}/rules)

97 98 99
configure_file(${IN_DIR}/libamdis-dev.install ${DEBIAN_DIR}/libamdis-dev.install @ONLY)
configure_file(${IN_DIR}/libamdis.install     ${DEBIAN_DIR}/libamdis.install     @ONLY)
configure_file(${IN_DIR}/libamdis-par.install ${DEBIAN_DIR}/libamdis-par.install @ONLY)
100 101 102
configure_file(${IN_DIR}/libamdis-debug.install     ${DEBIAN_DIR}/libamdis-debug.install     @ONLY)
configure_file(${IN_DIR}/libamdis-par-debug.install ${DEBIAN_DIR}/libamdis-par-debug.install @ONLY)

103
file(WRITE ${DEBIAN_DIR}/compat "9\n")
104
file(WRITE ${DEBIAN_DIR}/source/format "3.0 (quilt)\n")
105 106

# generate the debian package
107 108
execute_process(COMMAND ./generate_package.sh ${OUT_DIR}/${PACKAGE_PREFIX} ${PACKAGE_VERSION_FULL} ${IN_DIR}
                WORKING_DIRECTORY ${IN_DIR})