xezat 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.gitmodules +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +207 -0
  7. data/Rakefile +2 -0
  8. data/bin/xezat +14 -0
  9. data/lib/xezat.rb +6 -0
  10. data/lib/xezat/command/bump.rb +174 -0
  11. data/lib/xezat/command/create.rb +105 -0
  12. data/lib/xezat/command/debug.rb +30 -0
  13. data/lib/xezat/command/doctor.rb +45 -0
  14. data/lib/xezat/command/generate.rb +50 -0
  15. data/lib/xezat/command/validate.rb +43 -0
  16. data/lib/xezat/commands.rb +32 -0
  17. data/lib/xezat/cygchangelog.rb +53 -0
  18. data/lib/xezat/cygclasses.rb +33 -0
  19. data/lib/xezat/detector/autoconf.rb +16 -0
  20. data/lib/xezat/detector/automake.rb +16 -0
  21. data/lib/xezat/detector/boost.m4.rb +20 -0
  22. data/lib/xezat/detector/cmake.rb +16 -0
  23. data/lib/xezat/detector/gengetopt.rb +16 -0
  24. data/lib/xezat/detector/libtool.rb +16 -0
  25. data/lib/xezat/detector/make.rb +19 -0
  26. data/lib/xezat/detectors.rb +36 -0
  27. data/lib/xezat/main.rb +13 -0
  28. data/lib/xezat/packages.rb +21 -0
  29. data/lib/xezat/refine/linguist/file_blob.rb +14 -0
  30. data/lib/xezat/validator/m4.rb +30 -0
  31. data/lib/xezat/validator/pkgconfig.rb +23 -0
  32. data/lib/xezat/validators.rb +38 -0
  33. data/lib/xezat/variables.rb +48 -0
  34. data/lib/xezat/version.rb +3 -0
  35. data/share/xezat/compilers.json +39 -0
  36. data/share/xezat/invoke_cygport_dep.sh +5 -0
  37. data/share/xezat/repository/bitbucket.json +5 -0
  38. data/share/xezat/repository/github.json +5 -0
  39. data/share/xezat/repository/google.json +7 -0
  40. data/share/xezat/repository/sourceforge.json +6 -0
  41. data/share/xezat/show_cygport_description.sh +8 -0
  42. data/share/xezat/show_cygport_variable.sh +30 -0
  43. data/share/xezat/template/README.erb +60 -0
  44. data/share/xezat/template/cygport.erb +19 -0
  45. data/share/xezat/template/pkgconfig.erb +10 -0
  46. data/share/xezat/template/setup.erb +17 -0
  47. data/test/test.rb +18 -0
  48. data/test/xezat/command/fixture/doctor/a.lst.gz +0 -0
  49. data/test/xezat/command/fixture/doctor/b1.lst.gz +0 -0
  50. data/test/xezat/command/fixture/doctor/b2.lst.gz +0 -0
  51. data/test/xezat/command/test_create.rb +47 -0
  52. data/test/xezat/command/test_doctor.rb +16 -0
  53. data/test/xezat/detector/fixture/autoconf/no/configure.scan +1 -0
  54. data/test/xezat/detector/fixture/autoconf/yes_root/configure.ac +1 -0
  55. data/test/xezat/detector/fixture/autoconf/yes_subdir/subdir/configure.ac +1 -0
  56. data/test/xezat/detector/fixture/automake/no/Makefile.in +1 -0
  57. data/test/xezat/detector/fixture/automake/yes_root/Makefile.am +1 -0
  58. data/test/xezat/detector/fixture/automake/yes_subdir/subdir/Makefile.am +1 -0
  59. data/test/xezat/detector/fixture/boost.m4/no/configure.ac +1 -0
  60. data/test/xezat/detector/fixture/boost.m4/yes/configure.ac +1 -0
  61. data/test/xezat/detector/fixture/cmake/no/CMakeList.txt +1 -0
  62. data/test/xezat/detector/fixture/cmake/yes_root/CMakeLists.txt +1 -0
  63. data/test/xezat/detector/fixture/cmake/yes_subdir/subdir/CMakeLists.txt +1 -0
  64. data/test/xezat/detector/fixture/gengetopt/no/xezat.log +1 -0
  65. data/test/xezat/detector/fixture/gengetopt/yes_root/xezat.ggo +1 -0
  66. data/test/xezat/detector/fixture/gengetopt/yes_subdir/subdir/xezat.ggo +1 -0
  67. data/test/xezat/detector/test_autoconf.rb +23 -0
  68. data/test/xezat/detector/test_automake.rb +23 -0
  69. data/test/xezat/detector/test_boost.m4.rb +19 -0
  70. data/test/xezat/detector/test_cmake.rb +23 -0
  71. data/test/xezat/detector/test_gengetopt.rb +23 -0
  72. data/test/xezat/test_cygchangelog.rb +25 -0
  73. data/test/xezat/test_cygclasses.rb +31 -0
  74. data/test/xezat/test_variables.rb +15 -0
  75. data/test/xezat/validator/fixture/m4/no/usr/share/aclocal/.gitkeep +0 -0
  76. data/test/xezat/validator/fixture/m4/skip/usr/share/aclocal/.gitkeep +0 -0
  77. data/test/xezat/validator/fixture/m4/yes/usr/share/aclocal/test.m4 +1 -0
  78. data/test/xezat/validator/test_m4.rb +23 -0
  79. data/xezat.gemspec +28 -0
  80. metadata +239 -0
