Snappy needs to influence environment variables in applications

Bug #1583259 reported by Zygmunt Krynicki on 2016-05-18
70
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Canonical Click Reviewers tools
Undecided
Jamie Strandboge
Snapcraft
Wishlist
Sergio Schvezov
Snappy
Undecided
Unassigned
snap-confine
Undecided
Unassigned
click-reviewers-tools (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned
Yakkety
Undecided
Unassigned

Bug Description

= SRU for snapcraft =
[Impact]

 * Adding an environment keyword to snapcraft.yaml, which will make it to snap.yaml which the launcher will use to setup the environment.
 * This reduces the amount of wrapper files.

[Test Case]

 1. Run `snapcraft` on the ros demo.
 2. Install the snap.
 3. snap should run. (if it doesn't it mostly likely means the environent was setup incorrectly).
 4. snap.yaml's `assumes` gets a `snap-run` tag.

[Regression Potential]

 * Very low. Environment that was previously setup by wrapper scripts could be missing when the launcher launches using the environment keyword.
 * The use of `assumes` will make sure this doesn't break people on older versions of snapd or snap-run

= SRU for click-reviewers-tools =
[Impact]
This is already fixed in the store so the SRU is for users to not see this failure their local system

[Test Case]
Run snap-review on the attached snap:

$ snap-review ./snap-example-env_0_all.snap
./snap-example-env_0_all.snap: pass

[ Regression Potential]
Regression potential is extremely low since this is already on production in the Ubuntu Store for many weeks.

= Original description =

We see a common pattern across many snaps, all apps are really using wrappers to set environment variables. I'd like to propose that this is exposed as first class feature in snapcraft (same like plugs and slots), snappy (where interfaces can affect variables and snappy can have sensible defaults) and ubuntu-core-launcher (to actually apply those variables to each started process).

As a bit of context, this is a wrapper for a non trivial but still common app: the calculator:

https://bazaar.launchpad.net/~ubuntu-desktop/+junk/gnome-calculator-snap/view/head:/calc#L3

The wrapper is 44 lines long, all of which set up environment variables.

Support environment variable that would be available to snaps. The form should look like

snapcraft.yaml

name: ...
version: ...
...
environment: # these apply to all snaps
   ENV1: value1
   ENV2: value2

apps:
   app1:
     ...
     environment:
        ENV1: value1 # takes precedence over global ones

These environment values would be transported to snap.yaml

tags: added: snap-desktop-issue
Changed in snapcraft:
milestone: none → 2.10
description: updated
Changed in snapcraft:
importance: Undecided → Wishlist
status: New → In Progress
assignee: nobody → Sergio Schvezov (sergiusens)
description: updated
description: updated
Changed in click-reviewers-tools:
assignee: nobody → Jamie Strandboge (jdstrand)
Changed in snapcraft:
milestone: 2.10 → 2.11
Jamie Strandboge (jdstrand) wrote :

review tools supports environment in r678. Requested a store pull.

Changed in click-reviewers-tools:
status: New → Fix Committed
Changed in snapcraft:
milestone: 2.12 → 2.13
Zygmunt Krynicki (zyga) wrote :

I think that snap-confine won't have to do anything to support this. It will happen automatically with snap-exec.

Changed in snap-confine:
status: New → Invalid
Changed in snapcraft:
milestone: 2.13 → 2.14
Changed in snapcraft:
status: In Progress → Triaged
Changed in snapcraft:
milestone: 2.13 → none
Jamie Strandboge (jdstrand) wrote :

Fixed review tools in upstream 0.44 and in 16.10.

Changed in click-reviewers-tools:
status: Fix Committed → Fix Released
Changed in click-reviewers-tools (Ubuntu Yakkety):
status: New → Fix Released
Changed in click-reviewers-tools (Ubuntu Xenial):
status: New → In Progress
description: updated
Jamie Strandboge (jdstrand) wrote :
description: updated
Leon (leonbo) wrote :

It would also be nice to be able to do something like:

environment:
  GOROOT: "$SNAP/usr/local/go"

or even:

environment:
  GOROOT: "$SNAP/$GOROOT"

Hello Zygmunt, or anyone else affected,

Accepted click-reviewers-tools into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/click-reviewers-tools/0.44~16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in click-reviewers-tools (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed
Jamie Strandboge (jdstrand) wrote :

$ click-review ~/Downloads/snap-example-env_0_all.snap
/home/jamie/Downloads/snap-example-env_0_all.snap: pass

This uses:
environment:
  TESTENV1: foo
  TESTENV2: foo

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package click-reviewers-tools - 0.44~16.04.1

---------------
click-reviewers-tools (0.44~16.04.1) xenial-proposed; urgency=medium

  [ Jamie Strandboge ]
  * data/apparmor-easyprof-ubuntu.json:
    - add pulseaudio interface
    - add bluetooth policy group for Touch for 15.04 and higher
    - add location-observe and location-control
    - move all core interfaces to 'common'
    - add gsettings interface
    - set home to auto-approve
    - add mpris interface
    - add camera interface
    - add optical-drive interface
    - add serial-port interface
    - add content interface
  * clickreviews/common.py:
    - don't fail on libmvec.so since it comes from libc6 too (LP: #1584346)
    - extend the regex to also match ld-linux-x86-64.so.2
  * sr_common.py:
    - update _verify_pkgname() and _verify_appname() to use the same regex as
      in snapd and various tests
    - update attributes to be slots or plugs side and cleanup code for
      specifying attributes
  * bin/click-review, clickreviews/modules.py: exit '1' if error with
    init_object or running checks
  * sr_lint.py:
    - support 'environment' key in yaml (LP: #1583259)
    - support 'confinement' key in yaml
  * sr_security.py:
    - specifying mpris slot should not warn
    - adjust profile name length checks to use series 16 security label format
  * run_tests: exit non-zero with failures, errors or unexpectedSuccesses
  * cr_lint.py:
    - 'puritine' is a known, but redflagged hook
    - skip external symlinks and md5sums checks for puritine (since we expect
      external symlinks and the hash checks fail on broken symlinks)
    - 'puritine' hook should not be used with 'apparmor'
  * clickreviews/apparmor_policy.py: adjust for rename of store team
    (LP: #1608943)

  [ Celso Providelo ]
  * support for interface abbreviated syntax (LP: #1595184)

 -- Jamie Strandboge <email address hidden> Tue, 02 Aug 2016 08:43:31 -0500

Changed in click-reviewers-tools (Ubuntu Xenial):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for click-reviewers-tools has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Michael Vogt (mvo) on 2016-11-29
Changed in snappy:
status: New → Fix Released
Changed in snapcraft:
status: Triaged → In Progress
milestone: none → 2.27
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers