I have a part that only provides 2 files after the build process. This files are being built correctly, but I don’t want to use the standard stage process (autoconf plugin). But the following code doesn’t work:
override-stage: |
install -D -m0755 ../parts/openssl098/build/libssl.so.0.9.8 "usr/lib/libssl.so.0.9.8"
install -D -m0755 ../parts/openssl098/build/libcrypto.so.0.9.8 "usr/lib/libcrypto.so.0.9.8"
I can’t see what I’m doing wrong. Those files are not present on the final snap.
I wonder why you don’t want to use it? You may use the organize
keyword to re-arrange the location of the files in the part’s installdir, for more info check out:
snapcraft help plugins
Probably due to the fact that snapcraft keep track of all the files each part installs, but not including the ones you’ve install
ed to the stagedir manually via scriptlet and thus aren’t copied to the primedir during the prime
step(and thus not into the final snap).
If you really want to modify the content installed by a part you should use the override-build
scriptlet and operate the files installed in the installdir ($SNAPCRAFT_PART_INSTALL
, a.k.a. parts/part_name/install) to ensure it will be tracked by snapcraft:
override-build: |
snapcraftctl build
mkdir --parents $SNAPCRAFT_PART_INSTALL/usr/lib
mv $SNAPCRAFT_PART_INSTALL/lib/libssl.so.0.9.8 $SNAPCRAFT_PART_INSTALL/usr/lib
A good method to debug this is to run each step separately and inspect the resulting directory’s content using the tree
command to verify if the result is desirable:
snapcraft build _part_name_
tree parts/_part_name_/install | less
snapcraft stage _part_name_
tree stage | less
snapcraft prime _part_name_
tree prime | less
Like @Lin-Buo-Ren suggested, try using organize first.
organize:
openssl098/build: usr/lib
I do something similar with libraries I need inserted in my snap.
Cheers!
Well, after a big session of hit and miss, I’ve managed to make it work. The final part is:
openssl098:
plugin: autotools
source: https://github.com/openssl/openssl.git
source-type: git
source-depth: 1
source-branch: OpenSSL_0_9_8-stable
override-pull: |
snapcraftctl pull
patch -p0 < ../../../snap/openssl098/ca-dir.patch
patch -p0 < ../../../snap/openssl098/no-rpath.patch
sed -i '/^push(@INC/s|)|,".")|' crypto/des/asm/des-586.pl
override-build: |
./config --prefix="/usr" --openssldir="/etc/ssl" shared \
enable-md2 -Wa,--noexecstack
sed -i '/^CFLAG=/s/$/ $(CFLAGS)/' Makefile
make
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/lib
mv *.so.0.9.8 $SNAPCRAFT_PART_INSTALL/usr/lib
organize:
openssl098/install/usr/lib/*.so.0.9.8: usr/lib/
For some crazy reason, the make install part was not working as expected. That’s why I’m being forced to copy manually the final files to the final location.
Thanks for everyone that answered. Probably I’ll have to come back later with other issues =D