fpm 0.2.32 → 0.2.33

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fpm CHANGED
@@ -6,6 +6,16 @@ $: << File.join(File.dirname(__FILE__), "..", "lib")
6
6
  require "fpm"
7
7
  require "fpm/program"
8
8
 
9
+ if $DEBUG
10
+ module Kernel
11
+ alias :orig_system :system
12
+ def system(*args)
13
+ p :system => args
14
+ orig_system(*args)
15
+ end
16
+ end
17
+ end
18
+
9
19
  program = FPM::Program.new
10
20
  ret = program.run(ARGV)
11
21
  exit(ret.nil? ? 0 : ret)
data/lib/fpm.rb CHANGED
@@ -4,6 +4,7 @@ require "fpm/builder"
4
4
  require "fpm/package"
5
5
  require "fpm/target/deb"
6
6
  require "fpm/target/rpm"
7
+ require "fpm/target/solaris"
7
8
 
8
9
  require "fpm/source"
9
10
  require "fpm/source/dir"
@@ -84,7 +84,7 @@ class FPM::Builder
84
84
  ::Dir.chdir root do
85
85
  @source.make_tarball!(tar_path, builddir)
86
86
 
87
- generate_md5sums
87
+ generate_md5sums if @package.needs_md5sums
88
88
  generate_specfile
89
89
  edit_specfile if @edit
90
90
  end
@@ -111,11 +111,16 @@ class FPM::Package
111
111
  File.open(specfile(builddir), "w") { |f| f.puts spec }
112
112
  end # def generate_specfile
113
113
 
114
- def generate_md5sums(builddir, paths)
115
- md5sums = self.checksum(paths)
116
- File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums }
117
- md5sums
118
- end # def generate_md5sums
114
+ # nobody needs md5sums by default.
115
+ def needs_md5sums
116
+ false
117
+ end # def needs_md5sums
118
+
119
+ #def generate_md5sums(builddir, paths)
120
+ #md5sums = self.checksum(paths)
121
+ #File.open("#{builddir}/md5sums", "w") { |f| f.puts md5sums }
122
+ #md5sums
123
+ #end # def generate_md5sums
119
124
 
120
125
  # TODO [Jay]: make this better...?
121
126
  def type
@@ -96,21 +96,49 @@ class FPM::Source
96
96
  dirs.sort! { |a,b| a.size <=> b.size }
97
97
  paths.sort! { |a,b| a.size <=> b.size }
98
98
 
99
+
100
+ # Solaris's tar is pretty neutered, so implement --exclude and such
101
+ # ourselves.
102
+ # TODO(sissel): May need to implement our own tar file generator
103
+ # so we can enforce file ownership. Again, solaris' tar doesn't support
104
+ # --owner, etc.
105
+ #paths = []
106
+ #dirs.each do |dir|
107
+ #Dir.glob(File.join(dir, "**", "*")).each do |path|
108
+ #next if excludesFile.fnmatch?(
109
+ #end
110
+ #end
111
+
99
112
  excludes = self[:exclude].map { |e| ["--exclude", e] }.flatten
100
113
 
101
114
  # TODO(sissel): To properly implement excludes as regexps, we
102
115
  # will need to find files ourselves. That may be more work
103
116
  # than it is worth. For now, rely on tar's --exclude.
104
- dir_tar = ["tar", "-C", chdir, "--owner=root", "--group=root" ] \
117
+ dir_tar = [tar_cmd, "--owner=root", "--group=root" ] \
105
118
  + excludes \
106
119
  + ["-cf", output, "--no-recursion" ] \
107
120
  + dirs
108
- system(*dir_tar) if dirs.any?
109
121
 
110
- files_tar = [ "tar", "-C", chdir ] \
122
+ ::Dir.chdir(chdir) do
123
+ system(*dir_tar) if dirs.any?
124
+ end
125
+
126
+ files_tar = [ tar_cmd ] \
111
127
  + excludes \
112
128
  + [ "--owner=root", "--group=root", "-rf", output ] \
113
129
  + paths
114
- system(*files_tar)
130
+ ::Dir.chdir(chdir) do
131
+ system(*files_tar)
132
+ end
115
133
  end # def tar
116
- end
134
+
135
+ def tar_cmd
136
+ # Rely on gnu tar for solaris.
137
+ case %x{uname -s}.chomp
138
+ when "SunOS"
139
+ return "gtar"
140
+ else
141
+ return "tar"
142
+ end
143
+ end # def tar_cmd
144
+ end # class FPM::Source
@@ -15,7 +15,9 @@ class FPM::Source::Dir < FPM::Source
15
15
  # Prefix all files with a path if given.
16
16
  @paths.each do |path|
17
17
  # Trim @root (--chdir)
18
- path = path[@root.size .. -1] if path.start_with?(@root)
18
+ if @root != "." and path.start_with?(@root)
19
+ path = path[@root.size .. -1]
20
+ end
19
21
 
20
22
  # Copy to self[:prefix] (aka --prefix)
21
23
  if File.directory?(path)
@@ -4,6 +4,10 @@ require "fpm/package"
4
4
  require "fpm/errors"
5
5
 
6
6
  class FPM::Target::Deb < FPM::Package
7
+ def needs_md5sums
8
+ true
9
+ end # def needs_md5sums
10
+
7
11
  def architecture
8
12
  if @architecture.nil? or @architecture == "native"
