[cmake-developers] Make CPACK_RPM_PACKAGE_RELEASE match Fedora/RHOS/CentOS recommended behaviour
Harry Mallon
Harry at codexdigital.com
Sun May 8 16:50:17 EDT 2016
Hi,
Here is another go. I have added a 3rd variable but I think it means that current behaviour is continued and your input (thanks Dolf and Romen) has been addressed.
https://github.com/hm1992/CMake/commit/2f54442388ab767f60fcb8cde1db2236ae535080
# CPACK_RPM_DIST
if(NOT CPACK_RPM_DIST)
execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist}
OUTPUT_VARIABLE CPACK_RPM_DIST
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# CPACK_RPM_PACKAGE_RELEASE_NUMBER
# The RPM release is the numbering of the RPM package ITSELF
# this is the version of the PACKAGING and NOT the version
# of the CONTENT of the package.
# You may well need to generate a new RPM package release
# without changing the version of the packaged software.
# This is the case when the packaging is buggy (not) the software :=)
# If not set, 1 is a good candidate.
if(NOT CPACK_RPM_PACKAGE_RELEASE_NUMBER)
set(CPACK_RPM_PACKAGE_RELEASE_NUMBER "1")
endif()
# CPACK_RPM_PACKAGE_RELEASE
if(NOT CPACK_RPM_PACKAGE_RELEASE)
# CMake default e.g. "1"
set(CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE_NUMBER}")
elseif(${CPACK_RPM_PACKAGE_RELEASE} STREQUAL "RPMBUILD-DEFAULT")
# Fedora/CentOS default e.g. "1.el7.centos"
set(CPACK_RPM_PACKAGE_RELEASE
"${CPACK_RPM_PACKAGE_RELEASE_NUMBER}${CPACK_RPM_DIST}")
endif()
H
Harry Mallon
CODEX | Software Engineer
60 Poland Street | London | England | W1F 7NT
E harry at codexdigital.com<mailto:harry at codexdigital.com> | T +44 203 7000 989<callto:+44%20203%207000%20989>
Website<www.codexdigital.com> | Facebook<https://www.facebook.com/codexdigital> | Twitter<http://twitter.com/codexdigital>
[http://www.codexdigital.com/?action=asset&id=E55D8A6F-AF62-4978-8FF1-435A85AFADBF]<http://www.codexdigital.com>
On 7 May 2016, at 4:35 pm, Domen Vrankar <domen.vrankar at gmail.com<mailto:domen.vrankar at gmail.com>> wrote:
2016-05-06 19:09 GMT+02:00 Harry Mallon <Harry at codexdigital.com<mailto:Harry at codexdigital.com>>:
According to Fedora documentation the "Release:" variable in RPM files should be set to 1%{?dist}.
https://fedoraproject.org/wiki/How_to_create_an_RPM_package
https://fedoraproject.org/wiki/Packaging:DistTag
This means it should be set to a string which looks like "1.el7.centos" on my CentOS7 machine. CPack sets this to "1" by default, but can be changed with the CPACK_RPM_PACKAGE_RELEASE variable. I propose a change as follows:
https://github.com/hm1992/CMake/commit/94c611d5710a51072e15855ed96a225def975c38
* Adds CPACK_RPM_DIST which defaults to the output of "rpmbuild -E %{dist} 2>/dev/null".
* Makes CPACK_RPM_PACKAGE_RELEASE default to "1${CPACK_RPM_DIST}"
I think I am right in saying this would not change behaviour on distributions that did not use the %{dist} option as "rpmbuild -E %{dist}" should return nothing.
Hi,
dist tag looks like a good addition however there are some issues with the proposed patch:
- As Rolf already mentioned "2>/dev/null" should be replaced with ERROR_QUIET and also OUTPUT_STRIP_TRAILING_WHITESPACE
- there is no need to check for the existance of rpmbuild as that is already checked at the top of cpack_rpm_generate_package function
- rpmbuild -E %{dist} should use %{?dist} to check if tag is set otherwise %{dist} will be printed out instead of an empty string on platforms that don't set this tag
- CPACK_RPM_DIST is only applied in situations when CPACK_RPM_PACKAGE_RELEASE is not set by the user
To solve the last bullet I would propose that you extend the patch so that with CPACK_RPM_DIST:
- if not set current functionality would remain (${CPACK_RPM_PACKAGE_RELEASE} only - I would not make an exception for "1${CPACK_RPM_DIST}" default value)
- if set to value "RPMBUILD-DEFAULT" rpmbuild -E %{?dist} would be used to get CPACK_RPM_DIST value and then appended to CPACK_RPM_PACKAGE_RELEASE
- if set to any other value that value would be used (also a check would have to be made that if first character is not a dot it has to be added automatically)
Thanks,
Domen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160508/884ae53f/attachment.html>
More information about the cmake-developers
mailing list