summaryrefslogtreecommitdiff
path: root/recipes-support/snapd/files/0002-cmd-snap-do-not-allow-classic-snaps-on-other-distrib.patch
blob: b78eec0f038d183d18a524c0185c1cea7ce0aedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 24616e1c2b8ade1700ee77dc9549ae839addebf6 Mon Sep 17 00:00:00 2001
From: Simon Fels <simon.fels@canonical.com>
Date: Mon, 27 Mar 2017 10:17:03 +0200
Subject: [PATCH 2/4] cmd/snap: do not allow classic snaps on other
 distributions

As of right now classic snaps are not supported on other distributions
than Ubuntu or Debian. This is because of those not allowing us to have
a global /snap directory, so its moved into /var/lib/snapd/snap instead.

The changed /snap directory breaks classic snaps as those have static
paths hardcoded to binaries/libraries in /snap for the sake of the
linker to work.
---
 cmd/snap/cmd_snap_op.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/cmd/snap/cmd_snap_op.go b/cmd/snap/cmd_snap_op.go
index 50095f4..fb86b41 100644
--- a/cmd/snap/cmd_snap_op.go
+++ b/cmd/snap/cmd_snap_op.go
@@ -36,6 +36,7 @@ import (
 	"github.com/snapcore/snapd/i18n"
 	"github.com/snapcore/snapd/osutil"
 	"github.com/snapcore/snapd/progress"
+	"github.com/snapcore/snapd/release"
 )
 
 func lastLogStr(logs []string) string {
@@ -438,6 +439,14 @@ func (x *cmdInstall) installOne(name string, opts *client.SnapOptions) error {
 	var installFromFile bool
 	var changeID string
 
+	switch release.ReleaseInfo.ID {
+	case "fedora", "centos", "rhel", "opensuse", "suse":
+		if opts.Classic {
+			fmt.Fprintf(Stderr, i18n.G("snap %q can not be installed as classic snaps are not supported on your distribution\n"), name)
+			return nil
+		}
+	}
+
 	cli := Client()
 	if strings.Contains(name, "/") || strings.HasSuffix(name, ".snap") || strings.Contains(name, ".snap.") {
 		installFromFile = true
-- 
2.7.4