=== modified file 'debian/changelog'
--- debian/changelog	2014-12-12 22:02:20 +0000
+++ debian/changelog	2017-04-24 20:23:36 +0000
@@ -1,3 +1,10 @@
+dhelp (0.6.21+nmu6ubuntu1) UNRELEASED; urgency=medium
+
+  * Migrate to a module from the standard library
+    - Remove ruby-bdb dependency
+
+ -- Nicholas Guriev <guriev-ns@ya.ru>  Mon, 24 Apr 2017 23:21:54 +0300
+
 dhelp (0.6.21+nmu6) unstable; urgency=medium
 
   * Non-maintainer upload.

=== modified file 'debian/control'
--- debian/control	2014-05-18 13:18:39 +0000
+++ debian/control	2017-04-24 20:20:58 +0000
@@ -11,7 +11,7 @@
 Package: dhelp
 Depends: perl-modules, libtemplate-perl, libhtml-parser-perl,
  liburi-perl, liblocale-gettext-perl, libdata-page-perl,
- ruby | ruby-interpreter, ruby-bdb, ruby-debian, ruby-gettext,
+ ruby | ruby-interpreter, ruby-debian, ruby-gettext,
  doc-base, swish++, pstotext, poppler-utils, ucf (>= 0.8),
  ${misc:Depends}
 Recommends: www-browser | html2text

=== modified file 'devtools/list-dirs.rb'
--- devtools/list-dirs.rb	2012-06-12 21:50:00 +0000
+++ devtools/list-dirs.rb	2017-04-24 19:50:51 +0000
@@ -2,7 +2,7 @@
 
 path = ARGV.shift || Dhelp::DOC_DIR_DATABASE
 puts "Opening #{path}"
-ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, path)
+ddd = Dhelp::DocDirDatabase.open(DBM::READER, path)
 ddd.each do |dir, doc_id, title|
   puts "#{dir} -> #{doc_id} (#{title})"
 end

=== modified file 'lib/dhelp.rb'
--- lib/dhelp.rb	2014-05-18 13:18:39 +0000
+++ lib/dhelp.rb	2017-04-24 19:57:08 +0000
@@ -18,7 +18,7 @@
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 =end
 
-require 'bdb'
+require 'dbm'
 require 'pathname'
 require 'fileutils'
 
@@ -239,23 +239,18 @@
 
   # Database for doc-base directories. It contains base directories associated
   # with the corresponding doc-base doc id and the document title.
