name: my-lib
apps:
library-sample:
command: library_sample $SNAP/arg_file.json
parts:
library:
source: https://github.com/the/sample.git
plugin: cmake
install: |
cp -r samples/library_sample $SNAPCRAFT_PART_INSTALL/
cp -r ../src/samples/src/arg_file.json $SNAPCRAFT_PART_INSTALL/
cp --parents modules/dep_lib1/libdep_lib1.so $SNAPCRAFT_PART_INSTALL/
cp --parents modules/dep_lib2/libdep_lib2.so $SNAPCRAFT_PART_INSTALL/
当我创建这个快照时,我可以运行my-lib.library_sample
. 但是,当示例尝试使用相对路径加载依赖库时,使用该路径会失败./modules/dep_lib1/libdep_lib1.so
我的安装文件夹看起来像我预期的那样:
parts/library/install/
|-- arg_file.json
|-- library-sample
|-- include
| |-- ...
|-- lib
| |-- ...
|-- modules
|-- dep_lib1
| |-- libdep_lib1.so
|-- dep_lib2
|-- libdep_lib2.so
如果您查看command:
for library-sample:
,您会发现我需要在相对路径前面加上前缀$SNAP
,以便arg_file.json
正确加载示例。但是,我无法在参数文件中为依赖库指定相对路径。
如何从 snap 包中解析相对路径?