This repository has been archived by the owner on Jul 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
/
Rakefile
58 lines (47 loc) · 1.45 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
require 'puppetlabs_spec_helper/rake_tasks'
def get_version
`git describe`.strip
end
def get_temp
`mktemp -d -t tmpXXXXXX`.strip
end
def get_name
'puppetlabs-cloud-provisioner'
end
namespace :package do
desc "Create a release .tar.gz"
task :tar => :build_environment do
name = get_name
rm_rf 'pkg/tar'
temp=`mktemp -d -t tmpXXXXXX`.strip!
version = `git describe`.strip!
base = "#{temp}/#{name}-#{version}/"
mkdir_p base
sh "git checkout-index -af --prefix=#{base}"
mkdir_p "pkg/tar"
sh "tar -C #{temp} -p -c -z -f #{temp}/#{name}-#{version}.tar.gz #{name}-#{version}"
mv "#{temp}/#{name}-#{version}.tar.gz", "pkg/tar"
rm_rf temp
puts
puts "Tarball is pkg/tar/#{name}-#{version}.tar.gz"
end
task :build_environment do
unless ENV['FORCE'] == '1'
modified = `git status --porcelain | sed -e '/^\?/d'`
if modified.split(/\n/).length != 0
puts <<-HERE
!! ERROR: Your git working directory is not clean. You must
!! remove or commit your changes before you can create a package:
#{`git status | grep '^#'`.chomp}
!! To override this check, set FORCE=1 -- e.g. `rake package:deb FORCE=1`
HERE
raise
end
end
end
# Return the file with the latest mtime matching the String filename glob (e.g. "foo/*.bar").
def latest_file(glob)
require 'find'
return FileList[glob].map{|path| [path, File.mtime(path)]}.sort_by(&:last).map(&:first).last
end
end