yast-rake 0.2.33 → 0.2.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaa008190c1fafe2ba6626b4122791f3f8a1836d3cea7a0a062b3fcd28fea0a9
4
- data.tar.gz: 59bfc610ce26b37f11d40d0e525342d1a78c27680b11a4cf0450d44aa5e1a3a7
3
+ metadata.gz: 971c835f94b481a390e75f0e7854926c3da4c8fba8aa31acc9a1ae1014aad44d
4
+ data.tar.gz: 0343fe31d6fcde4d92824f8a0bba57e05108d0dac9e0b6d273aff150d9f93848
5
5
  SHA512:
6
- metadata.gz: 9acd95cd06cc8e22f902b03d7f1fef22a563a87d3272aa2b330ab825887bb6e89b69245bbda0f72e387b3fbc062231cf9923defeb884ab4574b10179f7c4f920
7
- data.tar.gz: 9bae5c07747905387532cb44bb08c214af492f59358d65b4cbcdc3d9271450dabb9ac3dbbbcec5b7f45c166f63a1199bda141d5fac9efdfa86dc2703d65cc675
6
+ metadata.gz: 6841283d6e2fa41e7307d688512a68ecc5dba4333b1394fa9f78bc18912f3f9514385e5dbe1ed8b46c0a7acec28d9f06556b289d587ede40a5382f981f6f5ac1
7
+ data.tar.gz: ed3c444e2d3ca1f2f008889f8b1bbd6c5be8894a4526fb0e07d6aca80dadc870bd82a9a7fb3fd38f01661218104e98db1ffa18b9bfd167b3d2803ff4dc7830e4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.33
1
+ 0.2.39
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <!-- This is a simple main page for the "rake server" task. -->
3
+ <html>
4
+ <head>
5
+ <title>Source Code Tarball Server</title>
6
+ </head>
7
+ <body>
8
+
9
+ <h1>Source Code Tarball Server</h1>
10
+ <p>This server provides dynamically generated source code tarballs.</p>
11
+
12
+ <h2>Supported URL Paths</h2>
13
+ <p>
14
+ <ul>
15
+ <li>
16
+ <b><a href = "/archive/current.tar.gz">/archive/current.tar.gz</a></b>
17
+ - dynamically generated tarball with the current source files
18
+ </li>
19
+ <li>
20
+ <b><a href = "/servers/index.json">/servers/index.json</a></b>
21
+ - index of other running servers on the machine
22
+ </li>
23
+ </ul>
24
+ </p>
25
+
26
+ </body>
27
+ </html>
@@ -63,8 +63,8 @@
63
63
  :sle12sp5:
64
64
  obs_api: "https://api.suse.de/"
65
65
  obs_project: "Devel:YaST:SLE-12-SP5"
66
- obs_sr_project: "SUSE:SLE-12-SP5:GA"
67
- obs_target: "SLE_12_SP5"
66
+ obs_sr_project: "SUSE:SLE-12-SP5:Update"
67
+ obs_target: "SUSE_SLE-12-SP5_Update"
68
68
  :sle15:
69
69
  obs_api: "https://api.suse.de/"
70
70
  obs_project: "Devel:YaST:SLE-15"
@@ -75,11 +75,21 @@
75
75
  obs_project: "Devel:YaST:SLE-15-SP1"
76
76
  obs_sr_project: "SUSE:SLE-15-SP1:Update"
77
77
  obs_target: "SUSE_SLE-15-SP1_Update"
78
+ :sle15sp2:
79
+ obs_api: "https://api.suse.de/"
80
+ obs_project: "Devel:YaST:SLE-15-SP2"
81
+ obs_sr_project: "SUSE:SLE-15-SP2:Update"
82
+ obs_target: "SUSE_SLE-15-SP2_Update"
83
+ :sle15sp3:
84
+ obs_api: "https://api.suse.de/"
85
+ obs_project: "Devel:YaST:SLE-15-SP3"
86
+ obs_sr_project: "SUSE:SLE-15-SP3:Update"
87
+ obs_target: "SUSE_SLE-15-SP3_Update"
78
88
  :sle_latest:
79
89
  obs_api: "https://api.suse.de/"
80
90
  obs_project: "Devel:YaST:Head"
