xezat 0.1.0 → 0.1.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 (60) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +75 -0
  3. data/.fasterer.yml +6 -0
  4. data/.rubocop.yml +33 -0
  5. data/Gemfile +4 -2
  6. data/README.md +2 -0
  7. data/Rakefile +5 -3
  8. data/bin/console +4 -3
  9. data/exe/xezat +1 -0
  10. data/lib/xezat.rb +8 -0
  11. data/lib/xezat/command/bump.rb +16 -127
  12. data/lib/xezat/command/bump/changelog.rb +29 -0
  13. data/lib/xezat/command/bump/compiler.rb +28 -0
  14. data/lib/xezat/command/bump/cygport_dep.rb +18 -0
  15. data/lib/xezat/command/bump/development_package.rb +22 -0
  16. data/lib/xezat/command/bump/file.rb +37 -0
  17. data/lib/xezat/command/bump/language.rb +30 -0
  18. data/lib/xezat/command/bump/runtime_package.rb +17 -0
  19. data/lib/xezat/command/bump/src_uri.rb +21 -0
  20. data/lib/xezat/command/bump/tool.rb +13 -0
  21. data/lib/xezat/command/debug.rb +2 -2
  22. data/lib/xezat/command/doctor.rb +4 -2
  23. data/lib/xezat/command/generate.rb +2 -2
  24. data/lib/xezat/command/init.rb +15 -11
  25. data/lib/xezat/command/port.rb +16 -7
  26. data/lib/xezat/config.rb +3 -1
  27. data/lib/xezat/cygchangelog.rb +24 -18
  28. data/lib/xezat/cygclasses.rb +4 -1
  29. data/lib/xezat/cygversion.rb +5 -3
  30. data/lib/xezat/debugger/linguist.rb +4 -0
  31. data/lib/xezat/debugger/variable.rb +2 -0
  32. data/lib/xezat/detector/autoconf.rb +2 -0
  33. data/lib/xezat/detector/automake.rb +2 -0
  34. data/lib/xezat/detector/boost.m4.rb +3 -0
  35. data/lib/xezat/detector/cmake.rb +2 -0
  36. data/lib/xezat/detector/gengetopt.rb +2 -0
  37. data/lib/xezat/detector/gnulib.rb +2 -0
  38. data/lib/xezat/detector/gobject-introspection.rb +2 -0
  39. data/lib/xezat/detector/halibut.rb +2 -0
  40. data/lib/xezat/detector/libQt5Core-devel.rb +2 -0
  41. data/lib/xezat/detector/libtool.rb +9 -0
  42. data/lib/xezat/detector/make.rb +3 -2
  43. data/lib/xezat/detector/meson.rb +2 -0
  44. data/lib/xezat/detector/ninja.rb +4 -0
  45. data/lib/xezat/detector/python27.rb +24 -0
  46. data/lib/xezat/detector/{python-docutils.rb → python3-docutils.rb} +5 -2
  47. data/lib/xezat/detector/python36.rb +24 -0
  48. data/lib/xezat/detector/roundup.rb +2 -0
  49. data/lib/xezat/detector/waf.rb +9 -1
  50. data/lib/xezat/detectors.rb +12 -1
  51. data/lib/xezat/ext/linguist/file_blob.rb +3 -1
  52. data/lib/xezat/generator/pkgconfig.rb +23 -20
  53. data/lib/xezat/main.rb +4 -3
  54. data/lib/xezat/packages.rb +7 -0
  55. data/lib/xezat/variables.rb +23 -4
  56. data/lib/xezat/version.rb +3 -1
  57. data/share/xezat/compilers.json +0 -3
  58. data/xezat.gemspec +13 -9
  59. metadata +70 -15
  60. data/.travis.yml +0 -6
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+ require 'xezat/command/bump/compiler'
5
+ require 'xezat/command/bump/language'
6
+ require 'xezat/command/bump/tool'
7
+
8
+ module Xezat
9
+ module Command
10
+ class Bump
11
+ def get_development_packages(variables, packages)
12
+ LOG.debug('Collect development packages')
13
+ compilers = get_compilers(get_languages(variables[:S]), variables)
14
+ tools = get_tools(variables)
15
+ development_packages = (compilers + tools + [:cygport]).uniq.sort
16
+ development_packages.map! do |package|
17
+ packages[package] || ''
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+
5
+ module Xezat
6
+ class IllegalStateError < StandardError
7
+ end
8
+
9
+ module Command
10
+ class Bump
11
+ def get_files(variables)
12
+ LOG.debug('Collect files')
13
+ pkg2files = {}
14
+ variables[:pkg_name].each do |pkg_name|
15
+ LOG.debug(" Collect #{pkg_name}")
16
+ lst_file = File.expand_path(File.join(variables[:T], ".#{pkg_name}.lst"))
17
+ raise IllegalStateError, "No such file: #{lst_file}" unless FileTest.readable?(lst_file)
18
+
19
+ lines = File.readlines(lst_file)
20
+ lines.delete_if do |path|
21
+ path.strip!
22
+ path[-1] == File::SEPARATOR # ignore directory
23
+ end
24
+ lines.map! do |path|
25
+ File::SEPARATOR + path
26
+ end
27
+ if variables[:PN] == pkg_name
28
+ readme = File::SEPARATOR + File.join('usr', 'share', 'doc', 'Cygwin', "#{pkg_name}.README")
29
+ lines << readme.strip unless lines.include?(readme)
30
+ end
31
+ pkg2files[pkg_name.intern] = lines.sort
32
+ end
33
+ pkg2files
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+ require 'xezat/ext/linguist/file_blob'
5
+
6
+ module Xezat
7
+ module Command
8
+ class Bump
9
+ def get_languages(top_src_dir)
10
+ LOG.debug('Collect languages')
11
+ languages_file = File.expand_path(File.join(DATA_DIR, 'languages.json'))
12
+ languages_candidates = JSON.parse(File.read(languages_file))
13
+ languages = []
14
+ Find.find(top_src_dir) do |path|
15
+ next if FileTest.directory?(path)
16
+
17
+ name = languages_candidates[File.extname(path)]
18
+ if name.nil?
19
+ language = Xezat::Linguist::FileBlob.new(path).language
20
+ next if language.nil?
21
+
22
+ name = language.name
23
+ end
24
+ languages << name
25
+ end
26
+ languages.uniq
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+ require 'xezat/command/bump/cygport_dep'
5
+ require 'xezat/variables'
6
+
7
+ module Xezat
8
+ module Command
9
+ class Bump
10
+ def get_runtime_packages(cygport)
11
+ LOG.debug('Collect runtime packages from cygport dep')
12
+ result = invoke_cygport_dep(cygport)
13
+ result.gsub(/^.*\*\*\*.*$/, '').split($INPUT_RECORD_SEPARATOR).map(&:lstrip)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat'
4
+ require 'xezat/cygclasses'
5
+
6
+ module Xezat
7
+ module Command
8
+ class Bump
9
+ def get_src_uri(vars, cygclasses = CygclassManager.new)
10
+ LOG.debug('Collect SRC_URI')
11
+ cygclasses.vcs.each do |vcs|
12
+ next unless vars.key?("_#{vcs}_CYGCLASS_".intern)
13
+
14
+ src_uri_key = "#{vcs.to_s.upcase}_URI".intern
15
+ return vars[src_uri_key].split if vars.key?(src_uri_key)
16
+ end
17
+ vars[:SRC_URI].split
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xezat/detectors'
4
+
5
+ module Xezat
6
+ module Command
7
+ class Bump
8
+ def get_tools(variables)
9
+ DetectorManager.new.detect(variables)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
2
4
 
