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

⌈⌋ ⎇ branch:  cross package maker


Check-in [4292cd85b6]

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

Overview
Comment:Merge branch 'feature/puppet' of github.com:jordansissel/fpm into feature/puppet
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4292cd85b67bb2d4f402507f098385bda3c5b123
User & Date: jls@semicomplete.com 2011-06-20 05:17:34
Context
2011-06-20
05:18
Merge branch 'feature/puppet' check-in: 3a51bdc6ce user: jls@semicomplete.com tags: trunk
05:17
Merge branch 'feature/puppet' of github.com:jordansissel/fpm into feature/puppet check-in: 4292cd85b6 user: jls@semicomplete.com tags: trunk
05:13
- downcase dependency names, too check-in: db1f2bb15c user: jls@semicomplete.com tags: trunk
2011-06-19
08:15
- work-in-progress making it so you can conver rpms to puppet modules. check-in: 3f92e4ba03 user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/fpm/builder.rb.

1


2
3
4
5
6
7
8
require 'fileutils'


class FPM::Builder
  # where is the package's root?
  def root
    @root ||= (@source.root || '.')
  end

  # where the package goes
|
>
>







1
2
3
4
5
6
7
8
9
10
require "fileutils"
require "pathname"

class FPM::Builder
  # where is the package's root?
  def root
    @root ||= (@source.root || '.')
  end

  # where the package goes
79
80
81
82
83
84
85
















86
87
88
89
90
91
92

    File.delete(output) if File.exists?(output) && !File.directory?(output)

    make_builddir!

    ::Dir.chdir root do
      @source.make_tarball!(tar_path, builddir)

















      generate_md5sums if @package.needs_md5sums
      generate_specfile
      edit_specfile if @edit
    end

    ::Dir.chdir(builddir) do







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

    File.delete(output) if File.exists?(output) && !File.directory?(output)

    make_builddir!

    ::Dir.chdir root do
      @source.make_tarball!(tar_path, builddir)

      # Hack to unpack before generating the spec, etc.
      # Need to formalize this feature.
      # Perhaps something like @package.prepare
      if @package.respond_to?(:unpack_data_to)
        data_tarball = File.join(builddir, "data.tar.gz")
        FileUtils.mkdir_p(output)
        Dir.chdir(output) do
          FileUtils.mkdir_p(@package.unpack_data_to)
          system("gzip -d #{data_tarball}")
          Dir.chdir(@package.unpack_data_to) do
            @source.root = Dir.pwd
            system("tar -xf #{data_tarball.gsub(/\.gz$/, "")}")
          end
        end
      end

      generate_md5sums if @package.needs_md5sums
      generate_specfile
      edit_specfile if @edit
    end

    ::Dir.chdir(builddir) do

Changes to lib/fpm/package.rb.

1
2
3

4
5
6
7
8
9
10
require "fpm/namespace"
require "socket" # for Socket.gethostname
require "logger"


class FPM::Package 
  # The name of this package
  attr_accessor :name

  # The version of this package (the upstream version)
  attr_accessor :version



>







1
2
3
4
5
6
7
8
9
10
11
require "fpm/namespace"
require "socket" # for Socket.gethostname
require "logger"
require "find" # for Find.find (directory walking)

class FPM::Package 
  # The name of this package
  attr_accessor :name

  # The version of this package (the upstream version)
  attr_accessor :version
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
159













160
  end # def type

  def template
    @template ||= begin
      tpl = File.read(
        "#{FPM::DIRS[:templates]}/#{type}.erb"
      )
      ERB.new(tpl, nil, "<>")
    end
  end # def template

  def render_spec
    # find all files in paths given.
    paths = []
    @source.paths.each do |path|
      entries = Dir.new(path).to_a
      entries.each do |entry|
        if File.directory?(entry)

      end
    end

    template.result(binding)
  end # def render_spec

  def default_output
    if iteration
      "#{name}-#{version}-#{iteration}.#{architecture}.#{type}"
    else
      "#{name}-#{version}.#{architecture}.#{type}"
    end
  end # def default_output













