[cmake-developers] CPackRPM not dealing correctly with symlinks

Attila Krasznahorkay attila.krasznahorkay at gmail.com
Tue Mar 29 06:19:15 EDT 2016


Hi Domen,

I just tried, it seems to do the trick. An example source setup that was breaking the RPM building before, is now functioning seemingly correctly. The produced RPM gets the symlink, pointing at the location outside of the package.

I would actually prefer if the code printed a warning in this case. (Requesting a relocatable package, yet pointing at a fixed location outside of the package.) As in our case it was definitely a mistake to include soft links like this in our build. But if that's hard to add to the code, then so be it.

Cheers,
             Attila

> On 28 Mar 2016, at 18:38, Domen Vrankar <domen.vrankar at gmail.com> wrote:
> 
> Attached is CPackRPM.cmake that fixes cases where symlink points to
> locations outside packaging directory.
> 
> Please confirm that it fixes your problem. Patched CPackRPM.cmake is
> from master branch so please replace the file in your 3.5.0 version of
> CMake.
> 
> Thanks,
> Domen
> 
> 2016-03-24 9:48 GMT+01:00 Attila Krasznahorkay <attila.krasznahorkay at gmail.com>:
>> Hi Domen,
>> 
>> Unfortunately I can't seem to create an easy-to-package example for the issue. Since it seems that the file given to the install(...) command has to be in a "very different place" than the source or binary directories for the issue to come up. (My guess is that if the file shares some of its path with the build directory, CPackRPM uses a different method for dealing with it than if the two paths don't share any prefix.)
>> 
>> In our case some files are picked up from a network drive, while the build happens (naturally) on a local drive. I can reproduce the issue with a CMakeLists.txt file like:
>> 
>> cmake_minimum_required( VERSION 2.8 )
>> project( CPackRPMLinkProblem )
>> 
>> install( FILES /afs/cern.ch/.../some_link.txt DESTINATION . )
>> 
>> set( CPACK_PACKAGE_RELOCATABLE TRUE )
>> include( CPack )
>> 
>> As long as the build directory's path name ends up being longer than the path name of the file specified in the install(...) command, the RPM building fails. As it does for instance here:
>> 
>> http://atlas-computing.web.cern.ch/atlas-computing/links/distDirectory/nightlies/experimentalWebArea/nicos_web_areaCMAKE64BS6G49AnlOpt/NICOS_Log_rel_4/nicos_rpm_build.html
>> 
>> Cheers,
>>           Attila
>> 
>>> On 23 Mar 2016, at 15:57, Domen Vrankar <domen.vrankar at gmail.com> wrote:
>>> 
>>> As a workaround you could set files that you would like to be excluded
>>> from symlink relocation with CPACK_RPM_USER_FILELIST or
>>> CPACK_RPM_<COMPONENT>_USER_FILELIST.
>>> 
>>> I'll have a look at how this could be solved for later versions of CPack.
>>> Do I understand correctly that those errors occur when a symlink is
>>> pointing to another simlink outside your project?
>>> Could you please provide a minimal example of all your cases?
>>> 
>>> Thanks,
>>> Domen
>>> 
>>> 
>>> 2016-03-23 14:13 GMT+01:00 Attila Krasznahorkay
>>> <attila.krasznahorkay at gmail.com>:
>>>> Hi Brad,
>>>> 
>>>> I did. Then I get:
>>>> 
>>>> CMake Error at /afs/cern.ch/work/k/krasznaa/public/cmake/3.5.0/share/cmake-3.5/Modules/CPackRPM.cmake:981 (string):
>>>> string begin index: 164 is out of range 0 - 156
>>>> Call Stack (most recent call first):
>>>> /afs/cern.ch/work/k/krasznaa/public/cmake/3.5.0/share/cmake-3.5/Modules/CPackRPM.cmake:1625 (cpack_rpm_prepare_install_files)
>>>> /afs/cern.ch/work/k/krasznaa/public/cmake/3.5.0/share/cmake-3.5/Modules/CPackRPM.cmake:1787 (cpack_rpm_generate_package)
>>>> 
>>>> You can find the full output here:
>>>> 
>>>> http://atlas-computing.web.cern.ch/atlas-computing/links/distDirectory/nightlies/experimentalWebArea/nicos_web_areaCMAKE64BS6G49TrgOpt/NICOS_Log_rel_3/nicos_rpm_build.html
>>>> 
>>>> Note that when I tried to build the project in a build area with a shorter path, then the RPM building succeeded. Just because by chance in that case in the expression
>>>> 
>>>> string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
>>>> 
>>>> the work directory length was shorter than the length of the path outside of the project.
>>>> 
>>>> Of course this is the code that we're talking about:
>>>> 
>>>> https://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/CPackRPM.cmake;h=7ffec136deabb8f28d6293cdc96e43cd4a2af70d;hb=HEAD#l994
>>>> 
>>>> Cheers,
>>>>            Attila
>>>> 
>>>>> On 23 Mar 2016, at 13:50, Brad King <brad.king at kitware.com> wrote:
>>>>> 
>>>>> On 03/23/2016 08:44 AM, Attila Krasznahorkay wrote:
>>>>>> CMake Error at /afs/cern.ch/sw/lcg/contrib/CMake/3.3.2/...
>>>>> 
>>>>> Please try with CMake 3.5.
>>>>> 
>>>>> -Brad
>>>>> 
>>>> 
>> 
> <CPackRPM.cmake>



More information about the cmake-developers mailing list