fpm 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,6 +86,9 @@ class FPM::Package::RPM < FPM::Package
86
86
  File.read(File.expand_path(file))
87
87
  end
88
88
 
89
+ option "--summary", "SUMMARY",
90
+ "Set the RPM summary. Overrides the first line on the description if set"
91
+
89
92
  option "--sign", :flag, "Pass --sign to rpmbuild"
90
93
 
91
94
  option "--auto-add-directories", :flag, "Auto add directories not part of filesystem"
@@ -119,6 +122,14 @@ class FPM::Package::RPM < FPM::Package
119
122
  next rpmbuild_filter_from_requires
120
123
  end
121
124
 
125
+ rpm_tags = []
126
+ option "--tag", "TAG",
127
+ "Adds a custom tag in the spec file as is. " \
128
+ "Example: --rpm-tag 'Requires(post): /usr/sbin/alternatives'" do |add_tag|
129
+ rpm_tags << add_tag
130
+ next rpm_tags
131
+ end
132
+
122
133
  option "--ignore-iteration-in-dependencies", :flag,
123
134
  "For '=' (equal) dependencies, allow iterations on the specified " \
124
135
  "version. Default is to be specific. This option allows the same " \
@@ -165,11 +176,15 @@ class FPM::Package::RPM < FPM::Package
165
176
  # Replace ? with [?] to make rpm not use globs
166
177
  # Replace % with [%] to make rpm not expand macros
167
178
  def rpm_fix_name(name)
168
- name = "\"#{name}\"" if name[/\s/]
169
- name = name.gsub("[", "[\\[]")
170
- name = name.gsub("*", "[*]")
171
- name = name.gsub("?", "[?]")
172
- name = name.gsub("%", "[%]")
179
+ name = name.gsub(/(\ |\[|\]|\*|\?|\%|\$)/, {
180
+ ' ' => '?',
181
+ '%' => '[%]',
182
+ '$' => '[$]',
183
+ '?' => '[?]',
184
+ '*' => '[*]',
185
+ '[' => '[\[]',
186
+ ']' => '[\]]'
187
+ })
173
188
  end
174
189
 
175
190
  def rpm_file_entry(file)
@@ -306,12 +321,16 @@ class FPM::Package::RPM < FPM::Package
306
321
 
307
322
  def rpm_get_trigger_type(flag)
308
323
  if (flag & (1 << 25)) == (1 << 25)
324
+ # RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
309
325
  :rpm_trigger_before_install
310
326
  elsif (flag & (1 << 16)) == (1 << 16)
327
+ # RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
311
328
  :rpm_trigger_after_install
312
329
  elsif (flag & (1 << 17)) == (1 << 17)
330
+ # RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
313
331
  :rpm_trigger_before_uninstall
314
332
  elsif (flag & (1 << 18)) == (1 << 18)
333
+ # RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
315
334
  :rpm_trigger_after_target_uninstall
316
335
  else
317
336
  @logger.fatal("I don't know about this triggerflag ('#{flag}')")
@@ -512,6 +531,14 @@ class FPM::Package::RPM < FPM::Package
512
531
  #return File.join("BUILD", prefix)
513
532
  end # def build_sub_dir
514
533
 
534
+ def summary
535
+ if !attributes[:rpm_summary]
536
+ return @description.split("\n").first || "_"
537
+ end
538
+
539
+ return attributes[:rpm_summary]
540
+ end # def summary
541
+
515
542
  def version
516
543
  if @version.kind_of?(String) and @version.include?("-")
517
544
  logger.warn("Package version '#{@version}' includes dashes, converting" \
@@ -527,7 +554,6 @@ class FPM::Package::RPM < FPM::Package
527
554
  return @epoch if @epoch.is_a?(Numeric)
528
555
 
529
556
  if @epoch.nil? or @epoch.empty?
530
- logger.warn("no value for epoch is set, defaulting to nil")
531
557
  return nil
532
558
  end
533
559
 
@@ -552,5 +578,5 @@ class FPM::Package::RPM < FPM::Package
552
578
 
553
579
  public(:input, :output, :converted_from, :architecture, :to_s, :iteration,
554
580
  :payload_compression, :digest_algorithm, :prefix, :build_sub_dir,
555
- :epoch, :version, :prefixed_path)
581
+ :summary, :epoch, :version, :prefixed_path)
556
582
  end # class FPM::Package::RPM
