參考網頁:
ubuntu snap
編譯環境:
ubuntu 16.04以上系統
主要思想:
配置snapcraft.yaml文件,配置中之處編譯的工具,和編譯源碼的所在。下面是一個簡單的snap app。
mkdir hello-wmy/
cd hello-wmy/
touch snapcraft.yaml
vim snapcraft.yaml:
name: hello-wmy
version: "0.1"
summary: orbbec first snap app
description: puts up a square
confinement: strict
build-packages:
- gcc
apps:
hello-wmy:
# FIXME: remove opengl-launch once base wrappers set LIBGL_DRIVERS_PATH
command: hello-wmy
# Many apps do this instead, but it requires e.g. 'after: [desktop-gtk2]', which makes the snap huge
#command: desktop-launch $SNAP/bin/hellogl
parts:
hello-wmy:
source: .
plugin: cmake
vim CMakeLists.txt
PROJECT (HELLO)
SET(SRC_LIST hello-wmy.c)
ADD_EXECUTABLE(hello-wmy ${SRC_LIST})
install(TARGETS hello-wmy DESTINATION bin)
vim hell-wmy.c
#include <stdio.h>
void main()
{
printf("hello snaps.\n");
}
最好事先安裝CMake:apt-get install cmake
最後執行:sudo snapcraft
生成hello-wmy_0.1_amd64.snap 應用。
然後安裝這個snap app到本地:
sudo snap install hello-wmy_0.1_amd64.snap –dangerous
然後運行:hello-wmy 會出現打印:hello snaps。說明成功!
需要加入 –dangerous 配置,因爲現在這個snap沒有經過簽名。
如果提示沒有找到–dangerous這個配置,更新一下snapd這個工具包:
apt-get install snapd