1
apps:
  library-sample:
    command: library_sample

parts:
  library:
    source: https://github.com/the/sample.git
    plugin: cmake

当 snapcraft 运行cmake安装时,“库”将安装在系统上(如我所料)。另外,cmake还会在samples目录下的文件夹中生成一个测试应用程序build

我想将示例(由“部分”生成)推广为 snap 包中的已安装应用程序。

如何使用 snap YAML 从build文件夹下的嵌套目录移动到 snaps/bin文件夹?

4

1 回答 1

2

您可以通过使用 Snapcraft 的scriptlet来做到这一点。具体来说,installscriptlet。它们本质上允许您通过自定义构建过程的部分来修改构建过程的行为。在build生命周期步骤中,snapcraft 本质上是运行cmake && make && make install的,但make install不会做你想让它做的所有事情。installscriptlet 紧随其后运行,因此make install您可以执行以下操作:

parts:
  library:
    source: https://github.com/the/sample.git
    plugin: cmake
    install: |
      cp -r path/to/samples $SNAPCRAFT_PART_INSTALL/

现在清理构建步骤snapcraft clean -s build并再次运行snapcraft。然后示例目录将在最终快照中结束。

于 2017-04-18T22:21:15.377 回答