Class: Vanagon::Platform::RPM
- Inherits:
-
Vanagon::Platform
- Object
- Vanagon::Platform
- Vanagon::Platform::RPM
- Defined in:
- lib/vanagon/platform/rpm.rb,
lib/vanagon/platform/rpm/aix.rb,
lib/vanagon/platform/rpm/eos.rb,
lib/vanagon/platform/rpm/wrl.rb,
lib/vanagon/platform/rpm/sles.rb
Defined Under Namespace
Constant Summary
Constants inherited from Vanagon::Platform
Instance Attribute Summary
Attributes inherited from Vanagon::Platform
#abs_resource_name, #architecture, #aws_ami, #aws_instance_type, #aws_key, #aws_key_name, #aws_region, #aws_shutdown_behavior, #aws_subnet_id, #aws_user_data, #aws_vpc_id, #build_dependencies, #build_hosts, #cflags, #codename, #copy, #cross_compiled, #defaultdir, #dist, #docker_image, #environment, #find, #install, #ldflags, #make, #name, #num_cores, #os_name, #os_version, #package_type, #patch, #platform_triple, #provisioning, #rpmbuild, #servicedir, #servicetype, #settings, #shell, #sort, #ssh_port, #tar, #target_user, #vmpooler_template
Instance Method Summary collapse
-
#add_repository(definition) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#generate_package(project) ⇒ Array
The specific bits used to generate an rpm package for a given project.
-
#generate_packaging_artifacts(workdir, name, binding) ⇒ Object
Method to generate the files required to build an rpm package for the project.
-
#initialize(name) ⇒ Vanagon::Platform::RPM
constructor
Constructor.
- #output_dir(target_repo = "products") ⇒ Object
-
#package_name(project) ⇒ String
Method to derive the package name for the project.
-
#package_override(project, var) ⇒ Object
Pass in a packaging override.
- #rpm_defines ⇒ Object
-
#source_output_dir(target_repo = "products") ⇒ Object
Method to derive the directory for source artifacts.
Methods inherited from Vanagon::Platform
#[], #add_build_repository, #add_group, #add_user, #is_aix?, #is_cisco_wrlinux?, #is_cross_compiled?, #is_cross_compiled_linux?, #is_deb?, #is_el?, #is_eos?, #is_fedora?, #is_huaweios?, #is_linux?, #is_macos?, #is_osx?, #is_rpm?, #is_sles?, #is_solaris?, #is_unix?, #is_windows?, load_platform, #provision_with
Methods included from HashableAttributes
Constructor Details
#initialize(name) ⇒ Vanagon::Platform::RPM
Constructor. Sets up some defaults for the rpm platform and calls the parent constructor
101 102 103 104 105 106 107 108 109 |
# File 'lib/vanagon/platform/rpm.rb', line 101 def initialize(name) @name = name @make ||= "/usr/bin/make" @tar ||= "tar" @patch ||= "/usr/bin/patch" @num_cores ||= "/bin/grep -c 'processor' /proc/cpuinfo" @rpmbuild ||= "/usr/bin/rpmbuild" super(name) end |
Instance Method Details
#add_repository(definition) ⇒ Object
rubocop:disable Metrics/AbcSize
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vanagon/platform/rpm.rb', line 66 def add_repository(definition) # rubocop:disable Metrics/AbcSize definition = URI.parse(definition) commands = ["rpm -q curl > /dev/null || yum -y install curl"] if definition.scheme =~ /^(http|ftp)/ if File.extname(definition.path) == '.rpm' # repo definition is an rpm (like puppetlabs-release) commands << "curl -o local.rpm '#{definition}'; rpm -Uvh local.rpm; rm -f local.rpm" else reponame = "#{SecureRandom.hex}-#{File.basename(definition.path)}" reponame = "#{reponame}.repo" if File.extname(reponame) != '.repo' if is_cisco_wrlinux? commands << "curl -o '/etc/yum/repos.d/#{reponame}' '#{definition}'" else commands << "curl -o '/etc/yum.repos.d/#{reponame}' '#{definition}'" end end end commands end |
#generate_package(project) ⇒ Array
The specific bits used to generate an rpm package for a given project
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vanagon/platform/rpm.rb', line 11 def generate_package(project) # rubocop:disable Metrics/AbcSize target_dir = project.repo ? output_dir(project.repo) : output_dir target_source_output_dir = project.repo ? source_output_dir(project.repo) : source_output_dir if project.source_artifacts rpmbuild = "#{@rpmbuild} -ba" artifact_copy = "mkdir -p output/#{target_source_output_dir}; cp $(tempdir)/rpmbuild/RPMS/**/*.rpm ./output/#{target_dir}; cp $(tempdir)/rpmbuild/SRPMS/*.rpm ./output/#{target_source_output_dir}" else rpmbuild = "#{@rpmbuild} -bb" artifact_copy = "cp $(tempdir)/rpmbuild/*RPMS/**/*.rpm ./output/#{target_dir}" end ["bash -c 'mkdir -p $(tempdir)/rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS}'", "cp #{project.name}-#{project.version}.tar.gz $(tempdir)/rpmbuild/SOURCES", "cp file-list-for-rpm $(tempdir)/rpmbuild/SOURCES", "cp #{project.name}.spec $(tempdir)/rpmbuild/SPECS", "PATH=/opt/freeware/bin:$$PATH #{rpmbuild} --target #{@architecture} #{rpm_defines} $(tempdir)/rpmbuild/SPECS/#{project.name}.spec", "mkdir -p output/#{target_dir}", artifact_copy] end |
#generate_packaging_artifacts(workdir, name, binding) ⇒ Object
Method to generate the files required to build an rpm package for the project
36 37 38 |
# File 'lib/vanagon/platform/rpm.rb', line 36 def generate_packaging_artifacts(workdir, name, binding) erb_file(File.join(VANAGON_ROOT, "resources/rpm/project.spec.erb"), File.join(workdir, "#{name}.spec"), false, { :binding => binding }) end |
#output_dir(target_repo = "products") ⇒ Object
48 49 50 |
# File 'lib/vanagon/platform/rpm.rb', line 48 def output_dir(target_repo = "products") super end |
#package_name(project) ⇒ String
Method to derive the package name for the project
44 45 46 |
# File 'lib/vanagon/platform/rpm.rb', line 44 def package_name(project) "#{project.name}-#{project.version}-#{project.release}.#{project.noarch ? 'noarch' : @architecture}.rpm" end |
#package_override(project, var) ⇒ Object
Pass in a packaging override. This will get added to the spec file, and is a good way to pass in arbitrary ‘%_define` or `%_global`
93 94 95 |
# File 'lib/vanagon/platform/rpm.rb', line 93 def package_override(project, var) project.package_overrides << var end |
#rpm_defines ⇒ Object
59 60 61 62 63 64 |
# File 'lib/vanagon/platform/rpm.rb', line 59 def rpm_defines defines = %(--define '_topdir $(tempdir)/rpmbuild' ) # RPM doesn't allow dashes in the os_name. This was added to # convert cisco-wrlinux to cisco_wrlinux defines << %(--define 'dist .#{dist}') end |
#source_output_dir(target_repo = "products") ⇒ Object
Method to derive the directory for source artifacts
55 56 57 |
# File 'lib/vanagon/platform/rpm.rb', line 55 def source_output_dir(target_repo = "products") @source_output_dir ||= File.join(@os_name, @os_version, target_repo, 'SRPMS') end |