* many: allow building without bolt using nobolt tag
Bolt is an abandoned project. Upstream is not accepting any patches.
Debian has three versions of bolt, none of which build on riscv64 due to
the lack of appropriate architecture tags.
In Debian, bolt is not built from the vendored package but instead from
the distribution package, one of three in the archive, each capturing a
different, outdated and differently patched fork.
Fortunately, bolt is not really heavily used in snapd. While we try to
address the issue regarding bolt and riscv64, we can continue to build
snapd on riscv64 without the ability to store information only used by
command-not-found helpers.
Allow advisor to fail with advisor.ErrNotSupported when snapd is built without
bolt support. Tests for the store, overlord package and the "snap advise"
command are adjusted to skip certain tests when that error is returned.
Debian-Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010686
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* advisor: adjust error message
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* tests: run unit tests for nobolt build tag
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* packaging: drop bolt from debian dependencies
With the ability to build snapd without bolt support, we can drop the patch
responsible for using non-forked bolt. Bolt is really only needed by the
advisor package, which is used and consumed as a command-not-found data set.
None of that is effective on Debian, making maintenance easier.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* packaging: do not use bolt on Debian
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
---------
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Now that we have the codecov metrics back I noticed that the
advisor/backend.go code has no tests for the rollback functionality.
This commit adds a simple testcase.
Before this change, `advise.Create` was opening the commands database
and holding it open while querying the store and repopulating it, which
blocked concurrent read-only clients (as returned by `advise.Open`).
This change instead has `advise.Create` write to a new database every
time, which is then renamed after Close using the atomic dance. This
together with the 1s timeout on `advise.Open` should minimise the
unavailability of `snap advise` results that were impacting the apt
integration test (and, possibly, users).
Fixes vet warning:
advisor/backend.go:199: literal copies lock value from *db: github.com/snapcore/snapd/vendor/github.com/snapcore/bolt.DB contains sync.Pool contains sync.noCopy
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
When running bolt.Open() even in readonly mode the DB file will
be created if it is missing. Our read-only advisor.Open() uses
mode 0600 to open the Db in read-only mode. This means that if
a root user triggers command-not-found and the DB file is not
yet downloaded the DB is created with 0600. This happend during
manual testing. This PR switches permissions to 0644. It also
adds a test to ensure that the file has the correct permissions.
This adds the backend to the advisor, and fills the backend from the
store via the existing catalog refresh call.
It uses boltdb as the actual backend.