# # Cookbook:: workstation # Recipe:: _ssh-ident # # Copyright:: 2022, The Authors, All Rights Reserved. username = node['my_workstation']['default_user'].first[0] user_repo_directory = ::File.join(node['my_workstation']['default_user'][username]['home'], 'repo') ssh_ident_repo = ::File.join(user_repo_directory, 'ssh-ident') ssh_ident_bin = ::File.join(ssh_ident_repo, 'ssh-ident') git ssh_ident_repo do repository 'https://github.com/ccontavalli/ssh-ident' user username action :checkout end # How to create a git patch: # Ref: https://devconnected.com/how-to-create-and-apply-git-patch-files/ patch_files = %w{ 001-ssh_ident-fix-python.patch 0001-fix-timeout-Increase-the-ssh-key-in-memory-timeout-t.patch } patch_files.each do |patch_file| cookbook_file ::File.join(ssh_ident_repo, patch_file) do source patch_file owner username group username end execute "git am #{patch_file}" do cwd ssh_ident_repo only_if "/usr/bin/git apply #{patch_file} --check" end execute "/usr/bin/install #{ssh_ident_bin} /usr/sbin/ssh-ident" do not_if { ::FileUtils.uptodate?('/usr/sbin/ssh-ident', [ssh_ident_bin]) } end end