tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg.refcount database as a flat file?

> Date: Sat, 11 Feb 2017 17:31:11 +0000
> From: "Johnny C. Lam" <>
> Over the years, has there been any discussion about changing the
> refcount database from a directory tree under /var/db/pkg.refcount
> to a text file, perhaps in structured format like JSON or a Lua
> table?

I'd be more inclined to use a sqlite3 database -- for this and the
rest of the pkgdb.

Atomic backup:  echo .backup /path/to/backup | sqlite3 /var/db/pkg.refcount
Diff:  diff -u <(echo .dump | sqlite3 old) <(echo .dump | sqlite3 new)
More advanced manipulation:  any SQL queries under the sun.

Updates become transactional, &c.  Can process with awk, e.g.:

echo 'select * from pkgrefcount' | sqlite3 | awk -F'|' ...

(This is subject to some constraints about the character `|', of
course; can get quoted CSV with `.mode csv'.)

There is, of course, a problem of gracefully transitioning any changes
to the file format in existing installations.

Home | Main Index | Thread Index | Old Index