28 Commits

Author SHA1 Message Date
Maciej Borzecki
0dd7e2f4e2 .github/workflows, advisor, packaging: switch to go.etcd.io/bbolt (#13804)
* go: add go.etcd.io/bbolt@1.3.9

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* advisor: switch to go.etcd.io/bbolt, since github.com/boltdb/bolt is no longer maintained

The upstream boltdb repository at https://github.com/boltdb/bolt is no longer
maintained and has been archived. The community has moved to forks, where
https://github.com/etcd-io/bbolt seems to be the one with most use.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* packaging/fedora: switch to go.etcd.io/bbolt

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* packaging/debian-sid: require bbolt

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* advisor: drop nobolt variant

Since we've switched to a different upstream, nobolt variant is no longer
needed.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* packaging/debian-sid: drop nobolt hacks

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* github: drop nobolt unit test variant

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* github: add missing newline

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

---------

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-11 16:33:37 +02:00
Zygmunt Bazyli Krynicki
b8e9bed636 many: allow building without bolt using nobolt tag (#13534)
* 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>
2024-02-07 13:48:42 +01:00
Michael Vogt
18f82a8a71 advisor: add a small unittest
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.
2023-07-10 10:52:47 +02:00
Samuele Pedroni
d7479b55d1 many: rename MakeRandomString to just RandomString 2020-02-03 19:02:21 +01:00
Samuele Pedroni
38e08b845c many: drop and replace strutil.MakeRandomString as appropriate 2020-02-03 14:43:35 +01:00
John R. Lenton
dfb7118ec9 advise: make the bolt database do the atomic rename dance
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).
2018-07-31 16:05:26 +01:00
John R. Lenton
3e723687b5 advisor, overlord/snapstate: address review feedback (thanks @zyga, @bboozzoo) 2018-04-06 15:40:23 +01:00
Michael Vogt
d826fa9e2f advisor: use json for package database, refactor/simplify code (use advisor.Package everyhwere) 2018-04-05 08:54:31 +02:00
Michael Vogt
116465b755 advisor: make package database use json as well 2018-04-05 08:49:04 +02:00
Michael Vogt
1f0fdf504b advisor,overlord: fix tests, remove some dead code 2018-04-05 08:34:29 +02:00
Michael Vogt
63858fa2c9 advisor: use json in the bolt-db 2018-04-04 17:56:39 +02:00
Michael Vogt
bbfd40c842 Merge remote-tracking branch 'upstream/master' into snap-advice-command-versions 2018-04-04 17:22:13 +02:00
Michael Vogt
bc24c87e9d advisor: add comment why osutil.FileExists(dirs.SnapCommandsDB) is needed 2018-03-23 09:33:22 +01:00
Michael Vogt
c9be8416e4 advisor: deal with missing commands.db file
If the commands.db file is missing the various advisor commands
should simply return an empty result instead of an error.

See https://forum.snapcraft.io/t/var-cache-snapd-commands-db-permission-denied/4590/8
2018-03-22 16:07:28 +01:00
Michael Vogt
9f607f1ff3 snap, store: store version numbers in the commands database 2018-03-15 10:10:59 +01:00
Maciej Borzecki
2661786d9e advisor: do not copy the instances of bolt.DB
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>
2018-03-14 09:13:43 +01:00
Michael Vogt
6616e03e89 advisor: ensure commands.db has mode 0644 and add test
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.
2018-02-02 09:18:26 +01:00
Michael Vogt
ac14cf9239 Merge pull request #4459 from mvo5/snap-advise-snap
snap: add support for `snap advise-snap pkgName`
2018-02-01 09:41:06 +01:00
Michael Vogt
f045cbda14 address review feedback 2018-01-31 21:24:07 +01:00
Michael Vogt
f7cb2d49d3 advisor: use forked bolt to make it work on ppc 2018-01-18 18:50:55 +01:00
Michael Vogt
ba6de1fb2c address review feedback 2018-01-09 16:08:35 +01:00
Michael Vogt
0e3e82e363 advisor: add missing pkgadvisor.go 2018-01-09 12:11:30 +01:00
Michael Vogt
21e7df66e0 snap: add support for snap advice-snap pkgName
This implements `snap advice-snap <pkgName>` and will give useful
advise if the given pkgname is available in the store.
2018-01-09 11:30:34 +01:00
John R. Lenton
2091a995d4 typo, and reviewe feedback (thanks mvo) 2018-01-04 17:36:42 +00:00
John R. Lenton
1073dd5f29 many: implement the advisor backend, populate it from the store
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.
2018-01-04 13:41:22 +00:00