end # class FPM::Package







|







<
<
<
|
|
<
>










>
>
>
>
>
>
>
>
>
>
>
>
>

130
131
132
133
134
135
136
137
138
139
140
141
142
143
144



145
146

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
  end # def type

  def template
    @template ||= begin
      tpl = File.read(
        "#{FPM::DIRS[:templates]}/#{type}.erb"
      )
      ERB.new(tpl, nil, "-")
    end
  end # def template

  def render_spec
    # find all files in paths given.
    paths = []
    @source.paths.each do |path|



      Find.find(path) { |p| paths << p }
    end

    #@logger.info(:paths => paths.sort)
    template.result(binding)
  end # def render_spec

  def default_output
    if iteration
      "#{name}-#{version}-#{iteration}.#{architecture}.#{type}"
    else
      "#{name}-#{version}.#{architecture}.#{type}"
    end
  end # def default_output

  def fixpath(path)
    p :fixpath => path
    if path.first != "/" 
      path = File.join(@source.root, path)
    end
    return path if File.symlink?(path)
    realpath = Pathname.new(path).realpath.to_s
    re = Regexp.new("^#{Regexp.escape(@source.root)}")
    realpath.gsub!(re, "")
    p :fixpath => {:path => realpath, :caller => caller[0] }
    return realpath
  end # def fixpath
end # class FPM::Package

Changes to lib/fpm/source.rb.

19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
  end

  def dependencies
    self[:dependencies] ||= []
  end

  attr_reader :paths

  attr_reader :root
  def initialize(paths, root, params={})
    @paths = paths
    @root = root

    self[:suffix] = params[:suffix]
    self[:settings] = params[:settings]








>
|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  end

  def dependencies
    self[:dependencies] ||= []
  end

  attr_reader :paths
  attr_accessor :root

  def initialize(paths, root, params={})
    @paths = paths
    @root = root

    self[:suffix] = params[:suffix]
    self[:settings] = params[:settings]

Changes to lib/fpm/source/rpm.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
require "fpm/source"

