fpm 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,80 @@
1
+ require 'rubygems/package'
2
+
3
+ module FPM
4
+ module Issues
5
+ module TarWriter
6
+ # See https://github.com/rubygems/rubygems/issues/1608
7
+ def self.has_issue_1608?
8
+ name, prefix = nil,nil
9
+ io = StringIO.new
10
+ ::Gem::Package::TarWriter.new(io) do |tw|
11
+ name, prefix = tw.split_name('/123456789'*9 + '/1234567890') # abs name 101 chars long
12
+ end
13
+ return prefix.empty?
14
+ end
15
+
16
+ def self.has_issues_with_split_name?
17
+ return false unless ::Gem::Package::TarWriter.method_defined?(:split_name)
18
+ return has_issue_1608?
19
+ end
20
+
21
+ def self.has_issues_with_add_symlink?
22
+ return !::Gem::Package::TarWriter.public_instance_methods.include?(:add_symlink)
23
+ end
24
+ end # module TarWriter
25
+ end # module Issues
26
+ end # module FPM
27
+
28
+ module FPM; module Util; end; end
29
+
30
+ # Like the ::Gem::Package::TarWriter but contains some backports and bug fixes
31
+ class FPM::Util::TarWriter < ::Gem::Package::TarWriter
32
+ if FPM::Issues::TarWriter.has_issues_with_split_name?
33
+ def split_name(name)
34
+ if name.bytesize > 256 then
35
+ raise ::Gem::Package::TooLongFileName.new("File \"#{name}\" has a too long path (should be 256 or less)")
36
+ end
37
+
38
+ prefix = ''
39
+ if name.bytesize > 100 then
40
+ parts = name.split('/', -1) # parts are never empty here
41
+ name = parts.pop # initially empty for names with a trailing slash ("foo/.../bar/")
42
+ prefix = parts.join('/') # if empty, then it's impossible to split (parts is empty too)
43
+ while !parts.empty? && (prefix.bytesize > 155 || name.empty?)
44
+ name = parts.pop + '/' + name
45
+ prefix = parts.join('/')
46
+ end
47
+
48
+ if name.bytesize > 100 or prefix.empty? then
49
+ raise ::Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long name (should be 100 or less)")
50
+ end
51
+
52
+ if prefix.bytesize > 155 then
53
+ raise ::Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long base path (should be 155 or less)")
54
+ end
55
+ end
56
+
57
+ return name, prefix
58
+ end
59
+ end # if FPM::Issues::TarWriter.spit_name_has_issues?
60
+
61
+ if FPM::Issues::TarWriter.has_issues_with_add_symlink?
62
+ # Backport Symlink Support to TarWriter
63
+ # https://github.com/rubygems/rubygems/blob/4a778c9c2489745e37bcc2d0a8f12c601a9c517f/lib/rubygems/package/tar_writer.rb#L239-L253
64
+ def add_symlink(name, target, mode)
65
+ check_closed
66
+
67
+ name, prefix = split_name name
68
+
69
+ header = ::Gem::Package::TarHeader.new(:name => name, :mode => mode,
70
+ :size => 0, :typeflag => "2",
71
+ :linkname => target,
72
+ :prefix => prefix,
73
+ :mtime => Time.now).to_s
74
+
75
+ @io.write header
76
+
77
+ self
78
+ end # def add_symlink
79
+ end
80
+ end
@@ -1,3 +1,3 @@
1
1
  module FPM
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+
3
+ show_cleanup_step() {
4
+ d="${1##.}"
5
+ if [ ! -z "$d" ] ; then
6
+ if [ -d "$1" -a ! -d "$d" ] ; then
7
+ echo "rmdir \"$d\""
8
+ fi
9
+ if [ -f "$1" ] ; then
10
+ echo "rm \"$d\""
11
+ fi
12
+ fi
13
+ }
14
+
15
+ for i in "$@" ; do
16
+ show_cleanup_step "$i"
17
+ done
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+
3
+ install_path() {
4
+ d="${1##.}"
5
+ if [ ! -z "$d" ] ; then
6
+ if [ -d "$1" -a ! -d "$d" ] ; then
7
+ mkdir "$d"
8
+ fi
9
+ if [ -f "$1" ] ; then
10
+ cp -p "$1" "$d"
11
+ fi
12
+ fi
13
+ }
14
+
15
+ for i in "$@" ; do
16
+ install_path "$i"
17
+ done
@@ -0,0 +1,117 @@
1
+ #!/bin/sh
2
+
3
+ source="<%= attributes[:prefix] %>"
4
+
5
+ cleanup_script="$source/cleanup.sh"
6
+
7
+ silent() {
8
+ "$@" > /dev/null 2>&1
9
+ }
10
+
11
+ install_files() {
12
+ # TODO(sissel): Need to know what prefix the files exist at
13
+ platform="$1"
14
+ version="$(version_${platform})"
15
+
16
+ (
17
+ # TODO(sissel): Should I just rely on rsync for this stuff?
18
+ cd "${source}/${platform}/${version}/files/" || exit 1
19
+
20
+ # Write a cleanup script
21
+ find . -print0 | xargs -r0 -n1 "$source/generate-cleanup.sh" > "$cleanup_script"
22
+
23
+ # Actually do the installation
24
+ find . -print0 | xargs -r0 -n1 "$source/install-path.sh"
25
+ )
26
+ }
27
+
28
+ install_actions() {
29
+ # TODO(sissel): Need to know what prefix the files exist at
30
+ platform="$1"
31
+ version="$(version_${platform})"
32
+
33
+
34
+ actions="${source}/${platform}/${version}/install_actions.sh"
35
+ if [ -f "$actions" ] ; then
36
+ . "$actions"
37
+ fi
38
+ }
39
+
40
+ version_systemd() {
41
+ # Treat all systemd versions the same
42
+ echo default
43
+ }
44
+
45
+ version_launchd() {
46
+ # Treat all launchd versions the same
47
+ echo 10.9
48
+ }
49
+
50
+ version_upstart() {
51
+ # Treat all upstart versions the same
52
+ # TODO(sissel): Upstart 0.6.5 needs to be handled specially.
53
+ version="$(initctl --version | head -1 | tr -d '()' | awk '{print $NF}')"
54
+
55
+ case $version in
56
+ 0.6.5) echo $version ;;
57
+ *) echo "1.5" ;; # default modern assumption
58
+ esac
59
+ }
60
+
61
+ version_sysv() {
62
+ # TODO(sissel): Once pleaserun supports multiple sysv implementations, maybe
63
+ # we inspect the OS to find out what we should target.
64
+ echo lsb-3.1
65
+ }
66
+
67
+ has_systemd() {
68
+ # Some OS vendors put systemd in ... different places ...
69
+ [ -d "/lib/systemd/system/" -o -d "/usr/lib/systemd/system" ] && silent which systemctl
70
+ }
71
+
72
+ has_upstart() {
73
+ [ -d "/etc/init" ] && silent which initctl
74
+ }
75
+
76
+ has_sysv() {
77
+ [ -d "/etc/init.d" ]
78
+ }
79
+
80
+ #has_freebsd_rcng() {
81
+ #[ -d "/etc/rc.d" ] && silent which rcorder
82
+ #}
83
+
84
+ has_daemontools() {
85
+ [ -d "/service" ] && silent which sv
86
+ }
87
+
88
+ has_launchd() {
89
+ [ -d "/Library/LaunchDaemons" ] && silent which launchtl
90
+ }
91
+
92
+ install_help() {
93
+ case $platform in
94
+ systemd) echo "To start this service, use: systemctl start <%= attributes[:pleaserun_name] %>" ;;
95
+ upstart) echo "To start this service, use: initctl start <%= attributes[:pleaserun_name] %>" ;;
96
+ launchd) echo "To start this service, use: launchctl start <%= attributes[:pleaserun_name] %>" ;;
97
+ sysv) echo "To start this service, use: /etc/init.d/<%= attributes[:pleaserun_name] %> start" ;;
98
+ esac
99
+ }
100
+
101
+ platforms="systemd upstart launchd sysv"
102
+ installed=0
103
+ for platform in $platforms ; do
104
+ if has_$platform ; then
105
+ version="$(version_$platform)"
106
+ echo "Platform $platform ($version) detected. Installing service."
107
+ install_files $platform
108
+ install_actions $platform
109
+ install_help $platform
110
+ installed=1
111
+ break
112
+ fi
113
+ done
114
+
115
+ if [ "$installed" -eq 0 ] ; then
116
+ echo "Failed to detect any service platform, so no service was installed. Files are available in ${source} if you need them."
117
+ fi
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+
3
+ source="<%= attributes[:prefix] %>"
4
+ exec sh "$source/install.sh"
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ source="<%= attributes[:prefix] %>"
4
+
5
+ if [ -f "$source/cleanup.sh" ] ; then
6
+ echo "Running cleanup to remove service for package <%= attributes[:name] %>"
7
+ set -e
8
+ sh "$source/cleanup.sh"
9
+
10
+ # Remove the script also since the package installation generated it.
11
+ rm "$source/cleanup.sh"
12
+ 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.5.0
4
+ version: 1.6.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: 2016-04-12 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.6'
75
+ version: 1.0.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.6'
82
+ version: 1.0.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: childprocess
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -151,19 +151,19 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: corefines
154
+ name: pleaserun
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.9'
159
+ version: 0.0.24
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.9'
166
+ version: 0.0.24
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +238,7 @@ files:
238
238
  - lib/fpm/errors.rb
