sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit c64a4aaed9664841822cb8889f714d2ad4ad94de
parent 1d675cacf246986d2bc98f035d6e50539e8ae69c
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Wed, 17 Sep 2014 10:06:54 +0200

xapian: correctly include extension, only install xapian when not installed.

It seems that the way the extension was included prevented it from being
run properly.

Also, xapian was always being installed on platforms where it should be
- but also when it was already installed. Now testing if exists before
installing.

Diffstat:
D ext/mkrf_conf.rb | 21 ---------------------
A ext/mkrf_conf_xapian.rb | 46 ++++++++++++++++++++++++++++++++++++++++++++++
M sup.gemspec | 5 ++++-
3 files changed, 50 insertions(+), 22 deletions(-)
diff --git a/ext/mkrf_conf.rb b/ext/mkrf_conf.rb
@@ -1,21 +0,0 @@
-require 'rubygems'
-require 'rubygems/command.rb'
-require 'rubygems/dependency_installer.rb'
-require 'rbconfig'
-
-begin
-  Gem::Command.build_args = ARGV
-rescue NoMethodError
-end
-
-inst = Gem::DependencyInstaller.new
-begin
-  if !RbConfig::CONFIG['arch'].include?('openbsd')
-    inst.install "xapian-ruby", "~> 1.2.15"
- end
-rescue
-  exit(1)
-end
-f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w") # create dummy rakefile to indicate success
-f.write("task :default\n")
-f.close
diff --git a/ext/mkrf_conf_xapian.rb b/ext/mkrf_conf_xapian.rb
@@ -0,0 +1,46 @@
+require 'rubygems'
+require 'rubygems/command.rb'
+require 'rubygems/dependency_installer.rb'
+require 'rbconfig'
+
+begin
+  Gem::Command.build_args = ARGV
+rescue NoMethodError
+end
+
+puts "xapian: platform specific dependencies.."
+
+inst = Gem::DependencyInstaller.new
+begin
+
+  if !RbConfig::CONFIG['arch'].include?('openbsd')
+    name    = "xapian-ruby"
+    version = "~> 1.2.15"
+
+    begin
+      # try to load gem
+
+      STDERR.puts "xapian: already installed."
+      gem name, version
+
+    rescue Gem::LoadError
+
+      STDERR.puts "xapian: installing xapian-ruby.."
+      inst.install name, version
+
+    end
+  else
+    STDERR.puts "xapian: openbsd: you have to install xapian-core and xapian-bindings manually, have a look at: https://github.com/sup-heliotrope/sup/wiki/Installation%3A-OpenBSD"
+  end
+
+rescue
+
+  exit(1)
+
+end
+
+# create dummy rakefile to indicate success
+f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
+f.write("task :default\n")
+f.close
+
diff --git a/sup.gemspec b/sup.gemspec
@@ -40,7 +40,10 @@ SUP: please note that our old mailing lists have been shut down,
   # xapian-core and xapian-bindings manually on OpenBSD
   # see https://github.com/sup-heliotrope/sup/wiki/Installation%3A-OpenBSD
   # and https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems#How_to_install_different_versions_of_gems_depending_on_which_version_of_ruby_the_installee_is_using
-  s.extensions = 'ext/mkrf_conf.rb'
+  s.extensions = %w[ext/mkrf_conf_xapian.rb]
+
+  ## remember to update the xapian dependency in
+  ## ext/mkrf_conf_xapian.rb.
 
   s.add_runtime_dependency "ncursesw", "~> 1.4.0"
   s.add_runtime_dependency "rmail-sup", "~> 1.0.1"