fpm 1.6.1 → 1.14.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.
- checksums.yaml +5 -5
- data/CHANGELOG.rst +674 -0
- data/CONTRIBUTORS +2 -0
- data/LICENSE +1 -1
- data/bin/fpm +0 -1
- data/lib/fpm/command.rb +26 -12
- data/lib/fpm/package/apk.rb +6 -6
- data/lib/fpm/package/cpan.rb +85 -30
- data/lib/fpm/package/deb.rb +298 -44
- data/lib/fpm/package/dir.rb +12 -17
- data/lib/fpm/package/empty.rb +13 -1
- data/lib/fpm/package/freebsd.rb +37 -33
- data/lib/fpm/package/gem.rb +167 -13
- data/lib/fpm/package/pacman.rb +28 -12
- data/lib/fpm/package/pleaserun.rb +13 -1
- data/lib/fpm/package/pyfpm/get_metadata.py +10 -0
- data/lib/fpm/package/python.rb +57 -8
- data/lib/fpm/package/rpm.rb +62 -10
- data/lib/fpm/package/sh.rb +1 -1
- data/lib/fpm/package/snap.rb +130 -0
- data/lib/fpm/package/tar.rb +2 -10
- data/lib/fpm/package/virtualenv.rb +76 -14
- data/lib/fpm/package/zip.rb +6 -22
- data/lib/fpm/package.rb +27 -6
- data/lib/fpm/util/tar_writer.rb +3 -1
- data/lib/fpm/util.rb +115 -62
- data/lib/fpm/version.rb +1 -1
- data/lib/fpm.rb +2 -0
- data/templates/deb/changelog.erb +1 -1
- data/templates/deb/deb.changes.erb +30 -0
- data/templates/deb/postinst_upgrade.sh.erb +30 -8
- data/templates/deb/postrm_upgrade.sh.erb +17 -5
- data/templates/deb/preinst_upgrade.sh.erb +5 -0
- data/templates/deb/prerm_upgrade.sh.erb +12 -4
- data/templates/deb.erb +7 -7
- data/templates/rpm.erb +14 -12
- data/templates/sh.erb +6 -1
- metadata +33 -64
- data/CHANGELIST +0 -650
- data/lib/fpm/package/pyfpm/__init__.pyc +0 -0
- data/lib/fpm/package/pyfpm/get_metadata.pyc +0 -0
data/lib/fpm/util.rb
CHANGED
@@ -1,20 +1,8 @@
|
|
1
1
|
require "fpm/namespace"
|
2
|
-
require "
|
3
|
-
require "ffi"
|
2
|
+
require "fileutils"
|
4
3
|
|
5
4
|
# Some utility functions
|
6
5
|
module FPM::Util
|
7
|
-
extend FFI::Library
|
8
|
-
ffi_lib FFI::Library::LIBC
|
9
|
-
|
10
|
-
# mknod is __xmknod in glibc a wrapper around mknod to handle
|
11
|
-
# various stat struct formats. See bits/stat.h in glibc source
|
12
|
-
begin
|
13
|
-
attach_function :mknod, :mknod, [:string, :uint, :ulong], :int
|
14
|
-
rescue FFI::NotFoundError
|
15
|
-
# glibc/io/xmknod.c int __xmknod (int vers, const char *path, mode_t mode, dev_t *dev)
|
16
|
-
attach_function :xmknod, :__xmknod, [:int, :string, :uint, :pointer], :int
|
17
|
-
end
|
18
6
|
|
19
7
|
# Raised if safesystem cannot find the program to run.
|
20
8
|
class ExecutableNotFound < StandardError; end
|
@@ -22,6 +10,12 @@ module FPM::Util
|
|
22
10
|
# Raised if a safesystem program exits nonzero
|
23
11
|
class ProcessFailed < StandardError; end
|
24
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
|
+
|
25
19
|
# Is the given program in the system's PATH?
|
26
20
|
def program_in_path?(program)
|
27
21
|
# return false if path is not set
|
@@ -145,31 +139,22 @@ module FPM::Util
|
|
145
139
|
|
146
140
|
stdout_r, stdout_w = IO.pipe
|
147
141
|
stderr_r, stderr_w = IO.pipe
|
142
|
+
stdin_r, stdin_w = IO.pipe
|
148
143
|
|
149
|
-
|
150
|
-
process.environment.merge!(env)
|
151
|
-
|
152
|
-
process.io.stdout = stdout_w
|
153
|
-
process.io.stderr = stderr_w
|
154
|
-
|
155
|
-
if block_given? and opts[:stdin]
|
156
|
-
process.duplex = true
|
157
|
-
end
|
158
|
-
|
159
|
-
process.start
|
144
|
+
pid = Process.spawn(env, *args2, :out => stdout_w, :err => stderr_w, :in => stdin_r)
|
160
145
|
|
161
146
|
stdout_w.close; stderr_w.close
|
162
|
-
logger.debug("Process is running", :pid =>
|
147
|
+
logger.debug("Process is running", :pid => pid)
|
163
148
|
if block_given?
|
164
149
|
args3 = []
|
165
150
|
args3.push(process) if opts[:process]
|
166
|
-
args3.push(
|
151
|
+
args3.push(stdin_w) if opts[:stdin]
|
167
152
|
args3.push(stdout_r) if opts[:stdout]
|
168
153
|
args3.push(stderr_r) if opts[:stderr]
|
169
154
|
|
170
155
|
yield(*args3)
|
171
156
|
|
172
|
-
|
157
|
+
stdin_w_close if opts[:stdin] and not stdin_w.closed?
|
173
158
|
stdout_r.close unless stdout_r.closed?
|
174
159
|
stderr_r.close unless stderr_r.closed?
|
175
160
|
else
|
@@ -178,9 +163,10 @@ module FPM::Util
|
|
178
163
|
logger.pipe(stdout_r => :info, stderr_r => :info)
|
179
164
|
end
|
180
165
|
|
181
|
-
|
166
|
+
Process.waitpid(pid)
|
167
|
+
status = $?
|
182
168
|
|
183
|
-
return
|
169
|
+
return status.exitstatus
|
184
170
|
end # def execmd
|
185
171
|
|
186
172
|
# Run a command safely in a way that gets reports useful errors.
|
@@ -190,9 +176,14 @@ module FPM::Util
|
|
190
176
|
if args.size == 1
|
191
177
|
args = [ default_shell, "-c", args[0] ]
|
192
178
|
end
|
193
|
-
program = args[0]
|
194
179
|
|
195
|
-
|
180
|
+
if args[0].kind_of?(Hash)
|
181
|
+
env = args.shift()
|
182
|
+
exit_code = execmd(env, args)
|
183
|
+
else
|
184
|
+
exit_code = execmd(args)
|
185
|
+
end
|
186
|
+
program = args[0]
|
196
187
|
success = (exit_code == 0)
|
197
188
|
|
198
189
|
if !success
|
@@ -226,37 +217,88 @@ module FPM::Util
|
|
226
217
|
return stdout_r_str
|
227
218
|
end # def safesystemout
|
228
219
|
|
220
|
+
# Get an array containing the recommended 'ar' command for this platform
|
221
|
+
# and the recommended options to quickly create/append to an archive
|
222
|
+
# without timestamps or uids (if possible).
|
223
|
+
def ar_cmd
|
224
|
+
return @@ar_cmd if defined? @@ar_cmd
|
225
|
+
|
226
|
+
@@ar_cmd_deterministic = false
|
227
|
+
|
228
|
+
# FIXME: don't assume current directory writeable
|
229
|
+
FileUtils.touch(["fpm-dummy.tmp"])
|
230
|
+
["ar", "gar"].each do |ar|
|
231
|
+
["-qc", "-qcD"].each do |ar_create_opts|
|
232
|
+
FileUtils.rm_f(["fpm-dummy.ar.tmp"])
|
233
|
+
# Return this combination if it creates archives without uids or timestamps.
|
234
|
+
# Exitstatus will be nonzero if the archive can't be created,
|
235
|
+
# or its table of contents doesn't match the regular expression.
|
236
|
+
# Be extra-careful about locale and timezone when matching output.
|
237
|
+
system("#{ar} #{ar_create_opts} fpm-dummy.ar.tmp fpm-dummy.tmp 2>/dev/null && env TZ=UTC LANG=C LC_TIME=C #{ar} -tv fpm-dummy.ar.tmp | grep '0/0.*1970' > /dev/null 2>&1")
|
238
|
+
if $?.exitstatus == 0
|
239
|
+
@@ar_cmd = [ar, ar_create_opts]
|
240
|
+
@@ar_cmd_deterministic = true
|
241
|
+
return @@ar_cmd
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
# If no combination of ar and options omits timestamps, fall back to default.
|
246
|
+
@@ar_cmd = ["ar", "-qc"]
|
247
|
+
return @@ar_cmd
|
248
|
+
ensure
|
249
|
+
# Clean up
|
250
|
+
FileUtils.rm_f(["fpm-dummy.ar.tmp", "fpm-dummy.tmp"])
|
251
|
+
end # def ar_cmd
|
252
|
+
|
253
|
+
# Return whether the command returned by ar_cmd can create deterministic archives
|
254
|
+
def ar_cmd_deterministic?
|
255
|
+
ar_cmd if not defined? @@ar_cmd_deterministic
|
256
|
+
return @@ar_cmd_deterministic
|
257
|
+
end
|
258
|
+
|
229
259
|
# Get the recommended 'tar' command for this platform.
|
230
260
|
def tar_cmd
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
261
|
+
return @@tar_cmd if defined? @@tar_cmd
|
262
|
+
|
263
|
+
# FIXME: don't assume current directory writeable
|
264
|
+
FileUtils.touch(["fpm-dummy.tmp"])
|
265
|
+
|
266
|
+
# Prefer tar that supports more of the features we want, stop if we find tar of our dreams
|
267
|
+
best="tar"
|
268
|
+
bestscore=0
|
269
|
+
@@tar_cmd_deterministic = false
|
270
|
+
# GNU Tar, if not the default, is usually on the path as gtar, but
|
271
|
+
# Mac OS X 10.8 and earlier shipped it as /usr/bin/gnutar
|
272
|
+
["tar", "gtar", "gnutar"].each do |tar|
|
273
|
+
opts=[]
|
274
|
+
score=0
|
275
|
+
["--sort=name", "--mtime=@0"].each do |opt|
|
276
|
+
system("#{tar} #{opt} -cf fpm-dummy.tar.tmp fpm-dummy.tmp > /dev/null 2>&1")
|
277
|
+
if $?.exitstatus == 0
|
278
|
+
opts << opt
|
279
|
+
score += 1
|
280
|
+
end
|
281
|
+
end
|
282
|
+
if score > bestscore
|
283
|
+
best=tar
|
284
|
+
bestscore=score
|
285
|
+
if score == 2
|
286
|
+
@@tar_cmd_deterministic = true
|
287
|
+
break
|
288
|
+
end
|
240
289
|
end
|
241
|
-
when "FreeBSD"
|
242
|
-
# use gnutar instead
|
243
|
-
return "gtar"
|
244
|
-
else
|
245
|
-
return "tar"
|
246
290
|
end
|
291
|
+
@@tar_cmd = best
|
292
|
+
return @@tar_cmd
|
293
|
+
ensure
|
294
|
+
# Clean up
|
295
|
+
FileUtils.rm_f(["fpm-dummy.tar.tmp", "fpm-dummy.tmp"])
|
247
296
|
end # def tar_cmd
|
248
297
|
|
249
|
-
#
|
250
|
-
def
|
251
|
-
|
252
|
-
|
253
|
-
when 'Linux'
|
254
|
-
# bits/stat.h #define _MKNOD_VER_LINUX 0
|
255
|
-
rc = xmknod(0, path, mode, FFI::MemoryPointer.new(dev))
|
256
|
-
else
|
257
|
-
rc = mknod(path, mode, dev)
|
258
|
-
end
|
259
|
-
rc
|
298
|
+
# Return whether the command returned by tar_cmd can create deterministic archives
|
299
|
+
def tar_cmd_supports_sort_names_and_set_mtime?
|
300
|
+
tar_cmd if not defined? @@tar_cmd_deterministic
|
301
|
+
return @@tar_cmd_deterministic
|
260
302
|
end
|
261
303
|
|
262
304
|
def copy_metadata(source, destination)
|
@@ -284,10 +326,21 @@ module FPM::Util
|
|
284
326
|
|
285
327
|
def copy_entry(src, dst, preserve=false, remove_destination=false)
|
286
328
|
case File.ftype(src)
|
287
|
-
when 'fifo'
|
288
|
-
|
289
|
-
|
290
|
-
|
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}")
|
291
344
|
when 'directory'
|
292
345
|
FileUtils.mkdir(dst) unless File.exists? dst
|
293
346
|
else
|
@@ -298,8 +351,8 @@ module FPM::Util
|
|
298
351
|
if known_entry
|
299
352
|
FileUtils.ln(known_entry, dst)
|
300
353
|
else
|
301
|
-
FileUtils.copy_entry(src, dst, preserve
|
302
|
-
remove_destination
|
354
|
+
FileUtils.copy_entry(src, dst, preserve, false,
|
355
|
+
remove_destination)
|
303
356
|
copied_entries[[st.dev, st.ino]] = dst
|
304
357
|
end
|
305
358
|
end # else...
|
data/lib/fpm/version.rb
CHANGED
data/lib/fpm.rb
CHANGED
data/templates/deb/changelog.erb
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
* Package created with FPM.
|
4
4
|
|
5
|
-
-- <%= maintainer %> <%= Time.now.strftime("%a, %d %b %Y %T %z") %>
|
5
|
+
-- <%= maintainer %> <%= (if attributes[:source_date_epoch].nil? then Time.now() else Time.at(attributes[:source_date_epoch].to_i) end).strftime("%a, %d %b %Y %T %z") %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Format: 1.8
|
2
|
+
Date: <%= (if attributes[:source_date_epoch].nil? then Time.now() else Time.at(attributes[:source_date_epoch].to_i) end).strftime("%a, %d %b %Y %T %z") %>
|
3
|
+
Source: <%= name %>
|
4
|
+
Binary: <%= name %>
|
5
|
+
Architecture: <%= architecture %>
|
6
|
+
Version: <%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>
|
7
|
+
Distribution: <%= distribution %>
|
8
|
+
Urgency: medium
|
9
|
+
Maintainer: <%= maintainer %>
|
10
|
+
<% lines = (description or "no description given").split("\n") -%>
|
11
|
+
<% firstline, *remainder = lines -%>
|
12
|
+
Description: <%= firstline %>
|
13
|
+
<% if remainder.any? -%>
|
14
|
+
<%= remainder.collect { |l| l =~ /^ *$/ ? " ." : " #{l}" }.join("\n") %>
|
15
|
+
<% end -%>
|
16
|
+
Changes:
|
17
|
+
<%= name %> (<%= "#{epoch}:" if epoch %><%= version %><%= "-" + iteration.to_s if iteration %>) whatever; urgency=medium
|
18
|
+
* Package created with FPM.
|
19
|
+
Checksums-Sha1:
|
20
|
+
<% changes_files.each do |file| -%>
|
21
|
+
<%= file[:sha1sum] %> <%= file[:size] %> <%= file[:name] %>
|
22
|
+
<% end -%>
|
23
|
+
Checksums-Sha256:
|
24
|
+
<% changes_files.each do |file| -%>
|
25
|
+
<%= file[:sha256sum] %> <%= file[:size] %> <%= file[:name] %>
|
26
|
+
<% end -%>
|
27
|
+
Files:
|
28
|
+
<% changes_files.each do |file| -%>
|
29
|
+
<%= file[:md5sum] %> <%= file[:size] %> default <%= attributes[:deb_priority] %> <%= file[:name] %>
|
30
|
+
<% end -%>
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
16
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
37
|
-
|
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 -%>
|
@@ -9,6 +14,16 @@ after_remove() {
|
|
9
14
|
<% end -%>
|
10
15
|
}
|
11
16
|
|
17
|
+
after_purge() {
|
18
|
+
<%# Making sure that at least one command is in the function -%>
|
19
|
+
<%# avoids a lot of potential errors, including the case that -%>
|
20
|
+
<%# the script is non-empty, but just whitespace and/or comments -%>
|
21
|
+
:
|
22
|
+
<% if script?(:after_purge) -%>
|
23
|
+
<%= script(:after_purge) %>
|
24
|
+
<% end -%>
|
25
|
+
}
|
26
|
+
|
12
27
|
dummy() {
|
13
28
|
:
|
14
29
|
}
|
@@ -25,11 +40,8 @@ elif [ "${1}" = "purge" -a -z "${2}" ]
|
|
25
40
|
then
|
26
41
|
# like "on remove", but executes after dpkg deletes config files
|
27
42
|
# 'apt-get purge' runs 'on remove' section, then this section.
|
28
|
-
#
|
29
|
-
|
30
|
-
# might perhaps be used here, but most people
|
31
|
-
# probably don't need it.
|
32
|
-
dummy
|
43
|
+
# There is no equivalent in RPM or ARCH.
|
44
|
+
after_purge
|
33
45
|
elif [ "${1}" = "upgrade" ]
|
34
46
|
then
|
35
47
|
# This represents the case where the old package's postrm is called after
|
@@ -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
|
-
<%#
|
12
|
-
<% if attributes[:deb_systemd] -%>
|
13
|
-
|
14
|
-
|
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/deb.erb
CHANGED
@@ -13,27 +13,27 @@ Depends: <%= dependencies.collect { |d| fix_dependency(d) }.flatten.join(", ") %
|
|
13
13
|
<% if !conflicts.empty? -%>
|
14
14
|
Conflicts: <%= conflicts.collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
15
15
|
<% end -%>
|
16
|
-
<% if attributes[:deb_breaks] -%>
|
16
|
+
<% if attributes[:deb_breaks] and !attributes[:deb_breaks].empty? -%>
|
17
17
|
Breaks: <%= attributes[:deb_breaks].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
18
18
|
<% end -%>
|
19
|
-
<% if attributes[:
|
19
|
+
<% if attributes[:deb_pre_depends] and !attributes[:deb_pre_depends].empty? -%>
|
20
20
|
Pre-Depends: <%= attributes[:deb_pre_depends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
21
21
|
<% end -%>
|
22
|
-
<% if attributes[:
|
22
|
+
<% if attributes[:deb_build_depends] and !attributes[:deb_build_depends].empty? -%>
|
23
23
|
Build-Depends: <%= attributes[:deb_build_depends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
24
24
|
<% end -%>
|
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.
|
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
|
-
<% if attributes[:
|
33
|
+
<% if attributes[:deb_recommends] and !attributes[:deb_recommends].empty? -%>
|
34
34
|
Recommends: <%= attributes[:deb_recommends].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
35
35
|
<% end -%>
|
36
|
-
<% if attributes[:
|
36
|
+
<% if attributes[:deb_suggests] and !attributes[:deb_suggests].empty? -%>
|
37
37
|
Suggests: <%= attributes[:deb_suggests].collect { |d| fix_dependency(d) }.flatten.join(", ") %>
|
38
38
|
<% end -%>
|
39
39
|
Section: <%= category %>
|
data/templates/rpm.erb
CHANGED
@@ -17,6 +17,9 @@
|
|
17
17
|
# Disable checking for unpackaged files ?
|
18
18
|
#%undefine __check_files
|
19
19
|
|
20
|
+
# Allow building noarch packages that contain binaries
|
21
|
+
%define _binaries_in_noarch_packages_terminate_build 0
|
22
|
+
|
20
23
|
# Use <%= attributes[:rpm_digest] %> file digest method.
|
21
24
|
# The first macro is the one used in RPM v4.9.1.1
|
22
25
|
%define _binary_filedigest_algorithm <%= digest_algorithm %>
|
@@ -58,9 +61,8 @@ AutoProv: yes
|
|
58
61
|
# Seems specifying BuildRoot is required on older rpmbuild (like on CentOS 5)
|
59
62
|
# fpm passes '--define buildroot ...' on the commandline, so just reuse that.
|
60
63
|
BuildRoot: %buildroot
|
61
|
-
# Add prefix, must not end with /
|
62
64
|
<% if !prefix.nil? and !prefix.empty? %>
|
63
|
-
Prefix: <%= prefix
|
65
|
+
Prefix: <%= prefix %>
|
64
66
|
<% end -%>
|
65
67
|
|
66
68
|
Group: <%= category %>
|
@@ -83,7 +85,7 @@ Packager: <%= maintainer %>
|
|
83
85
|
<% dependencies.each do |req| -%>
|
84
86
|
Requires: <%= req %>
|
85
87
|
<% end -%>
|
86
|
-
<% (attributes[:
|
88
|
+
<% (attributes[:rpm_tag] or []).each do |tag| -%>
|
87
89
|
<%= tag %>
|
88
90
|
<% end -%>
|
89
91
|
<% end -%>
|
@@ -124,7 +126,7 @@ Obsoletes: <%= repl %>
|
|
124
126
|
-%>
|
125
127
|
<% if script?(:before_upgrade) or script?(:after_upgrade) -%>
|
126
128
|
<% if script?(:before_upgrade) or script?(:before_install) -%>
|
127
|
-
%pre
|
129
|
+
%pre <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
128
130
|
upgrade() {
|
129
131
|
<%# Making sure that at least one command is in the function -%>
|
130
132
|
<%# avoids a lot of potential errors, including the case that -%>
|
@@ -134,7 +136,7 @@ upgrade() {
|
|
134
136
|
<%= script(:before_upgrade) %>
|
135
137
|
<% end -%>
|
136
138
|
}
|
137
|
-
|
139
|
+
_install() {
|
138
140
|
<%# Making sure that at least one command is in the function -%>
|
139
141
|
<%# avoids a lot of potential errors, including the case that -%>
|
140
142
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
@@ -146,7 +148,7 @@ install() {
|
|
146
148
|
if [ "${1}" -eq 1 ]
|
147
149
|
then
|
148
150
|
# "before install" goes here
|
149
|
-
|
151
|
+
_install
|
150
152
|
elif [ "${1}" -gt 1 ]
|
151
153
|
then
|
152
154
|
# "before upgrade" goes here
|
@@ -154,7 +156,7 @@ then
|
|
154
156
|
fi
|
155
157
|
<% end -%>
|
156
158
|
<% if script?(:after_upgrade) or script?(:after_install) -%>
|
157
|
-
%post
|
159
|
+
%post <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
158
160
|
upgrade() {
|
159
161
|
<%# Making sure that at least one command is in the function -%>
|
160
162
|
<%# avoids a lot of potential errors, including the case that -%>
|
@@ -164,7 +166,7 @@ upgrade() {
|
|
164
166
|
<%= script(:after_upgrade) %>
|
165
167
|
<% end -%>
|
166
168
|
}
|
167
|
-
|
169
|
+
_install() {
|
168
170
|
<%# Making sure that at least one command is in the function -%>
|
169
171
|
<%# avoids a lot of potential errors, including the case that -%>
|
170
172
|
<%# the script is non-empty, but just whitespace and/or comments -%>
|
@@ -176,7 +178,7 @@ install() {
|
|
176
178
|
if [ "${1}" -eq 1 ]
|
177
179
|
then
|
178
180
|
# "after install" goes here
|
179
|
-
|
181
|
+
_install
|
180
182
|
elif [ "${1}" -gt 1 ]
|
181
183
|
then
|
182
184
|
# "after upgrade" goes here
|
@@ -184,7 +186,7 @@ then
|
|
184
186
|
fi
|
185
187
|
<% end -%>
|
186
188
|
<% if script?(:before_remove) -%>
|
187
|
-
%preun
|
189
|
+
%preun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
188
190
|
if [ "${1}" -eq 0 ]
|
189
191
|
then
|
190
192
|
<%# Making sure that at least one command is in the function -%>
|
@@ -195,7 +197,7 @@ then
|
|
195
197
|
fi
|
196
198
|
<% end -%>
|
197
199
|
<% if script?(:after_remove) -%>
|
198
|
-
%postun
|
200
|
+
%postun <% if attributes[:rpm_macro_expansion?] -%><%= " -e " %> <% end %>
|
199
201
|
if [ "${1}" -eq 0 ]
|
200
202
|
then
|
201
203
|
<%# Making sure that at least one command is in the function -%>
|
@@ -217,7 +219,7 @@ fi
|
|
217
219
|
-%>
|
218
220
|
<% scriptmap.each do |name, rpmname| -%>
|
219
221
|
<% if script?(name) -%>
|
220
|
-
%<%= rpmname %>
|
222
|
+
%<%= rpmname -%> <%= ' -e' if attributes[:rpm_macro_expansion?] %>
|
221
223
|
<%= script(name) %>
|
222
224
|
<% end -%>
|
223
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
|
-
|
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(){
|