From f6a6c4982343e9b1e8e6c8d0e77de44eb04eb88b Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sun, 28 Apr 2024 11:51:43 +0900 Subject: [PATCH] Add `git` APT source setting for Ubuntu2404. --- cookbooks/base/packages.rb | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/cookbooks/base/packages.rb b/cookbooks/base/packages.rb index 621c6fe..11b917e 100644 --- a/cookbooks/base/packages.rb +++ b/cookbooks/base/packages.rb @@ -20,24 +20,28 @@ end ### Here we are going to install git. # Constants: -KEYSRV = 'hkp://keyserver.ubuntu.com:80' -ID = 'E1DF1F24' +case run_command('grep VERSION_ID /etc/os-release | awk -F\" \'{print $2}\'').stdout.chomp +when "24.04" + execute 'add-apt-repository -y ppa:git-core/ppa' do + not_if 'test -e /etc/apt/sources.list.d/git-core-ubuntu-ppa-noble.sources' + end +else + KEYSRV = 'hkp://keyserver.ubuntu.com:80' + ID = 'E1DF1F24' -GIT_PREPUSH = '/usr/share/git-core/templates/hooks/pre-push' -PREPUSH = 'https://gist.github.com/kazu634/8267388/raw/e9202cd4c29a66723c88d2be05f3cd19413d2137/pre-push' + # Retrieve the Ubuntu code: + DIST = run_command('lsb_release -cs').stdout.chomp -# Retrieve the Ubuntu code: -DIST = run_command('lsb_release -cs').stdout.chomp + # Add the public key file to install `git` + execute "apt-key adv --keyserver #{KEYSRV} --recv-keys #{ID}" do + not_if 'apt-key list | grep "E1DF 1F24"' + end -# Add the public key file to install `git` -execute "apt-key adv --keyserver #{KEYSRV} --recv-keys #{ID}" do - not_if 'apt-key list | grep "E1DF 1F24"' -end - -# Deploy the `apt` sources: -template '/etc/apt/sources.list.d/git.list' do - action :create - variables(distribution: DIST) + # Deploy the `apt` sources: + template '/etc/apt/sources.list.d/git.list' do + action :create + variables(distribution: DIST) + end end execute 'apt update' do @@ -48,6 +52,9 @@ execute 'apt install git -y' do not_if 'LANG=C apt-cache policy git | grep Installed | grep ppa' end +GIT_PREPUSH = '/usr/share/git-core/templates/hooks/pre-push' +PREPUSH = 'https://gist.github.com/kazu634/8267388/raw/e9202cd4c29a66723c88d2be05f3cd19413d2137/pre-push' + execute "wget #{PREPUSH} -O #{GIT_PREPUSH}" do not_if "test -e #{GIT_PREPUSH}" end