about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2015-01-14 22:16:44 +0000
committerEric Wong <normalperson@yhbt.net>2015-01-14 22:16:44 +0000
commitb5fa71328e8871b3ab81a02a3d3166814798d10b (patch)
treeebceec21112f8f496027fef22a3e835ce203a3c4
parent591e1dd6c31777c627242064accf6e6f2da067a0 (diff)
downloadmogilefs-client-b5fa71328e8871b3ab81a02a3d3166814798d10b.tar.gz
The documentation (and website) uses olddoc, now,
allowing faster load times and more consistent
user experience across different browsers, particularly
text-only ones.

The packaging is also updated to be consistent with
the rest of the projects I deal with.
-rw-r--r--.document1
-rw-r--r--.gitignore6
-rw-r--r--.olddoc.yml (renamed from .wrongdoc.yml)0
-rwxr-xr-xGIT-VERSION-GEN13
-rw-r--r--GNUmakefile92
-rw-r--r--Rakefile56
-rw-r--r--mogilefs-client.gemspec20
-rw-r--r--pkg.mk150
8 files changed, 188 insertions, 150 deletions
diff --git a/.document b/.document
index db7b04c..168db68 100644
--- a/.document
+++ b/.document
@@ -1,6 +1,5 @@
 NEWS
 History
-ChangeLog
 LICENSE
 README
 HACKING
diff --git a/.gitignore b/.gitignore
index cf042ad..8e46ee4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,8 @@
 /doc
 /.config
 /InstalledFiles
-/ChangeLog
-/NEWS
+/NEWS*
 /LATEST
+/GIT-VERSION-FILE
+/.manifest
 /lib/mogilefs/version.rb
-/Manifest.txt
diff --git a/.wrongdoc.yml b/.olddoc.yml
index d62f82d..d62f82d 100644
--- a/.wrongdoc.yml
+++ b/.olddoc.yml
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index fc89e39..06b78f8 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,6 +1,7 @@
 #!/usr/bin/env ruby
 CONSTANT = "MogileFS::VERSION"
 RVF = "lib/mogilefs/version.rb"
+GVF = "GIT-VERSION-FILE"
 DEF_VER = "v3.7.1"
 vn = DEF_VER
 
@@ -20,9 +21,19 @@ if File.exist?(".git")
 end
 
 vn = vn.sub!(/\Av/, "")
-new_ruby_version = "#{CONSTANT} = '#{vn}'\n"
+new_ruby_version = "#{CONSTANT} = '#{vn}' # :nodoc:\n"
 cur_ruby_version = File.read(RVF) rescue nil
 if new_ruby_version != cur_ruby_version
   File.open(RVF, "w") { |fp| fp.write(new_ruby_version) }
 end
+File.chmod(0644, RVF)
+
+# generate the makefile snippet
+new_make_version = "GIT_VERSION = #{vn}\n"
+cur_make_version = File.read(GVF) rescue nil
+if new_make_version != cur_make_version
+  File.open(GVF, "w") { |fp| fp.write(new_make_version) }
+end
+File.chmod(0644, GVF)
+
 puts vn if $0 == __FILE__
diff --git a/GNUmakefile b/GNUmakefile
index 8cd6df8..6b9ee5e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,90 +1,4 @@
-# use GNU Make to run tests in parallel, and without depending on Rubygems
-all:: test
+all::
 RSYNC_DEST := bogomips.org:/srv/bogomips/mogilefs-client
