fpm 0.2.18 → 0.2.19
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.
- data/bin/fpm +31 -0
- data/lib/fpm/builder.rb +3 -1
- data/lib/fpm/package.rb +7 -3
- data/lib/fpm/source.rb +1 -1
- data/lib/fpm/source/gem.rb +10 -3
- data/lib/fpm/target/deb.rb +21 -2
- data/templates/deb.erb +2 -2
- data/templates/rpm.erb +29 -9
- metadata +11 -11
data/bin/fpm
CHANGED
@@ -13,6 +13,9 @@ def main(args)
|
|
13
13
|
settings = OpenStruct.new
|
14
14
|
settings.exclude = []
|
15
15
|
|
16
|
+
# Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
|
17
|
+
settings.scripts ||= {}
|
18
|
+
|
16
19
|
opts = OptionParser.new do |opts|
|
17
20
|
# TODO(sissel): Maybe this should be '-o OUTPUT' ?
|
18
21
|
opts.on("-p PACKAGEFILE", "--package PACKAGEFILE",
|
@@ -87,6 +90,34 @@ def main(args)
|
|
87
90
|
settings.exclude << pattern
|
88
91
|
end # -x / --exclude
|
89
92
|
|
93
|
+
opts.on("--post-install SCRIPTPATH",
|
94
|
+
"Add a post-install action. This script will be included in the" \
|
95
|
+
" resulting package") do |path|
|
96
|
+
settings.scripts["post-install"] = File.expand_path(path)
|
97
|
+
end # --post-install
|
98
|
+
|
99
|
+
opts.on("--pre-install SCRIPTPATH",
|
100
|
+
"Add a pre-install action. This script will be included in the" \
|
101
|
+
" resulting package") do |path|
|
102
|
+
settings.scripts["pre-install"] = File.expand_path(path)
|
103
|
+
end # --pre-install
|
104
|
+
|
105
|
+
opts.on("--pre-uninstall SCRIPTPATH",
|
106
|
+
"Add a pre-uninstall action. This script will be included in the" \
|
107
|
+
" resulting package") do |path|
|
108
|
+
settings.scripts["pre-uninstall"] = File.expand_path(path)
|
109
|
+
end # --pre-uninstall
|
110
|
+
|
111
|
+
opts.on("--post-uninstall SCRIPTPATH",
|
112
|
+
"Add a post-uninstall action. This script will be included in the" \
|
113
|
+
" resulting package") do |path|
|
114
|
+
settings.scripts["post-uninstall"] = File.expand_path(path)
|
115
|
+
end # --post-uninstall
|
116
|
+
|
117
|
+
opts.on("--description DESCRIPTION",
|
118
|
+
"Add a description for this package.") do |description|
|
119
|
+
settings.description = description
|
120
|
+
end # --description
|
90
121
|
end # OptionParser
|
91
122
|
|
92
123
|
opts.parse!(args)
|
data/lib/fpm/builder.rb
CHANGED
@@ -39,7 +39,8 @@ class FPM::Builder
|
|
39
39
|
:suffix => settings.suffix,
|
40
40
|
:exclude => settings.exclude,
|
41
41
|
:maintainer => settings.maintainer,
|
42
|
-
:provides => []
|
42
|
+
:provides => [],
|
43
|
+
:description => settings.description
|
43
44
|
)
|
44
45
|
|
45
46
|
@edit = !!settings.edit
|
@@ -51,6 +52,7 @@ class FPM::Builder
|
|
51
52
|
# Append provides given from settings (--provides flag for fpm)
|
52
53
|
@package.provides += settings.provides if settings.provides
|
53
54
|
@package.architecture = settings.architecture if settings.architecture
|
55
|
+
@package.scripts = settings.scripts
|
54
56
|
|
55
57
|
@output = settings.package_path
|
56
58
|
@recurse_dependencies = settings.recurse_dependencies
|
data/lib/fpm/package.rb
CHANGED
@@ -48,8 +48,11 @@ class FPM::Package
|
|
48
48
|
attr_accessor :provides
|
49
49
|
|
50
50
|
# a summary or description of the package
|
51
|
-
attr_accessor :
|
52
|
-
|
51
|
+
attr_accessor :description
|
52
|
+
|
53
|
+
# hash of paths for maintainer/package scripts (postinstall, etc)
|
54
|
+
attr_accessor :scripts
|
55
|
+
|
53
56
|
def initialize(source)
|
54
57
|
@source = source
|
55
58
|
|
@@ -68,8 +71,9 @@ class FPM::Package
|
|
68
71
|
@license = source[:license] || "unknown"
|
69
72
|
@maintainer = source[:maintainer] || "<#{ENV["USER"]}@#{Socket.gethostname}>"
|
70
73
|
@architecture = source[:architecture] || %x{uname -m}.chomp
|
71
|
-
@
|
74
|
+
@description = source[:description] || "no description given"
|
72
75
|
@provides = source[:provides] || []
|
76
|
+
@scripts = source[:scripts]
|
73
77
|
end # def initialize
|
74
78
|
|
75
79
|
def generate_specfile(builddir, paths)
|
data/lib/fpm/source.rb
CHANGED
data/lib/fpm/source/gem.rb
CHANGED
@@ -91,13 +91,20 @@ class FPM::Source::Gem < FPM::Source
|
|
91
91
|
|
92
92
|
def make_tarball!(tar_path, builddir)
|
93
93
|
tmpdir = "#{tar_path}.dir"
|
94
|
-
|
94
|
+
gem = @paths.first
|
95
|
+
if self[:prefix]
|
96
|
+
installdir = "#{tmpdir}/#{self[:prefix]}"
|
97
|
+
# TODO(sissel): Overwriting @paths is bad mojo and confusing...
|
98
|
+
@paths = [ self[:prefix] ]
|
99
|
+
else
|
100
|
+
installdir = "#{tmpdir}/#{::Gem::dir}"
|
101
|
+
@paths = [ ::Gem::dir ]
|
102
|
+
end
|
95
103
|
::FileUtils.mkdir_p(installdir)
|
96
104
|
args = ["gem", "install", "--quiet", "--no-ri", "--no-rdoc",
|
97
|
-
"--install-dir", installdir, "--ignore-dependencies",
|
105
|
+
"--install-dir", installdir, "--ignore-dependencies", gem]
|
98
106
|
system(*args)
|
99
107
|
|
100
|
-
@paths = [ ::Gem::dir ]
|
101
108
|
tar(tar_path, ".#{@paths.first}", tmpdir)
|
102
109
|
FileUtils.rm_r(tmpdir)
|
103
110
|
|
data/lib/fpm/target/deb.rb
CHANGED
@@ -17,15 +17,34 @@ class FPM::Target::Deb < FPM::Package
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def build!(params)
|
20
|
+
control_files = [ "control", "md5sums" ]
|
21
|
+
# place the postinst prerm files
|
22
|
+
self.scripts.each do |name, path|
|
23
|
+
case name
|
24
|
+
when "pre-install"
|
25
|
+
system("cp #{path} ./preinst")
|
26
|
+
control_files << "preinst"
|
27
|
+
when "post-install"
|
28
|
+
system("cp #{path} ./postinst")
|
29
|
+
control_files << "postinst"
|
30
|
+
when "pre-uninstall"
|
31
|
+
system("cp #{path} ./prerm")
|
32
|
+
control_files << "prerm"
|
33
|
+
when "post-uninstall"
|
34
|
+
system("cp #{path} ./postrm")
|
35
|
+
control_files << "postrm"
|
36
|
+
else raise "Unsupported script name '#{name}' (path: #{path})"
|
37
|
+
end # case name
|
38
|
+
end # self.scripts.each
|
39
|
+
|
20
40
|
# Make the control
|
21
|
-
system("tar -zcf control.tar.gz
|
41
|
+
system("tar -zcf control.tar.gz #{control_files.join(" ")}")
|
22
42
|
|
23
43
|
# create debian-binary
|
24
44
|
File.open("debian-binary", "w") { |f| f.puts "2.0" }
|
25
45
|
|
26
46
|
# pack up the .deb
|
27
47
|
system("ar -qc #{params[:output]} debian-binary control.tar.gz data.tar.gz")
|
28
|
-
|
29
48
|
end # def build
|
30
49
|
|
31
50
|
def default_output
|
data/templates/deb.erb
CHANGED
@@ -37,5 +37,5 @@ Standards-Version: 3.9.1
|
|
37
37
|
Section: <%= category or "unknown" %>
|
38
38
|
Priority: extra
|
39
39
|
Homepage: <%= url or "http://nourlgiven.example.com/" %>
|
40
|
-
Description: <%=
|
41
|
-
<%=
|
40
|
+
Description: <%= description or "no description given" %>
|
41
|
+
<%= description or "no description given"%>
|
data/templates/rpm.erb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
Name: <%=
|
2
|
-
Version: <%=
|
3
|
-
<% if
|
4
|
-
Epoch: <%=
|
1
|
+
Name: <%= name %>
|
2
|
+
Version: <%= version %>
|
3
|
+
<% if epoch %>
|
4
|
+
Epoch: <%= epoch %>
|
5
5
|
<% end %>
|
6
|
-
Release: <%=
|
7
|
-
Summary: <%=
|
6
|
+
Release: <%= iteration or 1 %>
|
7
|
+
Summary: <%= description %>
|
8
8
|
BuildArch: <%= architecture %>
|
9
9
|
AutoReqProv: no
|
10
10
|
|
11
|
-
Group: <%=
|
11
|
+
Group: <%= category %>
|
12
12
|
<%#
|
13
13
|
TODO: [Jay] rpms require a license
|
14
14
|
let's detect it intelligently
|
15
15
|
%>
|
16
|
-
License: <%=
|
16
|
+
License: <%= license %>
|
17
17
|
Source0: %{_sourcedir}/data.tar.gz
|
18
18
|
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
19
19
|
|
@@ -39,7 +39,7 @@ Provides: <%= prov %>
|
|
39
39
|
<% end %>
|
40
40
|
|
41
41
|
%description
|
42
|
-
<%=
|
42
|
+
<%= description %>
|
43
43
|
|
44
44
|
%prep
|
45
45
|
echo "PREP"
|
@@ -55,6 +55,26 @@ tar -zvxf %SOURCE0
|
|
55
55
|
%clean
|
56
56
|
rm -rf $RPM_BUILD_ROOT
|
57
57
|
|
58
|
+
<% if scripts["pre-install"] %>
|
59
|
+
%pre
|
60
|
+
<%= File.read(scripts["pre-install"]) %>
|
61
|
+
<% end %>
|
62
|
+
|
63
|
+
<% if scripts["post-install"] %>
|
64
|
+
%post
|
65
|
+
<%= File.read(scripts["post-install"]) %>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<% if scripts["pre-uninstall"] %>
|
69
|
+
%preun
|
70
|
+
<%= File.read(scripts["pre-uninstall"]) %>
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
<% if scripts["post-uninstall"] %>
|
74
|
+
%postun
|
75
|
+
<%= File.read(scripts["post-uninstall"]) %>
|
76
|
+
<% end %>
|
77
|
+
|
58
78
|
%files
|
59
79
|
%defattr(-,root,root,-)
|
60
80
|
<%# Trim leading '.' from paths if they are './blah...' %>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 49
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 19
|
10
|
+
version: 0.2.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,16 +43,16 @@ extra_rdoc_files: []
|
|
43
43
|
|
44
44
|
files:
|
45
45
|
- lib/fpm/builder.rb
|
46
|
+
- lib/fpm/namespace.rb
|
46
47
|
- lib/fpm/source.rb
|
47
48
|
- lib/fpm/rubyfixes.rb
|
48
|
-
- lib/fpm/
|
49
|
-
- lib/fpm/target/rpm.rb
|
50
|
-
- lib/fpm/package.rb
|
51
|
-
- lib/fpm/namespace.rb
|
49
|
+
- lib/fpm/source/npm.rb
|
52
50
|
- lib/fpm/source/dir.rb
|
53
51
|
- lib/fpm/source/rpm.rb
|
54
|
-
- lib/fpm/source/npm.rb
|
55
52
|
- lib/fpm/source/gem.rb
|
53
|
+
- lib/fpm/target/deb.rb
|
54
|
+
- lib/fpm/target/rpm.rb
|
55
|
+
- lib/fpm/package.rb
|
56
56
|
- lib/fpm.rb
|
57
57
|
- bin/fpm
|
58
58
|
- bin/fpm-npm
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements: []
|
90
90
|
|
91
91
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
92
|
+
rubygems_version: 1.5.1
|
93
93
|
signing_key:
|
94
94
|
specification_version: 3
|
95
95
|
summary: fpm - package building and mangling
|