fpm 1.10.1 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require "backports" # gem backports
1
+ require "backports/latest" # gem backports/latest
2
2
  require "fpm/package"
3
3
  require "fpm/util"
4
4
  require "fileutils"
@@ -111,8 +111,7 @@ class FPM::Package::Virtualenv < FPM::Package
111
111
  # Why is this hack here? It looks important, so I'll keep it in.
112
112
  safesystem(python_exe, pip_exe, "install", "-U", "-i",
113
113
  attributes[:virtualenv_pypi],
114
- "pip", "distribute")
115
- safesystem(python_exe, pip_exe, "uninstall", "-y", "distribute")
114
+ "pip")
116
115
 
117
116
  extra_index_url_args = []
118
117
  if attributes[:virtualenv_pypi_extra_index_urls]
@@ -1,4 +1,4 @@
1
- require "backports" # gem backports
1
+ require "backports/latest" # gem backports/latest
2
2
  require "fpm/package"
3
3
  require "fpm/util"
4
4
  require "fileutils"
data/lib/fpm/util.rb CHANGED
@@ -1,21 +1,8 @@
1
1
  require "fpm/namespace"
2
- require "childprocess"
3
- require "ffi"
4
2
  require "fileutils"
5
3
 
6
4
  # Some utility functions
7
5
  module FPM::Util
8
- extend FFI::Library
9
- ffi_lib FFI::Library::LIBC
10
-
11
- # mknod is __xmknod in glibc a wrapper around mknod to handle
12
- # various stat struct formats. See bits/stat.h in glibc source
13
- begin
14
- attach_function :mknod, :mknod, [:string, :uint, :ulong], :int
15
- rescue FFI::NotFoundError
16
- # glibc/io/xmknod.c int __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
17
- attach_function :xmknod, :__xmknod, [:int, :string, :uint, :pointer], :int
18
- end
19
6
 
20
7
  # Raised if safesystem cannot find the program to run.
21
8
  class ExecutableNotFound < StandardError; end
@@ -23,6 +10,12 @@ module FPM::Util
23
10
  # Raised if a safesystem program exits nonzero
24
11
  class ProcessFailed < StandardError; end
25
12
 
13
+ # Raised when a named pipe cannot be copied due to missing functions in fpm and ruby.
14
+ class NamedPipeCannotBeCopied < StandardError; end
15
+
16
+ # Raised when an attempting to copy a special file such as a block device.
17
+ class UnsupportedSpecialFile < StandardError; end
18
+
26
19
  # Is the given program in the system's PATH?
27
20
  def program_in_path?(program)
28
21
  # return false if path is not set
@@ -146,31 +139,22 @@ module FPM::Util
146
139
 
147
140
  stdout_r, stdout_w = IO.pipe
148
141
  stderr_r, stderr_w = IO.pipe
142
+ stdin_r, stdin_w = IO.pipe
149
143
 
150
- process = ChildProcess.build(*args2)
151
- process.environment.merge!(env)
152
-
153
- process.io.stdout = stdout_w
154
- process.io.stderr = stderr_w
155
-
156
- if block_given? and opts[:stdin]
157
- process.duplex = true
158
- end
159
-
160
- process.start
144
+ pid = Process.spawn(env, *args2, :out => stdout_w, :err => stderr_w, :in => stdin_r)
161
145
 
162
146
  stdout_w.close; stderr_w.close
163
- logger.debug("Process is running", :pid => process.pid)
147
+ logger.debug("Process is running", :pid => pid)
164
148
  if block_given?
165
149
  args3 = []
166
150
  args3.push(process) if opts[:process]
167
- args3.push(process.io.stdin) if opts[:stdin]
151
+ args3.push(stdin_w) if opts[:stdin]
168
152
  args3.push(stdout_r) if opts[:stdout]
169
153
  args3.push(stderr_r) if opts[:stderr]
170
154
 
171
155
  yield(*args3)
172
156
 
173
- process.io.stdin.close if opts[:stdin] and not process.io.stdin.closed?
157
+ stdin_w_close if opts[:stdin] and not stdin_w.closed?
174
158
  stdout_r.close unless stdout_r.closed?
175
159
  stderr_r.close unless stderr_r.closed?
176
160
  else
