Skip to content

Commit

Permalink
Ensure database creation on initial installation
Browse files Browse the repository at this point in the history
Disabling implicit database creation on read-only handles in commit
afbc2b0 broke number of handy
use-cases such as install to an empty chroot directory, both with
rpm itself and dnf/yum at least, probably others too.

This minimally resurrects the desired part of the behavior: if people are
asking us to install something, creating a missing database is probably
okay to create without requiring an explicit --initdb action first.
It'll still spit some ugly errors from trying to load the keyring but
at least it'll work. The harmless errors we can try to deal with
separately later on.
  • Loading branch information
pmatilai committed Apr 16, 2021
1 parent 42f53a1 commit 86f593d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/depends.c
Expand Up @@ -4,6 +4,8 @@

#include "system.h"

#include <fcntl.h>

#include <rpm/rpmlib.h> /* rpmVersionCompare, rpmlib provides */
#include <rpm/rpmtag.h>
#include <rpm/rpmlog.h>
Expand Down Expand Up @@ -414,6 +416,10 @@ static int addPackage(rpmts ts, Header h,
if (isSource)
op = RPMTE_INSTALL;

/* Ensure database creation on initial installs */
if (!isSource && rpmtsGetDBMode(ts) == O_RDONLY)
rpmtsSetDBMode(ts, (O_RDWR|O_CREAT));

/* Do lazy (readonly?) open of rpm database for upgrades. */
if (op != RPMTE_INSTALL && rpmtsGetRdb(ts) == NULL && rpmtsGetDBMode(ts) != -1) {
if ((ec = rpmtsOpenDB(ts, rpmtsGetDBMode(ts))) != 0)
Expand Down

0 comments on commit 86f593d

Please sign in to comment.