-git_version_gen := $(shell ./GIT-VERSION-GEN)
-
-T := $(wildcard test/test*.rb)
-TO := $(subst .rb,.log,$(T))
-
-test: $(T)
-        @cat $(TO) | ruby test/aggregate.rb
-        @$(RM) $(TO)
-clean:
-        $(RM) $(TO) $(addsuffix +,$(TO))
-
-
-ifndef V
-  quiet_pre = @echo '* $@';
-  quiet_post = >$(t) 2>&1
-else
-  # we can't rely on -o pipefail outside of bash 3+,
-  # so we use a stamp file to indicate success and
-  # have rm fail if the stamp didn't get created
-  stamp = $@$(log_suffix).ok
-  quiet_pre = @echo $(ruby) $@ $(TEST_OPTS); ! test -f $(stamp) && (
-  quiet_post = && > $(stamp) )>&2 | tee $(t); rm $(stamp) 2>/dev/null
-endif
-ruby = ruby
-run_test = $(quiet_pre) setsid $(ruby) -w $@ $(TEST_OPTS) $(quiet_post) || \
-  (sed "s,^,$(extra): ," >&2 < $(t); exit 1)
-
-$(T): t = $(subst .rb,.log,$@)
-$(T): export RUBYLIB := $(CURDIR)/lib:$(RUBYLIB)
-$(T):
-        $(run_test)
-
-RUBY_VERSION_FILE = lib/mogilefs/version.rb
-package:
-        git diff --exit-code HEAD^0
-        $(RM) -r pkg/
-        rake fix_perms
-        rake package
-
-libs := $(wildcard lib/*.rb lib/*/*.rb)
-flay_flags =
-flog_flags =
-flay: $(libs)
-        flay $(flay_flags) $^
-flog: $(libs)
-        flog $(flog_flags) $^
-.PHONY: $(T)
-
-check-warnings:
-        @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
-          do ruby -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
-RSYNC = rsync
-WRONGDOC = wrongdoc
-
-doc:: .document .wrongdoc.yml $(pkg_extra)
-        -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
-        $(RM) -r doc
-        $(WRONGDOC) all
-        install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
-        cd doc && \
-                ln -s README README.txt && \
-                ln -s README.html README_txt.html && \
-                ln -s LICENSE LICENSE.txt && \
-                ln -s LICENSE.html LICENSE_txt.html && \
-                ln -s History History.txt && \
-                ln -s History.html History_txt.html
-
-# Create gzip variants of the same timestamp as the original so nginx
-# "gzip_static on" can serve the gzipped versions directly.
-doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
-doc_gz:
-        for i in $(docs); do \
-          gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
-
-# this requires GNU coreutils variants
-ifneq ($(RSYNC_DEST),)
-publish_doc:
-        -git set-file-times
-        $(MAKE) doc
-        find doc/images -type f | \
-                TZ=UTC xargs touch -d '1970-01-01 00:00:06' doc/rdoc.css
-        $(MAKE) doc_gz
-        $(RSYNC) -av doc/ $(RSYNC_DEST)/
-        git ls-files | xargs touch
-endif
-
-.PHONY: doc .FORCE-GIT-VERSION-FILE
+rfpackage := mogilefs-client
+include pkg.mk
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index 1adba47..0000000
--- a/Rakefile
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'rubygems'
-require 'hoe'
-load "./GIT-VERSION-GEN"
-
-include Rake::DSL if defined?(Rake::DSL)
-$:.unshift 'lib'
-require 'mogilefs'
-Hoe.plugin :seattlerb
-
-wd = %w(ChangeLog NEWS)
-wd_ok = true
-wd.each do |f|
-  next if File.exist?(f) || system("wrongdoc all")
-  wd_ok = false
-  File.open(f, "a") do |fp|
-    fp.puts "`wrongdoc all' failed, #{f} not generated properly"
-  end
-end
-
-warn "install `wrongdoc' gem to generate: #{wd.inspect}" unless wd_ok
-
-manifest = "Manifest.txt"
-if ! File.exist?(manifest) ||
-   File.stat(manifest).mtime < File.stat(RVF).mtime ||
-   File.stat(manifest).mtime < File.stat(__FILE__).mtime
-  system("git ls-files > #{manifest}")
-  File.open(manifest, "a") do |fp|
-    fp.puts "Manifest.txt"
-    fp.puts "ChangeLog"
-    fp.puts "NEWS"
-    fp.puts "lib/mogilefs/version.rb"
-  end
-end
-
-Hoe.spec 'mogilefs-client' do
-  self.rubyforge_name = 'seattlerb'
-  developer 'Eric Wong', 'normalperson@yhbt.net'
-  # developer 'drbrain@segment7.net', 'Eric Hodel'
-  self.readme_file = "README"
-  self.history_file = "NEWS"
-  self.urls = %w(http://bogomips.org/mogilefs-client/)
-  self.description = self.paragraphs_of("README", 1)
-  self.summary = "MogileFS client library for Ruby"
-end
-
-task :fix_perms do
-  IO.popen('git ls-tree -r HEAD^0') do |fp|
-    fp.each_line do |line|
-      mode, type, sha1, path = line.chomp.split(/\s+/)
-      case mode
-      when '100644' then File.chmod(0644, path)
-      when '100755' then File.chmod(0755, path)
-      end
-    end
-  end
-end
diff --git a/mogilefs-client.gemspec b/mogilefs-client.gemspec
new file mode 100644
index 0000000..f681ee4
--- /dev/null
+++ b/mogilefs-client.gemspec
@@ -0,0 +1,20 @@
+ENV["VERSION"] or abort "VERSION= must be specified"
+require 'olddoc'
+$LOAD_PATH << 'lib'
+require 'mogilefs'
+extend Olddoc::Gemspec
+name, summary, title = readme_metadata
+Gem::Specification.new do |s|
+  manifest = File.read('.manifest').split(/\n/)
+  s.name = 'mogilefs-client'
+  s.version = MogileFS::VERSION
+  s.executables = %w(mog)
+  s.authors = ["#{s.name} hackers"]
+  s.summary = summary
+  s.description = readme_description
+  s.email = 'bofh@bogomips.org'
+  s.files = manifest
+  s.add_development_dependency('olddoc', '~> 1.0')
+  s.homepage = Olddoc.config['rdoc_url']
+  s.license = 'BSD-3-Clause'
+end
diff --git a/pkg.mk b/pkg.mk
new file mode 100644
index 0000000..67ca94b
--- /dev/null
+++ b/pkg.mk
@@ -0,0 +1,150 @@
+RUBY = ruby
+RAKE = rake
+RSYNC = rsync
+OLDDOC = olddoc
+RDOC = rdoc
+
+GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
+        @./GIT-VERSION-GEN
+-include GIT-VERSION-FILE
+-include local.mk
+DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
+RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
+RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
+lib := lib
+
+ext := $(firstword $(wildcard ext/*))
+ifneq ($(ext),)
+ext_pfx := tmp/ext/$(RUBY_ENGINE)-$(RUBY_VERSION)
+ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
+ext_src := $(wildcard $(ext)/*.c $(ext_h))
+ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
+ext_d := $(ext_pfx)/$(ext)/.d
+$(ext)/extconf.rb: $(wildcard $(ext)/*.h)
+        @>> $@
+$(ext_d):
+        @mkdir -p $(@D)
+        @> $@
+$(ext_pfx)/$(ext)/%: $(ext)/% $(ext_d)
+        install -m 644 $< $@
+$(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb $(ext_d) $(ext_h)
+        $(RM) -f $(@D)/*.o
+        cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
+ext_sfx := _ext.$(DLEXT)
+ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
+$(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
+        @echo $^ == $@
+        $(MAKE) -C $(@D)
+lib := $(lib):$(ext_pfx)/$(ext)
+build: $(ext_dl)
+else
+build:
+endif
+
+pkg_extra += GIT-VERSION-FILE NEWS LATEST
+NEWS: GIT-VERSION-FILE .olddoc.yml
+        $(OLDDOC) prepare
+LATEST: NEWS
+
+manifest:
+        $(RM) .manifest
+        $(MAKE) .manifest
+
+.manifest: $(pkg_extra)
+        (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
+                LC_ALL=C sort > $@+
+        cmp $@+ $@ || mv $@+ $@
+        $(RM) $@+
+
+doc:: .document .olddoc.yml $(pkg_extra) $(PLACEHOLDERS)
+        -find lib -type f -name '*.rbc' -exec rm -f '{}' ';'
+        -find ext -type f -name '*.rbc' -exec rm -f '{}' ';'
+        $(RM) -r doc
+        $(RDOC) -f oldweb
+        $(OLDDOC) merge
+        if test -f COPYING; then install -m644 COPYING doc/COPYING; fi
+        install -m644 NEWS doc/NEWS
+        install -m644 NEWS.atom.xml doc/NEWS.atom.xml
+        install -m644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
+
+ifneq ($(VERSION),)
+pkggem := pkg/$(rfpackage)-$(VERSION).gem
+pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
+
+# ensures we're actually on the tagged $(VERSION), only used for release
+verify:
+        test x"$(shell umask)" = x0022
+        git rev-parse --verify refs/tags/v$(VERSION)^{}
+        git diff-index --quiet HEAD^0
+        test $$(git rev-parse --verify HEAD^0) = \
+             $$(git rev-parse --verify refs/tags/v$(VERSION)^{})
+
+fix-perms:
+        -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
+        -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
+
+gem: $(pkggem)
+
+install-gem: $(pkggem)
+        gem install $(CURDIR)/$<
+
+$(pkggem): manifest fix-perms
+        gem build $(rfpackage).gemspec
+        mkdir -p pkg
+        mv $(@F) $@
+
+$(pkgtgz): distdir = $(basename $@)
+$(pkgtgz): HEAD = v$(VERSION)
+$(pkgtgz): manifest fix-perms
+        @test -n "$(distdir)"
+        $(RM) -r $(distdir)
+        mkdir -p $(distdir)
+        tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
+        cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
+        mv $@+ $@
+
+package: $(pkgtgz) $(pkggem)
+
+release:: verify package
+        # push gem to RubyGems.org
+        gem push $(pkggem)
+else
+gem install-gem: GIT-VERSION-FILE
+        $(MAKE) $@ VERSION=$(GIT_VERSION)
+endif
+
+all:: check
+test_units := $(wildcard test/test_*.rb)
+test: check
+check: test-unit
+test-unit: $(test_units)
+$(test_units): build
+        $(RUBY) -I $(lib) $@ $(RUBY_TEST_OPTS)
+
+# this requires GNU coreutils variants
+ifneq ($(RSYNC_DEST),)
+publish_doc:
+        -git set-file-times
+        $(MAKE) doc
+        $(MAKE) doc_gz
+        $(RSYNC) -av doc/ $(RSYNC_DEST)/
+        git ls-files | xargs touch
+endif
+
+# Create gzip variants of the same timestamp as the original so nginx
+# "gzip_static on" can serve the gzipped versions directly.
+doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
+doc_gz:
+        for i in $(docs); do \
+          gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
+check-warnings:
+        @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \
+          do $(RUBY) -d -W2 -c $$i; done) | grep -v '^Syntax OK$$' || :
+
+ifneq ($(PLACEHOLDERS),)
+$(PLACEHOLDERS):
+        echo olddoc_placeholder > $@
+endif
+
+.PHONY: all .FORCE-GIT-VERSION-FILE doc check test $(test_units) manifest
+.PHONY: check-warnings