I’m trying to package a ruby app and I need to rewrite the shebang of a program added using stage-packages. I do this using sed in a prepare block. The command runs and I can see the changes in parts/librarian-puppet/install/usr/bin/puppet but the changes aren’t present in my final snap.
Why are the changes not present in the final snap?
Is there documentation that explains the flow of a snapcraft build, what gets executed first, what gets staged, etc…?
I would do this by adding a new part which runs after your librarian-puppet part and modifies the file accordingly. You ensure that it runs after the librarian-puppet has been staged by specifying after: [librarian-puppet], and modify the file in $SNAPCRAFT_STAGE. I’ve changed the scriptlet to install though any of the three scriptlet stages will work:
The alternative way is to build puppet from source, do not include puppet as a stage-package, and mangle the shebang line before building using prepare on the source.
That doesn’t seem to work, but the issue is not that it gets overwritten. If I add touch $SNAPCRAFT_PART_INSTALL/usr/bin/puppet2 to the install script, the puppet2 file isn’t included in my snap… What am I missing?
Edit: Turns out I’ve been running snapcraft build instead of snapcraft. This is the second time that has tripped me up: snapcraft cleanbuild is in no way equal to snapcraft clean and snapcraft build… snapcraft build isn’t even a “non-clean” snapcraft cleanbuild, it’s an entirely different action.? -_-
PS: Is there an explanation somewhere about when what runs?
snapcraft cleanbuild is a complete run through the stages pull, build, stage, and prime using a brand-new “clean” LXC container so that you don’t trample on your local system.
snapcraft clean is a maintenance procedure that will clean your current project for times where you’ve built without cleanbuild.
snapcraft build will run the build step only, unless you have not run pull yet, in which case it will run only pull and then build. Running snapcraft build will not give you a .snap file when it finishes.