Ubuntu – How to apply a patch on upstream source code while snapcraft build

packagingpatchsnap

I used to build Debian packages (quilt), it supports applying patches while build process. Patches are stored in debian/patches folder and they are usually used to add fixes not committed yet to the upstream source or add specific platform tunning.

My case is a package that needs custom build command:

make build; make install_api; make install_desktop

instead of standard way:

make; make install

Current proposed solution is to:

  • modify Makefile and add default: & install: entries.

The error got when running snapcraft --no-parallel-build without modifying source:

make install DESTDIR=/home/username/Desktop/sandbox/alfanous-snap/parts/alfanous-git/install
make: *** No rule to make target 'install'.  Stop.
Command '['/bin/sh', '/tmp/tmp_f_u1ktl', 'make', 'install', 
 'DESTDIR=/home/username/Desktop/sandbox/alfanous-snap/parts/alfanous-git/install']'
 returned non-zero exit status 2

So, is there any way to add a patch to snapcraft build? I'm open to any other solution/workaround.

Best Answer

This sounds like a good case for snapcraft "scriptlets". The build: stanza will let you replace the build step with your own shell commands (make build; make install_api; make install_desktop).

Related Question