Cross package maker. DEB/RPM generation or conversion. Derived from jordansissel/fpm.

⌈⌋ branch:  cross package maker


Check-in [9cef77c028]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:9cef77c028afe864f07c15ad1a3a1ee7ee8a2b80
Date: 2013-02-09 22:58:07
User: jls
Comment:- Folks gettin' angry about an abandoned prototype they mistook for functioning and supported code, so let's delete this 'fpm-npm' hackery. Someone will write proper npm package support for fpm eventually.
Tags And Properties
  • sym-trunk inherited from [2b439be7d6]
Context
2013-02-11
20:21
[638eb0dd8c] Merge pull request #360 from mblair/remove_npm_ref remove fpm-npm ref in gemspec so the gem builds. (user: jls, tags: trunk)
15:36
[13ee63f667] Fix debian dependency name mangling (user: pranay.kanwar, tags: trunk)
13:54
[eb2bf7e2c2] remove fpm-npm ref in gemspec so the gem builds. (user: me, tags: trunk)
13:31
[18904f1b71] Add empty source, -s empty (user: pranay.kanwar, tags: trunk)
2013-02-09
22:58
[9cef77c028] - Folks gettin' angry about an abandoned prototype they mistook for functioning and supported code, so let's delete this 'fpm-npm' hackery. Someone will write proper npm package support for fpm eventually. (user: jls, tags: trunk)
2013-02-08
23:52
[cbc463d64f] - escape the staging_path in a regexp when replacing the pear_dir paths (user: jls, tags: trunk)
Changes

Deleted bin/fpm-npm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env ruby

require "optparse"
require "ostruct"
require "json"

settings = OpenStruct.new
opts = OptionParser.new do |opts|
  opts.on("-n PACKAGENAME", "--name PACKAGENAME",
          "What name to give to the package") do |name|
    settings.name = name
  end

  opts.on("-v VERSION", "--version VERSION",
          "version to give the package") do |version|
    settings.version = version
  end

  opts.on("-t OUTPUTTYPE", "--type OUTPUTTYPE",
          "what kind of package you want as output (deb, etc)") do |packagetype|
    settings.packagetype = packagetype
  end
end

args = opts.parse(ARGV)

if !["deb"].include?(settings.packagetype)
  $stderr.puts "Unsupported output package type '#{settings.packagetype}'." \
               "Only supports 'deb' right now."
  exit 1
end

if !settings.name
  $stderr.puts "No npm package name given (missing -n?)"
  exit 1
end

builddir="#{Dir.pwd}/npm2pkg"
# Prefix package names with 'nodejs-'
PACKAGEPREFIX = "nodejs-"

Dir.mkdir(builddir) if !File.exists?(builddir)
File.open("#{builddir}/.npmrc", "w") do |file|
  file.puts "root = #{builddir}/usr/lib/node"
  file.puts "binroot = #{builddir}/usr/lib/node/bin"
  file.puts "manroot = #{builddir}/usr/share/man"
end

## Trick npm into using a custom .npmrc
system("env - PATH=$PATH HOME=#{builddir} npm install #{settings.name} #{settings.version}")

# Find all installed npms in builddir, make packages.
Dir.glob("#{builddir}/usr/lib/node/.npm/*/*") do |path|
  next if File.symlink?(path)
  puts path

  # Load the package.json and glean any information from it, then invoke pkg.rb
  package = JSON.parse(File.new("#{path}/package/package.json").read())

  # TODO(sissel): Ideally we want to say any version with the same 'release' number, like
  # So we'll specify deps of {v}-1 <= x <= {v}-999999....
  depends = Dir.glob("#{path}/dependson/*@*") \
    .collect { |p| PACKAGEPREFIX + File.basename(p) } \
    .collect { |p| n,v = p.split("@");
      ["#{n} (>= #{v}-1)", "#{n} (<= #{v}-99999999999999)"]
  }.flatten

  if package["author"]
    maintainer = package["author"]
  else
    m = package["maintainers"][0] \
      rescue { "name" => "missing upstream author", "email" => ENV["USER"] }
    maintainer = "#{m["name"]} <#{m["email"]}>"
  end

  pkgcmd = [ "fpm",
    "-n", "#{PACKAGEPREFIX}#{package["name"]}",
    "-v", package["version"],
    "-m", maintainer,
    "-a", "all",
  ]

  depends.each do |dep|
    pkgcmd += ["-d", dep]
  end

  pkgcmd += ["-p", "#{PACKAGEPREFIX}#{package["name"]}-VERSION_ARCH.deb"]
  pkgcmd += ["-C", builddir]
  pkgcmd << "usr/lib/node/.npm/#{package["name"]}/active"
  pkgcmd << "usr/lib/node/.npm/#{package["name"]}/#{package["version"]}"
  pkgcmd << "usr/lib/node/#{package["name"]}"
  pkgcmd << "usr/lib/node/#{package["name"]}@#{package["version"]}"

  # Include bin files, install to usr/lib/node/bin
  (package["bin"] or []).each do |bin, script|
    pkgcmd << "usr/lib/node/bin/#{bin}"
    pkgcmd << "usr/lib/node/bin/#{bin}@#{package["version"]}"
  end

  # TODO(sissel): We could include manpages and docs, but I don't care right
  # now. If you want it, I accept patches! :)

  system *pkgcmd
end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<