Эх сурвалжийг харах

feat(ssh-ident): Add the usage of ssh-ident

- Checkout the git repo
- Patch the 'ssh-ident' binary
- Install the binary

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 2 жил өмнө
parent
commit
232cce6079

+ 23 - 0
cookbooks/workstation/files/001-ssh_ident-fix-python.patch

@@ -0,0 +1,23 @@
+From 96084208d90aee11d8347b21f1a44ce361dc828c Mon Sep 17 00:00:00 2001
+From: Jeremy MAURO <jeremy.mauro@gmail.com>
+Date: Mon, 2 May 2022 16:21:48 +0200
+Subject: [PATCH] fix(python): force the usage of python3 by default
+
+Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
+---
+ ssh-ident | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ssh-ident b/ssh-ident
+index 911680f..ff218ba 100755
+--- a/ssh-ident
++++ b/ssh-ident
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python3
+ # vim: tabstop=2 shiftwidth=2 expandtab
+ """Start and use ssh-agent and load identities as necessary.
+ 
+-- 
+2.35.1
+

+ 1 - 1
cookbooks/workstation/recipes/_git.rb

@@ -21,7 +21,7 @@ directory user_repo_directory do
   recursive true
 end
 
-  include_recipe 'git'
+include_recipe 'workstation::_ssh-ident'
 
 node['workstation']['_git'].each do |scope_git, git_options|
   if scope_git.match(/^file_/)

+ 36 - 0
cookbooks/workstation/recipes/_ssh-ident.rb

@@ -0,0 +1,36 @@
+#
+# 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')
+patch_file = '001-ssh_ident-fix-python.patch'
+
+git ssh_ident_repo do
+  repository 'https://github.com/ccontavalli/ssh-ident'
+  user username
+  action :checkout
+end
+
+cookbook_file ::File.join(ssh_ident_repo, patch_file) do
+  source patch_file
+  owner username
+  group username
+  notifies :run, "execute[git am #{patch_file}]", :immediately
+end
+
+# How to create a git patch:
+#   Ref: https://devconnected.com/how-to-create-and-apply-git-patch-files/
+execute "git am #{patch_file}" do
+  cwd ssh_ident_repo
+  action :nothing
+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