# 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} # set(PACKAGE_SOURCE_NAME "amdis") set(PACKAGE_NAME "libamdis") set(PACKAGE_SECTION "libdevel") if (DEFINED DISTRIBUTION) set(PACKAGE_DISTRIBUTION "${DISTRIBUTION}") set(IS_RELEASE ON) else () set(PACKAGE_DISTRIBUTION "xenial") set(IS_RELEASE OFF) endif () set(PACKAGE_VERSION_MAJOR "1") set(PACKAGE_VERSION_MINOR "2") set(PACKAGE_VERSION_PATCH "0") 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 () set(PACKAGE_VERSION "${PACKAGE_VERSION}~${PACKAGE_DISTRIBUTION}") set(PACKAGE_VERSION_FULL "${PACKAGE_VERSION}-1") set(PACKAGE_CONTACT "Simon Praetorius ") set(PACKAGE_SOURCE "") 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") file(READ ${CMAKE_SOURCE_DIR}/AUTHORS PACKAGE_AUTHORS) string(STRIP "${PACKAGE_AUTHORS}" PACKAGE_AUTHORS) execute_process(COMMAND date OUTPUT_VARIABLE PACKAGE_DATE) set(IN_DIR ${CMAKE_SOURCE_DIR}/tools/packaging/debian) set(OUT_DIR ${CMAKE_SOURCE_DIR}/debian_package) file(MAKE_DIRECTORY ${OUT_DIR}) set(PACKAGE_FILENAME ${PACKAGE_SOURCE_NAME}_${PACKAGE_VERSION}) set(PACKAGE_PREFIX ${PACKAGE_SOURCE_NAME}-${PACKAGE_VERSION}) set(TGZ_FILENAME ${OUT_DIR}/${PACKAGE_FILENAME}.orig.tar.gz) # create source tar.gz archive using git archive execute_process(COMMAND git archive --format=tar.gz --prefix ${PACKAGE_PREFIX}/ -o ${TGZ_FILENAME} HEAD) # extract package generated above execute_process(COMMAND tar -xzf ${TGZ_FILENAME} -C ${OUT_DIR}) # fill debian source package directory set(DEBIAN_DIR ${OUT_DIR}/${PACKAGE_PREFIX}/debian) 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) if (NOT EXISTS ${CMAKE_SOURCE_DIR}/CHANGELOG) configure_file(${IN_DIR}/changelog.in ${CMAKE_SOURCE_DIR}/CHANGELOG @ONLY) 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") configure_file(${CMAKE_SOURCE_DIR}/CHANGELOG ${DEBIAN_DIR}/changelog @ONLY) 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) 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) 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) file(WRITE ${DEBIAN_DIR}/compat "9\n") file(WRITE ${DEBIAN_DIR}/source/format "3.0 (quilt)\n") # generate the debian package execute_process(COMMAND ./generate_package.sh ${OUT_DIR}/${PACKAGE_PREFIX} ${PACKAGE_VERSION_FULL} ${IN_DIR} WORKING_DIRECTORY ${IN_DIR})