File 0002-dirs-account-for-openSUSE-Slowroll.patch of Package snapd
From 3c27d3d693e5c5464992833204042c0a778f8ebe Mon Sep 17 00:00:00 2001
Message-ID: <3c27d3d693e5c5464992833204042c0a778f8ebe.1726645765.git.maciej.borzecki@canonical.com>
From: Maciej Borzecki <maciej.borzecki@canonical.com>
Date: Tue, 17 Sep 2024 08:21:28 +0200
Subject: [PATCH] dirs: account for openSUSE Slowroll
openSUSE Slowroll is a less frequently updated variant of Tumbleweed.
However, it still carries its own unique ID="opensuse-slowroll" in
/etc/os-release and thus causes incorrect identification of the libexec
directory. See [1] for details.
1. https://forum.snapcraft.io/t/tumbleweed-snapd-service-wont-start/42148
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
---
dirs/dirs.go | 19 ++++++++++++++++---
dirs/dirs_test.go | 16 ++++++++++++++--
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/dirs/dirs.go b/dirs/dirs.go
index df57ce80f45f64c68d269e1069f5deaa2cb94b34..f1d441ee33fec1cfbbb1c641f77a10c35565da0c 100644
--- a/dirs/dirs.go
+++ b/dirs/dirs.go
@@ -552,27 +552,40 @@ func SetRootDir(rootdir string) {
LocaleDir = filepath.Join(rootdir, "/usr/share/locale")
ClassicDir = filepath.Join(rootdir, "/writable/classic")
- opensuseTWWithLibexec := func() bool {
+ opensuseFlavorWithLibexec := func() bool {
// XXX: this is pretty naive if openSUSE ever starts going back
// and forth about the change
+
+ if release.DistroLike("opensuse-slowroll") {
+ // Slowroll does not need further checks, it has used /usr/libexec
+ // since the start
+ return true
+ }
+
if !release.DistroLike("opensuse-tumbleweed") {
+ // Leap and the like, are there others?
return false
}
+
+ // TW snapshots are YYYYMMDD
v, err := strconv.Atoi(release.ReleaseInfo.VersionID)
if err != nil {
// nothing we can do here
return false
}
+
+ // TODO: drop? do we still care about such old snapshot?
// first seen on snapshot "20200826"
if v < 20200826 {
return false
}
+
return true
}
- if release.DistroLike("fedora") || opensuseTWWithLibexec() {
+ if release.DistroLike("fedora") || opensuseFlavorWithLibexec() {
// RHEL, CentOS, Fedora and derivatives, some more recent
- // snapshots of openSUSE Tumbleweed;
+ // snapshots of openSUSE Tumbleweed and Slowroll;
// both RHEL and CentOS list "fedora" in ID_LIKE
DistroLibExecDir = filepath.Join(rootdir, "/usr/libexec/snapd")
} else {
diff --git a/dirs/dirs_test.go b/dirs/dirs_test.go
index 39abbd017d6120871b43f982c3fb0c094f2b0264..e0aa31489cf8a39c8af75031e83e8b7b324107f3 100644
--- a/dirs/dirs_test.go
+++ b/dirs/dirs_test.go
@@ -262,8 +262,14 @@ func (s *DirsTestSuite) TestAddRootDirCallback(c *C) {
c.Assert(someDerivedVar, Equals, filepath.Join("/hello", "var", "snap", "other", "mnt"))
}
-func (s *DirsTestSuite) TestLibexecdirOpenSUSETW(c *C) {
- restore := release.MockReleaseInfo(&release.OS{ID: "opensuse-tumbleweed", VersionID: "20200820"})
+func (s *DirsTestSuite) TestLibexecdirOpenSUSEFlavors(c *C) {
+ restore := release.MockReleaseInfo(&release.OS{ID: "opensuse-leap",
+ IDLike: []string{"suse", "opensuse"}, VersionID: "15.6"})
+ defer restore()
+ dirs.SetRootDir("/")
+ c.Check(dirs.DistroLibExecDir, Equals, "/usr/lib/snapd")
+
+ restore = release.MockReleaseInfo(&release.OS{ID: "opensuse-tumbleweed", VersionID: "20200820"})
defer restore()
dirs.SetRootDir("/")
c.Check(dirs.DistroLibExecDir, Equals, "/usr/lib/snapd")
@@ -277,4 +283,10 @@ func (s *DirsTestSuite) TestLibexecdirOpenSUSETW(c *C) {
defer restore()
dirs.SetRootDir("/")
c.Check(dirs.DistroLibExecDir, Equals, "/usr/libexec/snapd")
+
+ // from https://forum.snapcraft.io/t/tumbleweed-snapd-service-wont-start/42148
+ restore = release.MockReleaseInfo(&release.OS{ID: "opensuse-slowroll", VersionID: "20240904"})
+ defer restore()
+ dirs.SetRootDir("/")
+ c.Check(dirs.DistroLibExecDir, Equals, "/usr/libexec/snapd")
}
--
2.46.0