3
5
  module Xezat
4
6
  module Command
5
7
  class Debug < Thor
6
-
7
8
  desc 'linguist cygport', 'Show used programming languages'
8
9
 
9
10
  def linguist(cygport)
@@ -17,7 +18,6 @@ module Xezat
17
18
  require 'xezat/debugger/variable'
18
19
  Debugger::Variable.new(cygport).debug
19
20
  end
20
-
21
21
  end
22
22
  end
23
23
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'zlib'
2
4
 
3
5
  module Xezat
@@ -5,8 +7,7 @@ module Xezat
5
7
  class Doctor
6
8
  include Xezat
7
9
 
8
- def initialize
9
- end
10
+ def initialize; end
10
11
 
11
12
  def execute
12
13
  get_contents_uniqueness.each do |path, pkg|
@@ -22,6 +23,7 @@ module Xezat
22
23
  gz.each_line do |line|
23
24
  line.strip!
24
25
  next if line.end_with?('/')
26
+
25
27
  path = line.intern
26
28
  content2pkg[path] = [] unless content2pkg.key?(path)
27
29
  content2pkg[path] << pkg
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
2
4
 
3
5
  module Xezat
4
6
  module Command
5
7
  class Generate < Thor
6
-
7
8
  desc 'generate pkgconfig cygport', 'Generate *.pc'
8
9
  option :overwrite, type: :boolean, aliases: '-o', desc: 'overwrite *.pc'
9
10
 
@@ -11,7 +12,6 @@ module Xezat
11
12
  require 'xezat/generator/pkgconfig'
12
13
  Generator::Pkgconfig.new(options, cygport).generate
13
14
  end
14
-
15
15
  end
16
16
  end
17
17
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'facets/file/atomic_write'
2
4
  require 'json'
3
5
  require 'xezat/config'
4
6
  require 'xezat/cygclasses'