@@ -19,7 +19,7 @@ class FPM::Package::Tar < FPM::Package
19
19
  args = ["-xf", input_path, "-C", build_path]
20
20
 
21
21
  # Add the tar compression flag if necessary
22
- with(tar_compression_flag(input_path)) do |flag|
22
+ tar_compression_flag(input_path).tap do |flag|
23
23
  args << flag unless flag.nil?
24
24
  end
25
25
 
@@ -50,7 +50,7 @@ class FPM::Package::Tar < FPM::Package
50
50
  output_check(output_path)
51
51
  # Unpack the tarball to the staging path
52
52
  args = ["-cf", output_path, "-C", staging_path]
53
- with(tar_compression_flag(output_path)) do |flag|
53
+ tar_compression_flag(output_path).tap do |flag|
54
54
  args << flag unless flag.nil?
55
55
  end
56
56
  args << "."
@@ -25,6 +25,10 @@ class FPM::Package::Virtualenv < FPM::Package
25
25
  option "--other-files-dir", "DIRECTORY", "Optionally, the contents of the " \
26
26
  "specified directory may be added to the package. This is useful if the " \
27
27
  "virtualenv needs configuration files, etc.", :default => nil
28
+ option "--pypi-extra-url", "PYPI_EXTRA_URL",
29
+ "PyPi extra-index-url for pointing to your priviate PyPi",
30
+ :multivalued => true, :attribute_name => :virtualenv_pypi_extra_index_urls,
31
+ :default => nil
28
32
 
29
33
  private
30
34
 
@@ -72,9 +76,14 @@ class FPM::Package::Virtualenv < FPM::Package
72
76
  "pip", "distribute")
73
77
  safesystem(pip_exe, "uninstall", "-y", "distribute")
74
78
 
75
- safesystem(pip_exe, "install", "-i",
76
- attributes[:virtualenv_pypi],
77
- package)
79
+ extra_index_url_args = []
80
+ if attributes[:virtualenv_pypi_extra_index_urls]
81
+ attributes[:virtualenv_pypi_extra_index_urls].each do |extra_url|
82
+ extra_index_url_args << "--extra-index-url" << extra_url
83
+ end
84
+ end
85
+ pip_args = [pip_exe, "install", "-i", attributes[:virtualenv_pypi]] << extra_index_url_args << package
86
+ safesystem(*pip_args.flatten)
78
87
 
79
88
  if package_version.nil?
80
89
  frozen = safesystemout(pip_exe, "freeze")
