forked from vanderhoop/installfest_script
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
53 lines (40 loc) · 1.3 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
require 'fileutils'
task :default => ['installer:create_branch_file','installer:build']
namespace :installer do
desc "Build the script branch shell file dynamically"
task :create_branch_file do
File.open("scripts/set_script_branch.sh", "w+") do |f|
f << "\n# This refers to the branch of our repo that we are using (for cloning)." +
"\nBRANCH=#{`git rev-parse --abbrev-ref HEAD`}"
end
end
desc "Build installscripts from manifest files"
task :build do
puts "Building installs from manifests..."
system("./bin/build.rb")
puts "Finished!"
end
desc "Adds built files for committing"
task :add do
system("git add .")
system("git commit -m 'Rebuilds scripts'")
end
end
namespace :dotfiles do
desc "copy dotfiles"
task :copy do
# create backup folder
time = Time.now.strftime("%Y%m%d%H%M%S")
FileUtils.mkdir_p("#{ENV['HOME']}/.wdi/dotfiles/backup_#{time}")
Dir.glob("settings/*").each do |path|
file = File.basename(path)
local_file = File.expand_path("~/.#{file}")
if File.exist? local_file
puts "backing up #{local_file}"
FileUtils.cp(local_file, "#{ENV['HOME']}/.wdi/dotfiles/backup_#{time}/")
end
puts "copying file"
FileUtils.cp(path, "#{ENV['HOME']}/.#{file}")
end
end
end