Sha256: 857c80b736aa9a5b605e78b9ed80fe300240bfa39142dfcc6cb63e33a693b958
Contents?: true
Size: 1.98 KB
Versions: 2
Compression:
Stored size: 1.98 KB
Contents
# # Copyright 2010 Red Hat, Inc. # # This is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 3 of # the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this software; if not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA, or see the FSF site: http://www.fsf.org. module BoxGrinder class PackageHelper def initialize(config, appliance_config, dir, options = {}) @config = config @appliance_config = appliance_config @dir = dir @log = options[:log] || Logger.new(STDOUT) @exec_helper = options[:exec_helper] || ExecHelper.new({:log => @log}) end def package(dir, package, type = :tar) if File.exists?(package) @log.info "Package of #{type} type for #{@appliance_config.name} appliance already exists, skipping." return package end @log.info "Packaging #{@appliance_config.name} appliance to #{type}..." case type when :tar package_name = File.basename(package, '.tgz') symlink = "#{File.dirname(package)}/#{package_name}" FileUtils.ln_s(File.expand_path(dir), symlink) Dir.chdir(File.dirname(package)) do @exec_helper.execute "tar -hcvzf #{package_name}.tgz #{package_name}" end FileUtils.rm(symlink) else raise "Only tar format is currently supported." end @log.info "Appliance #{@appliance_config.name} packaged." package end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
boxgrinder-build-0.7.1 | lib/boxgrinder-build/helpers/package-helper.rb |
boxgrinder-build-0.7.0 | lib/boxgrinder-build/helpers/package-helper.rb |