运用snap run --shell 来调试我们的应用

大家如果使用snap的话,你可以发现如下的命令:

liuxg@liuxg:~$ snap --help
Usage:
  snap [OPTIONS] <command>

The snap tool interacts with the snapd daemon to control the snappy software platform.


Application Options:
      --version  Print the version and exit

Help Options:
  -h, --help     Show this help message

Available commands:
  abort        Abort a pending change
  ack          Adds an assertion to the system
  buy          Buys a snap
  change       List a change's tasks
  changes      List system changes
  connect      Connects a plug to a slot
  create-user  Creates a local system user
  disable      Disables a snap in the system
  disconnect   Disconnects a plug from a slot
  download     Download a given snap
  enable       Enables a snap in the system
  find         Finds packages to install
  get          Get snap configuration
  help         Help
  install      Installs a snap to the system
  interfaces   Lists interfaces in the system
  known        Shows known assertions of the provided type
  list         List installed snaps
  login        Authenticates on snapd and the store
  logout       Log out of the store
  refresh      Refreshes a snap in the system
  remove       Removes a snap from the system
  revert       Reverts the given snap to the previous state
  run          Run the given snap command
  set          Set snap configuration
  try          Tests a snap in the system

大家可以发现一个叫做"run"的命令.在大多数的情况下,我们并不需要运行这个命令.它在我们运行应用的时候被自动调用.但是,它有一个选项"--shell"非常有用,可以帮助我们调试我们的应用.比如,我们可以通过如下的方式:

$ sudo snap try prime --devmode
$ cp /usr/bin/strace prime
$ sudo snap run --shell <snap.app>
$ (sudo) ./strace

这样我们就可以在一个shell中来调试我们的应用.我们以 https://github.com/liu-xiao-guo/helloworld-snap例子为例.在安装完我们的snap应用后.我们可以使用如下的命令查看我们的环境:

liuxg@liuxg:~$ env | grep SNAP
liuxg@liuxg:~$ sudo -S snap run --shell hello-xiaoguo.hello-world
[sudo] password for liuxg: 
root@liuxg:/home/liuxg# env | grep SNAP
SNAP_USER_COMMON=/root/snap/hello-xiaoguo/common
SNAP_REEXEC=
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:
SNAP_COMMON=/var/snap/hello-xiaoguo/common
SNAP_USER_DATA=/root/snap/hello-xiaoguo/x1
SNAP_DATA=/var/snap/hello-xiaoguo/x1
SNAP_REVISION=x1
SNAP_NAME=hello-xiaoguo
SNAP_ARCH=amd64
SNAP_VERSION=1.0
SNAP=/snap/hello-xiaoguo/x1

从上面我们可以看出来,在shell中已经有我们的snap的环境变量等信息.





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值