[DRE-commits] [tdiary-contrib] 01/04: Move old packaging tools
Youhei SASAKI
uwabami-guest at moszumanska.debian.org
Wed Nov 2 10:17:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
uwabami-guest pushed a commit to branch master
in repository tdiary-contrib.
commit d7159bb9d3f314be98615b9de188b34183f9fd7b
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date: Wed Nov 2 18:49:16 2016 +0900
Move old packaging tools
Signed-off-by: Youhei SASAKI <uwabami at gfd-dennou.org>
---
.../old/packaging-tools-author-plugin.rb | 80 +++++++++++++
.../old/packaging-tools-author-theme.rb | 86 ++++++++++++++
.../packaging-tools/old/packaging-tools-author.rb | 56 +++++++++
debian/packaging-tools/packaging-tools-author.rb | 130 +++++++++++++++++++++
4 files changed, 352 insertions(+)
diff --git a/debian/packaging-tools/old/packaging-tools-author-plugin.rb b/debian/packaging-tools/old/packaging-tools-author-plugin.rb
new file mode 100644
index 0000000..79e92fb
--- /dev/null
+++ b/debian/packaging-tools/old/packaging-tools-author-plugin.rb
@@ -0,0 +1,80 @@
+#!/usr/bin/env ruby
+
+#
+# Extract copyright holders.
+# Author: Daigo Moriwaki <beatles at sgtpepper.net>
+# Copyright (c) 2005 Daigo Moriwaki
+# License: GNU GENERAL PUBLIC LICENSE Version 2 or later.
+#
+$KCODE = "E"
+
+require 'pathname'
+
+class Plugin < Struct.new(:name, :author, :copyright, :access, :license)
+ def has_license?
+ license && license.length > 0
+ end
+
+ def to_s
+ s = ""
+ s << "#{name}\n"
+ s << copyright
+ s << "\n\n"
+ s
+ end
+
+ def ==(a)
+ self.to_s == a.to_s
+ end
+end
+
+
+def parse_readme(f)
+ plugin = Plugin.new
+ /(.*)\.rb/ =~ f.basename
+ plugin.name = $1
+ plugin.copyright = ""
+
+ flag = nil
+ f.each_line do |line|
+ line.strip!
+ if /copyright/i =~ line
+ if /^#/ =~ line
+ flag = :sharp
+ else
+ flag = :block
+ end
+ end
+
+ if flag == :sharp
+ if /^#(.*)$/ =~ line
+ plugin.copyright += " " + $1.strip + "\n"
+ else
+ break
+ end
+ elsif flag == :block
+ next if /^=.*copyright/i =~ line
+ if /^=/ =~ line &&
+ break
+ else
+ plugin.copyright += " " + line + "\n"
+ end
+ end
+ end
+
+ plugin
+end
+
+
+def main
+ plugins = []
+ Pathname.new('../misc/plugin').find do |f|
+ plugins << parse_readme(f) if /\.rb$/ =~ f
+ end
+ plugins.sort! {|a,b| a.name <=> b.name}
+ plugins.uniq!
+ plugins.each {|p| print p.to_s}
+end
+
+
+main if __FILE__ == $0
diff --git a/debian/packaging-tools/old/packaging-tools-author-theme.rb b/debian/packaging-tools/old/packaging-tools-author-theme.rb
new file mode 100644
index 0000000..1d891d5
--- /dev/null
+++ b/debian/packaging-tools/old/packaging-tools-author-theme.rb
@@ -0,0 +1,86 @@
+#!/usr/bin/env ruby
+
+#
+# Extract copyright holders.
+# Author: Daigo Moriwaki <beatles at sgtpepper.net>
+# Copyright (c) 2005 Daigo Moriwaki
+# License: GNU GENERAL PUBLIC LICENSE Version 2 or later.
+#
+$KCODE = "E"
+
+require 'pathname'
+
+class Theme < Struct.new(:name, :author, :copyright, :access, :license)
+ def has_license?
+ license && license.length > 0
+ end
+
+ def has_author?
+ author && author.length > 0
+ end
+
+ def to_s
+ s = ""
+ if has_license?
+ s << "#{name}\n"
+ s << " " + author.strip + "\n" if author
+ s << " " + copyright.strip + "\n" if copyright
+ s << " " + access.strip + "\n" if access
+ s << " " + license.strip + "\n" if license
+ s << "\n"
+ else
+ s << "#{name}\n"
+ s << "### NO LICENSE ###\n"
+ s << "\n"
+ end
+
+ s
+ end
+
+ def valid?
+ has_license?
+ has_author?
+ end
+end
+
+
+def parse_readme(f)
+ theme = Theme.new
+ theme.name = f.dirname.basename
+ f.each_line do |line|
+ case line.strip!
+ when /author/i
+ theme.author = line
+ when /copyright/i
+ theme.copyright = line
+ when /access/i
+ theme.access = line
+ when /license/i
+ theme.license = line
+ end
+ end
+
+ theme
+end
+
+
+def main
+ themes = []
+ errors = []
+ Pathname.new('../theme').children.each do |dir|
+ next unless dir.directory?
+ next if /^\./ =~ dir.basename
+ themes << parse_readme(dir + "README")
+ end
+ erros = themes.select {|theme| not theme.valid?}
+ themes -= errors
+
+ themes.sort! {|a,b| a.name <=> b.name}
+ themes.each {|t| print t.to_s}
+
+ puts "### ERRORS ###"
+ p errors
+end
+
+
+main if __FILE__ == $0
diff --git a/debian/packaging-tools/old/packaging-tools-author.rb b/debian/packaging-tools/old/packaging-tools-author.rb
new file mode 100644
index 0000000..0b21c43
--- /dev/null
+++ b/debian/packaging-tools/old/packaging-tools-author.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+#
+# Extract copyright holders.
+# Author: Daigo Moriwaki <beatles at sgtpepper.net>
+# Copyright (c) 2005 Daigo Moriwaki
+# License: GNU GENERAL PUBLIC LICENSE Version 2 or later.
+#
+$KCODE = "E"
+
+def grep(pattern)
+ lines = IO.popen("zsh -c \"grep -i copyright #{pattern}\"") {|io| io.readlines}
+
+ authors = []
+ trush = []
+
+ lines.each do |l|
+ case l
+ when /\d{4},?\s+(.*)/ # 2004(,) ....
+ s = $1.strip
+ s.gsub!(/by\s+/i, "") # 2004 by ...
+ authors << s
+ when /by\s+(.*)$/i # by ...
+ s = $1.strip
+ authors << s
+ when /\(C\)\s*(.*)$/i # (C) ...
+ authors << $1.strip
+ else
+ trush << l
+ end
+ end
+
+ authors.map! do |s|
+ s.gsub!(/\(C\)\s*/,"")
+ s.gsub!(/\. All Rights Reserved\./, "")
+ s.gsub!(/^\d{4}-\d{4}\./,"")
+ s
+ end
+ return authors.uniq.sort, trush
+end
+
+def output(authors, trush)
+ puts authors
+ puts
+ puts trush
+end
+
+puts "+++ tdiary-plugin +++"
+output *grep("tdiary-plugin/**/*.rb")
+puts
+puts "+++ tdiary-theme +++"
+output *grep("tdiary-theme/**/README")
+puts
+puts "+++ tdiary-contrib +++"
+output *grep("tdiary-contrib/**/*.rb")
+
diff --git a/debian/packaging-tools/packaging-tools-author.rb b/debian/packaging-tools/packaging-tools-author.rb
new file mode 100644
index 0000000..d9b5e0e
--- /dev/null
+++ b/debian/packaging-tools/packaging-tools-author.rb
@@ -0,0 +1,130 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+# Extract copyright holders.
+# Author: Daigo Moriwaki <beatles at sgtpepper.net>
+# Copyright (C) 2005 Daigo Moriwaki
+# (C) 2015 Youhei SASAKI
+# License: GNU GENERAL PUBLIC LICENSE Version 2 or later.
+#
+require 'pp'
+def update_hash(hash, key, val)
+ @hash = hash
+ @key = key
+ @val = val
+ unless @hash[@key]
+ @hash[@key] = @val
+ else
+ unless @hash[@key] == ""
+ new = @hash[@key] + ", " + @val
+ else
+ new = @val
+ end
+ @hash[@key] = new
+ end
+ return @hash
+end
+
+def cleanup_author_year(str)
+ @str = str
+ @str = @str.gsub(/,/," ")
+ @str = @str.gsub(/all right reserved/i,"")
+ @str = @str.gsub(/\sby\s/,'')
+ @str = @str.gsub(/notices:/,'')
+ @str = @str.gsub(/\s+/," ")
+ # case @str
+ # when /^(\d{4})-(\S.*)/
+ # @str = $1 + "-" + $2
+ # # when /^(\d{4})\s\d{4}\s(\d{4}.*)/
+ # # @str = $1 + "-" + $2
+ # when /^(\d{4})(\S.*)/
+ # @str = $1 + " " + $2.gsub(/^-\s/,'')
+ # when /(.*)\s(\d{4})/
+ # @str = $2 + " " + $1
+ # end
+ # if @str =~/(\d{4})(\S.*)/
+ # left,right = $1.strip, $2.strip
+ # if right =~ /^-/
+ # @str = left + right
+ # elsif right=~/^(\d{4}.*)/
+ # @str = left + "-" + $1
+ # else
+ # @str = left.gsub(/-$/,'') + " " + right
+ # end
+ # elsif
+ # end
+ return @str
+end
+
+def file_grep
+ lines = IO.popen(
+ "find . -type f \|
+ xargs grep -i copyright \|
+ grep -v debian \|
+ grep -v .git \|
+ grep -v LICENSE \|
+ grep -v ChangeLog \|
+ grep -v misc/plugin/title_tag.rb \|
+ grep -v misc/plugin/makerss.rb
+ " ) {
+ |io| io.readlines
+ }
+ @copyright = Hash.new
+ @unknown = Hash.new
+ @authors = Array.new
+ lines.each do |l|
+ @fname = l.split(":")[0].gsub(/^\.\//,'')
+ @author = nil
+ case l
+ when /\(C\)\s*(.*)$/i # (C) ...
+ @author = $1.strip
+ @author = cleanup_author_year(@author)
+ update_hash(@copyright, @fname, @author)
+ when /Copyright\snotice[\r\n\)]+?(.*)/i
+ @author = $1.strip
+ @author = cleanup_author_year(@author)
+ update_hash(@copyright, @fname, @author)
+ when /Copyright[\s]+?(.*)/i
+ @author = $1.strip
+ @author = cleanup_author_year(@author)
+ update_hash(@copyright, @fname, @author)
+ when /\d{4},?\s+(.*)/ # 2004(,) ....
+ @author = $1.gsub!(/by\s+/i, "") # 2004 by ...
+ @author = cleanup_author_year(@author)
+ update_hash(@copyright, @fname, @author)
+ when /by\s+(.*)$/i # by ...
+ @author = $1.strip
+ @author = cleanup_author_year(@author)
+ update_hash(@copyright, @fname, @author)
+ else
+ update_hash(@unknown, @fname, "unknown")
+ end
+ end
+ @copyright.each do |k,v|
+ @authors.push v
+ end
+ return @copyright, @authors.uniq.sort, @unknwon
+end
+
+copyright, authors, unknown = file_grep
+
+authors.each do |author|
+ data = copyright.find_all {|k,v| v == author}
+ filename_line = "Files: "
+ data.each do |fname|
+ filename_line += fname[0] + " "
+ end
+ puts filename_line.rstrip
+ author = author.split(",")
+ puts "Copyright: (C) " + author.shift
+ unless author.nil?
+ author.each do |name|
+ puts " (C) " + name.strip
+ end
+ end
+ puts "License: GPL-2.0+"
+ puts ""
+ copyright.reject!{|k,v| v == author}
+end
+
+puts unknown
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/tdiary-contrib.git
More information about the Pkg-ruby-extras-commits
mailing list