Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Mar 2012 08:12:29 +0100
From:      Maks Verver <maksverver@geocities.com>
To:        ruby@FreeBSD.org
Subject:   portsdb unnecessarily recreated
Message-ID:  <20120305081229.16c44187.maksverver@geocities.com>

next in thread | raw e-mail | index | archive | help
Hi,

I noticed that when the pkgtools need to update the portsdb but the
default location (/usr/ports) is not writable and PKG_DBDIR doesn't
specify a suitable alternative, they automatically create a new version
in /var/db/pkg instead.

This is already a bit dubious because it leads to silent duplication
of data: when the original database in /usr/ports is updated, a 40+ MB
file will perpetually linger in /var/db/pkg for no purpose whatever.

But that's not what I'm writing to complain about.  Another problem is
that this alternative database is recreated every time any of the
pkgtools are invoked, because the check whether the database is
up-to-date only occurs before (and not after) selecting the alternate
location.

This doesn't break anything but makes the tools excruciatingly slow
(especially tools like ports_glob which are supposed to be reasonably
fast). This problem is easily fixed by something like this:

--- /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb
+++ /usr/local/lib/ruby/site_ruby/1.8/portsdb.rb
@@ -537,6 +537,8 @@ 
     select_db_dir(force) or raise "No directory available for portsdb!"
 
+    !force && up_to_date? and return false
+
     prev_sync = STDERR.sync
     STDERR.sync = true

I think this also fixes another bug, namely that select_db_dir will
(correctly) select a read-only directory if it contains an up-to-date
database, but then update_db will fail because it (incorrectly) tries
to recreate it.

Kind regards,
Maks Verver.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120305081229.16c44187.maksverver>