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

⌈⌋ ⎇ branch:  cross package maker


Check-in [f2cccfbef7]

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

Overview
Comment:Merge pull request #299 from exoscale/bugfix-solaris Restore solaris package building
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f2cccfbef789c31a363e15cddf7557e833314533
User & Date: jls@semicomplete.com 2012-11-28 17:14:56
Context
2012-11-30
07:18
Add pip support. check-in: 4de957e3d6 user: jls@semicomplete.com tags: trunk
2012-11-29
12:53
Add multiple provides correctly check-in: d949d8a0a3 user: pranay.kanwar@gmail.com tags: trunk
07:58
Add deb and rpm changelog support check-in: 270447e39d user: pranay.kanwar@gmail.com tags: trunk
2012-11-28
17:14
Merge pull request #299 from exoscale/bugfix-solaris Restore solaris package building check-in: f2cccfbef7 user: jls@semicomplete.com tags: trunk
10:17
Restore solaris package building I'm not sure all cases are correctly handled but previously no package at all would be built check-in: a41122a416 user: exoadmin@OI-Build.(none) tags: trunk
06:03
- I forgot a cardinal rule! Never use 'or' in ruby. check-in: 227f7f35db user: jls@semicomplete.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/fpm/package/solaris.rb.

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
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/pkginfo"
  end

  def build!(params)
    self.scripts.each do |name, path|
      case name
        when "pre-install"
          safesystem("cp #{path} ./preinstall")
          File.chmod(0755, "./preinstall")
        when "post-install"
          safesystem("cp #{path} ./postinstall")
          File.chmod(0755, "./postinstall")
        when "pre-uninstall"
          raise FPM::InvalidPackageConfiguration.new(
            "pre-uninstall is not supported by Solaris packages"
          )
        when "post-uninstall"
          raise FPM::InvalidPackageConfiguration.new(
            "post-uninstall is not supported by Solaris packages"
          )
      end # case name
    end # self.scripts.each

    # Unpack data.tar.gz so we can build a package from it.
    Dir.mkdir("data")
    safesystem("gzip -d data.tar.gz");
    Dir.chdir("data") do
      safesystem("tar -xf ../data.tar");
    end

    #system("(echo 'i pkginfo'; pkgproto data=/) > Prototype")

    # Generate the package 'Prototype' file
    # TODO(sissel): allow setting default file owner.
    File.open("Prototype", "w") do |prototype|
      prototype.puts("i pkginfo")
      prototype.puts("i preinstall") if self.scripts["pre-install"]
      prototype.puts("i postinstall") if self.scripts["post-install"]

      # TODO(sissel): preinstall/postinstall
      # strip @prefix, since BASEDIR will set prefix via the pkginfo file
      IO.popen("pkgproto data/#{@prefix}=").each_line do |line|
        type, klass, path, mode, user, group = line.split
        # Override stuff in pkgproto
        # TODO(sissel): Make this tunable?
        user = "root"
        group = "root"
        prototype.puts([type, klass, path, mode, user, group].join(" "))
      end # popen "pkgproto ..."
    end # File prototype


    # Should create a package directory named by the package name.
    safesystem("pkgmk -o -d .")



    # Convert the 'package directory' built above to a real solaris package.
    safesystem("pkgtrans -s . #{params[:output]} #{name}")

  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








|



|


|












|
|
|
<
<


<
<


|






|









>
|
|
>
|
>

|
>
|












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
    return @architecture
  end # def architecture

  def specfile(builddir)
    "#{builddir}/pkginfo"
  end

  def output(output_path)
    self.scripts.each do |name, path|
      case name
        when "pre-install"
          safesystem("cp", path, "./preinstall")
          File.chmod(0755, "./preinstall")
        when "post-install"
          safesystem("cp", path, "./postinstall")
          File.chmod(0755, "./postinstall")
        when "pre-uninstall"
          raise FPM::InvalidPackageConfiguration.new(
            "pre-uninstall is not supported by Solaris packages"
          )
        when "post-uninstall"
          raise FPM::InvalidPackageConfiguration.new(
            "post-uninstall is not supported by Solaris packages"
          )
      end # case name
    end # self.scripts.each

    template = template("solaris.erb")
    File.open("#{build_path}/pkginfo", "w") do |pkginfo|
      pkginfo.puts template.result(binding)


    end



    # Generate the package 'Prototype' file
    # TODO(sissel): allow setting default file owner.
    File.open("#{build_path}/Prototype", "w") do |prototype|
      prototype.puts("i pkginfo")
      prototype.puts("i preinstall") if self.scripts["pre-install"]
      prototype.puts("i postinstall") if self.scripts["post-install"]

      # TODO(sissel): preinstall/postinstall
      # strip @prefix, since BASEDIR will set prefix via the pkginfo file
      IO.popen("pkgproto #{staging_path}/#{@prefix}=").each_line do |line|
        type, klass, path, mode, user, group = line.split
        # Override stuff in pkgproto
        # TODO(sissel): Make this tunable?
        user = "root"
        group = "root"
        prototype.puts([type, klass, path, mode, user, group].join(" "))
      end # popen "pkgproto ..."
    end # File prototype

    ::Dir.chdir staging_path do
      # Should create a package directory named by the package name.
      safesystem("pkgmk", "-o", "-f", "#{build_path}/Prototype", "-d", build_path)
    end
    

    # Convert the 'package directory' built above to a real solaris package.
    safesystem("pkgtrans", "-s", build_path, output_path, name)
    safesystem("cp", "#{build_path}/#{output_path}", output_path)
  end # def output

  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

Changes to templates/solaris.erb.

1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
CLASSES=none
BASEDIR=<%= prefix %>
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[/<.+>/] or maintainer).gsub(/[<>]/, "") %>


<


>











1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
CLASSES=none

TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
BASEDIR=/
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[/<.+>/] or maintainer).gsub(/[<>]/, "") %>