forked from ManageIQ/manageiq-appliance-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
64 lines (51 loc) · 1.89 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
require_relative 'scripts/productization'
require 'pathname'
namespace :build do
module FilePaths
BUILD = Pathname.new(__dir__).join("../manageiq/BUILD")
VERSION = Pathname.new(__dir__).join("../manageiq/VERSION")
end
class ConfigOptions
require "yaml"
include FilePaths
def self.options
@options ||= YAML.load_file(Build::Productization.file_for("config/tarball/options.yml"))
end
def self.version
ENV["VERSION_ENV"] || options[:version] || File.read(VERSION).chomp
end
def self.prefix
options[:name_prefix]
end
end
task :build_file do
date = Time.now.strftime("%Y%m%d%H%M%S")
git_sha = `git rev-parse --short HEAD`
build = "#{ConfigOptions.version}-#{date}_#{git_sha}"
File.write(FilePaths::BUILD, build)
end
task :version_files do
File.write(FilePaths::VERSION, "#{ConfigOptions.version}\n")
end
task :precompile_assets do
Dir.chdir(File.join(__dir__, '..', 'manageiq'))
puts `bundle exec rake evm:compile_assets`
Dir.chdir(__dir__)
end
desc "Builds a tarball."
task :tar => [:version_files, :build_file, :precompile_assets] do
include_file = Build::Productization.file_for("config/tarball/include")
exclude_file = Build::Productization.file_for("config/tarball/exclude")
pkg_path = Pathname.new(__dir__).join("pkg")
FileUtils.mkdir_p(pkg_path)
tar_basename = "#{ConfigOptions.prefix}-#{ConfigOptions.version}"
tarball = "pkg/#{tar_basename}.tar.gz"
# Add a prefix-version directory to the top of the files added to the tar.
# This is needed by rpm tooling.
transform = RUBY_PLATFORM =~ /darwin/ ? "-s " : "--transform s"
transform << "',^,#{tar_basename}/,'"
`tar -C .. #{transform} -T #{include_file} -X #{exclude_file} -hcvzf #{tarball}`
puts "Built tarball at:\n #{File.expand_path(tarball)}"
end
end
task :default => "build:tar"