cure-fpm 1.3.3b → 1.6.0b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELIST +73 -0
- data/CONTRIBUTORS +1 -1
- data/LICENSE +1 -1
- data/lib/fpm.rb +2 -0
- data/lib/fpm/command.rb +100 -50
- data/lib/fpm/package.rb +42 -28
- data/lib/fpm/package/apk.rb +510 -0
- data/lib/fpm/package/cpan.rb +50 -25
- data/lib/fpm/package/deb.rb +211 -47
- data/lib/fpm/package/dir.rb +29 -28
- data/lib/fpm/package/empty.rb +6 -0
- data/lib/fpm/package/freebsd.rb +144 -0
- data/lib/fpm/package/gem.rb +5 -5
- data/lib/fpm/package/npm.rb +2 -2
- data/lib/fpm/package/osxpkg.rb +8 -7
- data/lib/fpm/package/p5p.rb +124 -0
- data/lib/fpm/package/pacman.rb +399 -0
- data/lib/fpm/package/pleaserun.rb +63 -0
- data/lib/fpm/package/pyfpm/get_metadata.py +9 -1
- data/lib/fpm/package/python.rb +19 -7
- data/lib/fpm/package/rpm.rb +58 -18
- data/lib/fpm/package/sh.rb +1 -7
- data/lib/fpm/package/solaris.rb +1 -1
- data/lib/fpm/package/tar.rb +14 -2
- data/lib/fpm/package/virtualenv.rb +145 -0
- data/lib/fpm/package/zip.rb +1 -1
- data/lib/fpm/rake_task.rb +60 -0
- data/lib/fpm/util.rb +176 -48
- data/lib/fpm/util/tar_writer.rb +80 -0
- data/lib/fpm/version.rb +1 -1
- data/templates/deb/postinst_upgrade.sh.erb +33 -2
- data/templates/deb/postrm_upgrade.sh.erb +10 -1
- data/templates/deb/preinst_upgrade.sh.erb +11 -2
- data/templates/deb/prerm_upgrade.sh.erb +14 -2
- data/templates/p5p_metadata.erb +12 -0
- data/templates/pacman.erb +47 -0
- data/templates/pacman/INSTALL.erb +41 -0
- data/templates/pleaserun/generate-cleanup.sh +17 -0
- data/templates/pleaserun/install-path.sh +17 -0
- data/templates/pleaserun/install.sh +117 -0
- data/templates/pleaserun/scripts/after-install.sh +4 -0
- data/templates/pleaserun/scripts/before-remove.sh +12 -0
- data/templates/rpm.erb +38 -6
- data/templates/sh.erb +38 -3
- metadata +81 -9
@@ -90,7 +90,15 @@ class get_metadata(Command):
|
|
90
90
|
|
91
91
|
output = open(self.output, "w")
|
92
92
|
if hasattr(json, 'dumps'):
|
93
|
-
|
93
|
+
def default_to_str(obj):
|
94
|
+
""" Fall back to using __str__ if possible """
|
95
|
+
# This checks if the class of obj defines __str__ itself,
|
96
|
+
# so we don't fall back to an inherited __str__ method.
|
97
|
+
if "__str__" in type(obj).__dict__:
|
98
|
+
return str(obj)
|
99
|
+
return json.JSONEncoder.default(self, obj)
|
100
|
+
|
101
|
+
output.write(json.dumps(data, indent=2, default=default_to_str))
|
94
102
|
else:
|
95
103
|
# For Python 2.5 and Debian's python-json
|
96
104
|
output.write(json.write(data))
|
data/lib/fpm/package/python.rb
CHANGED
@@ -7,7 +7,7 @@ require "fileutils"
|
|
7
7
|
require "tmpdir"
|
8
8
|
require "json"
|
9
9
|
|
10
|
-
# Support for python packages.
|
10
|
+
# Support for python packages.
|
11
11
|
#
|
12
12
|
# This supports input, but not output.
|
13
13
|
#
|
@@ -28,7 +28,7 @@ class FPM::Package::Python < FPM::Package
|
|
28
28
|
"is used instead", :default => nil
|
29
29
|
option "--pypi", "PYPI_URL",
|
30
30
|
"PyPi Server uri for retrieving packages.",
|
31
|
-
:default => "
|
31
|
+
:default => "https://pypi.python.org/simple"
|
32
32
|
option "--package-prefix", "NAMEPREFIX",
|
33
33
|
"(DEPRECATED, use --package-name-prefix) Name to prefix the package " \
|
34
34
|
"name with." do |value|
|
@@ -73,6 +73,10 @@ class FPM::Package::Python < FPM::Package
|
|
73
73
|
"The python package name to remove from dependency list",
|
74
74
|
:multivalued => true, :attribute_name => :python_disable_dependency,
|
75
75
|
:default => []
|
76
|
+
option "--setup-py-arguments", "setup_py_argument",
|
77
|
+
"Arbitrary argument(s) to be passed to setup.py",
|
78
|
+
:multivalued => true, :attribute_name => :python_setup_py_arguments,
|
79
|
+
:default => []
|
76
80
|
|
77
81
|
private
|
78
82
|
|
@@ -92,7 +96,7 @@ class FPM::Package::Python < FPM::Package
|
|
92
96
|
setup_py = path_to_package
|
93
97
|
end
|
94
98
|
|
95
|
-
if !File.
|
99
|
+
if !File.exist?(setup_py)
|
96
100
|
logger.error("Could not find 'setup.py'", :path => setup_py)
|
97
101
|
raise "Unable to find python package; tried #{setup_py}"
|
98
102
|
end
|
@@ -108,7 +112,7 @@ class FPM::Package::Python < FPM::Package
|
|
108
112
|
# part should go elsewhere.
|
109
113
|
path = package
|
110
114
|
# If it's a path, assume local build.
|
111
|
-
if File.directory?(path) or (File.
|
115
|
+
if File.directory?(path) or (File.exist?(path) and File.basename(path) == "setup.py")
|
112
116
|
return path
|
113
117
|
end
|
114
118
|
|
@@ -131,7 +135,8 @@ class FPM::Package::Python < FPM::Package
|
|
131
135
|
"--build-directory", target, want_pkg)
|
132
136
|
else
|
133
137
|
logger.debug("using pip", :pip => attributes[:python_pip])
|
134
|
-
|
138
|
+
# TODO: Support older versions of pip
|
139
|
+
safesystem(attributes[:python_pip], "download", "--no-clean", "--no-deps", "--no-binary", ":all:", "-i", attributes[:python_pypi], "--build", target, want_pkg)
|
135
140
|
end
|
136
141
|
|
137
142
|
# easy_install will put stuff in @tmpdir/packagename/, so find that:
|
@@ -149,7 +154,7 @@ class FPM::Package::Python < FPM::Package
|
|
149
154
|
attributes[:python_package_name_prefix] = attributes[:python_package_prefix]
|
150
155
|
end
|
151
156
|
|
152
|
-
begin
|
157
|
+
begin
|
153
158
|
json_test_code = [
|
154
159
|
"try:",
|
155
160
|
" import json",
|
@@ -274,7 +279,7 @@ class FPM::Package::Python < FPM::Package
|
|
274
279
|
|
275
280
|
prefix = "/"
|
276
281
|
prefix = attributes[:prefix] unless attributes[:prefix].nil?
|
277
|
-
|
282
|
+
|
278
283
|
# Some setup.py's assume $PWD == current directory of setup.py, so let's
|
279
284
|
# chdir first.
|
280
285
|
::Dir.chdir(project_dir) do
|
@@ -309,6 +314,13 @@ class FPM::Package::Python < FPM::Package
|
|
309
314
|
flags += [ "build_scripts", "--executable", attributes[:python_scripts_executable] ]
|
310
315
|
end
|
311
316
|
|
317
|
+
if !attributes[:python_setup_py_arguments].nil? and !attributes[:python_setup_py_arguments].empty?
|
318
|
+
# Add optional setup.py arguments
|
319
|
+
attributes[:python_setup_py_arguments].each do |a|
|
320
|
+
flags += [ a ]
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
312
324
|
safesystem(attributes[:python_bin], "setup.py", "install", *flags)
|
313
325
|
end
|
314
326
|
end # def install_to_staging
|
data/lib/fpm/package/rpm.rb
CHANGED
@@ -29,7 +29,7 @@ class FPM::Package::RPM < FPM::Package
|
|
29
29
|
"bzip2" => "w9.bzdio"
|
30
30
|
} unless defined?(COMPRESSION_MAP)
|
31
31
|
|
32
|
-
option "--use-file-permissions", :flag,
|
32
|
+
option "--use-file-permissions", :flag,
|
33
33
|
"Use existing file permissions when defining ownership and modes."
|
34
34
|
|
35
35
|
option "--user", "USER", "Set the user to USER in the %files section. Overrides the user when used with use-file-permissions setting."
|
@@ -55,6 +55,8 @@ class FPM::Package::RPM < FPM::Package
|
|
55
55
|
next rpmbuild_define
|
56
56
|
end
|
57
57
|
|
58
|
+
option "--dist", "DIST-TAG", "Set the rpm distribution."
|
59
|
+
|
58
60
|
option "--digest", DIGEST_ALGORITHM_MAP.keys.join("|"),
|
59
61
|
"Select a digest algorithm. md5 works on the most platforms.",
|
60
62
|
:default => "md5" do |value|
|
@@ -84,6 +86,9 @@ class FPM::Package::RPM < FPM::Package
|
|
84
86
|
File.read(File.expand_path(file))
|
85
87
|
end
|
86
88
|
|
89
|
+
option "--summary", "SUMMARY",
|
90
|
+
"Set the RPM summary. Overrides the first line on the description if set"
|
91
|
+
|
87
92
|
option "--sign", :flag, "Pass --sign to rpmbuild"
|
88
93
|
|
89
94
|
option "--auto-add-directories", :flag, "Auto add directories not part of filesystem"
|
@@ -98,7 +103,7 @@ class FPM::Package::RPM < FPM::Package
|
|
98
103
|
option "--attr", "ATTRFILE",
|
99
104
|
"Set the attribute for a file (%attr).",
|
100
105
|
:multivalued => true, :attribute_name => :attrs
|
101
|
-
|
106
|
+
|
102
107
|
option "--init", "FILEPATH", "Add FILEPATH as an init script",
|
103
108
|
:multivalued => true do |file|
|
104
109
|
next File.expand_path(file)
|
@@ -117,6 +122,14 @@ class FPM::Package::RPM < FPM::Package
|
|
117
122
|
next rpmbuild_filter_from_requires
|
118
123
|
end
|
119
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
|
+
|
120
133
|
option "--ignore-iteration-in-dependencies", :flag,
|
121
134
|
"For '=' (equal) dependencies, allow iterations on the specified " \
|
122
135
|
"version. Default is to be specific. This option allows the same " \
|
@@ -149,25 +162,29 @@ class FPM::Package::RPM < FPM::Package
|
|
149
162
|
match = trigger.match(/^(\[.*\]|)(.*): (.*)$/)
|
150
163
|
@logger.fatal("Trigger '#{trigger_type}' definition can't be parsed ('#{trigger}')") unless match
|
151
164
|
opt, pkg, file = match.captures
|
152
|
-
@logger.fatal("File given for --trigger-#{trigger_type} does not exist (#{file})") unless File.
|
165
|
+
@logger.fatal("File given for --trigger-#{trigger_type} does not exist (#{file})") unless File.exist?(file)
|
153
166
|
rpm_trigger << [pkg, File.read(file), opt.tr('[]','')]
|
154
167
|
next rpm_trigger
|
155
168
|
end
|
156
169
|
end
|
157
|
-
|
170
|
+
|
158
171
|
private
|
159
|
-
|
172
|
+
|
160
173
|
# Fix path name
|
161
174
|
# Replace [ with [\[] to make rpm not use globs
|
162
175
|
# Replace * with [*] to make rpm not use globs
|
163
176
|
# Replace ? with [?] to make rpm not use globs
|
164
177
|
# Replace % with [%] to make rpm not expand macros
|
165
178
|
def rpm_fix_name(name)
|
166
|
-
name =
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
179
|
+
name = name.gsub(/(\ |\[|\]|\*|\?|\%|\$)/, {
|
180
|
+
' ' => '?',
|
181
|
+
'%' => '[%]',
|
182
|
+
'$' => '[$]',
|
183
|
+
'?' => '[?]',
|
184
|
+
'*' => '[*]',
|
185
|
+
'[' => '[\[]',
|
186
|
+
']' => '[\]]'
|
187
|
+
})
|
171
188
|
end
|
172
189
|
|
173
190
|
def rpm_file_entry(file)
|
@@ -289,7 +306,7 @@ class FPM::Package::RPM < FPM::Package
|
|
289
306
|
script_path = self.attributes[scriptname]
|
290
307
|
# Skip scripts not set
|
291
308
|
next if script_path.nil?
|
292
|
-
if !File.
|
309
|
+
if !File.exist?(script_path)
|
293
310
|
logger.error("No such file (for #{scriptname.to_s}): #{script_path.inspect}")
|
294
311
|
script_errors << script_path
|
295
312
|
end
|
@@ -303,14 +320,17 @@ class FPM::Package::RPM < FPM::Package
|
|
303
320
|
end # def converted
|
304
321
|
|
305
322
|
def rpm_get_trigger_type(flag)
|
306
|
-
puts "#{flag.to_s(2)}"
|
307
323
|
if (flag & (1 << 25)) == (1 << 25)
|
324
|
+
# RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< %triggerprein dependency. */
|
308
325
|
:rpm_trigger_before_install
|
309
326
|
elsif (flag & (1 << 16)) == (1 << 16)
|
327
|
+
# RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
|
310
328
|
:rpm_trigger_after_install
|
311
329
|
elsif (flag & (1 << 17)) == (1 << 17)
|
330
|
+
# RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
|
312
331
|
:rpm_trigger_before_uninstall
|
313
332
|
elsif (flag & (1 << 18)) == (1 << 18)
|
333
|
+
# RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
|
314
334
|
:rpm_trigger_after_target_uninstall
|
315
335
|
else
|
316
336
|
@logger.fatal("I don't know about this triggerflag ('#{flag}')")
|
@@ -375,13 +395,13 @@ class FPM::Package::RPM < FPM::Package
|
|
375
395
|
[name, operator, version].join(" ")
|
376
396
|
end
|
377
397
|
#input.replaces += replaces
|
378
|
-
|
398
|
+
|
379
399
|
self.config_files += rpm.config_files
|
380
400
|
|
381
401
|
# rpms support '%dir' things for specifying empty directories to package,
|
382
402
|
# but the rpm header itself doesn't actually record this information.
|
383
403
|
# so there's no 'directories' to copy, so don't try to merge in the
|
384
|
-
# 'directories' feature.
|
404
|
+
# 'directories' feature.
|
385
405
|
# TODO(sissel): If you want this feature, we'll have to find scan
|
386
406
|
# the extracted rpm for empty directories. I'll wait until someone asks for
|
387
407
|
# this feature
|
@@ -414,6 +434,9 @@ class FPM::Package::RPM < FPM::Package
|
|
414
434
|
args += ["--target", rpm_target]
|
415
435
|
end
|
416
436
|
|
437
|
+
# set the rpm dist tag
|
438
|
+
args += ["--define", "dist .#{attributes[:rpm_dist]}"] if attributes[:rpm_dist]
|
439
|
+
|
417
440
|
args += [
|
418
441
|
"--define", "buildroot #{build_path}/BUILD",
|
419
442
|
"--define", "_topdir #{build_path}",
|
@@ -508,6 +531,14 @@ class FPM::Package::RPM < FPM::Package
|
|
508
531
|
#return File.join("BUILD", prefix)
|
509
532
|
end # def build_sub_dir
|
510
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
|
+
|
511
542
|
def version
|
512
543
|
if @version.kind_of?(String) and @version.include?("-")
|
513
544
|
logger.warn("Package version '#{@version}' includes dashes, converting" \
|
@@ -523,16 +554,25 @@ class FPM::Package::RPM < FPM::Package
|
|
523
554
|
return @epoch if @epoch.is_a?(Numeric)
|
524
555
|
|
525
556
|
if @epoch.nil? or @epoch.empty?
|
526
|
-
logger.warn("no value for epoch is set, defaulting to nil")
|
527
557
|
return nil
|
528
558
|
end
|
529
559
|
|
530
560
|
return @epoch
|
531
561
|
end # def epoch
|
532
562
|
|
563
|
+
def to_s_dist;
|
564
|
+
attributes[:rpm_dist] ? "#{attributes[:rpm_dist]}" : "DIST";
|
565
|
+
end
|
566
|
+
|
533
567
|
def to_s(format=nil)
|
534
|
-
|
535
|
-
|
568
|
+
if format.nil?
|
569
|
+
format = if attributes[:rpm_dist]
|
570
|
+
"NAME-VERSION-ITERATION.DIST.ARCH.EXTENSION"
|
571
|
+
else
|
572
|
+
"NAME-VERSION-ITERATION.ARCH.EXTENSION"
|
573
|
+
end
|
574
|
+
end
|
575
|
+
return super(format.gsub("DIST", to_s_dist))
|
536
576
|
end # def to_s
|
537
577
|
|
538
578
|
def payload_compression
|
@@ -545,5 +585,5 @@ class FPM::Package::RPM < FPM::Package
|
|
545
585
|
|
546
586
|
public(:input, :output, :converted_from, :architecture, :to_s, :iteration,
|
547
587
|
:payload_compression, :digest_algorithm, :prefix, :build_sub_dir,
|
548
|
-
:epoch, :version, :prefixed_path)
|
588
|
+
:summary, :epoch, :version, :prefixed_path)
|
549
589
|
end # class FPM::Package::RPM
|
data/lib/fpm/package/sh.rb
CHANGED
@@ -11,7 +11,7 @@ require "digest"
|
|
11
11
|
#
|
12
12
|
# This class only supports output of packages.
|
13
13
|
#
|
14
|
-
# The sh package is a single sh file with a
|
14
|
+
# The sh package is a single sh file with a tar payload concatenated to the end.
|
15
15
|
# The script can unpack the tarball to install it and call optional post install scripts.
|
16
16
|
class FPM::Package::Sh < FPM::Package
|
17
17
|
|
@@ -24,12 +24,6 @@ class FPM::Package::Sh < FPM::Package
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def create_scripts
|
27
|
-
if script?(:before_install)
|
28
|
-
# the scripts are kept in the payload so what would before install be if we've already
|
29
|
-
# unpacked the payload?
|
30
|
-
raise "sh package does not support before install scripts."
|
31
|
-
end
|
32
|
-
|
33
27
|
if script?(:after_install)
|
34
28
|
File.write(File.join(fpm_meta_path, "after_install"), script(:after_install))
|
35
29
|
end
|
data/lib/fpm/package/solaris.rb
CHANGED
@@ -75,7 +75,7 @@ class FPM::Package::Solaris < FPM::Package
|
|
75
75
|
# Should create a package directory named by the package name.
|
76
76
|
safesystem("pkgmk", "-o", "-f", "#{build_path}/Prototype", "-d", build_path)
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
|
80
80
|
# Convert the 'package directory' built above to a real solaris package.
|
81
81
|
safesystem("pkgtrans", "-s", build_path, output_path, name)
|
data/lib/fpm/package/tar.rb
CHANGED
@@ -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
|
-
|
22
|
+
tar_compression_flag(input_path).tap do |flag|
|
23
23
|
args << flag unless flag.nil?
|
24
24
|
end
|
25
25
|
|
@@ -48,9 +48,21 @@ class FPM::Package::Tar < FPM::Package
|
|
48
48
|
# the compression type.
|
49
49
|
def output(output_path)
|
50
50
|
output_check(output_path)
|
51
|
+
|
52
|
+
# Write the scripts, too.
|
53
|
+
scripts_path = File.join(staging_path, ".scripts")
|
54
|
+
::Dir.mkdir(scripts_path)
|
55
|
+
[:before_install, :after_install, :before_remove, :after_remove].each do |name|
|
56
|
+
next unless script?(name)
|
57
|
+
out = File.join(scripts_path, name.to_s)
|
58
|
+
logger.debug("Writing script", :source => name, :target => out)
|
59
|
+
File.write(out, script(name))
|
60
|
+
File.chmod(0755, out)
|
61
|
+
end
|
62
|
+
|
51
63
|
# Unpack the tarball to the staging path
|
52
64
|
args = ["-cf", output_path, "-C", staging_path]
|
53
|
-
|
65
|
+
tar_compression_flag(output_path).tap do |flag|
|
54
66
|
args << flag unless flag.nil?
|
55
67
|
end
|
56
68
|
args << "."
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require "fpm/namespace"
|
2
|
+
require "fpm/package"
|
3
|
+
require "fpm/util"
|
4
|
+
|
5
|
+
# Support for python virtualenv packages.
|
6
|
+
#
|
7
|
+
# This supports input, but not output.
|
8
|
+
#
|
9
|
+
class FPM::Package::Virtualenv < FPM::Package
|
10
|
+
# Flags '--foo' will be accessable as attributes[:virtualenv_foo]
|
11
|
+
|
12
|
+
option "--pypi", "PYPI_URL",
|
13
|
+
"PyPi Server uri for retrieving packages.",
|
14
|
+
:default => "https://pypi.python.org/simple"
|
15
|
+
option "--package-name-prefix", "PREFIX", "Name to prefix the package " \
|
16
|
+
"name with.", :default => "virtualenv"
|
17
|
+
|
18
|
+
option "--install-location", "DIRECTORY", "Location to which to " \
|
19
|
+
"install the virtualenv by default.", :default => "/usr/share/python" do |path|
|
20
|
+
File.expand_path(path)
|
21
|
+
end
|
22
|
+
|
23
|
+
option "--fix-name", :flag, "Should the target package name be prefixed?",
|
24
|
+
:default => true
|
25
|
+
option "--other-files-dir", "DIRECTORY", "Optionally, the contents of the " \
|
26
|
+
"specified directory may be added to the package. This is useful if the " \
|
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
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# Input a package.
|
36
|
+
#
|
37
|
+
# `package` can look like `psutil==2.2.1` or `psutil`.
|
38
|
+
def input(package)
|
39
|
+
installdir = attributes[:virtualenv_install_location]
|
40
|
+
m = /^([^=]+)==([^=]+)$/.match(package)
|
41
|
+
package_version = nil
|
42
|
+
|
43
|
+
if m
|
44
|
+
package_name = m[1]
|
45
|
+
package_version = m[2]
|
46
|
+
self.version ||= package_version
|
47
|
+
else
|
48
|
+
package_name = package
|
49
|
+
package_version = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
virtualenv_name = package_name
|
53
|
+
|
54
|
+
self.name ||= package_name
|
55
|
+
|
56
|
+
if self.attributes[:virtualenv_fix_name?]
|
57
|
+
self.name = [self.attributes[:virtualenv_package_name_prefix],
|
58
|
+
self.name].join("-")
|
59
|
+
end
|
60
|
+
|
61
|
+
virtualenv_folder =
|
62
|
+
File.join(installdir,
|
63
|
+
virtualenv_name)
|
64
|
+
|
65
|
+
virtualenv_build_folder = build_path(virtualenv_folder)
|
66
|
+
|
67
|
+
::FileUtils.mkdir_p(virtualenv_build_folder)
|
68
|
+
|
69
|
+
safesystem("virtualenv", virtualenv_build_folder)
|
70
|
+
pip_exe = File.join(virtualenv_build_folder, "bin", "pip")
|
71
|
+
python_exe = File.join(virtualenv_build_folder, "bin", "python")
|
72
|
+
|
73
|
+
# Why is this hack here? It looks important, so I'll keep it in.
|
74
|
+
safesystem(pip_exe, "install", "-U", "-i",
|
75
|
+
attributes[:virtualenv_pypi],
|
76
|
+
"pip", "distribute")
|
77
|
+
safesystem(pip_exe, "uninstall", "-y", "distribute")
|
78
|
+
|
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)
|
87
|
+
|
88
|
+
if package_version.nil?
|
89
|
+
frozen = safesystemout(pip_exe, "freeze")
|
90
|
+
package_version = frozen[/#{package}==[^=]+$/].split("==")[1].chomp!
|
91
|
+
self.version ||= package_version
|
92
|
+
end
|
93
|
+
|
94
|
+
::Dir[build_path + "/**/*"].each do |f|
|
95
|
+
if ! File.readable? f
|
96
|
+
File.lchmod(File.stat(f).mode | 444)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
::Dir.chdir(virtualenv_build_folder) do
|
101
|
+
safesystem("virtualenv-tools", "--update-path", virtualenv_folder)
|
102
|
+
end
|
103
|
+
|
104
|
+
if !attributes[:virtualenv_other_files_dir].nil?
|
105
|
+
# Copy all files from other dir to build_path
|
106
|
+
Find.find(attributes[:virtualenv_other_files_dir]) do |path|
|
107
|
+
src = path.gsub(/^#{attributes[:virtualenv_other_files_dir]}/, '')
|
108
|
+
dst = File.join(build_path, src)
|
109
|
+
copy_entry(path, dst, preserve=true, remove_destination=true)
|
110
|
+
copy_metadata(path, dst)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
remove_python_compiled_files virtualenv_build_folder
|
115
|
+
|
116
|
+
# use dir to set stuff up properly, mainly so I don't have to reimplement
|
117
|
+
# the chdir/prefix stuff special for tar.
|
118
|
+
dir = convert(FPM::Package::Dir)
|
119
|
+
|
120
|
+
if attributes[:chdir]
|
121
|
+
dir.attributes[:chdir] = File.join(build_path, attributes[:chdir])
|
122
|
+
else
|
123
|
+
dir.attributes[:chdir] = build_path
|
124
|
+
end
|
125
|
+
|
126
|
+
cleanup_staging
|
127
|
+
# Tell 'dir' to input "." and chdir/prefix will help it figure out the
|
128
|
+
# rest.
|
129
|
+
dir.input(".")
|
130
|
+
@staging_path = dir.staging_path
|
131
|
+
dir.cleanup_build
|
132
|
+
|
133
|
+
end # def input
|
134
|
+
|
135
|
+
# Delete python precompiled files found in a given folder.
|
136
|
+
def remove_python_compiled_files path
|
137
|
+
logger.debug("Now removing python object and compiled files from the virtualenv")
|
138
|
+
Find.find(path) do |path|
|
139
|
+
if path.end_with? '.pyc' or path.end_with? '.pyo'
|
140
|
+
FileUtils.rm path
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
public(:input)
|
145
|
+
end # class FPM::Package::Virtualenv
|