|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +# |
| 4 | +# Cookbook:: aws-parallelcluster-slurm |
| 5 | +# Recipe:: install_jwt |
| 6 | +# |
| 7 | +# Copyright:: Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 8 | +# |
| 9 | +# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the |
| 10 | +# License. A copy of the License is located at |
| 11 | +# |
| 12 | +# http://aws.amazon.com/apache2.0/ |
| 13 | +# |
| 14 | +# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 15 | +# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +jwt_version = node['cluster']['jwt']['version'] |
| 19 | +jwt_tarball = "#{node['cluster']['sources_dir']}/libjwt-#{jwt_version}.tar.gz" |
| 20 | + |
| 21 | +remote_file jwt_tarball do |
| 22 | + source node['cluster']['jwt']['url'] |
| 23 | + mode '0644' |
| 24 | + retries 3 |
| 25 | + retry_delay 5 |
| 26 | + not_if { ::File.exist?(jwt_tarball) } |
| 27 | +end |
| 28 | + |
| 29 | +ruby_block "Validate libjwt Tarball Checksum" do |
| 30 | + block do |
| 31 | + require 'digest' |
| 32 | + checksum = Digest::SHA1.file(jwt_tarball).hexdigest # nosemgrep |
| 33 | + raise "Downloaded Tarball Checksum #{checksum} does not match expected checksum #{node['cluster']['jwt']['sha1']}" if checksum != node['cluster']['jwt']['sha1'] |
| 34 | + end |
| 35 | +end |
| 36 | + |
| 37 | +jwt_build_deps = value_for_platform( |
| 38 | + 'ubuntu' => { |
| 39 | + 'default' => 'libjansson-dev', |
| 40 | + }, |
| 41 | + 'default' => 'jansson-devel' |
| 42 | +) |
| 43 | + |
| 44 | +package jwt_build_deps do |
| 45 | + retries 3 |
| 46 | + retry_delay 5 |
| 47 | +end |
| 48 | + |
| 49 | +bash 'libjwt' do |
| 50 | + user 'root' |
| 51 | + group 'root' |
| 52 | + cwd Chef::Config[:file_cache_path] |
| 53 | + code <<-LIBJWT |
| 54 | + set -e |
| 55 | + tar xf #{jwt_tarball} |
| 56 | + cd libjwt-#{jwt_version} |
| 57 | + autoreconf --force --install |
| 58 | + ./configure --prefix=/opt/libjwt |
| 59 | + CORES=$(grep processor /proc/cpuinfo | wc -l) |
| 60 | + make -j $CORES |
| 61 | + sudo make install |
| 62 | + LIBJWT |
| 63 | +end |
0 commit comments