fpm 0.2.26 → 0.2.27
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELIST +18 -0
- data/CONTRIBUTORS +12 -0
- data/LICENSE +21 -0
- data/bin/fpm +5 -157
- data/lib/fpm/builder.rb +2 -0
- data/lib/fpm/package.rb +25 -1
- data/lib/fpm/program.rb +196 -0
- data/lib/fpm/source.rb +2 -0
- data/lib/fpm/source/pyfpm/get_metadata.pyc +0 -0
- data/lib/fpm/source/python.rb +20 -4
- data/lib/fpm/target/deb.rb +26 -0
- data/lib/fpm/target/rpm.rb +6 -0
- data/templates/deb.erb +7 -28
- metadata +9 -5
data/CHANGELIST
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
0.2.27 (May 18, 2011)
|
2
|
+
- If present, DEBEMAIL and DEBFULLNAME environment variables will be used as
|
3
|
+
the default maintainer. Previously the default was simply <$user@$hostname>
|
4
|
+
https://github.com/jordansissel/fpm/issues/37
|
5
|
+
- Add '--replaces' flag for specifying packages replaced by the one you are
|
6
|
+
building. This only functions in .deb packages now until I find a suitable
|
7
|
+
synonym in RPM.
|
8
|
+
- Add --python-bin and --python-easyinstall flags. This lets you choose specific
|
9
|
+
python and easy_install tools to use when building. Default is simply
|
10
|
+
'python' and 'easy_install' respectively.
|
11
|
+
- Add support for ~/.fpmrc - The format of this file is the same as the flags.
|
12
|
+
One flag per line. https://github.com/jordansissel/fpm/issues/38
|
13
|
+
Example:
|
14
|
+
--python-bin=/usr/bin/python2.7
|
15
|
+
--python-easyinstall=/usr/bin/easy_install2.7
|
16
|
+
|
17
|
+
0.2.26 and earlier
|
18
|
+
No changelist tracked. My bad, yo.
|
data/CONTRIBUTORS
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(This is an MIT-style license)
|
2
|
+
|
3
|
+
Copyright (c) 2011 Jordan Sissel and contributors.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/bin/fpm
CHANGED
@@ -2,162 +2,10 @@
|
|
2
2
|
#
|
3
3
|
|
4
4
|
require "rubygems"
|
5
|
-
|
6
|
-
require "ostruct"
|
7
|
-
require "erb"
|
8
|
-
|
9
|
-
$: << "#{File.dirname(__FILE__)}/../lib"
|
5
|
+
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
10
6
|
require "fpm"
|
11
|
-
require "fpm/
|
12
|
-
|
13
|
-
def main(args)
|
14
|
-
settings = OpenStruct.new
|
15
|
-
settings.exclude = []
|
16
|
-
|
17
|
-
# Source-specific settings/flags go here.
|
18
|
-
settings.source = {}
|
19
|
-
|
20
|
-
# Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
|
21
|
-
settings.scripts ||= {}
|
22
|
-
|
23
|
-
opts = OptionParser.new do |opts|
|
24
|
-
# TODO(sissel): Maybe this should be '-o OUTPUT' ?
|
25
|
-
opts.on("-p PACKAGEFILE", "--package PACKAGEFILE",
|
26
|
-
"The package file to manage") do |path|
|
27
|
-
if path =~ /^\//
|
28
|
-
settings.package_path = path
|
29
|
-
else
|
30
|
-
settings.package_path = "#{Dir.pwd}/#{path}"
|
31
|
-
end
|
32
|
-
end # --package
|
33
|
-
|
34
|
-
opts.on("-n PACKAGENAME", "--name PACKAGENAME",
|
35
|
-
"What name to give to the package") do |name|
|
36
|
-
settings.package_name = name
|
37
|
-
end # --name
|
38
|
-
|
39
|
-
opts.on("-v VERSION", "--version VERSION",
|
40
|
-
"version to give the package") do |version|
|
41
|
-
settings.version = version
|
42
|
-
end # --version
|
43
|
-
|
44
|
-
opts.on("--epoch EPOCH",
|
45
|
-
"(optional) Set epoch value for this package.") do |epoch|
|
46
|
-
settings.epoch = epoch
|
47
|
-
end # --epoch
|
48
|
-
|
49
|
-
opts.on("-d DEPENDENCY", "--depends DEPENDENCY") do |dep|
|
50
|
-
settings.dependencies ||= []
|
51
|
-
settings.dependencies << dep
|
52
|
-
end # --depends
|
53
|
-
|
54
|
-
opts.on("--provides PROVIDES") do |thing|
|
55
|
-
settings.provides ||= []
|
56
|
-
settings.provides << thing
|
57
|
-
end # --depends
|
58
|
-
|
59
|
-
opts.on("-a ARCHITECTURE", "--architecture ARCHITECTURE") do |arch|
|
60
|
-
settings.architecture = arch
|
61
|
-
end # --architecture
|
62
|
-
|
63
|
-
opts.on("-m MAINTAINER", "--maintainer MAINTAINER") do |maintainer|
|
64
|
-
settings.maintainer = maintainer
|
65
|
-
end # --maintainer
|
66
|
-
|
67
|
-
opts.on("-C DIRECTORY", "Change directory before searching for files") do |dir|
|
68
|
-
settings.chdir = dir
|
69
|
-
end # -C
|
70
|
-
|
71
|
-
opts.on("-t PACKAGE_TYPE", "the type of package you want to create") do |type|
|
72
|
-
settings.package_type = type
|
73
|
-
end # -t
|
74
|
-
|
75
|
-
opts.on("-s SOURCE_TYPE", "what to build the package from") do |st|
|
76
|
-
settings.source_type = st
|
77
|
-
end # -s
|
78
|
-
|
79
|
-
opts.on("-S PACKAGE_SUFFIX", "which suffix to append to package and dependencies") do |sfx|
|
80
|
-
settings.suffix = sfx
|
81
|
-
end # -S
|
82
|
-
|
83
|
-
opts.on("--prefix PREFIX",
|
84
|
-
"A path to prefix files with when building the target package. This may not be necessary for all source types. For example, the 'gem' type will prefix with your gem directory (gem env | grep -A1 PATHS:)") do |prefix|
|
85
|
-
settings.prefix = prefix
|
86
|
-
end # --prefix
|
87
|
-
|
88
|
-
opts.on("-e", "--edit", "Edit the specfile before building") do
|
89
|
-
settings.edit = true
|
90
|
-
end # --edit
|
91
|
-
|
92
|
-
opts.on("-x PATTERN", "--exclude PATTERN",
|
93
|
-
"Exclude paths matching pattern (according to tar --exclude)") do |pattern|
|
94
|
-
settings.exclude << pattern
|
95
|
-
end # -x / --exclude
|
96
|
-
|
97
|
-
opts.on("--post-install SCRIPTPATH",
|
98
|
-
"Add a post-install action. This script will be included in the" \
|
99
|
-
" resulting package") do |path|
|
100
|
-
settings.scripts["post-install"] = File.expand_path(path)
|
101
|
-
end # --post-install
|
102
|
-
|
103
|
-
opts.on("--pre-install SCRIPTPATH",
|
104
|
-
"Add a pre-install action. This script will be included in the" \
|
105
|
-
" resulting package") do |path|
|
106
|
-
settings.scripts["pre-install"] = File.expand_path(path)
|
107
|
-
end # --pre-install
|
108
|
-
|
109
|
-
opts.on("--pre-uninstall SCRIPTPATH",
|
110
|
-
"Add a pre-uninstall action. This script will be included in the" \
|
111
|
-
" resulting package") do |path|
|
112
|
-
settings.scripts["pre-uninstall"] = File.expand_path(path)
|
113
|
-
end # --pre-uninstall
|
114
|
-
|
115
|
-
opts.on("--post-uninstall SCRIPTPATH",
|
116
|
-
"Add a post-uninstall action. This script will be included in the" \
|
117
|
-
" resulting package") do |path|
|
118
|
-
settings.scripts["post-uninstall"] = File.expand_path(path)
|
119
|
-
end # --post-uninstall
|
120
|
-
|
121
|
-
opts.on("--description DESCRIPTION",
|
122
|
-
"Add a description for this package.") do |description|
|
123
|
-
settings.description = description
|
124
|
-
end # --description
|
125
|
-
|
126
|
-
opts.on("--url URL",
|
127
|
-
"Add a url for this package.") do |url|
|
128
|
-
settings.url = url
|
129
|
-
end # --url
|
130
|
-
end # OptionParser
|
131
|
-
|
132
|
-
# Add extra flags.
|
133
|
-
FPM::Source::Gem.flags(FPM::Flags.new(opts, "gem", "gem source only"), settings)
|
134
|
-
|
135
|
-
opts.parse!(args)
|
136
|
-
|
137
|
-
ok = true
|
138
|
-
if settings.package_type.nil?
|
139
|
-
$stderr.puts "Missing package target type (no -t flag?)"
|
140
|
-
ok = false
|
141
|
-
end
|
142
|
-
|
143
|
-
if settings.source_type.nil?
|
144
|
-
$stderr.puts "Missing package source type (no -s flag?)"
|
145
|
-
ok = false
|
146
|
-
end
|
147
|
-
|
148
|
-
if !ok
|
149
|
-
$stderr.puts "There were errors; see above."
|
150
|
-
$stderr.puts
|
151
|
-
$stderr.puts opts.help
|
152
|
-
return 1
|
153
|
-
end
|
154
|
-
|
155
|
-
builder = FPM::Builder.new(settings, args)
|
156
|
-
builder.assemble!
|
157
|
-
puts "Created #{builder.output}"
|
158
|
-
|
159
|
-
return 0
|
160
|
-
end # def main
|
7
|
+
require "fpm/program"
|
161
8
|
|
162
|
-
|
163
|
-
|
9
|
+
program = FPM::Program.new
|
10
|
+
ret = program.run(ARGV)
|
11
|
+
exit(ret.nil? ? 0 : ret)
|
data/lib/fpm/builder.rb
CHANGED
@@ -40,6 +40,7 @@ class FPM::Builder
|
|
40
40
|
:exclude => settings.exclude,
|
41
41
|
:maintainer => settings.maintainer,
|
42
42
|
:provides => [],
|
43
|
+
:replaces => [],
|
43
44
|
:description => settings.description,
|
44
45
|
:url => settings.url,
|
45
46
|
:settings => settings.source
|
@@ -53,6 +54,7 @@ class FPM::Builder
|
|
53
54
|
@package.dependencies += settings.dependencies if settings.dependencies
|
54
55
|
# Append provides given from settings (--provides flag for fpm)
|
55
56
|
@package.provides += settings.provides if settings.provides
|
57
|
+
@package.replaces += settings.replaces if settings.replaces
|
56
58
|
@package.architecture = settings.architecture if settings.architecture
|
57
59
|
@package.scripts = settings.scripts
|
58
60
|
|
data/lib/fpm/package.rb
CHANGED
@@ -48,6 +48,10 @@ class FPM::Package
|
|
48
48
|
# (Not all packages support this)
|
49
49
|
attr_accessor :provides
|
50
50
|
|
51
|
+
# Array of things this package replaces.
|
52
|
+
# (Not all packages support this)
|
53
|
+
attr_accessor :replaces
|
54
|
+
|
51
55
|
# a summary or description of the package
|
52
56
|
attr_accessor :description
|
53
57
|
|
@@ -71,7 +75,26 @@ class FPM::Package
|
|
71
75
|
@url = source[:url] || "http://nourlgiven.example.com/no/url/given"
|
72
76
|
@category = source[:category] || "default"
|
73
77
|
@license = source[:license] || "unknown"
|
74
|
-
|
78
|
+
#@maintainer = source[:maintainer] || "<#{ENV["USER"]}@#{Socket.gethostname}>"
|
79
|
+
@maintainer = source[:maintainer]
|
80
|
+
|
81
|
+
# Default maintainer if none given.
|
82
|
+
if @maintainer.nil? or @maintainer.empty?
|
83
|
+
# Reference
|
84
|
+
# http://www.debian.org/doc/manuals/maint-guide/first.en.html
|
85
|
+
# http://wiki.debian.org/DeveloperConfiguration
|
86
|
+
# https://github.com/jordansissel/fpm/issues/37
|
87
|
+
if ENV.include?("DEBEMAIL") and ENV.include?("DEBFULLNAME")
|
88
|
+
# Use DEBEMAIL and DEBFULLNAME as the default maintainer if available.
|
89
|
+
@maintainer = "#{ENV["DEBFULLNAME"]} <#{ENV["DEBEMAIL"]}>"
|
90
|
+
else
|
91
|
+
# TODO(sissel): Maybe support using 'git config' for a default as well?
|
92
|
+
# git config --get user.name, etc can be useful.
|
93
|
+
#
|
94
|
+
# Otherwise default to user@currenthost
|
95
|
+
@maintainer = "<#{ENV["USER"]}@#{Socket.gethostname}>"
|
96
|
+
end
|
97
|
+
end
|
75
98
|
|
76
99
|
# If @architecture is nil, the target package should provide a default.
|
77
100
|
# Special 'architecture' values include "all" (aka rpm's noarch, debian's all)
|
@@ -79,6 +102,7 @@ class FPM::Package
|
|
79
102
|
@architecture = source[:architecture]
|
80
103
|
@description = source[:description] || "no description given"
|
81
104
|
@provides = source[:provides] || []
|
105
|
+
@replaces = source[:replaces] || []
|
82
106
|
@scripts = source[:scripts]
|
83
107
|
end # def initialize
|
84
108
|
|
data/lib/fpm/program.rb
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "erb" # TODO(sissel): Move to the class that needs it.
|
3
|
+
require "fpm/namespace"
|
4
|
+
require "optparse"
|
5
|
+
require "ostruct"
|
6
|
+
|
7
|
+
require "fpm"
|
8
|
+
require "fpm/flags"
|
9
|
+
|
10
|
+
class FPM::Program
|
11
|
+
def initialize
|
12
|
+
@settings = OpenStruct.new
|
13
|
+
@settings.dependencies = []
|
14
|
+
@settings.exclude = [] # Paths to exclude in packaging
|
15
|
+
@settings.provides = []
|
16
|
+
@settings.replaces = []
|
17
|
+
@settings.source = {} # source settings
|
18
|
+
|
19
|
+
# Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
|
20
|
+
@settings.scripts ||= {}
|
21
|
+
end # def initialize
|
22
|
+
|
23
|
+
def run(args)
|
24
|
+
$: << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
25
|
+
paths = options(args)
|
26
|
+
|
27
|
+
ok = true
|
28
|
+
if @settings.package_type.nil?
|
29
|
+
$stderr.puts "Missing package target type (no -t flag?)"
|
30
|
+
ok = false
|
31
|
+
end
|
32
|
+
|
33
|
+
if @settings.source_type.nil?
|
34
|
+
$stderr.puts "Missing package source type (no -s flag?)"
|
35
|
+
ok = false
|
36
|
+
end
|
37
|
+
|
38
|
+
if !ok
|
39
|
+
$stderr.puts "There were errors; see above."
|
40
|
+
$stderr.puts
|
41
|
+
$stderr.puts opts.help
|
42
|
+
return 1
|
43
|
+
end
|
44
|
+
|
45
|
+
builder = FPM::Builder.new(@settings, paths)
|
46
|
+
builder.assemble!
|
47
|
+
puts "Created #{builder.output}"
|
48
|
+
return 0
|
49
|
+
end # def run
|
50
|
+
|
51
|
+
def options(args)
|
52
|
+
opts = OptionParser.new
|
53
|
+
default_options(opts)
|
54
|
+
|
55
|
+
# Add extra flags from plugins
|
56
|
+
FPM::Source::Gem.flags(FPM::Flags.new(opts, "gem", "gem source only"), @settings)
|
57
|
+
FPM::Source::Python.flags(FPM::Flags.new(opts, "python", "python source only"),
|
58
|
+
@settings)
|
59
|
+
|
60
|
+
# Process fpmrc first
|
61
|
+
fpmrc(opts)
|
62
|
+
|
63
|
+
# Proces normal flags now.
|
64
|
+
remaining = opts.parse(args)
|
65
|
+
return remaining
|
66
|
+
end # def options
|
67
|
+
|
68
|
+
def fpmrc(options)
|
69
|
+
# Skip if we have no HOME environment variable.
|
70
|
+
return if !ENV.include?("HOME")
|
71
|
+
rcpath = File.expand_path("~/.fpmrc")
|
72
|
+
return if !File.exists?(rcpath)
|
73
|
+
|
74
|
+
# fpmrc exists, read it as flags, one per line.
|
75
|
+
File.new(rcpath, "r").each do |line|
|
76
|
+
flag = line.chomp
|
77
|
+
begin
|
78
|
+
options.parse([flag])
|
79
|
+
rescue => e
|
80
|
+
$stderr.puts "Error parsing fpmrc (#{rcpath})"
|
81
|
+
raise e
|
82
|
+
end # begin
|
83
|
+
end # File.new
|
84
|
+
end # def fpmrc
|
85
|
+
|
86
|
+
def default_options(opts)
|
87
|
+
# TODO(sissel): Maybe this should be '-o OUTPUT' ?
|
88
|
+
opts.on("-p PACKAGEFILE", "--package PACKAGEFILE",
|
89
|
+
"The package file to manage") do |path|
|
90
|
+
if path =~ /^\//
|
91
|
+
@settings.package_path = path
|
92
|
+
else
|
93
|
+
@settings.package_path = "#{Dir.pwd}/#{path}"
|
94
|
+
end
|
95
|
+
end # --package
|
96
|
+
|
97
|
+
opts.on("-n PACKAGENAME", "--name PACKAGENAME",
|
98
|
+
"What name to give to the package") do |name|
|
99
|
+
@settings.package_name = name
|
100
|
+
end # --name
|
101
|
+
|
102
|
+
opts.on("-v VERSION", "--version VERSION",
|
103
|
+
"version to give the package") do |version|
|
104
|
+
@settings.version = version
|
105
|
+
end # --version
|
106
|
+
|
107
|
+
opts.on("--epoch EPOCH",
|
108
|
+
"(optional) Set epoch value for this package.") do |epoch|
|
109
|
+
@settings.epoch = epoch
|
110
|
+
end # --epoch
|
111
|
+
|
112
|
+
opts.on("-d DEPENDENCY", "--depends DEPENDENCY") do |dep|
|
113
|
+
@settings.dependencies << dep
|
114
|
+
end # --depends
|
115
|
+
|
116
|
+
opts.on("--provides PROVIDES") do |thing|
|
117
|
+
@settings.provides << thing
|
118
|
+
end # --provides
|
119
|
+
|
120
|
+
opts.on("--replaces REPLACES") do |thing|
|
121
|
+
@settings.replaces << thing
|
122
|
+
end # --replaces
|
123
|
+
|
124
|
+
opts.on("-a ARCHITECTURE", "--architecture ARCHITECTURE") do |arch|
|
125
|
+
@settings.architecture = arch
|
126
|
+
end # --architecture
|
127
|
+
|
128
|
+
opts.on("-m MAINTAINER", "--maintainer MAINTAINER") do |maintainer|
|
129
|
+
@settings.maintainer = maintainer
|
130
|
+
end # --maintainer
|
131
|
+
|
132
|
+
opts.on("-C DIRECTORY", "Change directory before searching for files") do |dir|
|
133
|
+
@settings.chdir = dir
|
134
|
+
end # -C
|
135
|
+
|
136
|
+
opts.on("-t PACKAGE_TYPE", "the type of package you want to create") do |type|
|
137
|
+
@settings.package_type = type
|
138
|
+
end # -t
|
139
|
+
|
140
|
+
opts.on("-s SOURCE_TYPE", "what to build the package from") do |st|
|
141
|
+
@settings.source_type = st
|
142
|
+
end # -s
|
143
|
+
|
144
|
+
opts.on("-S PACKAGE_SUFFIX", "which suffix to append to package and dependencies") do |sfx|
|
145
|
+
@settings.suffix = sfx
|
146
|
+
end # -S
|
147
|
+
|
148
|
+
opts.on("--prefix PREFIX",
|
149
|
+
"A path to prefix files with when building the target package. This may not be necessary for all source types. For example, the 'gem' type will prefix with your gem directory (gem env | grep -A1 PATHS:)") do |prefix|
|
150
|
+
@settings.prefix = prefix
|
151
|
+
end # --prefix
|
152
|
+
|
153
|
+
opts.on("-e", "--edit", "Edit the specfile before building") do
|
154
|
+
@settings.edit = true
|
155
|
+
end # --edit
|
156
|
+
|
157
|
+
opts.on("-x PATTERN", "--exclude PATTERN",
|
158
|
+
"Exclude paths matching pattern (according to tar --exclude)") do |pattern|
|
159
|
+
@settings.exclude << pattern
|
160
|
+
end # -x / --exclude
|
161
|
+
|
162
|
+
opts.on("--post-install SCRIPTPATH",
|
163
|
+
"Add a post-install action. This script will be included in the" \
|
164
|
+
" resulting package") do |path|
|
165
|
+
@settings.scripts["post-install"] = File.expand_path(path)
|
166
|
+
end # --post-install
|
167
|
+
|
168
|
+
opts.on("--pre-install SCRIPTPATH",
|
169
|
+
"Add a pre-install action. This script will be included in the" \
|
170
|
+
" resulting package") do |path|
|
171
|
+
@settings.scripts["pre-install"] = File.expand_path(path)
|
172
|
+
end # --pre-install
|
173
|
+
|
174
|
+
opts.on("--pre-uninstall SCRIPTPATH",
|
175
|
+
"Add a pre-uninstall action. This script will be included in the" \
|
176
|
+
" resulting package") do |path|
|
177
|
+
@settings.scripts["pre-uninstall"] = File.expand_path(path)
|
178
|
+
end # --pre-uninstall
|
179
|
+
|
180
|
+
opts.on("--post-uninstall SCRIPTPATH",
|
181
|
+
"Add a post-uninstall action. This script will be included in the" \
|
182
|
+
" resulting package") do |path|
|
183
|
+
@settings.scripts["post-uninstall"] = File.expand_path(path)
|
184
|
+
end # --post-uninstall
|
185
|
+
|
186
|
+
opts.on("--description DESCRIPTION",
|
187
|
+
"Add a description for this package.") do |description|
|
188
|
+
@settings.description = description
|
189
|
+
end # --description
|
190
|
+
|
191
|
+
opts.on("--url URL",
|
192
|
+
"Add a url for this package.") do |url|
|
193
|
+
@settings.url = url
|
194
|
+
end # --url
|
195
|
+
end # def default_options
|
196
|
+
end # class FPM::Program
|
data/lib/fpm/source.rb
CHANGED
Binary file
|
data/lib/fpm/source/python.rb
CHANGED
@@ -7,6 +7,21 @@ require "tmpdir"
|
|
7
7
|
require "json"
|
8
8
|
|
9
9
|
class FPM::Source::Python < FPM::Source
|
10
|
+
def self.flags(opts, settings)
|
11
|
+
settings.source[:python] = "python"
|
12
|
+
settings.source[:easy_install] = "easy_install"
|
13
|
+
|
14
|
+
opts.on("--bin PYTHON_BINARY_LOCATION",
|
15
|
+
"The path to the python you want to run. Default is 'python'") do |path|
|
16
|
+
settings.source[:python] = path
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("--easyinstall EASY_INSTALL_PATH",
|
20
|
+
"The path to your easy_install tool. Default is 'easy_install'") do |path|
|
21
|
+
settings.source[:easy_install] = path
|
22
|
+
end
|
23
|
+
end # def flags
|
24
|
+
|
10
25
|
def get_source(params)
|
11
26
|
package = @paths.first
|
12
27
|
if ["setup.py", "."].include?(package)
|
@@ -23,7 +38,7 @@ class FPM::Source::Python < FPM::Source
|
|
23
38
|
end # def get_source
|
24
39
|
|
25
40
|
def download(package, version=nil)
|
26
|
-
puts "Trying to download #{package} (using easy_install)"
|
41
|
+
puts "Trying to download #{package} (using: #{self[:settings][:easy_install]})"
|
27
42
|
@tmpdir = ::Dir.mktmpdir("python-build", ::Dir.pwd)
|
28
43
|
|
29
44
|
if version.nil?
|
@@ -31,7 +46,8 @@ class FPM::Source::Python < FPM::Source
|
|
31
46
|
else
|
32
47
|
want_pkg = "#{package}==#{version}"
|
33
48
|
end
|
34
|
-
|
49
|
+
|
50
|
+
system(self[:settings][:easy_install], "--editable", "--build-directory", @tmpdir, want_pkg)
|
35
51
|
|
36
52
|
# easy_install will put stuff in @tmpdir/packagename/, flatten that.
|
37
53
|
# That is, we want @tmpdir/setup.py, and start with
|
@@ -55,7 +71,7 @@ class FPM::Source::Python < FPM::Source
|
|
55
71
|
end
|
56
72
|
|
57
73
|
pylib = File.expand_path(File.dirname(__FILE__))
|
58
|
-
setup_cmd = "env PYTHONPATH=#{pylib} python #{setup_py} --command-packages=pyfpm get_metadata"
|
74
|
+
setup_cmd = "env PYTHONPATH=#{pylib} #{self[:settings][:python]} #{setup_py} --command-packages=pyfpm get_metadata"
|
59
75
|
output = ::Dir.chdir(File.dirname(setup_py)) { `#{setup_cmd}` }
|
60
76
|
puts output
|
61
77
|
metadata = JSON.parse(output[/\{.*\}/msx])
|
@@ -81,7 +97,7 @@ class FPM::Source::Python < FPM::Source
|
|
81
97
|
# Some setup.py's assume $PWD == current directory of setup.py, so let's
|
82
98
|
# chdir first.
|
83
99
|
::Dir.chdir(dir) do
|
84
|
-
system(
|
100
|
+
system(self[:settings][:python], "setup.py", "bdist")
|
85
101
|
end
|
86
102
|
|
87
103
|
dist_tar = ::Dir.glob(File.join(dir, "dist", "*.tar.gz")).first
|
data/lib/fpm/target/deb.rb
CHANGED
@@ -67,5 +67,31 @@ class FPM::Target::Deb < FPM::Package
|
|
67
67
|
"#{name}_#{v}_#{architecture}.#{type}"
|
68
68
|
end
|
69
69
|
end # def default_output
|
70
|
+
|
71
|
+
def fix_dependency(dep)
|
72
|
+
# Convert strings 'foo >= bar' to 'foo (>= bar)'
|
73
|
+
if dep =~ /\(/
|
74
|
+
# nothing
|
75
|
+
else
|
76
|
+
# If the dependency is simply a name, turn it into 'name (>= 0)'
|
77
|
+
da = dep.split(/ +/)
|
78
|
+
if da.size == 1
|
79
|
+
da += [">=", "0"]
|
80
|
+
end
|
81
|
+
dep = "#{da[0]} (#{da[1]} #{da[2]})"
|
82
|
+
end
|
83
|
+
|
84
|
+
# Convert gem ~> X.Y.Z to '>= X.Y.Z' and << X.Y+1.0
|
85
|
+
if dep =~ /\(~>/
|
86
|
+
name, version = dep.gsub(/[()~>]/, "").split(/ +/)[0..1]
|
87
|
+
nextversion = version.split(".").collect { |v| v.to_i }
|
88
|
+
nextversion[1] += 1
|
89
|
+
nextversion[2] = 0
|
90
|
+
nextversion = nextversion.join(".")
|
91
|
+
return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
|
92
|
+
else
|
93
|
+
return dep
|
94
|
+
end
|
95
|
+
end # def fix_dependency
|
70
96
|
end # class FPM::Deb
|
71
97
|
|
data/lib/fpm/target/rpm.rb
CHANGED
@@ -23,6 +23,12 @@ class FPM::Target::Rpm < FPM::Package
|
|
23
23
|
raise "No package name given. Can't assemble package" if !@name
|
24
24
|
# TODO(sissel): Abort if 'rpmbuild' tool not found.
|
25
25
|
|
26
|
+
if !replaces.empty?
|
27
|
+
$stderr.puts "Warning: RPM does not support 'replaces'"
|
28
|
+
$stderr.puts "If you have suggstions as to what --replaces means to RPM"
|
29
|
+
$stderr.puts "Please let me know: https://github.com/jordansissel/fpm/issues"
|
30
|
+
end
|
31
|
+
|
26
32
|
%w(BUILD RPMS SRPMS SOURCES SPECS).each { |d| Dir.mkdir(d) }
|
27
33
|
args = ["rpmbuild", "-ba",
|
28
34
|
"--define", "buildroot #{Dir.pwd}/BUILD",
|
data/templates/deb.erb
CHANGED
@@ -2,38 +2,17 @@ Package: <%= name %>
|
|
2
2
|
Version: <%= "#{epoch}:" if epoch %><%= version %><%= iteration && '-'+iteration.to_s %>
|
3
3
|
Architecture: <%= architecture %>
|
4
4
|
Maintainer: <%= maintainer or "<unknown>" %>
|
5
|
-
<% if dependencies.
|
6
|
-
<%
|
7
|
-
|
8
|
-
# Convert strings 'foo >= bar' to 'foo (>= bar)'
|
9
|
-
if dep =~ /\(/
|
10
|
-
# nothing
|
11
|
-
else
|
12
|
-
# If the dependency is simply a name, turn it into 'name (>= 0)'
|
13
|
-
da = dep.split(/ +/)
|
14
|
-
if da.size == 1
|
15
|
-
da += [">=", "0"]
|
16
|
-
end
|
17
|
-
dep = "#{da[0]} (#{da[1]} #{da[2]})"
|
18
|
-
end
|
19
|
-
|
20
|
-
# Convert gem ~> X.Y.Z to '>= X.Y.Z' and << X.Y+1.0
|
21
|
-
if dep =~ /\(~>/
|
22
|
-
name, version = dep.gsub(/[()~>]/, "").split(/ +/)[0..1]
|
23
|
-
nextversion = version.split(".").collect { |v| v.to_i }
|
24
|
-
nextversion[1] += 1
|
25
|
-
nextversion[2] = 0
|
26
|
-
nextversion = nextversion.join(".")
|
27
|
-
["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
|
28
|
-
else
|
29
|
-
dep
|
30
|
-
end
|
31
|
-
end
|
32
|
-
%>Depends: <%= properdeps.flatten.join(", ") %>
|
5
|
+
<% if !dependencies.empty? %>
|
6
|
+
<% properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten %>
|
7
|
+
Depends: <%= properdeps.flatten.join(", ") %>
|
33
8
|
<% end %>
|
34
9
|
<% if !provides.empty? %>
|
35
10
|
Provides: <%= provides.join(", ") %>
|
36
11
|
<% end %>
|
12
|
+
<% if !replaces.empty? %>
|
13
|
+
<% properrepl = replaces.collect { |d| fix_dependency(d) }.flatten %>
|
14
|
+
Replaces: <%= properrepl.flatten.join(", ") %>
|
15
|
+
<% end %>
|
37
16
|
Standards-Version: 3.9.1
|
38
17
|
Section: <%= category or "unknown" %>
|
39
18
|
Priority: extra
|
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:
|
4
|
+
hash: 33
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 27
|
10
|
+
version: 0.2.27
|
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-05-
|
18
|
+
date: 2011-05-18 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -63,12 +63,16 @@ files:
|
|
63
63
|
- lib/fpm/source/gem.rb
|
64
64
|
- lib/fpm/target/deb.rb
|
65
65
|
- lib/fpm/target/rpm.rb
|
66
|
+
- lib/fpm/program.rb
|
66
67
|
- lib/fpm/package.rb
|
67
68
|
- lib/fpm.rb
|
68
69
|
- bin/fpm
|
69
70
|
- bin/fpm-npm
|
70
71
|
- templates/rpm.erb
|
71
72
|
- templates/deb.erb
|
73
|
+
- LICENSE
|
74
|
+
- CONTRIBUTORS
|
75
|
+
- CHANGELIST
|
72
76
|
has_rdoc: true
|
73
77
|
homepage: https://github.com/jordansissel/fpm
|
74
78
|
licenses: []
|
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
104
|
requirements: []
|
101
105
|
|
102
106
|
rubyforge_project:
|
103
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.6.0
|
104
108
|
signing_key:
|
105
109
|
specification_version: 3
|
106
110
|
summary: fpm - package building and mangling
|