Override-build has no effect on final build

I’m trying to use override-build to add a specific change to my code before building. Although I can see that the change was made to the file in the $SNAPCRAFT_PART_SRC folder, it does neither affect my $SNAPCRAFT_PART_BUILD, nor my final build:

  workspace:
    plugin: catkin-tools
    source: .
    rosinstall-files: [snap/local/snap.rosinstall]
    recursive-rosinstall: false
    catkin-packages: [catkin_simple, ads_catkin, eigen_catkin, mag_msgs, nav_launch]
    after: [qt5]
    override-build: |
      # adding local config file to corresponding line in roslaunch file before building
      sed -i '/\$(find nav\_controller)\/launch\/parameters\.yaml/a \ \ \ \ \ \ \ \ \<rosparam command\=\"load\" file\=\"\$(env SNAP\_DATA)\/nav\_controller\_parameters\.yaml\" \/\>' $SNAPCRAFT_PART_SRC/nav_launch/launch/file.launch
      snapcraftctl build

Applying it to $SNAPCRAFT_PART_BUILD would change the file correctly in the build folder, but also not affect the final build.

Adding the same line manually before executing snapcraft works fine.

I also tried to make this change with override-pull and change the line after pulling. Shows up in $SNAPCRAFT_PART_SRC and $SNAPCRAFT_PART_BUILD accordingly, but doesn’t affect the build either:

  workspace:
    plugin: catkin-tools
    source: .
    rosinstall-files: [snap/local/snap.rosinstall]
    recursive-rosinstall: false
    catkin-packages: [catkin_simple, ads_catkin, eigen_catkin, mag_msgs, nav_controller, nav_launch]
    after: [qt5]
    override-pull: |
      # adding local config file to corresponding line in roslaunch file before building
      snapcraftctl pull
      sed -i '/\$(find nav\_controller)\/launch\/parameters\.yaml/a \ \ \ \ \ \ \ \ \<rosparam command\=\"load\" file\=\"\$(env SNAP\_DATA)\/nav\_controller\_parameters\.yaml\" \/\>' $SNAPCRAFT_PART_SRC/nav_launch/launch/file.launch

I’m either not understanding the parts lifecycle or the plugin is doing something different than usual.

It’s not immediately clear why this isn’t working the way you expect; my first approach would have been the same as your latter approach, where you altered the launch file in $SNAPCRAFT_PART_SRC in an override-pull. I’m afraid I’m not as familiar with the catkin-tools plugin as I wish I was. I suspect this will work, however:

override-build: |
  # Do the part build/install as normal
  snapcraftctl build

  # Now alter the installed launch file, adding the local config file
  sed -i <expression> $SNAPCRAFT_PART_INSTALL/path/to/file.launch

path/to/file.launch is determined by the install rule in the CMakeLists.txt that actually installs the launch file.

Thanks @kyrofa. While searching for the ${CATKIN_PACKAGE_SHARE_DESTINATION} (where the launch files are installed to) in the snapcraft VM (I didn’t find it), I realized that the catkin plugins are using ${SNAPCRAFT_PART_SRC}/src as source workspace. So there’s this double src/src. Means that in my tries from before I changed the line in the wrong file. The override-pull is now working.

1 Like

Ah, good detective work! Thanks for sharing the solution :slight_smile: .