From owner-freebsd-ruby@FreeBSD.ORG Mon Mar 5 07:42:06 2012 Return-Path: Delivered-To: ruby@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0E397106564A for ; Mon, 5 Mar 2012 07:42:06 +0000 (UTC) (envelope-from maksverver@geocities.com) Received: from smtp.utwente.nl (smtp1.utsp.utwente.nl [130.89.2.8]) by mx1.freebsd.org (Postfix) with ESMTP id 7B3F18FC22 for ; Mon, 5 Mar 2012 07:42:04 +0000 (UTC) Received: from heaven.student.utwente.nl (heaven.student.utwente.nl [130.89.167.52]) by smtp.utwente.nl (8.12.10/SuSE Linux 0.7) with SMTP id q257CSc5026643 for ; Mon, 5 Mar 2012 08:12:28 +0100 Date: Mon, 5 Mar 2012 08:12:29 +0100 From: Maks Verver To: ruby@FreeBSD.org Message-Id: <20120305081229.16c44187.maksverver@geocities.com> X-Mailer: Sylpheed 3.1.2 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-From: maksverver@geocities.com X-Spam-Status: No Cc: Subject: portsdb unnecessarily recreated X-BeenThere: freebsd-ruby@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD-specific Ruby discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Mar 2012 07:42:06 -0000 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.