239
239
  - lib/fpm/namespace.rb
240
240
  - lib/fpm/package.rb
241
+ - lib/fpm/package/apk.rb
241
242
  - lib/fpm/package/cpan.rb
242
243
  - lib/fpm/package/deb.rb
243
244
  - lib/fpm/package/dir.rb
@@ -250,6 +251,7 @@ files:
250
251
  - lib/fpm/package/pacman.rb
251
252
  - lib/fpm/package/pear.rb
252
253
  - lib/fpm/package/pkgin.rb
254
+ - lib/fpm/package/pleaserun.rb
253
255
  - lib/fpm/package/puppet.rb
254
256
  - lib/fpm/package/pyfpm/__init__.py
255
257
  - lib/fpm/package/pyfpm/__init__.pyc
@@ -264,6 +266,7 @@ files:
264
266
  - lib/fpm/package/zip.rb
265
267
  - lib/fpm/rake_task.rb
266
268
  - lib/fpm/util.rb
269
+ - lib/fpm/util/tar_writer.rb
267
270
  - lib/fpm/version.rb
268
271
  - templates/deb.erb
269
272
  - templates/deb/changelog.erb
@@ -276,6 +279,11 @@ files:
276
279
  - templates/p5p_metadata.erb
277
280
  - templates/pacman.erb
278
281
  - templates/pacman/INSTALL.erb
282
+ - templates/pleaserun/generate-cleanup.sh
283
+ - templates/pleaserun/install-path.sh
284
+ - templates/pleaserun/install.sh
285
+ - templates/pleaserun/scripts/after-install.sh
286
+ - templates/pleaserun/scripts/before-remove.sh
279
287
  - templates/puppet/package.pp.erb
280
288
  - templates/puppet/package/remove.pp.erb
281
289
  - templates/rpm.erb