fpm 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fpm-npm +95 -0
- metadata +5 -3
data/bin/fpm-npm
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
|
4
|
+
require "optparse"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
settings = OpenStruct.new
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.on("-n PACKAGENAME", "--name PACKAGENAME",
|
11
|
+
"What name to give to the package") do |name|
|
12
|
+
settings.name = name
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.on("-v VERSION", "--version VERSION",
|
16
|
+
"version to give the package") do |version|
|
17
|
+
settings.version = version
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on("-t OUTPUTTYPE", "--type OUTPUTTYPE",
|
21
|
+
"what kind of package you want as output (deb, etc)") do |packagetype|
|
22
|
+
settings.packagetype = packagetype
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
args = opts.parse(ARGV)
|
27
|
+
|
28
|
+
if !["deb"].include?(settings.packagetype)
|
29
|
+
$stderr.puts "Unsupported output package type '#{settings.packagetype}'." \
|
30
|
+
"Only supports 'deb' right now."
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
if !settings.name
|
35
|
+
$stderr.puts "No npm package name given (missing -n?)"
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
|
39
|
+
builddir="#{Dir.pwd}/npm2pkg"
|
40
|
+
# Prefix package names with 'nodejs-'
|
41
|
+
PACKAGEPREFIX = "nodejs-"
|
42
|
+
|
43
|
+
INSTALLPATH="/usr/lib/node"
|
44
|
+
Dir.mkdir(builddir) if !File.exists?(builddir)
|
45
|
+
File.open("#{builddir}/.npmrc", "w") do |file|
|
46
|
+
file.puts "root = #{builddir}#{INSTALLPATH}"
|
47
|
+
end
|
48
|
+
|
49
|
+
## Trick npm into using a custom .npmrc
|
50
|
+
system("env - PATH=$PATH HOME=#{builddir} npm install #{settings.name} #{settings.version}")
|
51
|
+
|
52
|
+
# Find all installed npms in builddir, make packages.
|
53
|
+
Dir.glob("#{builddir}#{INSTALLPATH}/.npm/*/*") do |path|
|
54
|
+
next if File.symlink?(path)
|
55
|
+
puts path
|
56
|
+
|
57
|
+
# Load the package.json and glean any information from it, then invoke pkg.rb
|
58
|
+
package = JSON.parse(File.new("#{path}/package/package.json").read())
|
59
|
+
|
60
|
+
# TODO(sissel): Ideally we want to say any version with the same 'release' number, like
|
61
|
+
# So we'll specify deps of {v}-1 <= x <= {v}-999999....
|
62
|
+
depends = Dir.glob("#{path}/dependson/*@*") \
|
63
|
+
.collect { |p| PACKAGEPREFIX + File.basename(p) } \
|
64
|
+
.collect { |p| n,v = p.split("@");
|
65
|
+
["#{n} (>= #{v}-1)", "#{n} (<= #{v}-99999999999999)"]
|
66
|
+
}.flatten
|
67
|
+
|
68
|
+
if package["author"]
|
69
|
+
maintainer = package["author"]
|
70
|
+
else
|
71
|
+
m = package["maintainers"][0] \
|
72
|
+
rescue { "name" => "missing upstream author", "email" => ENV["USER"] }
|
73
|
+
maintainer = "#{m["name"]} <#{m["email"]}>"
|
74
|
+
end
|
75
|
+
|
76
|
+
pkgcmd = [ "fpm",
|
77
|
+
"-n", "#{PACKAGEPREFIX}#{package["name"]}",
|
78
|
+
"-v", package["version"],
|
79
|
+
"-m", maintainer,
|
80
|
+
"-a", "all",
|
81
|
+
]
|
82
|
+
|
83
|
+
depends.each do |dep|
|
84
|
+
pkgcmd += ["-d", dep]
|
85
|
+
end
|
86
|
+
|
87
|
+
pkgcmd += ["-p", "#{PACKAGEPREFIX}#{package["name"]}-VERSION_ARCH.deb"]
|
88
|
+
pkgcmd += ["-C", builddir]
|
89
|
+
pkgcmd << "#{INSTALLPATH[1..-1]}/.npm/#{package["name"]}/active"
|
90
|
+
pkgcmd << "#{INSTALLPATH[1..-1]}/#{package["name"]}"
|
91
|
+
pkgcmd << "#{INSTALLPATH[1..-1]}/#{package["name"]}@#{package["version"]}"
|
92
|
+
|
93
|
+
puts pkgcmd.map { |x| "\"#{x}\"" }.join(" ")
|
94
|
+
system *pkgcmd
|
95
|
+
end
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|
@@ -36,6 +36,7 @@ description: Turn directories into packages. Fix broken packages. Win the packag
|
|
36
36
|
email: jls@semicomplete.com
|
37
37
|
executables:
|
38
38
|
- fpm
|
39
|
+
- fpm-npm
|
39
40
|
extensions: []
|
40
41
|
|
41
42
|
extra_rdoc_files: []
|
@@ -46,6 +47,7 @@ files:
|
|
46
47
|
- lib/fpm/package.rb
|
47
48
|
- lib/fpm.rb
|
48
49
|
- bin/fpm
|
50
|
+
- bin/fpm-npm
|
49
51
|
- templates/deb.erb
|
50
52
|
has_rdoc: true
|
51
53
|
homepage: https://github.com/jordansissel/fpm
|