From 632b3d37736ce0df4f74edb2cdcbb88db4c9e975 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 Sep 2013 19:19:16 +0000 Subject: rework packaging to use GNU make + gemspec instead of Hoe Currently, this allows us to use different manpage paths for the tarball and gem; as gem-man and setup.rb expect different paths for manpages. Additionally, Hoe is designed for Ruby projects. dtas may include Perl/shell/Python/whatever in the future. So use GNU make as it is more suited for language agnosticism. --- .gitignore | 4 ++ GIT-VERSION-GEN | 10 +++++ GNUmakefile | 60 ++++++++++++++++++++++--- Rakefile | 133 ++++++++++++++------------------------------------------ dtas.gemspec | 13 ++++++ 5 files changed, 113 insertions(+), 107 deletions(-) create mode 100644 dtas.gemspec diff --git a/.gitignore b/.gitignore index 6552961..7d0fab2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Copyright (C) 2013, Eric Wong and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +/GIT-VERSION-FILE /Manifest.txt /NEWS /pkg @@ -10,3 +11,6 @@ /man *.gem *.gz +.manifest +.gem-manifest +.tgz-manifest diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index df7feb1..dd8ae37 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -3,6 +3,7 @@ # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) CONSTANT = "DTAS::VERSION" RVF = "lib/dtas/version.rb" +GVF = "GIT-VERSION-FILE" DEF_VER = "v0.4.0" vn = DEF_VER @@ -28,4 +29,13 @@ 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 = "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 a23e29e..4cb5162 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,7 +1,7 @@ # Copyright (C) 2013, Eric Wong and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) all:: - +pkg = dtas RUBY = ruby GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @./GIT-VERSION-GEN @@ -10,10 +10,9 @@ lib := lib all:: test test_units := $(wildcard test/test_*.rb) -test: test-unit -test-unit: $(test_units) +test: $(test_units) $(test_units): - $(RUBY) -w -I $(lib) $@ $(RUBY_TEST_OPTS) + $(RUBY) -w -I $(lib) $@ -v check-warnings: @(for i in $$(git ls-files '*.rb'| grep -v '^setup\.rb$$'); \ @@ -26,5 +25,54 @@ coverage: $(MAKE) check $(RUBY) ./test/covshow.rb -.PHONY: all .FORCE-GIT-VERSION-FILE test $(test_units) -.PHONY: check-warnings +pkggem := pkg/$(pkg)-$(VERSION).gem +pkgtgz := pkg/$(pkg)-$(VERSION).tar.gz + +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): .gem-manifest + VERSION=$(VERSION) gem build $(pkg).gemspec + mkdir -p pkg + mv $(@F) $@ + +pkg_extra := GIT-VERSION-FILE lib/dtas/version.rb NEWS +NEWS: + rake -s $@ +gem-man: + $(MAKE) -C Documentation/ gem-man +tgz-man: + $(MAKE) -C Documentation/ install-man mandir=$(CURDIR)/man +.PHONY: tgz-man gem-man + +.gem-manifest: .manifest gem-man + (ls man/*.?; cat .manifest) | LC_ALL=C sort > $@+ + cmp $@+ $@ || mv $@+ $@; rm -f $@+ +.tgz-manifest: .manifest tgz-man + (ls man/*/*; cat .manifest) | LC_ALL=C sort > $@+ + cmp $@+ $@ || mv $@+ $@; rm -f $@+ +.manifest: NEWS fix-perms + rm -rf man + (git ls-files; \ + for i in $(pkg_extra); do echo $$i; done) | \ + LC_ALL=C sort > $@+ + cmp $@+ $@ || mv $@+ $@; rm -f $@+ +$(pkgtgz): distdir = pkg/$(pkg)-$(VERSION) +$(pkgtgz): .tgz-manifest + @test -n "$(distdir)" + $(RM) -r $(distdir) + mkdir -p $(distdir) + tar cf - $$(cat .tgz-manifest) | (cd $(distdir) && tar xf -) + cd pkg && tar cf - $(pkg)-$(VERSION) | gzip -9 > $(@F)+ + mv $@+ $@ + +package: $(pkgtgz) $(pkggem) + +.PHONY: all .FORCE-GIT-VERSION-FILE test $(test_units) NEWS +.PHONY: check-warnings fix-perms diff --git a/Rakefile b/Rakefile index 225e7c0..d0075e6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,71 +1,39 @@ # Copyright (C) 2013, Eric Wong and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) -load "./GIT-VERSION-GEN" -manifest = "Manifest.txt" -gitidx = File.stat(".git/index") rescue nil -if ! File.exist?(manifest) || File.stat(manifest).mtime < gitidx.mtime - system("git ls-files > #{manifest}") - File.open(manifest, "a") do |fp| - fp.puts "NEWS" - fp.puts "lib/dtas/version.rb" - - if system("make -C Documentation") - require 'fileutils' - FileUtils.rm_rf 'man' - if system("make -C Documentation gem-man") - `git ls-files -o man`.split(/\n/).each do |man| - fp.puts man - end - else - warn "failed to install manpages for distribution" - end - else - warn "failed to build manpages for distribution" - end - end - File.open("NEWS", "w") do |fp| - `git tag -l`.split(/\n/).reverse.each do |tag| - %r{\Av(.+)} =~ tag or next - version = $1 - header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) - header = header.split(/\n/) - tagger = header.grep(/\Atagger /)[0] - time = Time.at(tagger.split(/ /)[-2].to_i).utc - date = time.strftime("%Y-%m-%d") - - fp.write("# #{version} / #{date}\n\n#{subject}\n\n#{body}") - end - fp.flush - if fp.size <= 5 - fp.puts "Unreleased" +require 'tempfile' +include Rake::DSL +task "NEWS" do + latest = nil + fp = Tempfile.new("NEWS", ".") + fp.sync = true + `git tag -l`.split(/\n/).reverse.each do |tag| + %r{\Av(.+)} =~ tag or next + version = $1 + header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) + header = header.split(/\n/) + tagger = header.grep(/\Atagger /)[0] + time = Time.at(tagger.split(/ /)[-2].to_i).utc + latest ||= time + date = time.strftime("%Y-%m-%d") + fp.puts "# #{version} / #{date}\n\n#{subject}" + if body && body.strip.size > 0 + fp.puts "\n\n#{body}" end - - fp.write("\n# COPYRIGHT\n") - bdfl = 'Eric Wong ' - fp.puts "Copyright (C) 2013, #{bdfl} and all contributors" - fp.puts "License: GPLv3 or later (http://www.gnu.org/licenses/gpl-3.0.txt)" + fp.puts end + fp.puts "Unreleased" unless fp.size > 0 + fp.puts "# COPYRIGHT" + bdfl = 'Eric Wong ' + fp.puts "Copyright (C) 2013, #{bdfl} and all contributors" + fp.puts "License: GPLv3 or later (http://www.gnu.org/licenses/gpl-3.0.txt)" + fp.rewind + assert_equal fp.read, File.read("NEWS") rescue nil + fp.chmod 0644 + File.rename(fp.path, "NEWS") + fp.close! end -require 'hoe' -Hoe.plugin :git -include Rake::DSL - -h = Hoe.spec('dtas') do |p| - developer 'Eric Wong', 'e@80x24.org' - - self.readme_file = 'README' - self.history_file = 'NEWS' - self.urls = %w(http://dtas.80x24.org/) - self.summary = x = File.readlines("README")[0].split(/\s+/)[1].chomp - self.description = self.paragraphs_of("README", 1) - # no public APIs, no HTML, either - self.need_rdoc = false - self.extra_rdoc_files = [] - license "GPLv3+" -end - -task :rsync_docs do +task rsync_docs: "NEWS" do dest = ENV["RSYNC_DEST"] || "80x24.org:/srv/dtas/" top = %w(INSTALL NEWS README COPYING) files = [] @@ -73,9 +41,9 @@ task :rsync_docs do # git-set-file-times is distributed with rsync, # Also available at: http://yhbt.net/git-set-file-times # on Debian systems: /usr/share/doc/rsync/scripts/git-set-file-times.gz - sh("git", "set-file-times", "Documentation", "examples") + sh("git", "set-file-times", "Documentation", "examples", *top) - Dir['Documentation/*.txt'].to_a.concat(top).each do |txt| + `git ls-files Documentation/*.txt`.split(/\n/).concat(top).each do |txt| gz = "#{txt}.gz" tmp = "#{gz}.#$$" sh("gzip -9 < #{txt} > #{tmp}") @@ -90,40 +58,3 @@ task :rsync_docs do examples = `git ls-files examples`.split("\n") sh("rsync --chmod=Fugo=r -av #{examples.join(' ')} #{dest}/examples/") end - -task :coverage do - env = { - "COVERAGE" => "1", - "RUBYOPT" => "-r./test/helper", - } - File.open("coverage.dump", "w").close # clear - pid = Process.spawn(env, "rake") - _, status = Process.waitpid2(pid) - require './test/covshow' - exit status.exitstatus -end - -base = "dtas-#{h.version}" -task tarball: "pkg/#{base}" do - Dir.chdir("pkg") do - tgz = "#{base}.tar.gz" - tmp = "#{tgz}.#$$" - sh "tar cf - #{base} | gzip -9 > #{tmp}" - File.rename(tmp, tgz) - end -end - -task "pkg/#{base}" => :fix_perms - -task :fix_perms do - sh "git ls-tree -r HEAD | awk '/^100644 / {print $NF}' | xargs chmod 644" - sh "git ls-tree -r HEAD | awk '/^100755 / {print $NF}' | xargs chmod 755" -end - -task dist: [ :tarball, :package ] do - Dir.chdir("pkg") do - %w(dtas-linux dtas-mpris).each do |gem| - sh "gem build ../#{gem}.gemspec" - end - end -end diff --git a/dtas.gemspec b/dtas.gemspec new file mode 100644 index 0000000..e94a927 --- /dev/null +++ b/dtas.gemspec @@ -0,0 +1,13 @@ +# Copyright (C) 2013, Eric Wong and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +Gem::Specification.new do |s| + s.name = %q{dtas} + s.version = ENV["VERSION"] + s.authors = ["dtas hackers"] + s.summary = "duct tape audio suite for *nix" + s.description = File.read("README").split(/\n\n/)[1].strip + s.email = %q{e@80x24.org} + s.files = File.read('.gem-manifest').split(/\n/) + s.homepage = 'http://dtas.80x24.org/' + s.licenses = "GPLv3+" +end -- cgit v1.2.3-24-ge0c7