Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DESTDIR make install variable in catkin_make for macports and other chroot build systems #499

Closed
kyonifer opened this issue Aug 7, 2013 · 8 comments

Comments

@kyonifer
Copy link

kyonifer commented Aug 7, 2013

Macports requires files to be staged in an install dir before being copied into the actual installation prefix. Unfortunately, catkin_make_isolated doesn't support passing flags to make install, which would be the usual solution to this problem via DESTDIR.

Simply appending a DESTDIR flag to the "make install" invocations in catkin/python/catkin/builder.py also doesnt work, because with --install mode toggled catkin_make wants to put env.sh files in the install dir specified by either --install or CMAKE_INSTALL_PREFIX. Unfortunately, with a staged install nothing can be directly installed into the install directory (e.g. ${prefix}), since the files are supposed to be installed to a destroot and then copied into the actual ${prefix} by macports.

I think the solution might be to have env.sh written to the develspace instead of the installspace. In the short term, I've hacked the port to work by not passing --install to catkin_make_isolated (so it doesnt touch installspace, since it thinks its not installing) and then patching builder.py to still run "make install" for both cmake and catkin packages with forced CMAKE_INSTALL_PREFIX and DESTDIR flags which are specific to macports.

Long term, a solution which allowed passing flags to make install and not writing other files to the installspace would be useful. Also possibly always pushing the env.sh to the develspace (I'm not sure what side effects this might cause).

The temporary patching of builder.py to work with macports can be seen at https://github.com/kyonifer/ros-macports/blob/master/devel/ros-desktop/Portfile starting at line 100. reinplace is a macports macro that does regular expression replaces within the file specified.

@dirk-thomas
Copy link
Member

Support for building in isolation with DESTDIR has already been added recently (8067802). Please try the latest version from source and check if that works for your use case. See #490 for more information.

@kyonifer
Copy link
Author

kyonifer commented Aug 7, 2013

That looks good, I missed that commit.

It looks like build_cmake_package() is still writing env.sh to new_env_path on line 464, and new_env_path is set to install_target which resolves to "installspace if install else develspace". new_setup_path is hard-coded to install_target in there too. Is there any way to have it not install anything to installspace?

@dirk-thomas
Copy link
Member

Sorry, but I don't understand your question. catkin_make_isolated must always install each package. Without installation the next package can not find/rely on the package before.

@kyonifer
Copy link
Author

kyonifer commented Aug 7, 2013

Macports requires files to be installed to a destdir, which is not the actual install prefix but somewhere buried in the build tree. The reason is so that it can manually register/activate files into the install prefix and thereby track what files are there in case they need to be uninstalled.

The issue then is if something is written to the install prefix manually it will be a permissions error. The temp env.sh files which are used to chain builds of packages together cannot be written to the install prefix since thats not a writable area.

I got around this in my port tree by not passing --install to catkin_make_isolated (which forces catkin to store these chained env.sh files in the develspace) and then patching builder.py to install anyway, using the env.sh files from the develspace.

While this works, its something of a hack. It'd be better if the env.sh temp files could be written to always be stored somewhere else (e.g. develspace, or even DESTDIR), and called from there when chaining to the next package. I don't know enough about catkin to know how this would affect things (other than that when I tried that yesterday with a simple patch it broke catkin).

@dirk-thomas
Copy link
Member

With latest changes of catkin from the GitHub repo and setting DESTDIR there should be no files written to the install prefix but only to the dest dir. If that is not the case for you please describe the exact steps/commands to reproduce it.

@kyonifer
Copy link
Author

kyonifer commented Aug 8, 2013

Ok sounds great, I'll give it a go as soon as I'm able (can't get latest from git to compile via macports for unrelated reasons atm).

@kyonifer
Copy link
Author

Unfortunately it looks like its still writing env.sh to the install-space. Here's the invocation (tcl script for macports, run in a directory that has groovy-desktop-full in it):

     system "DESTDIR=${destroot} ${worksrcpath}/src/catkin/bin/catkin_make_isolated \
          --source ${worksrcpath}/src \
          --build ${worksrcpath}/build_isolated \
          --devel ${worksrcpath}/devel_isolated \
          -DCMAKE_SKIP_RPATH:BOOL=OFF \
          -DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib \
          -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
          -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
          -DSETUPTOOLS_DEB_LAYOUT=OFF \
          -DPYTHON_EXECUTABLE:FILEPATH=${prefix}/bin/python2.7 \
          --install-space=${prefix} \
          --install"

And the relevant part of the output:


:info:build -- Installing: /opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/destroot/opt/local/bin/bfl/test_discrete_filter
:info:build Traceback (most recent call last):
:info:build   File "/opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/src/catkin/bin/../python/catkin/builder.py", line 766, in build_workspace_isolated
:info:build     number=index + 1, of=len(ordered_packages)
:info:build   File "/opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/src/catkin/bin/../python/catkin/builder.py", line 544, in build_package
:info:build     destdir=destdir
:info:build   File "/opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/src/catkin/bin/../python/catkin/builder.py", line 464, in build_cmake_package
:info:build     with open(os.path.join(new_env_path), 'w') as f:
:info:build IOError: [Errno 1] Operation not permitted: '/opt/local/env.sh'
:info:build build_isolated/bfl'
:info:build ==> make install in '/opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/build_isolated/bfl'
:info:build ==> Generating an env.sh
:info:build Unhandled exception of type 'IOError':
:info:build <== Failed to process package 'bfl': 
:info:build   [Errno 1] Operation not permitted: '/opt/local/env.sh'
:info:build Command failed, exiting.
:info:build Command failed: DESTDIR=/opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/destroot /opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/src/catkin/bin/catkin_make_isolated  --source /opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/src  --build /opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/build_isolated  --devel /opt/local/var/macports/build/_Users_kyon_ros-macports_devel_ros-groovy-desktop-full/ros-groovy-desktop-full/work/ros-groovy-desktop-full-1.0.0/devel_isolated  -DCMAKE_SKIP_RPATH:BOOL=OFF  -DCMAKE_INSTALL_NAME_DIR:STRING=/opt/local/lib  -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON  -DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON  -DSETUPTOOLS_DEB_LAYOUT=OFF  -DPYTHON_EXECUTABLE:FILEPATH=/opt/local/bin/python2.7  --install-space=/opt/local  --install
:info:build Exit code: 1
:error:build org.macports.build for port ros-groovy-desktop-full returned: command execution failed
:debug:build Error code: NONE

In the ":info:build Command failed:" line you can see its being called with DESTDIR set to within the macports build hierarchy. The full log is 300k but I can paste it somewhere if needed. It appears to be line 464 in builder.py, which is the env.sh files I believe.

@dirk-thomas
Copy link
Member

I have committed a patch which fixes the issue for me.

But since your example is overly complex and does not contain all information (the used variables as well as the content of the workspace is unknown) I was unable to run your example. Can you please try it with a current checkout of catkin in your workspace and report back if that solves the issue for you, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants