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

⌈⌋ branch:  cross package maker


Check-in [a39fcdaf36]

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

Overview
Comment:- More work converting npm to debs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a39fcdaf36c6b380bd059f007356cc2b67240749
User & Date: jls@semicomplete.com 2011-01-03 23:05:45
Context
2011-01-03
23:40
set group, too check-in: 37802d19c4 user: jls@semicomplete.com tags: trunk
23:05
- More work converting npm to debs check-in: a39fcdaf36 user: jls@semicomplete.com tags: trunk
23:05
- purge swap file check-in: 0605d57bcf user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bin/pkg.rb.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
100
101
102
103
104
105
106





















107
108
109
110
111
112
113
114
      settings.dependencies << dep
    end

    opts.on("-a ARCHITECTURE", "--architecture ARCHITECTURE") do |arch|
      settings.architecture = arch
    end

    opts.on("-m MAINTAINER", "--maintainer MAINTAINER") do |maint|
      settings.maintainer = maintainer
    end

    opts.on("-C DIRECTORY", "Change directory before searching for files") do |dir|
      settings.chdir = dir
    end
  end # OptionParser
................................................................................

  builddir = "#{Dir.pwd}/build-#{type}-#{File.basename(package_path)}"
  Dir.mkdir(builddir) if !File.directory?(builddir)
  template = File.new("#{File.dirname(__FILE__)}/../templates/#{type}.erb").read()

  Dir.chdir(settings.chdir || ".") do 
    puts Dir.pwd





















    system(*["tar","-zcf", "#{builddir}/data.tar.gz", *paths])

    # Generate md5sums
    md5sums = []
    paths.each do |path|
      md5sums += %x{find #{path} -type f -print0 | xargs -0 md5sum}.split("\n")
    end
    File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums.join("\n") }







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      settings.dependencies << dep
    end

    opts.on("-a ARCHITECTURE", "--architecture ARCHITECTURE") do |arch|
      settings.architecture = arch
    end

    opts.on("-m MAINTAINER", "--maintainer MAINTAINER") do |maintainer|
      settings.maintainer = maintainer
    end

    opts.on("-C DIRECTORY", "Change directory before searching for files") do |dir|
      settings.chdir = dir
    end
  end # OptionParser
................................................................................

  builddir = "#{Dir.pwd}/build-#{type}-#{File.basename(package_path)}"
  Dir.mkdir(builddir) if !File.directory?(builddir)
  template = File.new("#{File.dirname(__FILE__)}/../templates/#{type}.erb").read()

  Dir.chdir(settings.chdir || ".") do 
    puts Dir.pwd

    # Add directories first.
    dirs = []
    paths.each do |path|
      while path != "/" and path != "."
        if !dirs.include?(path) or File.symlink?(path)
          dirs << path 
        else
          #puts "Skipping: #{path}"
          #puts !dirs.include?(path) 
          #puts !File.symlink?(path)
        end
        path = File.dirname(path)
      end
    end
    dirs = dirs.sort { |a,b| a.length <=> b.length}
    puts dirs.join("\n")
    system(*["tar", "--owner=root", "-cf", "#{builddir}/data.tar", "--no-recursion", *dirs])
    puts paths.join("\n")
    #paths = paths.reject { |p| File.symlink?(p) }
    system(*["tar", "--owner=root", "-rf", "#{builddir}/data.tar", *paths])
    system(*["gzip", "-f", "#{builddir}/data.tar"])

    # Generate md5sums
    md5sums = []
    paths.each do |path|
      md5sums += %x{find #{path} -type f -print0 | xargs -0 md5sum}.split("\n")
    end
    File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums.join("\n") }

Added tools/npm2pkg.rb.





























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#!/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
end

args = opts.parse(ARGV)

#builddir="#{Dir.pwd}/npm2pkg-#{settings.name}-#{settings.version or "latest"}"
builddir="#{Dir.pwd}/npm2pkg"
#if File.exists?(builddir)
  #system("rm -r #{builddir}")
#end

INSTALLPATH="/usr/lib/node"
Dir.mkdir(builddir) if !File.exists?(builddir)
File.open("#{builddir}/.npmrc", "w") do |file|
  file.puts "root = #{builddir}#{INSTALLPATH}"
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}#{INSTALLPATH}/.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())
  depends = Dir.glob("#{path}/dependson/*@*").collect { |p| File.basename(p) }\
    .collect { |p| n,v = p.split("@"); "#{n} (= #{v})" }

  require "rubygems"
  require "ap"
  ap package
  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 = [ "ruby", "bin/pkg.rb", 
    "-n", "nodejs-#{package["name"]}",
    "-v", package["version"],
    "-m", maintainer,
    "-a", "all",
  ]

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

  pkgcmd += ["-p", "nodejs-#{package["name"]}-VERSION_ARCH.deb"]
  pkgcmd += ["-C", builddir]
  pkgcmd << "#{INSTALLPATH[1..-1]}/.npm/#{package["name"]}/active"
  pkgcmd << "#{INSTALLPATH[1..-1]}/#{package["name"]}"
  pkgcmd << "#{INSTALLPATH[1..-1]}/#{package["name"]}@#{package["version"]}"

  puts pkgcmd.map { |x| "\"#{x}\"" }.join(" ")
  system *pkgcmd
end