@@ -0,0 +1,59 @@
1
+ require "ostruct"
2
+ require "rake"
3
+ require "rake/tasklib"
4
+
5
+ class FPM::RakeTask < Rake::TaskLib
6
+ attr_reader :options
7
+
8
+ def initialize(package_name, opts = {}, &block)
9
+ @options = OpenStruct.new(:name => package_name.to_s)
10
+ @source, @target = opts.values_at(:source, :target).map(&:to_s)
11
+ @directory = File.expand_path(opts[:directory].to_s)
12
+
13
+ (@source.empty? || @target.empty? || options.name.empty?) &&
14
+ abort("Must specify package name, source and output")
15
+
16
+ desc "Package #{@name}" unless ::Rake.application.last_comment
17
+
18
+ task(options.name) do |_, task_args|
19
+ block.call(*[options, task_args].first(block.arity)) if block_given?
20
+ abort("Must specify args") unless options.respond_to?(:args)
21
+ @args = options.delete_field(:args)
22
+ run_cli
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def parsed_options
29
+ options.to_h.map do |option, value|
30
+ opt = option.to_s.tr("_", "-")
31
+
32
+ case
33
+ when value.is_a?(String), value.is_a?(Symbol)
34
+ %W(--#{opt} #{value})
35
+ when value.is_a?(Array)
36
+ value.map { |v| %W(--#{opt} #{v}) }
37
+ when value.is_a?(TrueClass)
38
+ "--#{opt}"
39
+ when value.is_a?(FalseClass)
40
+ "--no-#{opt}"
41
+ else
42
+ fail TypeError, "Unexpected type: #{value.class}"
43
+ end
44
+ end
45
+ end
46
+
47
+ def run_cli
48
+ require "fpm"
49
+ require "fpm/command"
50
+
51
+ args = %W(-t #{@target} -s #{@source} -C #{@directory})
52
+ args << parsed_options
53
+ args << @args
54
+
55
+ args.flatten!.compact!
56
+
57
+ exit(FPM::Command.new("fpm").run(args) || 0)
58
+ end
59
+ end
@@ -135,17 +135,14 @@ module FPM::Util
135
135
  system("#{tar} > /dev/null 2> /dev/null")
136
136
  return tar unless $?.exitstatus == 127
137
137
  end
138
+ when "FreeBSD"
139
+ # use gnutar instead
140
+ return "gtar"
138
141
  else
139
142
  return "tar"
140
143
  end
141
144
  end # def tar_cmd
142
145
 
143
- # Run a block with a value.
144
- # Useful in lieu of assigning variables
145
- def with(value, &block)
146
- block.call(value)
147
- end # def with
148
-
149
146
  # wrapper around mknod ffi calls
150
147
  def mknod_w(path, mode, dev)
151
148
  rc = -1
@@ -1,3 +1,3 @@
1
1
  module FPM
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -7,6 +7,19 @@ after_upgrade() {
7
7
  <% if script?(:after_upgrade) -%>
8
8
  <%= script(:after_upgrade) %>
9
9
  <% end -%>
10
+
11
+ <% if attributes[:deb_systemd] -%>
12
+ systemctl --system daemon-reload >/dev/null || true
13
+ if ! systemctl is-enabled <%= attributes[:deb_systemd] %> >/dev/null
14
+ then
15
+ systemctl enable <%= attributes[:deb_systemd] %> >/dev/null || true
16
+ systemctl start <%= attributes[:deb_systemd] %> >/dev/null || true
17
+ <% if attributes[:deb_systemd_restart_after_upgrade?] -%>
18
+ else
19
+ systemctl restart <%= attributes[:deb_systemd] %> >/dev/null || true
20
+ <% end -%>
21
+ fi
22
+ <% end -%>
10
23
  }
11
24
 
12
25
  after_install() {
@@ -17,6 +30,12 @@ after_install() {
17
30
  <% if script?(:after_install) -%>
18
31
  <%= script(:after_install) %>
19
32
  <% end -%>
33
+
34
+ <% if attributes[:deb_systemd] -%>
35
+ 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
38
+ <% end -%>
20
39
  }
21
40
 
22
41
  if [ "${1}" = "configure" -a -z "${2}" ] || \
@@ -7,6 +7,13 @@ before_remove() {
7
7
  <% if script?(:before_remove) -%>
8
8
  <%= script(:before_remove) %>
9
9
  <% end -%>
10
+
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
15
+ systemctl --system daemon-reload >/dev/null || true
16
+ <% end -%>
10
17
  }
11
18
 
12
19
  dummy() {
@@ -0,0 +1,47 @@
1
+ # Generated by fpm
2
+ # Hello packaging friend!
3
+ #
4
+ # If you find yourself using this 'fpm --edit' feature frequently, it is
5
+ # a sign that fpm is missing a feature! I welcome your feature requests!
6
+ # Please visit the following URL and ask for a feature that helps you never
7
+ # need to edit this file again! :)
8
+ # https://github.com/jordansissel/fpm/issues
9
+ # ------------------------------------------------------------------------
10
+ #
11
+ pkgname = <%= name %>
12
+ <% if !epoch.nil? -%>
13
+ pkgver = <%= epoch %>:<%= version %>-<%= iteration %>
14
+ <% else -%>
15
+ pkgver = <%= version %>-<%= iteration %>
16
+ <% end -%>
17
+ pkgdesc = <%= description %>
18
+ <% if !url.nil? and !url.empty? -%>
19
+ url = <%= url %>
20
+ <% else -%>
21
+ url = http://nourlgiven.example.com/
22
+ <% end -%>
23
+ builddate = <%= builddate %>
24
+ packager = <%= maintainer %>
25
+ size = <%= size %>
26
+ arch = <%= architecture %>
27
+ license = <%= license %>
28
+ <% replaces.each do |repl| -%>
29
+ replaces = <%= repl %>
30
+ <% end -%>
31
+ group = <%= category %>
32
+ <% conflicts.each do |confl| -%>
33
+ conflict = <%= confl %>
34
+ <% end -%>
35
+ <% provides.each do |prov| -%>
36
+ provides = <%= prov %>
37
+ <% end -%>
38
+ <% config_files.each do |conf| -%>
39
+ <% conf.gsub(/^\/+/, "") -%>
40
+ backup = <%= conf %>
41
+ <% end -%>
42
+ <% dependencies.each do |req| -%>
43
+ depend = <%= req %>
44
+ <% end -%>
45
+ <% attributes.fetch(:pacman_opt_depends, []).each do |opt| -%>
46
+ optdepend = <%= opt %>
47
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%# In each function, a `:` is the first command. -%>
2
+ <%# This makes sure that at least one command is in the function -%>
3
+ <%# This avoids a lot of potential errors, including the case that -%>
4
+ <%# the script is non-empty, but just whitespace and/or comments -%>
5
+ <%# see issue #875 for more details -%>
6
+ <% if script?(:before_install) -%>
7
+ pre_install() {
8
+ :
9
+ <%= script(:before_install) %>
10
+ }
11
+ <% end -%>
12
+ <% if script?(:after_install) -%>
13
+ post_install() {
14
+ :
15
+ <%= script(:after_install) %>
16
+ }
17
+ <% end -%>
18
+ <% if script?(:before_upgrade) -%>
19
+ pre_upgrade() {
20
+ :
21
+ <%= script(:before_upgrade) %>
22
+ }
23
+ <% end -%>
24
+ <% if script?(:after_upgrade) -%>
25
+ post_upgrade() {
26
+ :
27
+ <%= script(:after_upgrade) %>
28
+ }
29
+ <% end -%>
30
+ <% if script?(:before_remove) -%>
31
+ pre_remove() {
32
+ :
33
+ <%= script(:before_remove) %>
34
+ }
35
+ <% end -%>
36
+ <% if script?(:after_remove) -%>
37
+ post_remove() {
38
+ :
39
+ <%= script(:after_remove) %>
40
+ }
41
+ <% end -%>
@@ -43,7 +43,7 @@ Epoch: <%= epoch %>
43
43
  <% end -%>
44
44
  Release: <%= iteration or 1 %><%= "%{?dist}" if attributes[:rpm_dist] %>
45
45
  <%# use the first line of the description as the summary -%>
46
- Summary: <%= description.split("\n").first.empty? ? "_" : description.split("\n").first %>
46
+ Summary: <%= summary %>
47
47
  <% if !attributes[:rpm_autoreqprov?] -%>
48
48
  AutoReqProv: no
49
49
  <% else -%>
@@ -83,6 +83,9 @@ Packager: <%= maintainer %>
83
83
  <% dependencies.each do |req| -%>
84
84
  Requires: <%= req %>
85
85
  <% end -%>
86
+ <% (attributes[:rpm_tags] or []).each do |tag| -%>
87
+ <%= tag %>
88
+ <% end -%>
86
89
  <% end -%>
87
90
  <% provides.each do |prov| -%>
88
91
  Provides: <%= prov %>
@@ -62,8 +62,9 @@ function slug_already_current(){
62
62
  if [ "$FORCE" == "1" ] ; then
63
63
  log "Force was specified. Proceeding with install after renaming live directory to allow running service to shutdown correctly."
64
64
  local real_dir=$(readlink ${INSTALL_ROOT}/current)
65
- if [ -f ${real_dir}.old ] ; then
65
+ if [ -e ${real_dir}.old ] ; then
66
66
  # remove that .old directory, if needed
67
+ log "removing existing .old version of release"
67
68
  rm -rf ${real_dir}.old
68
69
  fi
69
70
  mv ${real_dir} ${real_dir}.old
@@ -196,6 +197,7 @@ function unpack_payload(){
196
197
  function run_post_install(){
197
198
  local AFTER_INSTALL=$INSTALL_DIR/.fpm/after_install
198
199
  if [ -r $AFTER_INSTALL ] ; then
200
+ set_post_install_vars
199
201
  chmod +x $AFTER_INSTALL
200
202
  log "Running post install script"
201
203
  output=$($AFTER_INSTALL 2>&1)
@@ -206,11 +208,23 @@ function run_post_install(){
206
208
  return 0
207
209
  }
208
210
 
211
+ function set_post_install_vars(){
212
+ # for rationale on the `:`, see #871
213
+ :
214
+ <% if respond_to?(:package_metadata)%>
215
+ <% package_metadata_hash = JSON.parse(package_metadata)%>
216
+ <% package_metadata_hash.each do |k,v| %>
217
+ <%= "export #{k.upcase}='#{v}'; "%>
218
+ <% end %>
219
+ <% end %>
220
+ }
221
+
209
222
  function create_symlinks(){
210
223
  [ -n "$USE_FLAT_RELEASE_DIRECTORY" ] && return
211
224
 
212
225
  export CURRENT_DIR="$INSTALL_ROOT/current"
213
- if [ -e "$CURRENT_DIR" ] ; then
226
+ if [ -e "$CURRENT_DIR" ] || [ -h "$CURRENT_DIR" ] ; then
227
+ log "Removing current symlink"
214
228
  OLD_CURRENT_TARGET=$(readlink $CURRENT_DIR)
215
229
  rm "$CURRENT_DIR"
216
230
  fi
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.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-27 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -108,6 +108,62 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: archive-tar-minitar
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: ruby-xz
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: corefines
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.9'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.9'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: rspec
113
169
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +184,14 @@ dependencies:
128
184
  requirements:
129
185
  - - "~>"
130
186
  - !ruby/object:Gem::Version
131
- version: 0.0.5
187
+ version: 1.0.0
132
188
  type: :development
133
189
  prerelease: false
134
190
  version_requirements: !ruby/object:Gem::Requirement
135
191
  requirements:
136
192
  - - "~>"
137
193
  - !ruby/object:Gem::Version
138
- version: 0.0.5
194
+ version: 1.0.0
139
195
  - !ruby/object:Gem::Dependency
140
196
  name: pry
141
197
  requirement: !ruby/object:Gem::Requirement
@@ -186,15 +242,19 @@ files:
186
242
  - lib/fpm/package/deb.rb
187
243
  - lib/fpm/package/dir.rb
188
244
  - lib/fpm/package/empty.rb
245
+ - lib/fpm/package/freebsd.rb
189
246
  - lib/fpm/package/gem.rb
190
247
  - lib/fpm/package/npm.rb
191
248
  - lib/fpm/package/osxpkg.rb
192
249
  - lib/fpm/package/p5p.rb
250
+ - lib/fpm/package/pacman.rb
193
251
  - lib/fpm/package/pear.rb
194
252
  - lib/fpm/package/pkgin.rb
195
253
  - lib/fpm/package/puppet.rb
196
254
  - lib/fpm/package/pyfpm/__init__.py
255
+ - lib/fpm/package/pyfpm/__init__.pyc
197
256
  - lib/fpm/package/pyfpm/get_metadata.py
257
+ - lib/fpm/package/pyfpm/get_metadata.pyc
198
258
  - lib/fpm/package/python.rb
199
259
  - lib/fpm/package/rpm.rb
200
260
  - lib/fpm/package/sh.rb
@@ -202,6 +262,7 @@ files:
202
262
  - lib/fpm/package/tar.rb
203
263
  - lib/fpm/package/virtualenv.rb
204
264
  - lib/fpm/package/zip.rb
265
+ - lib/fpm/rake_task.rb
205
266
  - lib/fpm/util.rb
206
267
  - lib/fpm/version.rb
207
268
  - templates/deb.erb
@@ -213,6 +274,8 @@ files:
213
274
  - templates/deb/prerm_upgrade.sh.erb
214
275
  - templates/osxpkg.erb
215
276
  - templates/p5p_metadata.erb
277
+ - templates/pacman.erb
278
+ - templates/pacman/INSTALL.erb
216
279
  - templates/puppet/package.pp.erb
217
280
  - templates/puppet/package/remove.pp.erb
218
281
  - templates/rpm.erb