@@ -0,0 +1,16 @@
1
+ require 'find'
2
+ require 'xezat/detectors'
3
+
4
+ module Xezat
5
+ module Detector
6
+ class Cmake
7
+ DetectorManager::register(:cmake, self)
8
+ def detect(variables)
9
+ Find::find(variables[:S]) do |file|
10
+ return true if file.end_with?(File::SEPARATOR + 'CMakeLists.txt')
11
+ end
12
+ false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'find'
2
+ require 'xezat/detectors'
3
+
4
+ module Xezat
5
+ module Detector
6
+ class Gengetopt
7
+ DetectorManager::register(:gengetopt, self)
8
+ def detect(variables)
9
+ Find::find(variables[:S]) do |file|
10
+ return true if file.end_with?('.ggo')
11
+ end
12
+ false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'find'
2
+ require 'xezat/detectors'
3
+
4
+ module Xezat
5
+ module Detector
6
+ class Libtool
7
+ DetectorManager::register(:libtool, self)
8
+ def detect(variables)
9
+ Find::find(variables[:S]) do |file|
10
+ return true if file.end_with?(File::SEPARATOR + 'ltmain.sh')
11
+ end
12
+ false
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ require 'find'
2
+ require 'xezat/detectors'
3
+
4
+ module Xezat
5
+ module Detector
6
+ class Make
7
+ DetectorManager::register(:make, self)
8
+ def detect(variables)
9
+ Find::find(variables[:B]) do |file|
10
+ return true if file.end_with?(File::SEPARATOR + 'Makefile')
11
+ end
12
+ File::foreach(File::join(variables[:top], variables[:cygportfile])) do |line|
13
+ return true if line.index('cygmake')
14
+ end
15
+ false
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ module Xezat
2
+ # detector が多重定義された場合に投げられる例外
3
+ class MultipleDetectorDefinitionError < StandardError
4
+ end
5
+
6
+ class DetectorManager
7
+ @@detectors = {}
8
+
9
+ # detector を登録する
10
+ def self.register(name, klass)
11
+ raise MultipleDetectorDefinitionError, "'#{name}' already defined" if @@detectors.key?(name)
12
+ @@detectors[name] = klass.new
13
+ end
14
+
15
+ # detector をロードする
16
+ def self.load_default_detectors(path = File::expand_path(File::join(File::dirname(__FILE__), 'detector')))
17
+ Dir::glob(File::join(path, '*.rb')) do |rb|
18
+ require rb
19
+ end
20
+ end
21
+
22
+ # 登録されている detector で source tree を検証する
23
+ def self.detect(variables)
24
+ tools = []
25
+ @@detectors.each do |name, detector|
26
+ tools << name if detector.detect(variables)
27
+ end
28
+ tools
29
+ end
30
+
31
+ def self.[](name)
32
+ @@detectors[name]
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,13 @@
1
+ require 'logger/colors'
2
+ require 'mercenary'
3
+ require 'xezat/commands'
4
+ require 'xezat/version'
5
+
6
+ Mercenary.program(:xezat) do |p|
7
+ p.version Xezat::VERSION
8
+ p.description 'Xezat is the complement of cygport'
9
+ p.syntax 'xezat <subcommand> [options]'
10
+
11
+ Xezat::CommandManager::program = p
12
+ Xezat::CommandManager::load_default_commands
13
+ end
@@ -0,0 +1,21 @@
1
+ module Xezat
2
+ class PackageManager
3
+ # install.db を解析して Hash にする
4
+ def initialize(str)
5
+ @packages = {}
6
+ str.lines do |line|
7
+ record = line.split(/\s+/)
8
+ next unless record.size == 3 # /^hoge hoge-ver-rel.tar.bz2 0$/
9
+ @packages[record[0].intern] = record[1].gsub(/\.tar\.bz2$/, '')
10
+ end
11
+ end
12
+
13
+ def [](key)
14
+ @packages[key]
15
+ end
16
+
17
+ def self.get_installed_packages(db_path = '/etc/setup/installed.db')
18
+ self.new(File::read(db_path))
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'linguist'
2
+ require 'string/scrub' unless String::respond_to?(:scrub)
3
+
4
+ module Xezat
5
+ module Refine
6
+ module Linguist
7
+ class FileBlob < ::Linguist::FileBlob
8
+ def data
9
+ super.scrub
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'fileutils'
2
+ require 'open3'
3
+ require 'xezat/validators'
4
+
5
+ module Xezat
6
+ module Validator
7
+ # /usr/share/aclocal/*.m4 を検証する
8
+ class M4
9
+ ValidatorManager::register(:m4, self)
10
+ def validate(variables)
11
+ acdir = File::join(variables[:D], 'usr', 'share', 'aclocal')
12
+ detail = nil
13
+ result = nil
14
+ if Dir::exists?(acdir)
15
+ command = ['aclocal', "--system-acdir=#{acdir}"]
16
+ Dir::chdir(variables[:T]) do
17
+ FileUtils::touch('configure.ac')
18
+ stdout, error, status = Open3.capture3(command.join(' '))
19
+ result = error.empty?
20
+ unless result
21
+ detail = error.gsub(acdir + '/', '')
22
+ end
23
+ end
24
+ end
25
+ [result, detail]
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ require 'xezat/validators'
2
+
3
+ module Xezat
4
+ module Validator
5
+ class Pkgconfig
6
+ ValidatorManager::register(:pkgconfig ,self)
7
+ def validate(variables)
8
+ pcdir = File::join(variables[:D], 'usr', 'lib', 'pkgconfig')
9
+ result = false
10
+ if Dir::exists?(pcdir)
11
+ Find::find(pcdir) do |file|
12
+ if file.end_with?('.pc')
13
+ result = result || File::open(file).read().index('@').nil?
14
+ end
15
+ end
16
+ else
17
+ result = nil
18
+ end
19
+ [result, nil]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ module Xezat
2
+ # validator が多重定義された場合に投げられる例外
3
+ class MultipleValidatorDefinitionError < StandardError
4
+ end
5
+
6
+ # validator を管理するクラス
7
+ class ValidatorManager
8
+ @@validators = {}
9
+
10
+ # validator を登録する
11
+ def self.register(name, klass)
12
+ raise MultipleValidatorDefinitionError, "'#{name}' already defined" if @@validators.key?(name)
13
+ @@validators[name] = klass.new
14
+ end
15
+
16
+ # validator をロードする
17
+ def self.load_default_validators(path = File::expand_path(File::join(File::dirname(__FILE__), 'validator')))
18
+ Dir::glob(File::join(path, '*.rb')) do |rb|
19
+ require rb
20
+ end
21
+ end
22
+
23
+ # 登録されている validator で install tree を検証する
24
+ def self.validate(variables)
25
+ results = {}
26
+ @@validators.each do |name, validator|
27
+ result, detail = validator.validate(variables)
28
+ results[name] = {result: result, detail: detail}
29
+ end
30
+ results
31
+ end
32
+
33
+ def self.[](name)
34
+ @@validators[name]
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ require 'open3'
2
+ require 'uri'
3
+ require 'yaml'
4
+ require 'xezat'
5
+
6
+ module Xezat
7
+ # cygport 外部プロセスが異常終了した場合に投げられる例外
8
+ class CygportProcessError < StandardError
9
+ end
10
+
11
+ # cygport 変数を管理するクラス
12
+ class VariableManager
13
+ def initialize(str, description = nil)
14
+ @variables = YAML.load(str).each_value do |v|
15
+ v.strip! if v.respond_to?(:strip)
16
+ end
17
+ @variables[:DESCRIPTION] = description unless description.nil?
18
+ end
19
+
20
+ def [](key)
21
+ @variables[key]
22
+ end
23
+
24
+ def key?(key)
25
+ @variables.key?(key)
26
+ end
27
+
28
+ def each(&block)
29
+ @variables.each do |key, value|
30
+ block.call(key, value)
31
+ end
32
+ end
33
+
34
+ # 指定された cygport に基づいたシェル変数群を取得する
35
+ def self.get_default_variables(cygport)
36
+ command = ['bash', File.expand_path(File.join(DATA_DIR, 'show_cygport_variable.sh')), cygport]
37
+ result, error, status = Open3.capture3(command.join(' '))
38
+ raise CygportProcessError, error unless status.success?
39
+
40
+ # DESCRIPTION だけ改行を保持したまま取り込みたい
41
+ command = ['bash', File.expand_path(File.join(DATA_DIR, 'show_cygport_description.sh')), cygport]
42
+ description, error, status = Open3.capture3(command.join(' '))
43
+ raise CygportProcessError, error unless status.success?
44
+
45
+ self.new(result, description)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Xezat
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,39 @@
1
+ {
2
+ "BISON": {
3
+ "package": "bison"
4
+ },
5
+ "C": {
6
+ "package": "gcc-core",
7
+ "dependencies": [
8
+ "binutils"
9
+ ]
10
+ },
11
+ "C++": {
12
+ "package": "gcc-g++",
13
+ "dependencies": [
14
+ "binutils",
15
+ "gcc-core"
16
+ ]
17
+ },
18
+ "FORTRAN": {
19
+ "package": "gcc-fortran",
20
+ "dependencies": [
21
+ "binutils",
22
+ "gcc-core"
23
+ ]
24
+ },
25
+ "Objective-C": {
26
+ "package": "gcc-objc",
27
+ "dependencies": [
28
+ "binutils",
29
+ "gcc-core"
30
+ ]
31
+ },
32
+ "Objective-C++": {
33
+ "package": "gcc-objc++",
34
+ "dependencies": [
35
+ "binutils",
36
+ "gcc-core"
37
+ ]
38
+ }
39
+ }
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ export LANG=C
4
+
5
+ source ${CYGPORT:-/usr/bin/cygport} $* dep
@@ -0,0 +1,5 @@
1
+ {
2
+ "HOMEPAGE": "https://bitbucket.org/fd00/${PN}",
3
+ "SRC_URI": "https://bitbucket.org/fd00/${PN}/downloads/${P}.tar.gz",
4
+ "HG_URI": "https://bitbucket.org/fd00/${PN}"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "HOMEPAGE": "https://github.com/fd00/${PN}",
3
+ "SRC_URI": "https://github.com/fd00/${PN}/archive/v${PV}.tar.gz",
4
+ "GIT_URI": "https://github.com/fd00/${PN}.git"
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "HOMEPAGE": "https://code.google.com/p/${PN}/",
3
+ "SRC_URI": "https://${PN}.googlecode.com/files/${P}.tar.gz",
4
+ "SVN_URI": "http://${PN}.googlecode.com/svn/trunk/",
5
+ "GIT_URI": "https://code.google.com/p/${PN}/",
6
+ "HG_URI": "https://code.google.com/p/${PN}/"
7
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "HOMEPAGE": "http://${PN}.sf.net/",
3
+ "SRC_URI": "mirror://sourceforge/${PN}/${P}.tar.gz",
4
+ "SVN_URI": "svn://svn.code.sf.net/p/${PN}/code",
5
+ "GIT_URI": "git://git.code.sf.net/p/${PN}/code"
6
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ show_cygport_description()
4
+ {
5
+ declare | grep '^DESCRIPTION=' | sed -e 's/^DESCRIPTION=\$//g' -e 's/\\n/\n/g' -e "s/^'//g" -e "s/'$//" -e "s/\\\//g"
6
+ }
7
+
8
+ source ${CYGPORT:-/usr/bin/cygport} $* show_cygport_description
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+
3
+ show_cygport_variables()
4
+ {
5
+ for var in `compgen -A variable`
6
+ do
7
+ [ $var = 'BASH_COMMAND' ] && continue
8
+ [ $var = 'COMP_WORDBREAKS' ] && continue
9
+ [ $var = 'HOMEPATH' ] && continue
10
+ [[ ${!var} =~ ^[A-Za-z]:.* ]] && continue
11
+
12
+ echo -n "!ruby/sym" $var:
13
+ if [[ `declare -p $var` =~ "declare -a" ]]
14
+ then
15
+ echo
16
+ x=`printf '${!%s[@]}' $var`
17
+ eval "keys=$x"
18
+ for key in $keys
19
+ do
20
+ x=`printf '${%s[%s]}' $var $key`
21
+ eval "value=$x"
22
+ echo " -" $value
23
+ done
24
+ else
25
+ echo ' "'`echo "${!var}" | sed -e "s/\\n/ /g"`'"'
26
+ fi
27
+ done
28
+ }
29
+
30
+ source ${CYGPORT:-/usr/bin/cygport} $* show_cygport_variables
@@ -0,0 +1,60 @@
1
+ <%= variables[:PN] %>
2
+ ------------------------------------------
3
+ <%= variables[:DESCRIPTION] -%>
4
+
5
+ Runtime requirements:
6
+ <% info[:runtimes].each { |runtime| -%>
7
+ <%= runtime %>
8
+ <% } -%>
9
+
10
+ Build requirements:
11
+ (besides corresponding -devel packages)
12
+ <% info[:developments].each { |development| -%>
13
+ <%= development %>
14
+ <% } -%>
15
+
16
+ Canonical website:
17
+ <%= variables[:HOMEPAGE] %>
18
+
19
+ Canonical download:
20
+ <% if info[:src_uri].is_a?(Array) -%>
21
+ <%= info[:src_uri][0] %>
22
+ <% else -%>
23
+ <%= info[:src_uri] %>
24
+ <% end -%>
25
+
26
+ -------------------------------------------
27
+
28
+ Build instructions:
29
+ 1. unpack <%= variables[:P] -%>-X-src.tar.xz
30
+ 2. if you use setup to install this src package,
31
+ it will be unpacked under /usr/src automatically
32
+ % cd /usr/src
33
+ % cygport ./<%= variables[:P] -%>-X.cygport all
34
+
35
+ This will create:
36
+ /usr/src/<%= variables[:P] %>-X-src.tar.xz
37
+ <% variables[:pkg_name].each { |pkg_name| -%>
38
+ /usr/src/<%= pkg_name + '-' + variables[:PVR].sub('-' + variables[:PR], '') %>-X.tar.xz
39
+ <% } -%>
40
+
41
+ -------------------------------------------
42
+
43
+ Files included in the binary package:
44
+
45
+ <% variables[:pkg_name].each { |pkg_name| -%>
46
+ (<%= pkg_name %>)
47
+ <% info[:files][pkg_name.intern].each { |file| -%>
48
+ <%= file %>
49
+ <% } -%>
50
+
51
+ <% } -%>
52
+ ------------------
53
+
54
+ Port Notes:
55
+
56
+ <% info[:changelog].each { |version, log| -%>
57
+ ----- version <%= version -%> -----
58
+ <%= log %>
59
+
60
+ <% } -%>