about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-29 09:18:14 +0000
committerEric Wong <normalperson@yhbt.net>2010-12-29 09:18:14 +0000
commit4b72673e4614d0942c8ac9fab9caf7ac2c9f19f0 (patch)
treebe72088baa70e9793b4bffae93129f84e1bbc1bc
parent1e3d8e09d4fe7ad2eaa69200226ddc9931b89f7b (diff)
downloadzbatery-4b72673e4614d0942c8ac9fab9caf7ac2c9f19f0.tar.gz
packaging updates (wrongdoc!)
-rw-r--r--.document1
-rw-r--r--.gitignore1
-rw-r--r--.wrongdoc.yml7
-rw-r--r--GNUmakefile78
-rw-r--r--Rakefile122
-rw-r--r--zbatery.gemspec37
6 files changed, 55 insertions, 191 deletions
diff --git a/.document b/.document
index fbffcd1..29ed197 100644
--- a/.document
+++ b/.document
@@ -5,3 +5,4 @@ NEWS
 README
 FAQ
 zbatery_1
+LATEST
diff --git a/.gitignore b/.gitignore
index a9cb887..e71d8b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ pkg/
 /.manifest
 /GIT-VERSION-FILE
 /man
+/LATEST
diff --git a/.wrongdoc.yml b/.wrongdoc.yml
new file mode 100644
index 0000000..b268cfc
--- /dev/null
+++ b/.wrongdoc.yml
@@ -0,0 +1,7 @@
+---
+cgit_url: http://git.bogomips.org/cgit/zbatery.git
+git_url: git://git.bogomips.org/zbatery.git
+rdoc_url: http://zbatery.bogomip.org/
+changelog_start: v0.3.1
+merge_html:
+  zbatery_1: Documentation/zbatery.1.html
diff --git a/GNUmakefile b/GNUmakefile
index 3c2fb29..2e396e3 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -4,15 +4,11 @@ MRI = ruby
 RUBY = ruby
 RAKE = rake
 RSYNC = rsync
-GIT_URL = git://git.bogomips.org/zbatery.git
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
         @./GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 -include local.mk
-ifeq ($(DLEXT),) # "so" for Linux
-  DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
-endif
 ifeq ($(RUBY_VERSION),)
   RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
 endif
@@ -43,77 +39,40 @@ clean:
         -$(MAKE) -C Documentation clean
         $(RM) $(setup_rb_files) $(t_log)
 
-man:
-        $(MAKE) -C Documentation install-man
+man html:
+        $(MAKE) -C Documentation install-$@
 
-pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
+pkg_extra := GIT-VERSION-FILE ChangeLog LATEST NEWS $(man1_paths)
 manifest: $(pkg_extra) man
         $(RM) .manifest
         $(MAKE) .manifest
 
 .manifest:
-        (git ls-files && \
-         for i in $@ $(pkg_extra) $(man1_paths); \
+        (git ls-files && for i in $@ $(pkg_extra) $(man1_paths); \
          do echo $$i; done) | LC_ALL=C sort > $@+
         cmp $@+ $@ || mv $@+ $@
         $(RM) $@+
 
-NEWS: GIT-VERSION-FILE
-        $(RAKE) -s news_rdoc > $@+
-        mv $@+ $@
-
-SINCE = 0.3.1
-ChangeLog: LOG_VERSION = \
-  $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
-          echo $(GIT_VERSION) || git describe)
-ifneq ($(SINCE),)
-ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
-endif
-ChangeLog: GIT-VERSION-FILE
-        @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
-        @echo >> $@+
-        git log $(log_range) | sed -e 's/^/    /' >> $@+
-        mv $@+ $@
-
-news_atom := http://zbatery.bogomip.org/NEWS.atom.xml
-cgit_atom := http://git.bogomips.org/cgit/zbatery.git/atom/?h=master
-atom = <link rel="alternate" title="Atom feed" href="$(1)" \
-             type="application/atom+xml"/>
+ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
+        wrongdoc prepare
 
-# using rdoc 2.5.x+
-doc: .document NEWS ChangeLog
+doc: .document ChangeLog GIT-VERSION-FILE
         for i in $(man1_rdoc); do echo > $$i; done
         find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
-        rdoc -t "$(shell sed -ne '1s/^= //p' README)"
+        $(RM) -r doc
+        wrongdoc all
         install -m644 COPYING doc/COPYING
-        install -m644 $(shell grep '^[A-Z]' .document)  doc/
-        $(MAKE) -C Documentation install-html install-man
+        install -m644 $(shell grep '^[A-Z]' .document) doc/
         install -m644 $(man1_paths) doc/