@@ -179,9 +163,10 @@ module FPM::Util
179
163
  logger.pipe(stdout_r => :info, stderr_r => :info)
180
164
  end
181
165
 
182
- process.wait if process.alive?
166
+ Process.waitpid(pid)
167
+ status = $?
183
168
 
184
- return process.exit_code
169
+ return status.exitstatus
185
170
  end # def execmd
186
171
 
187
172
  # Run a command safely in a way that gets reports useful errors.
@@ -316,19 +301,6 @@ module FPM::Util
316
301
  return @@tar_cmd_deterministic
317
302
  end
318
303
 
319
- # wrapper around mknod ffi calls
320
- def mknod_w(path, mode, dev)
321
- rc = -1
322
- case %x{uname -s}.chomp
323
- when 'Linux'
324
- # bits/stat.h #define _MKNOD_VER_LINUX 0
325
- rc = xmknod(0, path, mode, FFI::MemoryPointer.new(dev))
326
- else
327
- rc = mknod(path, mode, dev)
328
- end
329
- rc
330
- end
331
-
332
304
  def copy_metadata(source, destination)
333
305
  source_stat = File::lstat(source)
334
306
  dest_stat = File::lstat(destination)
@@ -354,10 +326,21 @@ module FPM::Util
354
326
 
355
327
  def copy_entry(src, dst, preserve=false, remove_destination=false)
356
328
  case File.ftype(src)
357
- when 'fifo', 'characterSpecial', 'blockSpecial', 'socket'
358
- st = File.stat(src)
359
- rc = mknod_w(dst, st.mode, st.dev)
360
- raise SystemCallError.new("mknod error", FFI.errno) if rc == -1
329
+ when 'fifo'
330
+ if File.respond_to?(:mkfifo)
331
+ File.mkfifo(dst)
332
+ elsif program_exists?("mkfifo")
333
+ safesystem("mkfifo", dst)
334
+ else
335
+ raise NamedPipeCannotBeCopied("Unable to copy. Cannot find program 'mkfifo' and Ruby is missing the 'File.mkfifo' method: #{src}")
336
+ end
337
+ when 'socket'
338
+ require "socket"
339
+ # In 2019, Ruby's FileUtils added this as a way to "copy" a unix socket.
340
+ # Reference: https://github.com/ruby/fileutils/pull/36/files
341
+ UNIXServer.new(dst).close()
342
+ when 'characterSpecial', 'blockSpecial'
343
+ raise UnsupportedSpecialFile.new("File is device which fpm doesn't know how to copy (#{File.ftype(src)}): #{src}")
361
344
  when 'directory'
362
345
  FileUtils.mkdir(dst) unless File.exists? dst
363
346
  else
@@ -29,7 +29,7 @@ end # module FPM
29
29
 
30
30
  module FPM; module Util; end; end
31
31
 
32
- # Like the ::Gem::Package::TarWriter but contains some backports and bug fixes
32
+ # Like the ::Gem::Package::TarWriter but contains some backports/latest and bug fixes
33
33
  class FPM::Util::TarWriter < ::Gem::Package::TarWriter
34
34
  if FPM::Issues::TarWriter.has_issues_with_split_name?
35
35
  def split_name(name)
data/lib/fpm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FPM
2
- VERSION = "1.10.1"
2
+ VERSION = "1.13.1"
3
3
  end
