portsdb unnecessarily recreated
Maks Verver
maksverver at geocities.com
Mon Mar 5 07:42:06 UTC 2012
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.
More information about the freebsd-ruby
mailing list