-        cd doc && for i in $(base_bins); do \
-          $(RM) 1.html $${i}.1.html; \
-          sed -e '/"documentation">/r man1/'$$i'.1.html' \
-                < $${i}_1.html > tmp && mv tmp $${i}_1.html; \
-          ln $${i}_1.html $${i}.1.html; \
-          done
-        $(MRI) -i -p -e \
-          '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
-          doc/ChangeLog.html
-        $(MRI) -i -p -e \
-          '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
-          doc/NEWS.html doc/README.html
-        $(RAKE) -s news_atom > doc/NEWS.atom.xml
-        cd doc && ln README.html tmp && mv tmp index.html
         $(RM) $(man1_rdoc)
 
 # publishes docs to http://zbatery.bogomip.org/
 publish_doc:
         -git set-file-times
-        $(RM) -r doc ChangeLog NEWS
-        $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
-        awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
-         < NEWS > doc/LATEST
-        find doc/images doc/js -type f | \
-                TZ=UTC xargs touch -d '1970-01-01 00:00:01' doc/rdoc.css
+        $(RM) -r doc
+        $(MAKE) doc
+        find doc/images -type f | \
+                TZ=UTC xargs touch -d '1970-01-01 00:00:03' doc/rdoc.css
         $(MAKE) doc_gz
         chmod 644 $$(find doc -type f)
         $(RSYNC) -av doc/ zbatery.bogomip.org:/srv/zbatery/
@@ -123,7 +82,6 @@ publish_doc:
 # "gzip_static on" can serve the gzipped versions directly.
 doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$')
 doc_gz:
-        touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)"
         for i in $(docs); do \
           gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
 
@@ -138,10 +96,10 @@ release_changes := release_changes-$(VERSION)
 release-notes: $(release_notes)
 release-changes: $(release_changes)
 $(release_changes):
-        $(RAKE) -s release_changes > $@+
+        wrongdoc release_changes > $@+
         $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
 $(release_notes):
-        GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
+        wrongdoc release_notes > $@+
         $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
 
 # ensures we're actually on the tagged $(VERSION), only used for release
@@ -172,8 +130,8 @@ $(pkgtgz): manifest fix-perms
         @test -n "$(distdir)"
         $(RM) -r $(distdir)
         mkdir -p $(distdir)
-        tar c `cat .manifest` | (cd $(distdir) && tar x)
-        cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
+        tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
+        cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
         mv $@+ $@
 
 package: $(pkgtgz) $(pkggem)
diff --git a/Rakefile b/Rakefile
index a57f249..bf8e231 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,112 +1,27 @@
 # -*- encoding: binary -*-
 autoload :Gem, 'rubygems'
 
-# most tasks are in the GNUmakefile which offers better parallelism
-
-def tags
-  timefmt = '%Y-%m-%dT%H:%M:%SZ'
-  @tags ||= `git tag -l`.split(/\n/).map do |tag|
-    if %r{\Av[\d\.]+\z} =~ tag
-      header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
-      header = header.split(/\n/)
-      tagger = header.grep(/\Atagger /).first
-      body ||= "initial"
-      {
-        :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt),
-        :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
-        :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
-        :id => `git rev-parse refs/tags/#{tag}`.chomp!,
-        :tag => tag,
-        :subject => subject,
-        :body => body,
-      }
-    end
-  end.compact.sort { |a,b| b[:time] <=> a[:time] }
-end
-
-cgit_url = "http://git.bogomips.org/cgit/zbatery.git"
-git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/zbatery.git'
-
-desc 'prints news as an Atom feed'
-task :news_atom do
-  require 'nokogiri'
-  new_tags = tags[0,10]
-  puts(Nokogiri::XML::Builder.new do
-    feed :xmlns => "http://www.w3.org/2005/Atom" do
-      id! "http://zbatery.bogomip.org/NEWS.atom.xml"
-      title "Zbatery news"
-      subtitle "HTTP server without a fork stuck in it"
-      link! :rel => 'alternate', :type => 'text/html',
-            :href => 'http://zbatery.bogomip.org/NEWS.html'
-      updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time])
-      new_tags.each do |tag|
-        entry do
-          title tag[:subject]
-          updated tag[:time]
-          published tag[:time]
-          author {
-            name tag[:tagger_name]
-            email tag[:tagger_email]
-          }
-          url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
-          link! :rel => "alternate", :type => "text/html", :href =>url
-          id! url
-          message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
-          content({:type =>:text}, message_only)
-          content(:type =>:xhtml) { pre tag[:body] }
-        end
-      end
-    end
-  end.to_xml)
-end
-
-desc 'prints RDoc-formatted news'
-task :news_rdoc do
-  tags.each do |tag|
-    time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
-    puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}"
-    puts ""
-
-    body = tag[:body]
-    puts tag[:body].gsub(/^/sm, "  ").gsub(/[ \t]+$/sm, "")
-    puts ""
-  end
-end
-
-desc "print release changelog for Rubyforge"
-task :release_changes do
-  version = ENV['VERSION'] or abort "VERSION= needed"
-  version = "v#{version}"
-  vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
-  prev = vtags[vtags.index(version) - 1]
-  if prev
-    system('git', 'diff', '--stat', prev, version) or abort $?
-    puts ""
-    system('git', 'log', "#{prev}..#{version}") or abort $?
-  else
-    system('git', 'log', version) or abort $?
-  end
-end
-
-desc "print release notes for Rubyforge"
-task :release_notes do
-  spec = Gem::Specification.load('zbatery.gemspec')
-  puts spec.description.strip
-  puts ""
-  puts "* #{spec.homepage}"
-  puts "* #{spec.email}"
-  puts "* #{git_url}"
-
-  _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
-  print "\nChanges:\n\n"
-  puts body
-end
+cgit_url = "http://git.bogomips.org/cgit/rainbows.git"
+git_url = 'git://git.bogomips.org/rainbows.git'
 
 desc "read news article from STDIN and post to rubyforge"
 task :publish_news do
   require 'rubyforge'