-  class DocDirDatabase < BDB::Hash
-    def self.open(flags   = BDB::RDONLY,
+  class DocDirDatabase < DBM
+    def self.open(flags   = DBM::READER,
                   name    = DOC_DIR_DATABASE,
                   options = {},
                   mode    = 0644)
-      default_options = {"ffactor"   => 8,
-                         "nelem"     => 1,
-                         "cachesize" => 5000,
-                         "hash"      => nil,
-                         "lorder"    => 0}
-      super(name, nil, flags, mode, default_options.merge(options))
+      super(name, mode, flags)
     end
 
     # Traverse entire BD, passing directory, doc_id and title of each item to
     # the block
     def each
-      super do |k,v|
+      each_pair do |k,v|
         value = DocDirDatabaseValue.new(v)
         yield DocDirDatabaseKey.new(k).dir, value.doc_id, value.title
       end
@@ -266,19 +261,19 @@
     def add(dir, doc_id, title)
       key = DocDirDatabaseKey.new(:dir => dir)
       value = DocDirDatabaseValue.new(:doc_id => doc_id, :title => title)
-      put(key.to_raw_data, value.to_raw_data)
+      self[key.to_raw_data] = value.to_raw_data
     end
 
     def include?(dir)
       key = DocDirDatabaseKey.new(:dir => dir)
-      return super(key.to_raw_data)
+      return has_key?(key.to_raw_data)
     end
 
     # Returns an array with two elements, doc_id and title, for the registered
     # doc-base document in the given directory
     def info_for_path(dir)
       key = DocDirDatabaseKey.new(:dir => dir)
-      raw_value = get(key.to_raw_data)
+      raw_value = self[key.to_raw_data]
       if raw_value.nil?
         raise KeyNotFoundError, "Can't find information for path #{dir}"
       end
@@ -448,10 +443,11 @@
     # Registers a list of doc-base documents as part of Dhelp
     def _register_docs(doc_list, user_opts={})
       register_opts = {:regenerate_index => false}.merge(user_opts)
-      open_flag = register_opts[:regenerate_index] ? (BDB::CREATE|
-                                                      BDB::TRUNCATE) :
-                                                     BDB::CREATE
-      doc_dir_db = DocDirDatabase.open(open_flag, @doc_dir_database)
+      if register_opts[:regenerate_index]
+        doc_dir_db = DocDirDatabase.open(DBM::NEWDB, @doc_dir_database)
+      else
+        doc_dir_db = DocDirDatabase.open(DBM::WRCREAT, @doc_dir_database)
+      end
       index_paths = []
       doc_list.each do |doc|
         doc.formats.each do |format|

=== modified file 'test/tc_dhelpdocumentpool.rb'
--- test/tc_dhelpdocumentpool.rb	2014-05-18 13:18:39 +0000
+++ test/tc_dhelpdocumentpool.rb	2017-04-24 20:19:29 +0000
@@ -1,6 +1,7 @@
 require 'test/unit'
 require 'dhelp'
 require 'fileutils'
+require 'set'
 
 class TC_DhelpDocumentPool < Test::Unit::TestCase
 
@@ -57,7 +58,7 @@
       doc.formats.find {|f| f.format.downcase == 'html'}.index
     # Register document, see if the containing directory is added
     @pool.register(doc)
-    ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
+    ddd = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
     assert_equal doc_id, ddd.info_for_path(File.dirname(index_file)).first
     ddd.close
   end
@@ -84,7 +85,7 @@
 
   def test_doc_base_dirs
     @pool.register(doc_base_document('docbook-xsl-doc-html'))
-    dddbh1 = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
+    dddbh1 = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
     assert dddbh1.include?('test/share-doc/docbook-xsl-doc-html/doc'),
            "The docbook-xsl-doc-html directory should be registered"
     assert !dddbh1.include?('test/share-doc/pica/manual.html'),
@@ -92,7 +93,7 @@
     dddbh1.close
 
     @pool.register(doc_base_document('pica-manual'))
-    dddbh2 = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
+    dddbh2 = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
     assert dddbh2.include?('test/share-doc/docbook-xsl-doc-html/doc'),
            "The docbook-xsl-doc-html directory should still be registered"
     assert dddbh2.include?('test/share-doc/pica/manual.html'),
@@ -141,7 +142,7 @@
     # 5) Rebuild, check that the directory database doesn't include the deleted
     #    document
     tmp_pool.rebuild
-    doc_dir_db = Dhelp::DocDirDatabase.open(BDB::RDONLY, dddb)
+    doc_dir_db = Dhelp::DocDirDatabase.open(DBM::READER, dddb)
     assert !doc_dir_db.include?('test/tmp/share-doc/dir-test-1/manual.html'),
            "The directory for dir-test-1 should NOT exist"
     assert doc_dir_db.include?('test/tmp/share-doc/dir-test-2/manual.html'),
@@ -155,7 +156,7 @@
   def test_register_dirs
     doc    = Dhelp::DocBaseDocument.new('test/doc-base/ghc6-users-guide')
     @pool.register(doc)
-    ddd = Dhelp::DocDirDatabase.open(BDB::RDONLY, TEST_DOC_DIR_DATABASE)
+    ddd = Dhelp::DocDirDatabase.open(DBM::READER, TEST_DOC_DIR_DATABASE)
     assert ddd.include?('test/share-doc/ghc6-doc/html/libraries'),
            "Docdir should include the libraries subdir"
     assert ddd.include?('test/share-doc/ghc6-doc/html'),
@@ -165,7 +166,7 @@
   def teardown
     @pool = nil
     @doc_base_id_set = nil
-    FileUtils.rm_f TEST_DOC_DIR_DATABASE
+    FileUtils.rm_f Dir.glob("#{TEST_DOC_DIR_DATABASE}.*")
     FileUtils.rm_f TEST_INDEX_FILE
     FileUtils.rm_f TEST_PENDING_FILE
   end