data/templates/deb.erb CHANGED
@@ -25,10 +25,10 @@ Build-Depends: <%= attributes[:deb_build_depends].collect { |d| fix_dependency(d
25
25
  <% if !provides.empty? -%>
26
26
  <%# Turn each provides from 'foo = 123' to simply 'foo' because Debian :\ -%>
27
27
  <%# http://www.debian.org/doc/debian-policy/ch-relationships.html -%>
28
- Provides: <%= provides.map {|p| p.split(" ").first}.join ", " %>
28
+ Provides: <%= provides.join ", " %>
29
29
  <% end -%>
30
30
  <% if !replaces.empty? -%>
31
- Replaces: <%= replaces.join(", ") %>
31
+ Replaces: <%= replaces.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
32
32
  <% end -%>
33
33
  <% if attributes[:deb_recommends] and !attributes[:deb_recommends].empty? -%>
34
34
  Recommends: <%= attributes[:deb_recommends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
@@ -14,9 +14,8 @@ Description: <%= firstline %>
14
14
  <%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
15
15
  <% end -%>
16
16
  Changes:
17
- <%= name %> (<%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>) whatever; urgency=medium
18
- .
19
- * Package created with FPM.
17
+ <%= name %> (<%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>) whatever; urgency=medium
18
+ * Package created with FPM.
20
19
  Checksums-Sha1:
21
20
  <% changes_files.each do |file| -%>
22
21
  <%= file[:sha1sum] %> <%= file[:size] %> <%= file[:name] %>
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+
3
+ <% if attributes[:deb_maintainerscripts_force_errorchecks?] -%>
4
+ set -e
5
+ <% end -%>
6
+
2
7
  after_upgrade() {
3
8
  <%# Making sure that at least one command is in the function -%>
4
9
  <%# avoids a lot of potential errors, including the case that -%>
@@ -8,18 +13,27 @@ after_upgrade() {
8
13
  <%= script(:after_upgrade) %>
9
14
  <% end -%>
10
15
 
11
- <% if attributes[:deb_systemd] -%>
16
+ <%# if any systemd services specified, loop through and start them -%>
17
+ <% if attributes[:deb_systemd].any? -%>
12
18
  systemctl --system daemon-reload >/dev/null || true
13
- if ! systemctl is-enabled <%= attributes[:deb_systemd] %> >/dev/null
19
+ debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
20
+ <% attributes[:deb_systemd].each do |service| -%>
21
+ if ! systemctl is-enabled <%= service %> >/dev/null
14
22
  then
15
- systemctl enable <%= attributes[:deb_systemd] %> >/dev/null || true
16
- systemctl start <%= attributes[:deb_systemd] %> >/dev/null || true
23
+ : # Ensure this if-clause is not empty. If it were empty, and we had an 'else', then it is an error in shell syntax
24
+ <% if attributes[:deb_systemd_enable?]-%>
25
+ systemctl enable <%= service %> >/dev/null || true
26
+ <% end -%>
27
+ <% if attributes[:deb_systemd_auto_start?]-%>
28
+ $debsystemctl start <%= service %> >/dev/null || true
29
+ <% end -%>
17
30
  <% if attributes[:deb_systemd_restart_after_upgrade?] -%>
18
31
  else
19
- systemctl restart <%= attributes[:deb_systemd] %> >/dev/null || true
32
+ $debsystemctl restart <%= service %> >/dev/null || true
20
33
  <% end -%>
21
34
  fi
22
35
  <% end -%>
36
+ <% end -%>
23
37
  }
24
38
 
25
39
  after_install() {
@@ -31,10 +45,18 @@ after_install() {
31
45
  <%= script(:after_install) %>
32
46
  <% end -%>
33
47
 
34
- <% if attributes[:deb_systemd] -%>
48
+ <%# if any systemd services specified, loop through and start them -%>
49
+ <% if attributes[:deb_systemd].any? -%>
35
50
  systemctl --system daemon-reload >/dev/null || true
36
- systemctl enable <%= attributes[:deb_systemd] %> >/dev/null || true
37
- systemctl start <%= attributes[:deb_systemd] %> >/dev/null || true
51
+ debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
52
+ <% attributes[:deb_systemd].each do |service| -%>
53
+ <% if attributes[:deb_systemd_enable?]-%>
54
+ systemctl enable <%= service %> >/dev/null || true
55
+ <% end -%>
56
+ <% if attributes[:deb_systemd_auto_start?]-%>
57
+ $debsystemctl start <%= service %> >/dev/null || true
58
+ <% end -%>
59
+ <% end -%>
38
60
  <% end -%>
39
61
  }
40
62
 
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+
3
+ <% if attributes[:deb_maintainerscripts_force_errorchecks?] -%>
4
+ set -e
5
+ <% end -%>
6
+
2
7
  after_remove() {
3
8
  <%# Making sure that at least one command is in the function -%>
4
9
  <%# avoids a lot of potential errors, including the case that -%>
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+
3
+ <% if attributes[:deb_maintainerscripts_force_errorchecks?] -%>
4
+ set -e
5
+ <% end -%>
6
+
2
7
  before_upgrade() {
3
8
  <%# Making sure that at least one command is in the function -%>
4
9
  <%# avoids a lot of potential errors, including the case that -%>
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+
3
+ <% if attributes[:deb_maintainerscripts_force_errorchecks?] -%>
4
+ set -e
5
+ <% end -%>
6
+
2
7
  before_remove() {
3
8
  <%# Making sure that at least one command is in the function -%>
4
9
  <%# avoids a lot of potential errors, including the case that -%>
@@ -8,10 +13,13 @@ before_remove() {
8
13
  <%= script(:before_remove) %>
9
14
  <% end -%>
10
15
 
11
- <%# Removing the systemd service-%>
12
- <% if attributes[:deb_systemd] -%>
13
- systemctl stop <%= attributes[:deb_systemd] %> >/dev/null || true
14
- systemctl disable <%= attributes[:deb_systemd] %> >/dev/null || true
16
+ <%# Stop and remove any systemd services that were installed-%>
17
+ <% if attributes[:deb_systemd].any? -%>
18
+ debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
19
+ <% attributes[:deb_systemd].each do |service| -%>
20
+ $debsystemctl stop <%= service %> >/dev/null || true
21
+ systemctl disable <%= service %> >/dev/null || true
22
+ <% end -%>
15
23
  systemctl --system daemon-reload >/dev/null || true
16
24
  <% end -%>
17
25
  }
data/templates/rpm.erb CHANGED
@@ -126,7 +126,7 @@ Obsoletes: <%= repl %>
126
126
  -%>
127
127
  <% if script?(:before_upgrade) or script?(:after_upgrade) -%>
128
128
  <% if script?(:before_upgrade) or script?(:before_install) -%>
129
- %pre
129
+ %pre <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
130
130
  upgrade() {
131
131
  <%# Making sure that at least one command is in the function -%>
132
132
  <%# avoids a lot of potential errors, including the case that -%>
@@ -156,7 +156,7 @@ then
156
156
  fi
157
157
  <% end -%>
158
158
  <% if script?(:after_upgrade) or script?(:after_install) -%>
159
- %post
159
+ %post <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
160
160
  upgrade() {
161
161
  <%# Making sure that at least one command is in the function -%>
162
162
  <%# avoids a lot of potential errors, including the case that -%>
@@ -186,7 +186,7 @@ then
186
186
  fi
187
187
  <% end -%>
188
188
  <% if script?(:before_remove) -%>
189
- %preun
189
+ %preun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
190
190
  if [ "${1}" -eq 0 ]
191
191
  then
192
192
  <%# Making sure that at least one command is in the function -%>
@@ -197,7 +197,7 @@ then
197
197
  fi
198
198
  <% end -%>
199
199
  <% if script?(:after_remove) -%>
200
- %postun
200
+ %postun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
201
201
  if [ "${1}" -eq 0 ]
202
202
  then
203
203
  <%# Making sure that at least one command is in the function -%>
@@ -219,7 +219,7 @@ fi
219
219
  -%>
220
220
  <% scriptmap.each do |name, rpmname| -%>
221
221
  <% if script?(name) -%>
222
- %<%= rpmname %>
222
+ %<%= rpmname -%> <%= ' -e' if attributes[:rpm_macro_expansion?] %>
223
223
  <%= script(name) %>
224
224
  <% end -%>
225
225
  <% end -%>
data/templates/sh.erb CHANGED
@@ -268,7 +268,12 @@ function clean_out_old_releases(){
268
268
  function print_package_metadata(){
269
269
  local metadata_line=$(grep -a -n -m1 '__METADATA__$' $0 | sed 's/:.*//')
270
270
  local archive_line=$(grep -a -n -m1 '__ARCHIVE__$' $0 | sed 's/:.*//')
271
- sed -n "$((metadata_line + 1)),$((archive_line - 1)) p" $0
271
+
272
+ # This used to be a sed call but it was taking _forever_ and this method is super fast
273
+ local start_at=$((metadata_line + 1))
274
+ local take_num=$((archive_line - start_at))
275
+
276
+ head -n${start_at} $0 | tail -n${take_num}
272
277
  }
273
278
 
274
279
  function print_usage(){
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.1
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-04 00:00:00.000000000 Z
11
+ date: 2021-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.7.7
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.0'
22
+ version: '3.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.7.7
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.0'
32
+ version: '3.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: cabin
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.0.10
67
+ version: 0.0.11
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.0.10
74
+ version: 0.0.11
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: clamp
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -87,77 +87,69 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.0.0
89
89
  - !ruby/object:Gem::Dependency
90
- name: childprocess
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :runtime
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: ffi
90
+ name: rake
105
91
  requirement: !ruby/object:Gem::Requirement
106
92
  requirements:
107
- - - ">="
93
+ - - "~>"
108
94
  - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :runtime
95
+ version: '10'
96
+ type: :development
111
97
  prerelease: false
112
98
  version_requirements: !ruby/object:Gem::Requirement
113
99
  requirements:
114
- - - ">="
100
+ - - "~>"
115
101
  - !ruby/object:Gem::Version
116
- version: '0'
102
+ version: '10'
117
103
  - !ruby/object:Gem::Dependency
118
- name: rake
104
+ name: pleaserun
119
105
  requirement: !ruby/object:Gem::Requirement
120
106
  requirements:
121
107
  - - "~>"
122
108
  - !ruby/object:Gem::Version
123
- version: '10'
124
- type: :development
109
+ version: 0.0.29
110
+ type: :runtime
125
111
  prerelease: false
126
112
  version_requirements: !ruby/object:Gem::Requirement
127
113
  requirements:
128
114
  - - "~>"
129
115
  - !ruby/object:Gem::Version
130
- version: '10'
116
+ version: 0.0.29
131
117
  - !ruby/object:Gem::Dependency
132
- name: ruby-xz
118
+ name: git
133
119
  requirement: !ruby/object:Gem::Requirement
134
120
  requirements:
135
- - - "~>"
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.3.0
124
+ - - "<"
136
125
  - !ruby/object:Gem::Version
137
- version: 0.2.3
126
+ version: '2.0'
138
127
  type: :runtime
139
128
  prerelease: false
140
129
  version_requirements: !ruby/object:Gem::Requirement
141
130
  requirements:
142
- - - "~>"
131
+ - - ">="
143
132
  - !ruby/object:Gem::Version
144
- version: 0.2.3
133
+ version: 1.3.0
134
+ - - "<"
135
+ - !ruby/object:Gem::Version
136
+ version: '2.0'
145
137
  - !ruby/object:Gem::Dependency
146
- name: pleaserun
138
+ name: stud
147
139
  requirement: !ruby/object:Gem::Requirement
148
140
  requirements:
149
- - - "~>"
141
+ - - ">="
150
142
  - !ruby/object:Gem::Version
151
- version: 0.0.29
143
+ version: '0'
152
144
  type: :runtime
153
145
  prerelease: false
154
146
  version_requirements: !ruby/object:Gem::Requirement
155
147
  requirements:
156
- - - "~>"
148
+ - - ">="
157
149
  - !ruby/object:Gem::Version
158
- version: 0.0.29
150
+ version: '0'
159
151
  - !ruby/object:Gem::Dependency
160
- name: stud
152
+ name: rexml
161
153
  requirement: !ruby/object:Gem::Requirement
162
154
  requirements:
163
155
  - - ">="
@@ -250,6 +242,7 @@ files:
250
242
  - lib/fpm/package/python.rb
251
243
  - lib/fpm/package/rpm.rb
252
244
  - lib/fpm/package/sh.rb
245
+ - lib/fpm/package/snap.rb
253
246
  - lib/fpm/package/solaris.rb
254
247
  - lib/fpm/package/tar.rb
255
248
  - lib/fpm/package/virtualenv.rb
@@ -285,7 +278,7 @@ homepage: https://github.com/jordansissel/fpm
285
278
  licenses:
286
279
  - MIT-like
287
280
  metadata: {}
288
- post_install_message:
281
+ post_install_message:
289
282
  rdoc_options: []
290
283
  require_paths:
291
284
  - lib
@@ -301,9 +294,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
294
  - !ruby/object:Gem::Version
302
295
  version: '0'
303
296
  requirements: []
304
- rubyforge_project:
305
- rubygems_version: 2.6.11
306
- signing_key:
297
+ rubygems_version: 3.2.15
298
+ signing_key:
307
299
  specification_version: 4
308
300
  summary: fpm - package building and mangling
309
301
  test_files: []