Pino Toscano
2020-Aug-26 16:57 UTC
[Libguestfs] [supermin PATCH] rpm: check for SQLite-based RPM DB
Fedora 33 switched the DB of RPM to SQLite, so no more Packages/Name/etc files. Because any missing file exception is ignored when checking for --if-newer, the lack of the Package files was not properly noticed, so the appliance was always considered out out date. Check for the SQLite-based DB first, falling back to the old format. Signed-off-by: Pino Toscano <ptoscano@redhat.com> --- src/ph_rpm.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml index dbe3bda..0821126 100644 --- a/src/ph_rpm.ml +++ b/src/ph_rpm.ml @@ -234,7 +234,10 @@ let rpm_package_name pkg rpm.name let rpm_get_package_database_mtime () - (lstat "/var/lib/rpm/Packages").st_mtime + try + (lstat "/var/lib/rpm/rpmdb.sqlite").st_mtime + with Unix_error (ENOENT, _, _) -> + (lstat "/var/lib/rpm/Packages").st_mtime (* Return the best provider of a particular RPM requirement. * -- 2.26.2
Richard W.M. Jones
2020-Aug-26 19:15 UTC
Re: [Libguestfs] [supermin PATCH] rpm: check for SQLite-based RPM DB
On Wed, Aug 26, 2020 at 06:57:43PM +0200, Pino Toscano wrote:> Fedora 33 switched the DB of RPM to SQLite, so no more Packages/Name/etc > files. Because any missing file exception is ignored when checking for > --if-newer, the lack of the Package files was not properly noticed, so > the appliance was always considered out out date. > > Check for the SQLite-based DB first, falling back to the old format. > > Signed-off-by: Pino Toscano <ptoscano@redhat.com> > --- > src/ph_rpm.ml | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml > index dbe3bda..0821126 100644 > --- a/src/ph_rpm.ml > +++ b/src/ph_rpm.ml > @@ -234,7 +234,10 @@ let rpm_package_name pkg > rpm.name > > let rpm_get_package_database_mtime () > - (lstat "/var/lib/rpm/Packages").st_mtime > + try > + (lstat "/var/lib/rpm/rpmdb.sqlite").st_mtime > + with Unix_error (ENOENT, _, _) -> > + (lstat "/var/lib/rpm/Packages").st_mtime > > (* Return the best provider of a particular RPM requirement.Yes this looks fine, ACK. If you really wanted you could factor out the (...).st_mtime, something like: (try lstat "/var/lib/rpm/rpmdb.sqlite" with Unix_error (ENOENT, _, _) -> lstat "/var/lib/rpm/Packages" ).st_mtime Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Pino Toscano
2020-Aug-27 04:50 UTC
Re: [Libguestfs] [supermin PATCH] rpm: check for SQLite-based RPM DB
On Wednesday, 26 August 2020 21:15:36 CEST Richard W.M. Jones wrote:> On Wed, Aug 26, 2020 at 06:57:43PM +0200, Pino Toscano wrote: > > Fedora 33 switched the DB of RPM to SQLite, so no more Packages/Name/etc > > files. Because any missing file exception is ignored when checking for > > --if-newer, the lack of the Package files was not properly noticed, so > > the appliance was always considered out out date. > > > > Check for the SQLite-based DB first, falling back to the old format. > > > > Signed-off-by: Pino Toscano <ptoscano@redhat.com> > > --- > > src/ph_rpm.ml | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml > > index dbe3bda..0821126 100644 > > --- a/src/ph_rpm.ml > > +++ b/src/ph_rpm.ml > > @@ -234,7 +234,10 @@ let rpm_package_name pkg > > rpm.name > > > > let rpm_get_package_database_mtime () > > - (lstat "/var/lib/rpm/Packages").st_mtime > > + try > > + (lstat "/var/lib/rpm/rpmdb.sqlite").st_mtime > > + with Unix_error (ENOENT, _, _) -> > > + (lstat "/var/lib/rpm/Packages").st_mtime > > > > (* Return the best provider of a particular RPM requirement. > > Yes this looks fine, ACK. If you really wanted you could factor out > the (...).st_mtime, something like: > > (try > lstat "/var/lib/rpm/rpmdb.sqlite" > with Unix_error (ENOENT, _, _) -> > lstat "/var/lib/rpm/Packages" > ).st_mtimeACK. Sadly List.find_map is OCaml 4.10.0+ only. Should I backport it to stable-5.2? -- Pino Toscano
Possibly Parallel Threads
- [supermin PATCH] rpm: check for SQLite-based RPM DB
- Re: [supermin PATCH] rpm: check for SQLite-based RPM DB
- [supermin PATCH 0/5] rpm: fix package selection w/ multilib
- [supermin PATCH] rpm: support openSUSE Leap 15
- [supermin PATCH] rpm: generalize openSUSE support