Re: [cmake-developers] (Re-)Added RPM Suggested Dependency Support

2016-11-05 Thread Domen Vrankar
2016-11-04 14:15 GMT+01:00 Alexander Adam :

> On Freitag, 4. November 2016 09:34:46 CET you wrote:
>
> > Would you be willing to also write a test for the SUGGESTS tag?
> > The tests are located in Tests/RunCMake/CPack, you add the test to
> > RunCMakeTest.cmake and for an example of a test similar to what you'd
> need
> > to write you can search the CPack directory for all files containing
> > PER_COMPONENT_FIELDS in their name.
>
> I took the LONG_FILENAME test for deb packages as a template for the
> following
> patch. Is it more or less what you had in mind?
>

That was more or less what I needed, thanks.

I've made some changes to the patch and test and also extended it to work
correctly for some tags that are not listed by rpmbuild --querytags.

The topic is now in next for testing:
https://cmake.org/gitweb?p=cmake.git;a=commit;h=838fd5c

Thanks,
Domen
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] (Re-)Added RPM Suggested Dependency Support

2016-11-04 Thread Alexander Adam
On Freitag, 4. November 2016 09:34:46 CET you wrote:

> Would you be willing to also write a test for the SUGGESTS tag?
> The tests are located in Tests/RunCMake/CPack, you add the test to
> RunCMakeTest.cmake and for an example of a test similar to what you'd need
> to write you can search the CPack directory for all files containing
> PER_COMPONENT_FIELDS in their name.

I took the LONG_FILENAME test for deb packages as a template for the following 
patch. Is it more or less what you had in mind?

Alexanderdiff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake
new file mode 100644
index 000..e714884
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-ExpectedFiles.cmake
@@ -0,0 +1,5 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_1 "suggested*.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/suggested.txt$")
diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-Prerequirements.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-Prerequirements.cmake
new file mode 100644
index 000..af4285d
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-Prerequirements.cmake
@@ -0,0 +1,21 @@
+function(get_test_prerequirements found_var)
+  find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
+  find_program(RPM_EXECUTABLE NAMES rpm)
+
+  if(RPMBUILD_EXECUTABLE AND RPM_EXECUTABLE)
+execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags
+OUTPUT_VARIABLE RPMBUILD_CAPS
+RESULT_VARIABLE RPMBUILD_CAPS_RESULT)
+
+if(RPMBUILD_CAPS_RESULT)
+  string(REPLACE "\n" " " RPMBUILD_CAPS_LINE ${RPMBUILD_CAPS})
+  set(RPMBUILD_CAPS_LINE " ${RPMBUILD_CAPS_LINE}")
+
+  string(FIND "${RPMBUILD_CAPS_LINE}" " SUGGESTS " RPMBUILD_HAS_SUGGESTS)
+
+  if(RPMBUILD_HAS_SUGGESTS)
+set(${found_var} true PARENT_SCOPE)
+  endif()
+endif()
+  endif()
+endfunction()
diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake
new file mode 100644
index 000..046e2d3
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake
@@ -0,0 +1,10 @@
+execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p ${FOUND_FILE_1}
+RESULT_VARIABLE rpm_result_
+OUTPUT_VARIABLE rpm_output_
+OUTPUT_QUIET)
+
+string(FIND "${rpm_output_}" "suggested" HAS_SUGGESTED)
+
+if(NOT (rpm_result_ AND HAS_SUGGESTED))
+  message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages"
+endif()
diff --git a/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake b/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake
new file mode 100644
index 000..1dd7e29
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM_SUGGESTS.cmake
@@ -0,0 +1,11 @@
+set(FILENAME
+  "${CMAKE_CURRENT_BINARY_DIR}/suggests_test.txt")
+
+file(WRITE
+  "${LONG_FILENAME}"
+  "suggests_test")
+
+install(FILES ${FILENAME} DESTINATION foo)
+
+set(CPACK_RPM_PACKAGE_SUGGESTS "libsuggested")
+set(CPACK_PACKAGE_NAME "suggested")
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index 474ee33..38bd0ea 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ run_cpack_test(CUSTOM_NAMES "RPM;DEB" true)
 run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false)
 run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
 run_cpack_test(RPM_DIST "RPM" false)
+run_cpack_test(RPM_SUGGESTS "RPM" false)
 run_cpack_test(INSTALL_SCRIPTS "RPM" false)
 run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
 run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Re: [cmake-developers] (Re-)Added RPM Suggested Dependency Support

2016-11-04 Thread Domen Vrankar
>
> after searching how to use the documented
> CPACK_RPM__PACKAGE_SUGGESTS feature, I stumbled across the
> following ticket: https://gitlab.kitware.com/cmake/cmake/issues/13423
>
> After reading through the discussion, I tried to fix the remaining issues
> and
> came up with the attached patch (against master). I also added the patched
> CPackRPM.cmake for security.
>

