commit 54d02b877755ee295d34556aa3c310290759e062
parent 4a6e80c5eb295a06365232691c3e1b909eb5dc7c
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Mon, 18 Jan 2010 11:52:47 -0500
make all bin/* scripts check sup library version
Previously just bin/sup was doing this.
Diffstat:
8 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -12,21 +12,7 @@ end
require 'fileutils'
require 'trollop'
-require "sup"
-
-BIN_VERSION = "git"
-
-unless Redwood::VERSION == BIN_VERSION
- $stderr.puts <<EOS
-
-Error: version mismatch!
-The sup executable is at version #{BIN_VERSION.inspect}.
-The sup libraries are at version #{Redwood::VERSION.inspect}.
-
-Is your development environment conflicting with rubygems?
-EOS
- exit(-1)
-end
+require "sup"; Redwood::check_library_version_against "git"
if no_ncursesw
debug "No 'ncursesw' gem detected. Install it for wide character support."
diff --git a/bin/sup-convert-ferret-index b/bin/sup-convert-ferret-index
@@ -2,7 +2,7 @@
require 'rubygems'
require 'trollop'
-require 'sup'
+require "sup"; Redwood::check_library_version_against "git"
STATE_BACKUP_FN = "/tmp/sup-state.txt"
SOURCE_BACKUP_FN = "sources.yaml-before-xapian-upgrade"
diff --git a/bin/sup-dump b/bin/sup-dump
@@ -2,7 +2,7 @@
require 'rubygems'
require 'trollop'
-require "sup"
+require "sup"; Redwood::check_library_version_against "git"
$opts = Trollop::options do
version "sup-dump (sup #{Redwood::VERSION})"
diff --git a/bin/sup-sync b/bin/sup-sync
@@ -3,7 +3,7 @@
require 'uri'
require 'rubygems'
require 'trollop'
-require "sup"
+require "sup"; Redwood::check_library_version_against "git"
PROGRESS_UPDATE_INTERVAL = 15 # seconds
diff --git a/bin/sup-sync-back b/bin/sup-sync-back
@@ -5,7 +5,7 @@ require 'uri'
require 'tempfile'
require 'trollop'
require 'enumerator'
-require "sup"
+require "sup"; Redwood::check_library_version_against "git"
## save a message 'm' to an open file pointer 'fp'
def save m, fp
diff --git a/bin/sup-tweak-labels b/bin/sup-tweak-labels
@@ -3,7 +3,7 @@
require 'rubygems'
require 'trollop'
require 'enumerator'
-require "sup"
+require "sup"; Redwood::check_library_version_against "git"
class Float
def to_s; sprintf '%.2f', self; end
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -188,8 +188,37 @@ EOM
end
end
+ ## to be called by entry points in bin/, to ensure that
+ ## their versions match up against the library versions.
+ ##
+ ## this is a perennial source of bug reports from people
+ ## who both use git and have a gem version installed.
+ def check_library_version_against v
+ unless Redwood::VERSION == v
+ $stderr.puts <<EOS
+
+Error: version mismatch!
+The sup executable is at version #{BIN_VERSION.inspect}.
+The sup libraries are at version #{Redwood::VERSION.inspect}.
+
+Your development environment may be picking up code from a
+rubygems installation of sup.
+
+If you're running from git with a commandline like
+
+ ruby -Ilib bin/#{$0}
+
+try this instead:
+
+ RUBY_INVOCATION="ruby -Ilib" ruby -Ilib bin/#{$0}"
+
+EOS
+ abort
+ end
+ end
+
module_function :save_yaml_obj, :load_yaml_obj, :start, :finish,
- :report_broken_sources
+ :report_broken_sources, :check_library_version_against
end
## set up default configuration file
diff --git a/release-script.txt b/release-script.txt
@@ -8,7 +8,7 @@ vi CONTRIBUTORS # and merge
vi www/index.html # and include CONTRIBUTORS
# ... git add, commit, etc
git checkout -b release-<releasename>
-vi lib/sup.rb bin/sup # and bump BOTH version numbers
+vi lib/sup.rb bin/* # and bump version numbers in all files
# ... git add, commit, etc
rake gem
rake tarball