Skip to content

Commit

Permalink
Include OS version and build number in panic backup folder name
Browse files Browse the repository at this point in the history
As suggested by @mralexgray
  • Loading branch information
darwin committed May 24, 2015
1 parent 092bb8c commit ecd7c14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ctl/cmd/install_wrapper.rb
Expand Up @@ -29,7 +29,8 @@ def cmd_install_wrapper(options)

# make timestamped panic backup
timestamp = Time.now.strftime("%Y%m%d%H%M%S")
panic_backup_folder_with_timestamp = "#{DS_LIB_PANIC_BACKUP_FOLDER}_#{timestamp}"
os_marker = os_version_marker()
panic_backup_folder_with_timestamp = "#{DS_LIB_PANIC_BACKUP_FOLDER}_#{os_marker}_#{timestamp}"
unless File.exists? panic_backup_folder_with_timestamp then
sys("sudo cp -a \"#{DS_LIB_FOLDER}\" \"#{panic_backup_folder_with_timestamp}\"")
end
Expand Down
15 changes: 15 additions & 0 deletions ctl/lib/helpers.rb
Expand Up @@ -110,4 +110,19 @@ def prior_yosemite?
def desktopservicespriv_wrapper?(file)
# this is simple and stupid test: our wrapper library is small, under 100kb
File.size(file) <= 100*1024
end

def safe_string_to_filename(s)
s.gsub(/[^a-zA-Z0-9]/, "_").gsub(/_+/, "_")
end

def os_version_marker()
begin
vers = `sw_vers`.split("\n")
os_version = vers[1].match(/:\s*(.*)/)[1]
build_version = vers[2].match(/:\s*(.*)/)[1]
safe_string_to_filename("#{os_version}_#{build_version}")
rescue
""
end
end

0 comments on commit ecd7c14

Please sign in to comment.