81
- obs_sr_project: "SUSE:SLE-15-SP2:GA"
82
- obs_target: "SUSE_SLE-15-SP2_GA"
91
+ obs_sr_project: "SUSE:SLE-15-SP3:GA"
92
+ obs_target: "SUSE_SLE-15-SP3_GA"
83
93
  :factory:
84
94
  obs_project: "YaST:Head"
85
95
  obs_sr_project: "openSUSE:Factory"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -76,13 +78,13 @@ task :install do
76
78
  config.install_locations.each_pair do |glob, install_to|
77
79
  FileUtils.mkdir_p(install_to, verbose: true) unless File.directory?(install_to)
78
80
  Dir[glob].each do |source|
79
- begin
80
- # do not use FileUtils.cp_r as it have different behavior if target
81
- # exists and we copy a symlink
82
- sh "cp -r '#{source}' '#{install_to}'"
83
- rescue => e
84
- raise "Cannot install file #{source} to #{install_to}: #{e.message}"
85
- end
81
+
82
+ # do not use FileUtils.cp_r as it have different behavior if target
83
+ # exists and we copy a symlink
84
+ sh "cp -r '#{source}' '#{install_to}'"
85
+ rescue StandardError => e
86
+ raise "Cannot install file #{source} to #{install_to}: #{e.message}"
87
+
86
88
  end
87
89
  end
88
90
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -25,19 +27,36 @@ task :pot do
25
27
  end
26
28
 
27
29
  namespace :check do
30
+
31
+ def interpolation_message
32
+ <<~MSG
33
+ Note: \#{foo} substitution in translatable strings does
34
+ not work properly, use
35
+ _("foo %{bar} baz") % { :bar => bar }
36
+ or
37
+ _("foo %s baz") % bar
38
+ MSG
39
+ end
40
+
41
+ def angle_brackets_message
42
+ <<~MSG
43
+ Note: %<foo> placeholder should not be used in translatable strings
44
+ because GNU Gettext does not support any suitable language format for that,
45
+ use %{foo} instead.
46
+ MSG
47
+ end
48
+
28
49
  # print failed lines and a hint to STDERR
29
- def report_pot_errors(lines)
30
- $stderr.puts "Failed lines:"
31
- $stderr.puts "-" * 30
32
- $stderr.puts lines
33
- $stderr.puts "-" * 30
34
- $stderr.puts
35
- $stderr.puts "Note: \#{foo} substitution in translatable strings does" \
36
- " not work properly, use"
37
- $stderr.puts " _(\"foo %{bar} baz\") % { :bar => bar }"
38
- $stderr.puts "or"
39
- $stderr.puts " _(\"foo %s baz\") % bar"
40
- $stderr.puts
50
+ def report_pot_errors(lines, message)
51
+ return if lines.empty?
52
+
53
+ warn "Failed lines:"
54
+ warn "-" * 30
55
+ warn lines
56
+ warn "-" * 30
57
+ warn ""
58
+ warn message
59
+ warn ""
41
60
  end
42
61
 
43
62
  # remove gettext keywords and extra quotes
@@ -51,7 +70,9 @@ namespace :check do
51
70
  end
52
71
 
53
72
  desc "Check translatable strings for common mistakes"
54
- # depends on the global "pot" task defined above
73
+ # depends on the global "pot" task defined above,
74
+ # this scans for the #{} interpolations (do not work in translations)
75
+ # and %<> (no compatible language format in Gettext)
55
76
  task pot: :"rake:pot" do
56
77
  Dir["*.pot"].each do |pot|
57
78
  puts "Checking #{pot}..."
@@ -59,14 +80,18 @@ namespace :check do
59
80
  # remove comments
