Class: Omnibus::Packager::PKGSRC

Inherits:
Base
  • Object
show all
Defined in:
lib/omnibus/packagers/pkgsrc.rb

Constant Summary collapse

PKGTOOLS_VERSION =
"20091115".freeze

Constants included from Util

Util::SHELLOUT_OPTIONS

Constants included from NullArgumentable

NullArgumentable::NULL

Instance Attribute Summary

Attributes inherited from Base

#project

Instance Method Summary collapse

Methods inherited from Base

build, #exclusions, id, #id, #initialize, #install_dir, #package_path, #resource_path, #resources_path, #run!, setup, #skip_packager, #staging_dir, #staging_dir_path

Methods included from Util

#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #shellout, #shellout!, #windows_safe_path

Methods included from Templating

included, #render_template, #render_template_content

Methods included from Sugarable

extended, included, #node

Methods included from NullArgumentable

included, #null?

Methods included from Logging

included

Methods included from Instrumentation

#measure

Methods included from Digestable

#digest, #digest_directory, included

Constructor Details

This class inherits a constructor from Omnibus::Packager::Base

Instance Method Details

#build_infoObject



31
32
33
# File 'lib/omnibus/packagers/pkgsrc.rb', line 31

def build_info
  staging_dir_path("build-info")
end

#build_verObject



35
36
37
# File 'lib/omnibus/packagers/pkgsrc.rb', line 35

def build_ver
  staging_dir_path("build-ver")
end

#comment_fileObject



39
40
41
# File 'lib/omnibus/packagers/pkgsrc.rb', line 39

def comment_file
  staging_dir_path("comment")
end

#create_pkgObject



47
48
49
50
51
52
# File 'lib/omnibus/packagers/pkgsrc.rb', line 47

def create_pkg
  postinst = "#{project.package_scripts_path}/postinst"
  postrm = "#{project.package_scripts_path}/postrm"

  shellout! "cd #{Config.package_dir} && pkg_create -i #{postinst} -k #{postrm} -p  #{project.install_dir} -b #{build_ver} -B #{build_info} -c #{comment_file} -d #{comment_file} -f #{pack_list} -I #{project.install_dir} -l -U #{package_name}"
end

#opsysObject



91
92
93
# File 'lib/omnibus/packagers/pkgsrc.rb', line 91

def opsys
  Ohai["kernel"]["name"]
end

#os_versionObject



95
96
97
# File 'lib/omnibus/packagers/pkgsrc.rb', line 95

def os_version
  Ohai["kernel"]["release"]
end

#pack_listObject



43
44
45
# File 'lib/omnibus/packagers/pkgsrc.rb', line 43

def pack_list
  staging_dir_path("packlist")
end

#package_nameObject



54
55
56
# File 'lib/omnibus/packagers/pkgsrc.rb', line 54

def package_name
  "#{project.package_name}-#{project.build_version}.tgz"
end

#safe_architectureObject



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/omnibus/packagers/pkgsrc.rb', line 99

def safe_architecture
  if smartos?
    if Ohai["kernel"]["update"] == "86_64"
      "x86_64"
    else
      "i386"
    end
  else
    # FIXME: this undoubtedly will need filling out once we make this go for platforms that aren't SmartOS
    Ohai["kernel"]["machine"]
  end
end

#write_buildinfoObject



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/omnibus/packagers/pkgsrc.rb', line 64

def write_buildinfo
  buildinfo_content = <<~EOF
    MACHINE_ARCH=#{safe_architecture}
    OPSYS=#{opsys}
    OS_VERSION=#{os_version}
    PKGTOOLS_VERSION=#{PKGTOOLS_VERSION}
  EOF

  File.open(build_info, "w+") do |f|
    f.write(buildinfo_content)
  end
end

#write_buildverObject



58
59
60
61
62
# File 'lib/omnibus/packagers/pkgsrc.rb', line 58

def write_buildver
  File.open build_ver, "w+" do |f|
    f.write"#{project.build_version}-#{project.build_iteration}"
  end
end

#write_commentObject



77
78
79
80
81
# File 'lib/omnibus/packagers/pkgsrc.rb', line 77

def write_comment
  File.open(comment_file, "w+") do |f|
    f.write(project.description)
  end
end

#write_packlistObject



83
84
85
86
87
88
89
# File 'lib/omnibus/packagers/pkgsrc.rb', line 83

def write_packlist
  File.open pack_list, "w+" do |f|
    f.write "@pkgdir #{project.install_dir}\n@cwd #{project.install_dir}/\n"
  end

  shellout! "cd #{project.install_dir} && find . -type l -or -type f | sort >> #{pack_list}"
end