From 55882360ef6503d781364b60e07f159f77703521 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 18 Sep 2018 00:45:33 +0200 Subject: [PATCH] Fix RPM suffix --- cmake/Rpm.cmake | 85 ++++++++++++++++++++++++++++++++------------- dist/CMakeLists.txt | 6 ++-- 2 files changed, 65 insertions(+), 26 deletions(-) diff --git a/cmake/Rpm.cmake b/cmake/Rpm.cmake index 93c702e7a..b91c6e9a0 100644 --- a/cmake/Rpm.cmake +++ b/cmake/Rpm.cmake @@ -1,28 +1,65 @@ -find_program(LSB_RELEASE_EXEC lsb_release) -execute_process(COMMAND ${LSB_RELEASE_EXEC} -is - OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT - OUTPUT_STRIP_TRAILING_WHITESPACE -) +find_program(LSB_RELEASE_EXEC lsb-release) if (LSB_RELEASE_EXEC) - set(RPMBUILD_DIR ~/rpmbuild CACHE STRING "Rpmbuild directory, for the rpm target") - set(RPM_ARCH x86_64 CACHE STRING "Architecture of the rpm file") - if (${LSB_RELEASE_ID_SHORT} STREQUAL "openSUSE") - set(RPM_DISTRO opensuse CACHE STRING "Suffix of the rpm file") - add_custom_target(rpm - COMMAND ${CMAKE_SOURCE_DIR}/dist/scripts/maketarball.sh - COMMAND ${CMAKE_COMMAND} -E copy strawberry-${STRAWBERRY_VERSION_PACKAGE}.tar.xz ${RPMBUILD_DIR}/SOURCES/ - COMMAND rpmbuild -bs ${CMAKE_SOURCE_DIR}/dist/opensuse/strawberry.spec - COMMAND rpmbuild -bb ${CMAKE_SOURCE_DIR}/dist/opensuse/strawberry.spec - ) - endif() - if (${LSB_RELEASE_ID_SHORT} STREQUAL "Fedora") - set(RPM_DISTRO fedora CACHE STRING "Suffix of the rpm file") - add_custom_target(rpm - COMMAND ${CMAKE_SOURCE_DIR}/dist/scripts/maketarball.sh - COMMAND ${CMAKE_COMMAND} -E copy strawberry-${STRAWBERRY_VERSION_PACKAGE}.tar.xz ${RPMBUILD_DIR}/SOURCES/ - COMMAND rpmbuild -bs ${CMAKE_SOURCE_DIR}/dist/fedora/strawberry.spec - COMMAND rpmbuild -bb ${CMAKE_SOURCE_DIR}/dist/fedora/strawberry.spec - ) + execute_process(COMMAND /bin/sh "-c" "${LSB_RELEASE_EXEC} -is | tr '[:upper:]' '[:lower:]'" + OUTPUT_VARIABLE DIST_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process(COMMAND /bin/sh "-c" "${LSB_RELEASE_EXEC} -ds | tr '[:upper:]' '[:lower:]' | sed 's/\"//g' | cut -d' ' -f2" + OUTPUT_VARIABLE DIST_RELEASE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process(COMMAND /bin/sh "-c" "${LSB_RELEASE_EXEC} -ds | tr '[:upper:]' '[:lower:]' | sed 's/\"//g' | sed 's/\\.//g' | cut -d' ' -f3" + OUTPUT_VARIABLE DIST_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if (DIST_NAME) + message(STATUS "Distro Name: ${DIST_NAME}") + if (DIST_RELEASE) + message(STATUS "Distro Release: ${DIST_RELEASE}") + endif() + if (DIST_VERSION) + message(STATUS "Distro Version: ${DIST_VERSION}") + endif() + set(RPM_ARCH x86_64 CACHE STRING "Architecture of the rpm file") + set(RPMBUILD_DIR ~/rpmbuild CACHE STRING "Rpmbuild directory, for the rpm target") + if (${DIST_NAME} STREQUAL "opensuse") + if (DIST_RELEASE) + if (${DIST_RELEASE} STREQUAL "leap") + if (DIST_VERSION) + set(RPM_DISTRO "lp${DIST_VERSION}" CACHE STRING "Suffix of the rpm file") + else() + set(RPM_DISTRO ${DIST_RELEASE} CACHE STRING "Suffix of the rpm file") + endif() + elseif (${DIST_RELEASE} STREQUAL "tumbleweed") + set(RPM_DISTRO ${DIST_RELEASE} CACHE STRING "Suffix of the rpm file") + else () + set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file") + endif() + else() + set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file") + endif() + add_custom_target(rpm + COMMAND ${CMAKE_SOURCE_DIR}/dist/scripts/maketarball.sh + COMMAND ${CMAKE_COMMAND} -E copy strawberry-${STRAWBERRY_VERSION_PACKAGE}.tar.xz ${RPMBUILD_DIR}/SOURCES/ + COMMAND rpmbuild -bs ${CMAKE_SOURCE_DIR}/dist/opensuse/strawberry.spec + COMMAND rpmbuild -bb ${CMAKE_SOURCE_DIR}/dist/opensuse/strawberry.spec + ) + elseif (${DIST_NAME} STREQUAL "fedora") + if (DIST_RELEASE) + set(RPM_DISTRO ${DIST_NAME}${DIST_RELEASE} CACHE STRING "Suffix of the rpm file") + else () + set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file") + endif() + add_custom_target(rpm + COMMAND ${CMAKE_SOURCE_DIR}/dist/scripts/maketarball.sh + COMMAND ${CMAKE_COMMAND} -E copy strawberry-${STRAWBERRY_VERSION_PACKAGE}.tar.xz ${RPMBUILD_DIR}/SOURCES/ + COMMAND rpmbuild -bs ${CMAKE_SOURCE_DIR}/dist/fedora/strawberry.spec + COMMAND rpmbuild -bb ${CMAKE_SOURCE_DIR}/dist/fedora/strawberry.spec + ) + else() + set(RPM_DISTRO ${DIST_NAME} CACHE STRING "Suffix of the rpm file") + endif() + message(STATUS "RPM Suffix: ${RPM_DISTRO}") endif() endif() diff --git a/dist/CMakeLists.txt b/dist/CMakeLists.txt index 6273576c2..72f668372 100644 --- a/dist/CMakeLists.txt +++ b/dist/CMakeLists.txt @@ -2,8 +2,10 @@ execute_process(COMMAND env LC_ALL="en_US.utf8" date "+%a %b %d %Y" OUTPUT_VARIA execute_process(COMMAND env LC_ALL=C date "+%a, %-d %b %Y %H:%M:%S %z" OUTPUT_VARIABLE DEB_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/maketarball.sh.in ${CMAKE_CURRENT_SOURCE_DIR}/scripts/maketarball.sh @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/opensuse/strawberry.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/opensuse/strawberry.spec @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fedora/strawberry.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/fedora/strawberry.spec @ONLY) +if (RPM_DISTRO) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/opensuse/strawberry.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/opensuse/strawberry.spec @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fedora/strawberry.spec.in ${CMAKE_CURRENT_SOURCE_DIR}/fedora/strawberry.spec @ONLY) +endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog.in ${CMAKE_CURRENT_SOURCE_DIR}/debian/changelog) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist.in ${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/windows/strawberry.nsi.in ${CMAKE_CURRENT_SOURCE_DIR}/windows/strawberry.nsi @ONLY)