5
7
 
6
8
  module Xezat
7
-
8
9
  class NoSuchRepositoryError < StandardError
9
10
  end
10
11
 
@@ -29,7 +30,8 @@ module Xezat
29
30
  def execute
30
31
  cygclass_dir = config(@options[:config])['cygwin']['cygclassdir']
31
32
  repository_variables = get_repository_variables(@options['repository'])
32
- raise UnoverwritableCygportError, "#{cygport} already exists" if (FileTest.exist?(@cygport) && !@options['overwrite'])
33
+ raise UnoverwritableCygportError, "#{cygport} already exists" if FileTest.exist?(@cygport) && !@options['overwrite']
34
+
33
35
  cygclasses = (@options['inherit'] || '').split(',')
34
36
  template_variables = get_template_variables(repository_variables, CygclassManager.new(cygclass_dir), cygclasses)
35
37
  File.atomic_write(@cygport) do |f|
@@ -40,12 +42,13 @@ module Xezat
40
42
  def get_repository_variables(repository)
41
43
  if repository
42
44
  repository_file = File.expand_path(File.join(REPOSITORY_DIR, "#{repository}.json"))
43
- raise NoSuchRepositoryError, "No such repository: #{template}" unless (FileTest.exist?(repository_file) || FileTest.readable?(repository_file))
45
+ raise NoSuchRepositoryError, "No such repository: #{template}" unless FileTest.exist?(repository_file) || FileTest.readable?(repository_file)
46
+
44
47
  JSON.parse(File.read(repository_file), symbolize_names: true)
45
48
  else
46
49
  {
47
- HOMEPAGE: '',
48
- SRC_URI: ''
50
+ HOMEPAGE: '',
51
+ SRC_URI: ''
49
52
  }
50
53
  end
51
54
  end
@@ -55,16 +58,17 @@ module Xezat
55
58
  vcs_prefix = 'SRC'
56
59
  cygclasses.each do |cygclass|
57
60
  raise NoSuchCygclassError, "No such cygclass: #{cygclass}" unless cygclass_manager.include?(cygclass.intern)
58
- if cygclass_manager.vcs?(cygclass.intern)
59
- raise CygclassConflictError, "#{cygclass} conflict with #{vcs_class}" if vcs_class
60
- vcs_class = cygclass
61
- end
61
+
62
+ next unless cygclass_manager.vcs?(cygclass.intern)
63
+ raise CygclassConflictError, "#{cygclass} conflict with #{vcs_class}" if vcs_class
64
+
65
+ vcs_class = cygclass
62
66
  end
63
67
  vcs_prefix = vcs_class.to_s.upcase if vcs_class
64
68
  vcs_uri = "#{vcs_prefix}_URI".intern
65
69
  {
66
- :HOMEPAGE => original_template_variables[:HOMEPAGE],
67
- vcs_uri => original_template_variables[vcs_uri]
70
+ :HOMEPAGE => original_template_variables[:HOMEPAGE],
71
+ vcs_uri => original_template_variables[vcs_uri]
68
72
  }
69
73
  end
70
74
 
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'xezat'
1
5
  require 'xezat/config'
2
6
  require 'xezat/variables'
3
7
 
4
8
  module Xezat
5
-
6
9
  class NoPortDirectoryError < StandardError
7
10
  end
8
11
 
@@ -16,24 +19,30 @@ module Xezat
16
19
  end
17
20
 
18
21
  def execute
22
+ LOG.debug('Start porting')
19
23
  vars = variables(@cygport)
20
24
  d = File.expand_path(File.join(get_port_directory(@options), vars[:PN]))
25
+ cygport = File.expand_path(File.join(vars[:top], @cygport))
26
+ readme = File.expand_path(File.join(vars[:C], 'README'))
27
+ src_patch = File.expand_path(File.join(vars[:patchdir], "#{vars[:PF]}.src.patch"))
28
+
21
29
  fuo = {
22
- noop: @options[:noop],
23
- verbose: @options[:noop] || @options[:verbose]
30
+ noop: @options[:noop],
31
+ verbose: @options[:noop] || @options[:verbose]
24
32
  }
25
33
 
26
34
  FileUtils.mkdir_p(d, fuo)
27
- FileUtils.cp(File.expand_path(File.join(vars[:top], @cygport)), d, fuo)
28
- FileUtils.cp(File.expand_path(File.join(vars[:C], 'README')), d, fuo)
29
- src_patch = File.expand_path(File.join(vars[:patchdir], "#{vars[:PF]}.src.patch"))
35
+ FileUtils.cp(cygport, d, fuo)
36
+ FileUtils.cp(readme, d, fuo)
30
37
  FileUtils.cp(src_patch, d, fuo) unless FileTest.zero?(src_patch)