9
13
  # Default architecture should be 'native' which we'll need
@@ -0,0 +1,85 @@
1
+ require "erb"
2
+ require "fpm/namespace"
3
+ require "fpm/package"
4
+ require "fpm/errors"
5
+
6
+ # TODO(sissel): Add dependency checking support.
7
+ # IIRC this has to be done as a 'checkinstall' step.
8
+ class FPM::Target::Solaris < FPM::Package
9
+ def architecture
10
+ case @architecture
11
+ when nil, "native"
12
+ @architecture = %x{uname -p}.chomp
13
+ end
14
+ # "all" is a valid arch according to
15
+ # http://www.bolthole.com/solaris/makeapackage.html
16
+
17
+ return @architecture
18
+ end # def architecture
19
+
20
+ def specfile(builddir)
21
+ "#{builddir}/pkginfo"
22
+ end
23
+
24
+ def build!(params)
25
+ self.scripts.each do |name, path|
26
+ case name
27
+ when "pre-install"
28
+ system("cp #{path} ./preinstall")
29
+ File.chmod(0755, "./preinstall")
30
+ when "post-install"
31
+ system("cp #{path} ./postinstall")
32
+ File.chmod(0755, "./postinstall")
33
+ when "pre-uninstall"
34
+ raise FPM::InvalidPackageConfiguration.new(
35
+ "pre-uninstall is not supported by Solaris packages"
36
+ )
37
+ when "post-uninstall"
38
+ raise FPM::InvalidPackageConfiguration.new(
39
+ "post-uninstall is not supported by Solaris packages"
40
+ )
41
+ end # case name
42
+ end # self.scripts.each
43
+
44
+ # Unpack data.tar.gz so we can build a package from it.
45
+ Dir.mkdir("data")
46
+ system("gzip -d data.tar.gz");
47
+ Dir.chdir("data") do
48
+ system("tar -xf ../data.tar");
49
+ end
50
+
51
+ #system("(echo 'i pkginfo'; pkgproto data=/) > Prototype")
52
+
53
+ # Generate the package 'Prototype' file
54
+ # TODO(sissel): allow setting default file owner.
55
+ File.open("Prototype", "w") do |prototype|
56
+ prototype.puts("i pkginfo")
57
+ # TODO(sissel): preinstall/postinstall
58
+ IO.popen("pkgproto data=/").each_line do |line|
59
+ type, klass, path, mode, user, group = line.split
60
+ # Override stuff in pkgproto
61
+ # TODO(sissel): Make this tunable?
62
+ user = "root"
63
+ group = "root"
64
+ prototype.puts([type, klass, path, mode, user, group].join(" "))
65
+ end # popen "pkgproto ..."
66
+ end # File prototype
67
+
68
+ # Should create a package directory named by the package name.
69
+ system("pkgmk -o -d .")
70
+
71
+ # Convert the 'package directory' built above to a real solaris package.
72
+ system("pkgtrans -s . #{params[:output]} #{name}")
73
+ end # def build
74
+
75
+ def default_output
76
+ v = version
77
+ v = "#{epoch}:#{v}" if epoch
78
+ if iteration
79
+ "#{name}_#{v}-#{iteration}_#{architecture}.#{type}"
80
+ else
81
+ "#{name}_#{v}_#{architecture}.#{type}"
82
+ end
83
+ end # def default_output
84
+ end # class FPM::Deb
85
+
@@ -0,0 +1,15 @@
1
+ CLASSES=none
2
+ BASEDIR=/usr/local
3
+ TZ=PST
4
+ PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
5
+ PKG=<%= name %>
6
+ NAME=<%= name %>
7
+ ARCH=<%= architecture %>
8
+ VERSION=<%= version %><%= iteration && "-" + iteration.to_s %>
9
+ CATEGORY=application
10
+ <%# pkginfo(4) says DESC is max 256 characters %>
11
+ DESC=<%= description.split("\n").first[0..255] or "no description given" %>
12
+ VENDOR=<%= maintainer %>
13
+ <%# Take maintainer of "Foo <bar@baz.com>" and use "bar@baz.com" %>
14
+ EMAIL=<%= maintainer[/<.+>/].gsub(/[<>]/, "") %>
15
+
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: 87
4
+ hash: 85
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 32
10
- version: 0.2.32
9
+ - 33
10
+ version: 0.2.33
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-06-09 00:00:00 -07:00
18
+ date: 2011-06-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,7 @@ files:
63
63
  - lib/fpm/source/pyfpm/__init__.py
64
64
  - lib/fpm/source/tar.rb
65
65
  - lib/fpm/source/gem.rb
66
+ - lib/fpm/target/solaris.rb
66
67
  - lib/fpm/target/deb.rb
67
68
  - lib/fpm/target/rpm.rb
68
69
  - lib/fpm/program.rb
@@ -70,6 +71,7 @@ files:
70
71
  - lib/fpm.rb
71
72
  - bin/fpm
72
73
  - bin/fpm-npm
74
+ - templates/solaris.erb
73
75
  - templates/rpm.erb
74
76
  - templates/deb.erb
75
77
  - LICENSE
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  requirements: []
107
109
 
108
110
  rubyforge_project:
109
- rubygems_version: 1.6.2
111
+ rubygems_version: 1.5.1
110
112
  signing_key:
111
113
  specification_version: 3
112
114
  summary: fpm - package building and mangling