在我先前的一个例程webcam中,我们的snapcraft.yaml显示如下:
name: webcam-app
version: "1.0"
summary: Webcam app for snappy ubuntu core
description: Exposes your webcam and access using a Ubuntu phone app called "webcamapp"
confinement: strict
apps:
webcam:
command: bin/webcamserv
daemon: simple
plugs: [camera,network,network-bind]
sh:
command: bin/sh
parts:
cam:
plugin: go
source: https://github.com/liu-xiao-guo/webcamserv
source-type: git
stage-packages:
- fswebcam
filesets:
fswebcam:
- usr/bin/fswebcam
- lib
- usr/lib
go-server:
- bin/webcam*
snap:
- $fswebcam
- $go-server
glue:
plugin: copy
files:
webcam: bin/webcam
capture: bin/capture
./bin/sh: bin/sh
我们使用了copy plugin来拷贝我们的文件.如果我们编译我们的项目的话,你就会发现:
liuxg@liuxg:~/temp/webcam$ snapcraft
"grade" property not specified: defaulting to "stable"
DEPRECATED: The 'copy' plugin's functionality has been replaced by the 'dump' plugin, and it will soon be removed.
它建议我们使用dump plugin来替换.关于plugin的更多的技术细节,我们可以在 http://snapcraft.io/docs/reference/plugins/地址找到.我们可以找到dump plugin的技术细节 http://snapcraft.io/docs/reference/plugins/dump:
This plugin just dumps the content from a specified source.
In the cases where dumping the content needs some mangling or organizing one would take advantage of the core functionalities available to plugins such as: filesets, stage, snap and organize.
在上面的网址,我们可以找到很多例程来参考.针对我们的例子,我们可以有如下的方案:
方案一:
我们把我们项目中的webcam及capture两个执行文件移到我们的bin目录下,这样整个的项目文件如下:
liuxg@liuxg:~/snappy/desktop/webcam$ tree
.
├── bin
│ ├── capture
│ ├── sh
│ └── webcam
└── snapcraft.yaml
接下来,我们通过修改我们的snapcraft.yaml:
glue:
plugin: dump
source: .
liuxg@liuxg:~/snappy/desktop/webcam/prime$ tree -L 3
.
├── bin
│ ├── capture
│ ├── sh
│ ├── webcam
│ └── webcamserv
├── command-sh.wrapper
├── command-webcam.wrapper
├── lib
│ └── x86_64-linux-gnu
│ ├── libexpat.so.1 -> libexpat.so.1.6.0
│ ├── libexpat.so.1.6.0
│ ├── libpng12.so.0 -> libpng12.so.0.54.0
│ └── libpng12.so.0.54.0
├── meta
│ └── snap.yaml
└── usr
├── bin
│ └── fswebcam
└── lib
├── gcc
└── x86_64-linux-gnu
方案二:
如果我们不想把我们的webcam和capture移动到我们的bin目录下,那么我们怎么办呢?我们可以通过利用organize的方法来做.具体实践,我们可以参阅一个例程:
我们把我们的snapcraft.yaml的文件修改为:
glue:
plugin: dump
source: .
organize:
webcam: bin/webcam
capture: bin/capture
stage:
- bin/webcam
- bin/capture
- bin/sh
snap:
- bin/webcam
- bin/capture
- bin/sh
编译完我们的项目后,我们可以重新看到我们的包里的内容:
glue:
plugin: dump
source: .
organize:
webcam: bin/webcam
capture: bin/capture
stage:
- bin/webcam
- bin/capture
- bin/sh
snap:
- bin/webcam
- bin/capture
- bin/sh
glue:
plugin: dump
source: .
organize:
webcam: bin/webcam
capture: bin/capture
我们也可以把上面的代码更进一步修改为:
glue:
plugin: dump
source: .
organize:
'*': bin/
这样我么可以把我们当前目录下的所有的文件安装到我们的bin目录下.