60
81
  lines.reject! { |line| line.match(/^#/) }
61
82
  # Ruby substitution present?
62
- lines.select! { |line| line.include?("\#{") }
83
+ interpolations = lines.select { |line| line.include?("\#{") }
84
+ angle_brackets = lines.select { |line| line.include?("%<") }
85
+
86
+ next if interpolations.empty? && angle_brackets.empty?
87
+
88
+ clean_pot_lines(interpolations)
89
+ clean_pot_lines(angle_brackets)
63
90
 
64
- clean_pot_lines(lines)
91
+ report_pot_errors(interpolations, interpolation_message)
92
+ report_pot_errors(angle_brackets, angle_brackets_message)
65
93
 
66
- if !lines.empty?
67
- report_pot_errors(lines)
68
- raise "ERROR: Ruby substitution found in a translatable string"
69
- end
94
+ raise "ERROR: Found invalid or unsupported translatable string"
70
95
  end
71
96
  end
72
97
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -13,6 +15,20 @@
13
15
  #
14
16
  #++
15
17
 
18
+ def rubocop_bin
19
+ return @rubocop_bin if @rubocop_bin
20
+ return @rubocop_bin = ENV["RUBOCOP_BIN"] if ENV["RUBOCOP_BIN"]
21
+
22
+ version = File.read(".rubocop.yml").include?("rubocop-0.71.0") ? "0.71.0" : "0.41.2"
23
+ binary = `/usr/sbin/update-alternatives --list rubocop | grep '#{version}'`.strip
24
+ if !system("which #{binary}")
25
+ raise "cannot find proper version of rubocop binary in " \
26
+ "'/usr/sbin/update-alternatives --list rubocop'." \
27
+ "If rubocop is installed via gem, define its binary name via env variable RUBOCOP_BIN."
28
+ end
29
+ @rubocop_bin = binary
30
+ end
31
+
16
32
  # run Rubocop in parallel
17
33
  # @param params [String] optional Rubocop parameters
18
34
  def run_rubocop(params = "")
@@ -26,8 +42,8 @@ def run_rubocop(params = "")
26
42
  # a) use -P with number of processors to run the commands in parallel
27
43
  # b) use -n to set the maximum number of files per process, this number
28
44
  # is computed to equally distribute the files across the workers
29
- sh "rubocop -L | sort -R | xargs -P`nproc` -n$(expr `rubocop -L | wc -l` / " \
30
- "`nproc` + 1) rubocop #{params}"
45
+ sh "#{rubocop_bin} -L | sort -R | xargs -P`nproc` -n$(expr `#{rubocop_bin} -L | wc -l` / " \
46
+ "`nproc` + 1) #{rubocop_bin} #{params}"
31
47
  end
32
48
 
33
49
  namespace :check do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -32,8 +34,9 @@ task :run, :client do |_t, args|
32
34
  clients = Dir["**/src/clients/*.rb"]
33
35
  client = clients.reduce do |min, n|
34
36
  next n if min.nil?
37
+
35
38
  # use client with shortest name by default
36
- min.size > n.size ? n : min
39
+ (min.size > n.size) ? n : min
37
40
  end
38
41
  end
39
42
 
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2020, SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require_relative "../yast/tarball_server"
22
+
23
+ # Rake task for running a source code web server,
24
+ # designed for the `yupdate` script.
25
+ desc "Start an HTTP server providing dynamically generated source code tarball"
26
+ task :server, [:port] do |_task, args|
27
+ server = Yast::TarballServer.new(args[:port])
28
+
29
+ puts "Starting tarball webserver:"
30
+ server.addresses.each { |a| puts " * #{a}" }
31
+ puts
32
+
33
+ server.start
34
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -33,8 +35,8 @@ require "rake/tasklib"
33
35
  module Yast
34
36
  # Defines a spellcheck rake task
35
37
  class SpellcheckTask < Rake::TaskLib
36
- GLOBAL_SPELL_CONFIG_FILE = File.expand_path("../spell.yml", __FILE__)
37
- CUSTOM_SPELL_CONFIG_FILE = ".spell.yml".freeze
38
+ GLOBAL_SPELL_CONFIG_FILE = File.expand_path("spell.yml", __dir__)
39
+ CUSTOM_SPELL_CONFIG_FILE = ".spell.yml"
38
40
 
39
41
  # define the Rake task in the constructor
40
42
  def initialize
@@ -65,11 +67,12 @@ module Yast
65
67
  # @return [Aspell] the speller object
66
68
  def speller
67
69
  return @speller if @speller
70
+
68
71
  # raspell is an optional dependency, handle the missing case nicely
69
72
  begin
70
73
  require "raspell"
71
74
  rescue LoadError
72
- $stderr.puts "ERROR: Ruby gem \"raspell\" is not installed."
75
+ warn "ERROR: Ruby gem \"raspell\" is not installed."
73
76
  exit 1
74
77
  end
75
78
 
@@ -105,9 +108,9 @@ module Yast
105
108
  duplicates = dict1 & dict2
106
109
  return if duplicates.empty?
107
110
 
108
- $stderr.puts "Warning: Found dictionary duplicates in the local dictionary " \
111
+ warn "Warning: Found dictionary duplicates in the local dictionary " \
109
112
  "(#{CUSTOM_SPELL_CONFIG_FILE}):\n"
110
- duplicates.each { |duplicate| $stderr.puts " #{duplicate}" }
113
+ duplicates.each { |duplicate| warn " #{duplicate}" }
111
114
  $stderr.puts
112
115
  end
113
116
 
@@ -161,6 +164,7 @@ module Yast
161
164
  def misspelled_on_line(text)
162
165
  switch_block_tag if block_line?(text)
163
166
  return [] if inside_block
167
+
164
168
  speller.list_misspelled([text]) - config["dictionary"]
165
169
  end
166
170
 
@@ -179,7 +183,7 @@ module Yast
179
183
  if files_to_check.all? { |file| check_file(file) }
180
184
  puts "Spelling OK."
181
185
  else
182
- $stderr.puts "Spellcheck failed! (Fix it or add the words to " \
186
+ warn "Spellcheck failed! (Fix it or add the words to " \
183
187
  "'#{CUSTOM_SPELL_CONFIG_FILE}' file if it is OK.)"
184
188
  exit 1
185
189
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -36,6 +38,8 @@ def run_parallel_tests(files)
36
38
  Coveralls::RakeTask.new
37
39
  Rake::Task["coveralls:push"].invoke
38
40
  end
41
+
42
+ nil
39
43
  end
40
44
 
41
45
  def run_sequential_tests(files)
@@ -56,7 +60,7 @@ namespace :test do
56
60
  run_parallel_tests(files)
57
61
  else
58
62
  if parallel_tests_wanted?
59
- $stderr.puts "WARNING: parallel tests enabled, but 'parallel_rspec' is" \
63
+ warn "WARNING: parallel tests enabled, but 'parallel_rspec' is" \
60
64
  " not installed, falling back to the standard 'rspec' runner."
61
65
  end
62
66
  run_sequential_tests(files)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2020, SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require "webrick"
22
+
23
+ module Yast
24
+ # a webrick servlet which returns a basic HTML info about the server,
25
+ # just to avoid that nasty 404 error page when someone opens the
26
+ # server URL in a web browser
27
+ class IndexServlet < WEBrick::HTTPServlet::AbstractServlet
28
+ INDEX_FILE = File.expand_path("../../data/index.html", __dir__)
29
+
30
+ def do_GET(_request, response)
31
+ response.status = 200
32
+ response.content_type = "text/html"
33
+ response.body = File.read(INDEX_FILE)
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -36,7 +38,7 @@ Yast::Tasks.configuration do |conf|
36
38
  end
37
39
 
38
40
  # load own tasks
39
- task_path = File.expand_path("../../tasks", __FILE__)
41
+ task_path = File.expand_path("../tasks", __dir__)
40
42
  Dir["#{task_path}/*.rake"].each do |f|
41
43
  load f
42
44
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2020, SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require "json"
22
+ require "webrick"
23
+
24
+ module Yast
25
+ # a webrick servlet which lists all rake servers running on this machine
26
+ class ServersServlet < WEBrick::HTTPServlet::AbstractServlet
27
+ def do_GET(_request, response)
28
+ response.status = 200
29
+ response.content_type = "application/json"
30
+ response.body = servers.to_json
31
+ end
32
+
33
+ private
34
+
35
+ # find the locally running "rake server" processes
36
+ def servers
37
+ output = `pgrep -a -f "rake server \\([0-9]+,.*\\)"`
38
+ output.lines.map do |l|
39
+ l.match(/rake server \(([0-9]+),(.*)\)/)
40
+ {
41
+ port: Regexp.last_match[1],
42
+ dir: Regexp.last_match[2]
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2020, SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require "webrick"
22
+ require "socket"
23
+
24
+ require_relative "index_servlet"
25
+ require_relative "servers_servlet"
26
+ require_relative "tarball_servlet"
27
+
28
+ module Yast
29
+ # a webrick server which provides the source tarballs
30
+ #
31
+ # the server handles these URL paths:
32
+ # - "/archive/current.tar.gz" - the generated source code tarball
33
+ # - "/servers/index.json" - index of the tarball servers running on this machine
34
+ # - "/" - just a simple index page
35
+ #
36
+ # to stop the server press Ctrl+C
37
+ class TarballServer
38
+ # the default port number
39
+ DEFAULT_HTTP_PORT = 8000
40
+
41
+ attr_reader :port
42
+
43
+ # create all URLs valid for this machine, use all network interfaces
44
+ # (except the loop backs, the server will be used only from outside)
45
+ # @return [Array<String>] list of URLs
46
+ def addresses
47
+ # ignore the loopback addresses
48
+ hosts = Socket.ip_address_list.reject { |a| a.ipv4_loopback? || a.ipv6_loopback? }
49
+ # IPv6 addresses need to be closed in square brackets in URLs
50
+ hosts.map! { |a| a.ipv6? ? "[#{a.ip_address}]" : a.ip_address.to_s }
51
+ # include also the hostname to make it easier to write
52
+ hostname = Socket.gethostname
53
+ hosts << hostname if !hostname&.empty?
54
+ hosts.map! { |h| "http://#{h}:#{port}" }
55
+ end
56
+
57
+ # constructor
58
+ #
59
+ # @param port [Integer,nil] the port number, if nil the port will be found automatically
60
+ #
61
+ def initialize(port = nil)
62
+ @port = port || find_port
63
+ end
64
+
65
+ # start the webserver, it can be closed by pressing Ctrl+C or by sending SIGTERM signal
66
+ def start
67
+ dir = File.basename(Dir.pwd)
68
+ # change the process title so we can find the running
69
+ # servers and their ports just by simple grepping the running processes
70
+ Process.setproctitle("rake server (#{port},#{dir})")
71
+
72
+ # Use "*" to bind also the IPv6 addresses
73
+ server = WEBrick::HTTPServer.new(Port: port, BindAddress: "*")
74
+ server.mount("/archive/current.tar.gz", TarballServlet)
75
+ server.mount("/servers/index.json", ServersServlet)
76
+ server.mount("/", IndexServlet)
77
+
78
+ # stop the server when receiving a signal like Ctrl+C
79
+ # (inspired by the "un.rb" from the Ruby stdlib)
80
+ signals = ["TERM", "QUIT"]
81
+ signals.concat(["HUP", "INT"]) if $stdin.tty?
82
+ signals.each do |s|
83
+ trap(s) { server.shutdown }
84
+ end
85
+
86
+ server.start
87
+ end
88
+
89
+ private
90
+
91
+ # is the local port already taken by some other application?
92
+ # @param port [Integer] the port number
93
+ # @return [Boolean] true if the port is taken, false otherwise
94
+ def port_taken?(port)
95
+ # open the port and close it immediately, if that succeeds
96
+ # some other application is already using it
97
+ TCPSocket.new("localhost", port).close
98
+ true
99
+ rescue Errno::ECONNREFUSED
100
+ false
101
+ end
102
+
103
+ # find a free port starting from the default port number
104
+ # @return [Integer] the free port number
105
+ def find_port
106
+ DEFAULT_HTTP_PORT.step.find { |p| !port_taken?(p) }
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Yast rake
5
+ #
6
+ # Copyright (C) 2020, SUSE LLC
7
+ # This library is free software; you can redistribute it and/or modify
8
+ # it only under the terms of version 2.1 of the GNU Lesser General Public
9
+ # License as published by the Free Software Foundation.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
+ # details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ #++
20
+
21
+ require "webrick"
22
+
23
+ module Yast
24
+ # a webrick servlet which dynamically creates a tarball
25
+ # with the content of the current Git checkout
26
+ class TarballServlet < WEBrick::HTTPServlet::AbstractServlet
27
+ def do_GET(_request, response)
28
+ response.status = 200
29
+ response.content_type = "application/gzip"
30
+ response.body = source_archive
31
+ end
32
+
33
+ private
34
+
35
+ # compress the current sources into a tarball,
36
+ # no caching to ensure we always provide the latest content
37
+ def source_archive
38
+ # pack all Git files (including the non-tracked files (-o),
39
+ # use --ignore-failed-read to not fail for removed files)
40
+ # -z and --null: NUL-delimited
41
+ git = "git ls-files --cached --others --exclude-standard -z"
42
+ tar = "tar --create --ignore-failed-read --null --files-from -"
43
+ `#{git} | #{tar} | #{gzip}`
44
+ end
45
+
46
+ # find which gzip is installed, use the faster parallel gzip ("pigz") if it is available
47
+ # @return [String] "pigz or "gzip"
48
+ def gzip
49
+ return @gzip if @gzip
50
+
51
+ # parallel gzip installed?
52
+ @gzip = system("which pigz") ? "pigz" : "gzip"
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
4
  # Yast rake
3
5
  #
@@ -23,7 +25,7 @@ module Yast
23
25
  # Yast::Task module contains helper methods
24
26
  module Tasks
25
27
  # Targets definition
26
- TARGETS_FILE = File.expand_path("../../../data/targets.yml", __FILE__)
28
+ TARGETS_FILE = File.expand_path("../../data/targets.yml", __dir__)
27
29
 
28
30
  def self.configuration(&block)
29
31
  ::Packaging.configuration(&block)
@@ -34,7 +36,7 @@ module Yast
34
36
  # use the first *.spec file found, assume all spec files
35
37
  # contain the same version
36
38
  File.readlines(Dir.glob("package/*.spec").first)
37
- .grep(/^\s*Version:\s*/).first.sub("Version:", "").strip
39
+ .grep(/^\s*Version:\s*/).first.sub("Version:", "").strip
38
40
  end
39
41
 
40
42
  def self.submit_to(target, file = TARGETS_FILE)
@@ -43,6 +45,7 @@ module Yast
43
45
  if config.nil?
44
46
  raise "No configuration found for #{target}. Known values: #{targets.keys.join(", ")}"
45
47
  end
48
+
46
49
  Yast::Tasks.configuration do |conf|
47
50
  config.each do |meth, val|
48
51
  conf.public_send("#{meth}=", val)
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yast-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.33
4
+ version: 0.2.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Reidinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: packaging_rake_tasks
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.1.4
27
27
  - !ruby/object:Gem::Dependency
28
- name: packaging_rake_tasks
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.4
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.4
40
+ version: '0'
41
41
  description: |
42
42
  Rake tasks that support work-flow of Yast developer. It allows packaging repo,
43
43
  send it to build service, create submit request to target repo or run client
@@ -49,17 +49,23 @@ extra_rdoc_files: []
49
49
  files:
50
50
  - COPYING
51
51
  - VERSION
52
+ - data/index.html
52
53
  - data/targets.yml
53
54
  - lib/tasks/install.rake
54
55
  - lib/tasks/pot.rake
55
56
  - lib/tasks/rubocop.rake
56
57
  - lib/tasks/run.rake
58
+ - lib/tasks/server.rake
57
59
  - lib/tasks/spell.yml
58
60
  - lib/tasks/spellcheck.rake
59
61
  - lib/tasks/spellcheck_task.rb
60
62
  - lib/tasks/test_unit.rake
61
63
  - lib/tasks/version.rake
64
+ - lib/yast/index_servlet.rb
62
65
  - lib/yast/rake.rb
66
+ - lib/yast/servers_servlet.rb
67
+ - lib/yast/tarball_server.rb
68
+ - lib/yast/tarball_servlet.rb
63
69
  - lib/yast/tasks.rb
64
70
  homepage: https://github.com/yast/yast-rake
65
71
  licenses:
@@ -80,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
86
  - !ruby/object:Gem::Version
81
87
  version: '0'
82
88
  requirements: []
83
- rubygems_version: 3.0.3
89
+ rubygems_version: 3.1.2
84
90
  signing_key:
85
91
  specification_version: 4
86
92
  summary: Rake tasks providing basic work-flow for Yast development