Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to using pkgmk for solaris #72

Merged
merged 2 commits into from
Sep 20, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 59 additions & 6 deletions lib/omnibus/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def package_types
when 'aix'
[ "bff" ]
when 'solaris2'
[ "solaris" ]
[ "pkgmk" ]
when 'windows'
[ "msi" ]
else
Expand Down Expand Up @@ -461,6 +461,8 @@ def output_package(pkg_type)
"#{package_name}-#{build_version}-#{iteration}.msi"
when "bff"
"#{package_name}.#{bff_version}.bff"
when "pkgmk"
"#{package_name}-#{build_version}-#{iteration}.solaris"
else # fpm
require "fpm/package/#{pkg_type}"
pkg = FPM::Package.types[pkg_type].new
Expand Down Expand Up @@ -507,6 +509,11 @@ def bff_command
[bff_command.join(" "), {:returns => [0]}]
end

def pkgmk_command
pkgmk_command = ["pkgmk -o -r / -d /tmp/pkgmk -f /tmp/pkgmk/Prototype"]
[pkgmk_command.join(" "), {:returns => [0]}]
end

# The {https://github.com/jordansissel/fpm fpm} command to
# generate a package for RedHat, Ubuntu, Solaris, etc. platforms.
#
Expand Down Expand Up @@ -537,15 +544,15 @@ def fpm_command(pkg_type)
end

if File.exist?("#{package_scripts_path}/postinst")
command_and_opts << "--post-install '#{package_scripts_path}/postinst'"
command_and_opts << "--after-install '#{File.join(package_scripts_path, "postinst")}'"
end
# solaris packages don't support --pre-uninstall
if File.exist?("#{package_scripts_path}/prerm") && pkg_type != "solaris"
command_and_opts << "--pre-uninstall '#{package_scripts_path}/prerm'"
if File.exist?("#{package_scripts_path}/prerm")
command_and_opts << "--before-remove '#{File.join(package_scripts_path, "prerm")}'"
end
# solaris packages don't support --post-uninstall
if File.exist?("#{package_scripts_path}/postrm") && pkg_type != "solaris"
command_and_opts << "--post-uninstall '#{package_scripts_path}/postrm'"
if File.exist?("#{package_scripts_path}/postrm")
command_and_opts << "--after-remove '#{File.join(package_scripts_path, "postrm")}'"
end

@exclusions.each do |pattern|
Expand Down Expand Up @@ -625,6 +632,50 @@ def run_bff
FileUtils.cp "/tmp/chef.#{bff_version}.bff", "/var/cache/omnibus/pkg/chef.#{bff_version}.bff"
end

def run_pkgmk
system "sudo rm -rf /tmp/pkgmk"
FileUtils.mkdir "/tmp/pkgmk"

system "find #{install_path} -print > /tmp/pkgmk/files"

File.open "/tmp/pkgmk/Prototype", "w+" do |f|
f.write <<-EOF
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think this bit would be easier to read to store the heredoc value into a local variable and then write it out to file in a subsequent step. What's confusing is the f.write <<-EOF nested stuff.

i pkginfo
i postinstall
i postremove
EOF
end

system "pkgproto < /tmp/pkgmk/files >> /tmp/pkgmk/Prototype"

File.open "/tmp/pkgmk/pkginfo", "w+" do |f|
f.write <<-EOF
CLASSES=none
TZ=PST
PATH=/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin
BASEDIR=/
PKG=chef
NAME=chef
ARCH=sparc
VERSION=11.8.0.alpha.0-166-g918ae91-1.solaris2.5.9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, that is still hardcoded... along with the PSTAMP later...

CATEGORY=application
DESC=The full stack of chef
VENDOR=Opscode, Inc.
EMAIL=Opscode, Inc.
PSTAMP=build-oss-sol9-sparc20130913220319
EOF
end

FileUtils.cp "#{package_scripts_path}/postinst", "/tmp/pkgmk/postinstall"
FileUtils.cp "#{package_scripts_path}/postrm", "/tmp/pkgmk/postremove"

run_package_command(pkgmk_command)

system "pkgchk -vd /tmp/pkgmk chef"

system "pkgtrans /tmp/pkgmk /var/cache/omnibus/pkg/#{output_package("pkgmk")} chef"
end

# Runs the necessary command to make a package with fpm. As a side-effect,
# sets `output_package`
# @return void
Expand Down Expand Up @@ -676,6 +727,8 @@ def render_tasks
run_msi
elsif pkg_type == "bff"
run_bff
elsif pkg_type == "pkgmk"
run_pkgmk
else # pkg_type == "fpm"
run_fpm(pkg_type)
end
Expand Down