-  IO.select([STDIN], nil, nil, 1) or abort "E: news must be read from stdin"
-  msg = STDIN.readlines
+  spec = Gem::Specification.load('zbatery.gemspec')
+  tmp = Tempfile.new('rf-news')
+  _, subject, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
+  tmp.puts subject
+  tmp.puts
+  tmp.puts spec.description.strip
+  tmp.puts ""
+  tmp.puts "* #{spec.homepage}"
+  tmp.puts "* #{spec.email}"
+  tmp.puts "* #{git_url}"
+  tmp.print "\nChanges:\n\n"
+  tmp.puts body
+  tmp.flush
+  system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
+  msg = File.readlines(tmp.path)
   subject = msg.shift
   blank = msg.shift
   blank == "\n" or abort "no newline after subject!"
@@ -165,9 +80,8 @@ task :fm_update do
   uri = URI.parse('http://freshmeat.net/projects/zbatery/releases.json')
   rc = Net::Netrc.locate('zbatery-fm') or abort "~/.netrc not found"
   api_token = rc.password
-  changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
+  _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
   tmp = Tempfile.new('fm-changelog')
-  tmp.syswrite(changelog)
   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
   changelog = File.read(tmp.path).strip
 
diff --git a/zbatery.gemspec b/zbatery.gemspec
index b9f9f03..1fd80b2 100644
--- a/zbatery.gemspec
+++ b/zbatery.gemspec
@@ -1,45 +1,27 @@
 # -*- encoding: binary -*-
-
 ENV["VERSION"] or abort "VERSION= must be specified"
 manifest = File.readlines('.manifest').map! { |x| x.chomp! }
-
-# don't bother with tests that fork, not worth our time to get working
-# with `gem check -t` ... (of course we care for them when testing with
-# GNU make when they can run in parallel)
-test_files = manifest.grep(%r{\Atest/unit/test_.*\.rb\z}).map do |f|
-  File.readlines(f).grep(/\bfork\b/).empty? ? f : nil
-end.compact
+require 'wrongdoc'
+extend Wrongdoc::Gemspec
+name, summary, title = readme_metadata
 
 Gem::Specification.new do |s|
   s.name = %q{zbatery}
-  s.version = ENV["VERSION"]
+  s.version = ENV["VERSION"].dup
 
   s.authors = ["Zbatery hackers"]
   s.date = Time.now.utc.strftime('%Y-%m-%d')
-  s.description = File.read("README").split(/\n\n/)[1]
+  s.description = readme_description
   s.email = %q{rainbows-talk@rubyforge.org}
   s.executables = %w(zbatery)
-
-  s.extra_rdoc_files = File.readlines('.document').map! do |x|
-    x.chomp!
-    if File.directory?(x)
-      manifest.grep(%r{\A#{x}/})
-    elsif File.file?(x)
-      x
-    else
-      nil
-    end
-  end.flatten.compact
-
+  s.extra_rdoc_files = extra_rdoc_files(manifest)
   s.files = manifest
-  s.homepage = %q{http://zbatery.bogomip.org/}
-  s.summary = %q{Rack HTTP server without a fork stuck in it}
-  s.rdoc_options = [ "-t", "Zbatery - #{s.summary}" ]
+  s.homepage = Wrongdoc.config[:rdoc_url]
+  s.summary = summary
+  s.rdoc_options = rdoc_options
   s.require_paths = %w(lib)
   s.rubyforge_project = %q{rainbows}
 
-  s.test_files = test_files
-
   # rainbows has a boatload of optional dependencies
   # required:
   #   unicorn + rack
@@ -51,6 +33,7 @@ Gem::Specification.new do |s|
   #   async_sinatra + sinatra + eventmachine
   #
   s.add_dependency(%q<rainbows>, ["~> 2.1"])
+  s.add_development_dependency(%q<wrongdoc>, "~> 1.1")
   s.add_development_dependency(%q<isolate>, "~> 3.0.0")
 
   # s.licenses = %w(GPLv2 Ruby) # accessor not compatible with older RubyGems