Module: OodPackaging::Utils
Overview
Shared utility functions
Instance Method Summary collapse
- #container_runtime ⇒ Object
- #ctr_gems_dir ⇒ Object
- #ctr_gpg_dir ⇒ Object
- #ctr_home ⇒ Object
- #ctr_rpmmacros ⇒ Object
- #ctr_scripts_dir ⇒ Object
- #ctr_user ⇒ Object
- #docker_runtime? ⇒ Boolean
- #gpg_passphrase ⇒ Object
- #gpg_private_key ⇒ Object
- #nodejs_package ⇒ Object
- #nodejs_version ⇒ Object
- #ondemand_repo_version ⇒ Object
- #ondemand_rpm_repo_baseurl ⇒ Object
- #podman_runtime? ⇒ Boolean
- #proj_root ⇒ Object
- #rt_specific_flags ⇒ Object
- #ruby_package ⇒ Object
- #ruby_version ⇒ Object
- #sed ⇒ Object
- #tar ⇒ Object
- #template_file(filename) ⇒ Object
Instance Method Details
#container_runtime ⇒ Object
33 34 35 |
# File 'lib/ood_packaging/utils.rb', line 33 def container_runtime podman_runtime? ? 'podman' : 'docker' end |
#ctr_gems_dir ⇒ Object
91 92 93 |
# File 'lib/ood_packaging/utils.rb', line 91 def ctr_gems_dir File.join(ctr_scripts_dir, 'gems') end |
#ctr_gpg_dir ⇒ Object
115 116 117 |
# File 'lib/ood_packaging/utils.rb', line 115 def ctr_gpg_dir File.join(ctr_home, '.gnupg') end |
#ctr_home ⇒ Object
107 108 109 |
# File 'lib/ood_packaging/utils.rb', line 107 def ctr_home File.join('/home', ctr_user) end |
#ctr_rpmmacros ⇒ Object
111 112 113 |
# File 'lib/ood_packaging/utils.rb', line 111 def ctr_rpmmacros File.join(ctr_home, '.rpmmacros') end |
#ctr_scripts_dir ⇒ Object
87 88 89 |
# File 'lib/ood_packaging/utils.rb', line 87 def ctr_scripts_dir '/ondemand-packaging' end |
#ctr_user ⇒ Object
103 104 105 |
# File 'lib/ood_packaging/utils.rb', line 103 def ctr_user 'ood' end |
#docker_runtime? ⇒ Boolean
29 30 31 |
# File 'lib/ood_packaging/utils.rb', line 29 def docker_runtime? !podman_runtime? end |
#gpg_passphrase ⇒ Object
99 100 101 |
# File 'lib/ood_packaging/utils.rb', line 99 def gpg_passphrase File.join(ctr_scripts_dir, '.gpgpass') end |
#gpg_private_key ⇒ Object
95 96 97 |
# File 'lib/ood_packaging/utils.rb', line 95 def gpg_private_key File.join(ctr_scripts_dir, 'ondemand.sec') end |
#nodejs_package ⇒ Object
81 82 83 84 85 |
# File 'lib/ood_packaging/utils.rb', line 81 def nodejs_package return "nodejs#{nodejs_version}" if dist == 'amzn2023' 'nodejs' end |
#nodejs_version ⇒ Object
77 78 79 |
# File 'lib/ood_packaging/utils.rb', line 77 def nodejs_version '20' end |
#ondemand_repo_version ⇒ Object
57 58 59 |
# File 'lib/ood_packaging/utils.rb', line 57 def ondemand_repo_version '4.0' end |
#ondemand_rpm_repo_baseurl ⇒ Object
61 62 63 |
# File 'lib/ood_packaging/utils.rb', line 61 def ondemand_rpm_repo_baseurl "https://yum.osc.edu/ondemand/build/#{ondemand_repo_version}/web/#{dist}/\\$basearch/" end |
#podman_runtime? ⇒ Boolean
25 26 27 |
# File 'lib/ood_packaging/utils.rb', line 25 def podman_runtime? @podman_runtime ||= ENV['CONTAINER_RT'] == 'podman' || ENV['container'] == 'podman' end |
#proj_root ⇒ Object
7 8 9 |
# File 'lib/ood_packaging/utils.rb', line 7 def proj_root File.(File.join(File.dirname(__FILE__), '../..')) end |
#rt_specific_flags ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ood_packaging/utils.rb', line 37 def rt_specific_flags if podman_runtime? # SELinux doesn't like it if you're mounting from $HOME [ '--security-opt', 'label=disable' ] else ['--privileged', '--tty'] end end |
#ruby_package ⇒ Object
71 72 73 74 75 |
# File 'lib/ood_packaging/utils.rb', line 71 def ruby_package return "ruby#{ruby_version}" if dist == 'amzn2023' 'ruby' end |
#ruby_version ⇒ Object
65 66 67 68 69 |
# File 'lib/ood_packaging/utils.rb', line 65 def ruby_version return '3.2' if dist == 'amzn2023' '3.3' end |
#sed ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ood_packaging/utils.rb', line 18 def sed @sed ||= begin `which gsed 1>/dev/null 2>&1` $CHILD_STATUS.success? ? 'gsed' : 'sed' end end |
#tar ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ood_packaging/utils.rb', line 11 def tar @tar ||= begin `which gtar 1>/dev/null 2>&1` $CHILD_STATUS.success? ? 'gtar' : 'tar' end end |
#template_file(filename) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/ood_packaging/utils.rb', line 48 def template_file(filename) cwd = File.(__dir__).to_s src = File.join(cwd, filename) dest = File.join(cwd, filename.gsub('.erb', '')) content = ERB.new(File.read(src), trim_mode: '-').result(binding) File.open(dest, 'w') { |f| f.write(content) } dest end |