Date: Sun, 30 Mar 2014 16:12:19 +0200 (CEST) From: Christoph Moench-Tegeder <cmt@burggraben.net> To: FreeBSD-gnats-submit@freebsd.org Subject: ports/188084: ports-mgmt/portupgrade : not working without ruby-bdb Message-ID: <20140330141219.935FA301CA@elch.exwg.net> Resent-Message-ID: <201403301420.s2UEK0Vf045104@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 188084 >Category: ports >Synopsis: ports-mgmt/portupgrade : not working without ruby-bdb >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 30 14:20:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Christoph Moench-Tegeder >Release: FreeBSD 10.0-RELEASE amd64 >Organization: >Environment: System: FreeBSD elch.exwg.net 10.0-RELEASE FreeBSD 10.0-RELEASE #2 r260689: Wed Jan 15 18:32:44 CET 2014 cmt@elch.exwg.net:/usr/obj/usr/src/sys/ELCH amd64 portupgrade-2.4.12,2 ports-mgmt/portupgrade >Description: When upgrading my ruby stack to ruby 2.1, I disconvered that ruby-bdb is utterly broken with recent versions of ruby (ports/188083). Trying to use portupgrade without ruby-bdb gave me : /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgdbtools.rb:104:in `rescue in db_driver=': uninitialized constant PkgDBTools::DBError (NameError) : from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgdbtools.rb:63:in `db_driver=' : from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/portsdb.rb:168:in `setup' : from /usr/local/lib/ruby/site_ruby/2.1/pkgtools/pkgtools.rb:242:in `init_pkgtools_global' : from /usr/local/sbin/portupgrade:530:in `block in main' : from /usr/local/lib/ruby/2.1/optparse.rb:880:in `initialize' : from /usr/local/sbin/portupgrade:237:in `new' : from /usr/local/sbin/portupgrade:237:in `main' : from /usr/local/sbin/portupgrade:2371:in `<main>' so I set out to integrate yet another dbm into portupgrade. I happened to choose qdbm, which may not have been such a good idea, as ruby-qdbm itself is quite behind current ruby and needed patching, too (ports/188079). I'm proposing three patches: 1. do not try to use databases/ruby-bdb when on ruby 2.1 (it's already blacklisted for ruby 2.0) 2. explicitly stringify port_info when inserting it @db (portsdb.rb l.598) - some databases do not do that implicitly 3. switch pkgtools to using qdbm (even as a default). I'm open to discussion and suggestions on this one (what DBM does the ruby community prefer these days?), as I'm not feeling too good about qdbm myself (see above). For the same reason I've not added ruby-qdbm as a dependency to portupgrade's Makefile. >How-To-Repeat: >Fix: Part 1, blacklist ruby-bdb for ruby 2.1: Index: Makefile =================================================================== --- Makefile (revision 349592) +++ Makefile (working copy) @@ -38,8 +38,8 @@ INSTALL_TARGET+= install-doc .endif -# Reported that ruby-bdb is BROKEN with 2.0 -.if ${RUBY_VER} != 2.0 +# Reported that ruby-bdb is BROKEN with 2.0 and 2.1 +.if ${RUBY_VER} != 2.0 && ${RUBY_VER} != 2.1 # For PKG_DBDRIVER={bdb_btree,bdb_hash} RUN_DEPENDS+= ${RUBY_SITEARCHLIBDIR}/bdb.so:${PORTSDIR}/databases/ruby-bdb .endif Patches to be applied to the pkgtools source (not the port): Part 2, explicitly stringify port_info: --- lib/pkgtools/portsdb.rb.orig 2014-03-30 15:42:56.000000000 +0200 +++ lib/pkgtools/portsdb.rb 2014-03-30 15:46:49.000000000 +0200 @@ -595,7 +595,7 @@ @origins << origin @pkgnames << pkgname - @db[origin] = port_info + @db[origin] = port_info.to_s @db[pkgname.to_s] = origin rescue => e STDERR.puts index_file + ":#{lineno}:#{e.message}" Part 3, switch to qdbm: --- lib/pkgtools/pkgdbtools.rb.orig 2014-03-30 15:42:40.000000000 +0200 +++ lib/pkgtools/pkgdbtools.rb 2014-03-30 15:49:38.000000000 +0200 @@ -61,7 +61,7 @@ def db_driver=(new_db_driver) begin - case new_db_driver || ENV['PKG_DBDRIVER'] || 'bdb_btree' + case new_db_driver || ENV['PKG_DBDRIVER'] || 'qdbm' when 'pkg' @db_driver = :pkg when 'bdb_btree' @@ -72,6 +72,8 @@ @db_driver = :bdb1_btree when 'bdb1_hash', 'hash', 'bdb1' @db_driver = :bdb1_hash + when 'qdbm' + @db_driver = :qdbm else @db_driver = :dbm_hash end @@ -95,6 +97,9 @@ next_driver = 'dbm' require 'bdb1' @db_params = ["set_pagesize" => 1024, "set_cachesize" => 32 * 1024] + when :qdbm + next_driver = 'dbm' + require 'depot' else next_driver = nil require 'dbm' @@ -200,6 +205,9 @@ db = BDB1::Btree.open @db_file, mode, perm, *@db_params when :bdb1_hash db = BDB1::Hash.open @db_file, mode, perm, *@db_params + when :qdbm + qmode = mode == 'r' ? Depot::OREADER : (Depot::OWRITER | Depot::OCREAT) + db = Depot::new(@db_file, qmode, perm) else if mode == 'w+' File.unlink(@db_file) if File.exist?(@db_file) --- etc/pkgtools.conf.orig 2014-03-30 16:02:36.000000000 +0200 +++ etc/pkgtools.conf 2014-03-30 16:03:06.000000000 +0200 @@ -130,7 +130,7 @@ # failed too, it will fall to 'dbm_hash' that require no external # modules. # Possible values for ENV['PKG_DBDRIVER'] are bdb_btree, bdb_hash, - # bdb1_btree, bdb1_hash and dbm_hash. + # bdb1_btree, bdb1_hash, dbm_hash and qdbm. # # e.g.: # ENV['PORTSDIR'] ||= '/export/freebsd/ports' Any thought? Best Regards, Christoph >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140330141219.935FA301CA>