class FPM::Source::RPM < FPM::Source
  def get_metadata

    self[:name] = %x{rpm -q --qf '%{name}' -p #{@paths.first}}

    self[:version] = %x{rpm -q --qf '%{version}' -p #{@paths.first}}
    self[:iteration] = %x{rpm -q --qf '%{release}' -p #{@paths.first}}
    self[:summary] = %x{rpm -q --qf '%{summary}' -p #{@paths.first}}
    #self[:description] = %x{rpm -q --qf '%{description}' -p #{@paths.first}}
    self[:dependencies] = %x{rpm -qRp #{@paths.first}}.split("\n")\
      .collect { |line| line.strip }

    @rpm = @paths.first
    @paths = %x{rpm -qlp #{@paths.first}}.split("\n")

  end

  def make_tarball!(tar_path, builddir)
    tmpdir = "#{tar_path}.dir"
    ::Dir.mkdir(tmpdir)
    system("rpm2cpio #{@rpm} | (cd #{tmpdir}; cpio -i --make-directories)")
    tar(tar_path, ".", tmpdir)



    # TODO(sissel): Make a helper method.
    system(*["gzip", "-f", tar_path])
  end
end




>
|

|
|
|
|
|


<
|
<







>
>





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
require "fpm/source"

class FPM::Source::RPM < FPM::Source
  def get_metadata
    @rpm = @paths.first
    self[:name] = %x{rpm -q --qf '%{name}' -p #{@rpm}}

    self[:version] = %x{rpm -q --qf '%{version}' -p #{@rpm}}
    self[:iteration] = %x{rpm -q --qf '%{release}' -p #{@rpm}}
    self[:summary] = %x{rpm -q --qf '%{summary}' -p #{@rpm}}
    #self[:description] = %x{rpm -q --qf '%{description}' -p #{@rpm}}
    self[:dependencies] = %x{rpm -qRp #{@rpm}}.split("\n")\
      .collect { |line| line.strip }


    @paths = %x{rpm -qlp #{@rpm}}.split("\n")

  end

  def make_tarball!(tar_path, builddir)
    tmpdir = "#{tar_path}.dir"
    ::Dir.mkdir(tmpdir)
    system("rpm2cpio #{@rpm} | (cd #{tmpdir}; cpio -i --make-directories)")
    tar(tar_path, ".", tmpdir)
    @paths = "."
    @root = tmpdir

    # TODO(sissel): Make a helper method.
    system(*["gzip", "-f", tar_path])
  end
end

Changes to lib/fpm/target/deb.rb.

120
121
122
123
124
125
126
127
128
      nextversion[2] = 0
      nextversion = nextversion.join(".")
      return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
    else
      return dep
    end
  end # def fix_dependency
end # class FPM::Deb








|

120
121
122
123
124
125
126
127
128
      nextversion[2] = 0
      nextversion = nextversion.join(".")
      return ["#{name} (>= #{version})", "#{name} (<< #{nextversion})"]
    else
      return dep
    end
  end # def fix_dependency
end # class FPM::Target::Deb

Changes to lib/fpm/target/puppet.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
require "erb"
require "fpm/namespace"
require "fpm/package"
require "fpm/errors"




# TODO(sissel): Add dependency checking support.
# IIRC this has to be done as a 'checkinstall' step.
class FPM::Target::Puppet < FPM::Package
  def architecture
    case @architecture
    when nil, "native"
      @architecture = %x{uname -m}.chomp
    end
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/pacakge.pp"
  end # def specfile





  def build!(params)

    self.scripts.each do |name, path|
      case name
        when "pre-install"
        when "post-install"
        when "pre-uninstall"
        when "post-uninstall"
      end # case name
    end # self.scripts.each

    # Unpack data.tar.gz
    Dir.mkdir("files")



    Dir.mkdir("manifests")
    system("gzip -d data.tar.gz");
    Dir.chdir("files") { system("tar -xf ../data.tar") }


    # Files are now in the 'files' path
    # Generate a manifest 'package.pp' with all the information from
  end # def build!



  def default_output
    v = version

    v = "#{epoch}:#{v}" if epoch
    if iteration




      "#{name}_#{v}-#{iteration}_#{architecture}.#{type}"








    else

      "#{name}_#{v}_#{architecture}.#{type}"








    end
  end # def default_output
end # class FPM::Deb





>
>
>













|


>
>
>
>

>









<
|
>
>
>
|
<
<
|
>




>
>

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

|
|

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
require "erb"
require "fpm/namespace"
require "fpm/package"
require "fpm/errors"
require "etc"

require "fileutils" # for FileUtils

# TODO(sissel): Add dependency checking support.
# IIRC this has to be done as a 'checkinstall' step.
class FPM::Target::Puppet < FPM::Package
  def architecture
    case @architecture
    when nil, "native"
      @architecture = %x{uname -m}.chomp
    end
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/package.pp"
  end # def specfile

  def unpack_data_to
    "files"
  end

  def build!(params)
    # TODO(sissel): Support these somehow, perhaps with execs and files.
    self.scripts.each do |name, path|
      case name
        when "pre-install"
        when "post-install"
        when "pre-uninstall"
        when "post-uninstall"
      end # case name
    end # self.scripts.each


    Dir.mkdir(params[:output])
    builddir = Dir.pwd

    Dir.chdir(params[:output]) do
      Dir.mkdir("manifests")


      FileUtils.cp(specfile(builddir), "manifests")
    end
    # Files are now in the 'files' path
    # Generate a manifest 'package.pp' with all the information from
  end # def build!

  # The directory we create should just be the name of the package as the
  # module name
  def default_output
    name
  end # def default_output

  def puppetsort(hash)
    # TODO(sissel): Implement sorting that follows the puppet style guide
    # Such as, 'ensure' goes first, etc.
    return hash.to_a
  end # def puppetsort

  def uid2user(uid)
    begin
      pwent = Etc.getpwuid(uid)
      return pwent.name
    rescue ArgumentError => e
      # Invalid user id? No user? Return the uid.
      @logger.warn("Failed to find username for uid #{uid}")
      return uid.to_s
    end
  end # def uid2user

  def gid2group(gid)
    begin
      grent = Etc.getgrgid(gid)
      return grent.name
    rescue ArgumentError => e
      # Invalid user id? No user? Return the uid.
      @logger.warn("Failed to find group for gid #{gid}")
      return gid.to_s
    end
  end # def uid2user
end # class FPM::Target::Puppet

Changes to lib/fpm/target/rpm.rb.

41
42
43
44
45
46
47
48
49
50
      raise "rpmbuild failed (exit code: #{$?.exitstatus})"
    end

    Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
      # This should only output one rpm, should we verify this?
      system("mv", path, params[:output])
    end

  end
end







|
|
<
41
42
43
44
45
46
47
48
49

      raise "rpmbuild failed (exit code: #{$?.exitstatus})"
    end

    Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
      # This should only output one rpm, should we verify this?
      system("mv", path, params[:output])
    end
  end # def build!
end # class FPM::Target::RPM

Changes to templates/deb.erb.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Package: <%= name %>
Version: <%= "#{epoch}:" if epoch %><%= version %><%= iteration && '-'+iteration.to_s %>
Architecture: <%= architecture %>
Maintainer: <%= maintainer or "<unknown>" %>
<% if !dependencies.empty? %>
<%   properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten %>
Depends: <%= properdeps.flatten.join(", ") %>
<% end %>
<% if !provides.empty? %>
Provides: <%= provides.join(", ") %>
<% end %>
<% if !replaces.empty? %>
<%   properrepl = replaces.collect { |d| fix_dependency(d) }.flatten %>
Replaces: <%= properrepl.flatten.join(", ") %>
<% end %>
Standards-Version: 3.9.1
Section: <%= category or "unknown" %> 
Priority: extra
Homepage: <%= url or "http://nourlgiven.example.com/" %>
Description: <%= description or "no description given" %>





|
|

|
|
|
|
|
|

|






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Package: <%= name %>
Version: <%= "#{epoch}:" if epoch %><%= version %><%= iteration && '-'+iteration.to_s %>
Architecture: <%= architecture %>
Maintainer: <%= maintainer or "<unknown>" %>
<% if !dependencies.empty? -%>
<%   properdeps = dependencies.collect { |d| fix_dependency(d) }.flatten -%>
Depends: <%= properdeps.flatten.join(", ") %>
<% end -%>
<% if !provides.empty? -%>
Provides: <%= provides.join(", ") -%>
<% end -%>
<% if !replaces.empty? -%>
<%   properrepl = replaces.collect { |d| fix_dependency(d) }.flatten -%>
Replaces: <%= properrepl.flatten.join(", ") %>
<% end -%>
Standards-Version: 3.9.1
Section: <%= category or "unknown" %> 
Priority: extra
Homepage: <%= url or "http://nourlgiven.example.com/" %>
Description: <%= description or "no description given" %>

Changes to templates/puppet.erb.


1


2
3
4












5











6
7
8

class <%= name %>::package {



  file {
<% @source.paths.each do |path| %>












    "<%= path %>":











<% end %>

}
>

>
>


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

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
# TODO(sissel): implement 'anti' class for this package.
class <%= name %>::package {
  $version = "<%= version %>"
  $iteration = "<%= iteration %>"

  file {
<% paths.each do |path|
     stat = File.lstat(path)
     params = {}
     if stat.directory?
       params[:ensure] = "directory"
     elsif stat.symlink?
       params[:ensure] = "link"
       params[:target] = File.readlink(path)
       stat = File.stat(path)
     else
       params[:ensure] = "file"
       params[:source] = "puppet:///modules/#{name}/#{path}"
     end

     if params[:ensure] != "link"
       params[:owner] = uid2user(stat.uid)
       params[:group] = gid2group(stat.gid)
       params[:mode] = sprintf("%04o", stat.mode & 0777)
     end

     settings = puppetsort(params).collect { |k,v| "#{k} => \"#{v}\"" }.join(",\n      ")
-%>
    # <%= stat.inspect %>
    "<%= fixpath(path) %>":
      <%= settings %>;
<% end # paths.each -%>
  }
}

Changes to templates/rpm.erb.

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
Name: <%= name %>
Version: <%= version %>
<% if epoch %>
Epoch: <%= epoch %>
<% end %>
Release: <%= iteration or 1 %>
<%# use the first line of the description as the summary %>
Summary: <%= description.split("\n").first %>
BuildArch: <%= architecture %>
AutoReqProv: no

Group: <%= category %>
<%#
TODO: [Jay] rpms require a license
let's detect it intelligently
%>
License: <%= license %> 
URL: <%= url or "http://nourlgiven.example.com/" %>
Source0:  %{_sourcedir}/data.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

<% if !dependencies.empty? %>
<%
  properdeps = dependencies.collect do |d|
    # Convert gem ~> X.Y.Z to '>= X.Y.Z' and < X.Y+1.0
    if d =~ /\~>/
      name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
      nextversion = version.split(".").collect { |v| v.to_i }
      nextversion[1] += 1
      nextversion[2] = 0 
      nextversion = nextversion.join(".")
      ["#{name} >= #{version}", "#{name} < #{nextversion}"]
    # Convert gem >= A.B.C <= X.Y.Z to '>= A.B.C' and '<= X.Y.Z'
    elsif d =~ /\d [<>]=? \d/
      puts d
      # split out version numbers with their equality sign
      name, lower_version, upper_version = d.scan(/([\w-]+) ([<>]=? [\d\.]+) ([<>]=? [\d\.]+)/)[0]
      ["#{name} #{lower_version}", "#{name} #{upper_version}"]
    else
      d
    end
  end
%>Requires: <%= properdeps.join(", ") %>
<% end %>
<% provides.each do |prov| %>
Provides: <%= prov %>
<% end %>

<%# The closes equivalent in RPM to "replaces" is "Obsoletes" %>
<% replaces.each do |repl| %>
Obsoletes: <%= repl %>
<% end %>

<%# rpm rejects descriptions with blank lines (even between content), so hack
    around it by replacing blank lines with ' .' %>
%description
<%= description.gsub(/^\s*$/, " .") %>

%prep
# noop

%build
# some rpm implementations delete the build dir and then recreate it by
# default, for some reason. Whatever, let's work around it.
cd $RPM_BUILD_ROOT
tar -zxf %SOURCE0

%install
#noop

%clean
rm -rf $RPM_BUILD_ROOT

<% if scripts["pre-install"] %>
%pre
<%= File.read(scripts["pre-install"]) %>
<% end %>


<% if scripts["post-install"] %>
%post
<%= File.read(scripts["post-install"]) %>
<% end %>


<% if scripts["pre-uninstall"] %>
%preun
<%= File.read(scripts["pre-uninstall"]) %>
<% end %>


<% if scripts["post-uninstall"] %>
%postun
<%= File.read(scripts["post-uninstall"]) %>
<% end %>


%files
%defattr(-,root,root,-)
<%# Trim leading '.' from paths if they are './blah...' %>
<%# Also ensure paths start with '/' %>
<%= @source.paths.collect { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }.join("\n") %>

%changelog


|

|

|








|





|




















|
|
|

|
>
|
<

|
<

|


















|


<

>
|


<

>
|


<

>
|


<

>


|
|



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
Name: <%= name %>
Version: <%= version %>
<% if epoch -%>
Epoch: <%= epoch %>
<% end -%>
Release: <%= iteration or 1 %>
<%# use the first line of the description as the summary -%>
Summary: <%= description.split("\n").first %>
BuildArch: <%= architecture %>
AutoReqProv: no

Group: <%= category %>
<%#
TODO: [Jay] rpms require a license
let's detect it intelligently
-%>
License: <%= license %> 
URL: <%= url or "http://nourlgiven.example.com/" %>
Source0:  %{_sourcedir}/data.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

<% if !dependencies.empty? -%>
<%
  properdeps = dependencies.collect do |d|
    # Convert gem ~> X.Y.Z to '>= X.Y.Z' and < X.Y+1.0
    if d =~ /\~>/
      name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
      nextversion = version.split(".").collect { |v| v.to_i }
      nextversion[1] += 1
      nextversion[2] = 0 
      nextversion = nextversion.join(".")
      ["#{name} >= #{version}", "#{name} < #{nextversion}"]
    # Convert gem >= A.B.C <= X.Y.Z to '>= A.B.C' and '<= X.Y.Z'
    elsif d =~ /\d [<>]=? \d/
      puts d
      # split out version numbers with their equality sign
      name, lower_version, upper_version = d.scan(/([\w-]+) ([<>]=? [\d\.]+) ([<>]=? [\d\.]+)/)[0]
      ["#{name} #{lower_version}", "#{name} #{upper_version}"]
    else
      d
    end
  end
-%>Requires: <%= properdeps.join(", ") %>
<% end -%>
<% provides.each do |prov| -%>
Provides: <%= prov %>
<% end -%>
<% replaces.each do |repl| -%>
<%# The closes equivalent in RPM to "replaces" is "Obsoletes" -%>

Obsoletes: <%= repl %>
<% end -%>

<%# rpm rejects descriptions with blank lines (even between content), so hack
    around it by replacing blank lines with ' .' -%>
%description
<%= description.gsub(/^\s*$/, " .") %>

%prep
# noop

%build
# some rpm implementations delete the build dir and then recreate it by
# default, for some reason. Whatever, let's work around it.
cd $RPM_BUILD_ROOT
tar -zxf %SOURCE0

%install
#noop

%clean
rm -rf $RPM_BUILD_ROOT

<% if scripts["pre-install"] -%>
%pre
<%= File.read(scripts["pre-install"]) %>


<% end -%>
<% if scripts["post-install"] -%>
%post
<%= File.read(scripts["post-install"]) %>


<% end -%>
<% if scripts["pre-uninstall"] -%>
%preun
<%= File.read(scripts["pre-uninstall"]) %>


<% end -%>
<% if scripts["post-uninstall"] -%>
%postun
<%= File.read(scripts["post-uninstall"]) %>


<% end -%>
%files
%defattr(-,root,root,-)
<%# Trim leading '.' from paths if they are './blah...' -%>
<%# Also ensure paths start with '/' -%>
<%= @source.paths.collect { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }.join("\n") %>

%changelog

Changes to templates/solaris.erb.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CLASSES=none
BASEDIR=/usr/local
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=<%= name %>
NAME=<%= name %>
ARCH=<%= architecture %>
VERSION=<%= version %><%= iteration && "-" + iteration.to_s %>
CATEGORY=application
<%# pkginfo(4) says DESC is max 256 characters %>
DESC=<%= description.split("\n").first[0..255] or "no description given" %>
VENDOR=<%= maintainer %>
<%# Take maintainer of "Foo <bar@baz.com>" and use "bar@baz.com" %>
EMAIL=<%= maintainer[/<.+>/].gsub(/[<>]/, "") %>










|


|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CLASSES=none
BASEDIR=/usr/local
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
PKG=<%= name %>
NAME=<%= name %>
ARCH=<%= architecture %>
VERSION=<%= version %><%= iteration && "-" + iteration.to_s %>
CATEGORY=application
<%# pkginfo(4) says DESC is max 256 characters -%>
DESC=<%= description.split("\n").first[0..255] or "no description given" %>
VENDOR=<%= maintainer %>
<%# Take maintainer of "Foo <bar@baz.com>" and use "bar@baz.com" -%>
EMAIL=<%= maintainer[/<.+>/].gsub(/[<>]/, "") %>