38
+ LOG.debug('End porting')
31
39
  end
32
40
 
33
41
  def get_port_directory(options)
34
- conf = config(@options[:config])
42
+ conf = config(options[:config])
35
43
  port_dir = conf['xezat']['portdir'] || options[:portdir]
36
44
  raise NoPortDirectoryError if port_dir.nil?
45
+
37
46
  port_dir
38
47
  end
39
48
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'inifile'
2
4
 
3
5
  module Xezat
4
6
  def config(filepath = nil)
5
7
  config = IniFile.new
6
8
  config['cygwin'] = {
7
- 'cygclassdir' => '/usr/share/cygport/cygclass'
9
+ 'cygclassdir' => '/usr/share/cygport/cygclass'
8
10
  }
9
11
  config['xezat'] = {
10
12
  }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'xezat/cygversion'
2
4
 
3
5
  module Xezat
@@ -6,29 +8,32 @@ module Xezat
6
8
 
7
9
  class Cygchangelog
8
10
  def initialize(str = '')
9
- @changelogs = str.empty? ? {} : nil
11
+ @changelogs = nil
10
12
  version = nil
11
13
  str.each_line do |line|
12
14
  line.rstrip!
13
- if /^Port Notes:$/ === line
15
+ if line == 'Port Notes:'
14
16
  @changelogs = {}
17
+ next
18
+ end
19
+ next if @changelogs.nil?
20
+
21
+ match_version = /^----- version (.+) -----$/.match(line)
22
+ if match_version
23
+ version = match_version[1].intern
24
+ next
25
+ end
26
+ match_content = /^(.+)$/.match(line)
27
+ next unless match_content
28
+ raise ReadmeSyntaxError, 'Version missing' if version.nil?
29
+
30
+ if @changelogs.key?(version)
31
+ @changelogs[version] << $INPUT_RECORD_SEPARATOR << match_content[1]
15
32
  else
16
- unless @changelogs.nil?
17
- if match_data = /^----- version (.+) -----$/.match(line)
18
- version = match_data[1].intern
19
- else
20
- if match_data = /^(.+)$/.match(line)
21
- raise ReadmeSyntaxError, 'Version missing' if version.nil?
22
- if @changelogs.key?(version)
23
- @changelogs[version] << $INPUT_RECORD_SEPARATOR << match_data[1]
24
- else
25
- @changelogs[version] = match_data[1]
26
- end
27
- end
28
- end
29
- end
33
+ @changelogs[version] = match_content[1]
30
34
  end
31
35
  end
36
+ @changelogs ||= {}
32
37
  end
33
38
 
34
39
  def [](key)
@@ -44,9 +49,10 @@ module Xezat
44
49
  end
45
50
 
46
51
  def each
47
- @changelogs.sort do |a, b|
52
+ logs = @changelogs.sort do |a, b|
48
53
  -(Cygversion.new(a[0].to_s) <=> Cygversion.new(b[0].to_s))
49
- end.each do |k, v|
54
+ end
55
+ logs.each do |k, v|
50
56
  yield(k, v)
51
57
  end
52
58
  end
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Xezat
2
4
  class CygclassManager
3
5
  def initialize(cygclass_dir = '/usr/share/cygport/cygclass')
4
6
  raise ArgumentError, "#{cygclass_dir} not found" unless Dir.exist?(cygclass_dir)
7
+
5
8
  @cygclasses = []
6
9
  @vcs_cygclasses = []
7
10
  Dir.glob(File.join(cygclass_dir, '*.cygclass')) do |filename|
8
11
  cygclass = File.basename(filename, '.cygclass')
9
12
  @cygclasses << cygclass.intern
10
13
  File.foreach(filename) do |line|
11
- @vcs_cygclasses << cygclass.intern if "readonly -f #{cygclass}_fetch" == line.strip
14
+ @vcs_cygclasses << cygclass.intern if line.strip == "readonly -f #{cygclass}_fetch"
12
15
  end
13
16
  end
14
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
 
3
5
  module Xezat
@@ -7,7 +9,7 @@ module Xezat
7
9
  version = matched[1]
8
10
  @release = matched[2]
9
11
  splitted = version.split('+')
10
- @version = splitted[0].gsub('_', '.')
12
+ @version = splitted[0].tr('_', '.')
11
13
  @revision = splitted.length >= 2 ? splitted[1].match(/(\d+)/)[0].to_i : Time.at(0).strftime('%Y%m%d').to_i
12
14
  end
13
15
 
@@ -19,8 +21,8 @@ module Xezat
19
21
  [@version, @revision, @release]
20
22
  end
21
23
 
22
- def <=>(operand)
23
- to_v <=> operand.to_v
24
+ def <=>(other)
25
+ to_v <=> other.to_v
24
26
  end
25
27
  end
26
28
  end