At first glance I like the solution. I'll take a more detailed look at it
in the afternoon.

Would you be willing to also write a test for the SUGGESTS tag?
The tests are located in Tests/RunCMake/CPack, you add the test to
RunCMakeTest.cmake and for an example of a test similar to what you'd need
to write you can search the CPack directory for all files containing
PER_COMPONENT_FIELDS in their name.

Thanks,
Domen
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

[cmake-developers] (Re-)Added RPM Suggested Dependency Support

2016-11-04 Thread Alexander Adam
Hello,

after searching how to use the documented 
CPACK_RPM__PACKAGE_SUGGESTS feature, I stumbled across the 
following ticket: https://gitlab.kitware.com/cmake/cmake/issues/13423

After reading through the discussion, I tried to fix the remaining issues and 
came up with the attached patch (against master). I also added the patched 
CPackRPM.cmake for security.

Alexander# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#.rst:
# CPackRPM
# 
#
# The built in (binary) CPack RPM generator (Unix only)
#
# Variables specific to CPack RPM generator
# ^
#
# CPackRPM may be used to create RPM packages using :module:`CPack`.
# CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
# variables used by :module:`CPack`.
#
# CPackRPM has specific features which are controlled by the specifics
# :code:`CPACK_RPM_XXX` variables.
#
# :code:`CPACK_RPM__` variables may be used in order to have
# **component** specific values.  Note however that  refers to the
# **grouping name** written in upper case. It may be either a component name or
# a component GROUP name. Usually those variables correspond to RPM spec file
# entities. One may find information about spec files here
# http://www.rpm.org/wiki/Docs
#
# .. note::
#
#  `` part of variables is preferred to be in upper case (for e.g. if
#  component is named `foo` then use `CPACK_RPM_FOO_` variable name format)
#  as is with other `CPACK__` variables.
#  For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
#  support for same cased component (e.g. `fOo` would be used as
#  `CPACK_RPM_fOo_`) is still supported for variables defined in older
#  versions of CMake/CPack but is not guaranteed for variables that
#  will be added in the future. For the sake of back compatibility same cased
#  component variables also override upper cased versions where both are
#  present.
#
# Here are some CPackRPM wiki resources that are here for historic reasons and
# are no longer maintained but may still prove useful:
#
#  - https://cmake.org/Wiki/CMake:CPackConfiguration
#  - https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
#
# List of CPackRPM specific variables:
#
# .. variable:: CPACK_RPM_PACKAGE_COMPONENT
#
#  Enable component packaging for CPackRPM
#
#  * Mandatory : NO
#  * Default   : OFF
#
#  If enabled (ON) multiple packages are generated. By default a single package
#  containing files of all components is generated.
#
# .. variable:: CPACK_RPM_PACKAGE_SUMMARY
#   CPACK_RPM__PACKAGE_SUMMARY
#
#  The RPM package summary.
#
#  * Mandatory : YES
#  * Default   : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
#
# .. variable:: CPACK_RPM_PACKAGE_NAME
#   CPACK_RPM__PACKAGE_NAME
#
#  The RPM package name.
#
#  * Mandatory : YES
#  * Default   : :variable:`CPACK_PACKAGE_NAME`
#
# .. variable:: CPACK_RPM_FILE_NAME
#   CPACK_RPM__FILE_NAME
#
#  Package file name.
#
#  * Mandatory : YES
#  * Default   : ``[-].rpm`` with spaces
#replaced by '-'
#
#  This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package
#  file name by itself.
#  Alternatively provided package file name must end with ``.rpm`` suffix.
#
#  .. note::
#
#By using user provided spec file, rpm macro extensions such as for
#generating debuginfo packages or by simply using multiple components more
#than one rpm file may be generated, either from a single spec file or from
#multiple spec files (each component execution produces it's own spec file).
#In such cases duplicate file names may occur as a result of this variable
#setting or spec file content structure. Duplicate files get overwritten
#and it is up to the packager to set the variables in a manner that will
#prevent such errors.
#
# .. variable:: CPACK_RPM_PACKAGE_VERSION
#
#  The RPM package version.
#
#  * Mandatory : YES
#  * Default   : :variable:`CPACK_PACKAGE_VERSION`
#
# .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
#   CPACK_RPM__PACKAGE_ARCHITECTURE
#
#  The RPM package architecture.
#
#  * Mandatory : YES
#  * Default   : Native architecture output by ``uname -m``
#
#  This may be set to ``noarch`` if you know you are building a noarch package.
#
# .. variable:: CPACK_RPM_PACKAGE_RELEASE
#
#  The RPM package release.
#
#  * Mandatory : YES
#  * Default   : 1
#
#  This is the numbering of the RPM package itself, i.e. the version of the
#  packaging and not the version of the content (see
#  :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
#  the previous packaging was buggy and/or you want to put here a fancy Linux
#  distro specific numbering.
#
# .. note::
#
#  This is the string that goes into the RPM ``Release:`` field. Some distros
#  (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a