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_version ⇒ Object
- #ondemand_repo_version ⇒ Object
- #podman_runtime? ⇒ Boolean
- #proj_root ⇒ Object
- #rt_specific_flags ⇒ Object
- #ruby_version ⇒ Object
- #scl_ruby ⇒ 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
77 78 79 |
# File 'lib/ood_packaging/utils.rb', line 77 def ctr_gems_dir File.join(ctr_scripts_dir, 'gems') end |
#ctr_gpg_dir ⇒ Object
101 102 103 |
# File 'lib/ood_packaging/utils.rb', line 101 def ctr_gpg_dir File.join(ctr_home, '.gnupg') end |
#ctr_home ⇒ Object
93 94 95 |
# File 'lib/ood_packaging/utils.rb', line 93 def ctr_home File.join('/home', ctr_user) end |
#ctr_rpmmacros ⇒ Object
97 98 99 |
# File 'lib/ood_packaging/utils.rb', line 97 def ctr_rpmmacros File.join(ctr_home, '.rpmmacros') end |
#ctr_scripts_dir ⇒ Object
73 74 75 |
# File 'lib/ood_packaging/utils.rb', line 73 def ctr_scripts_dir '/ondemand-packaging' end |
#ctr_user ⇒ Object
89 90 91 |
# File 'lib/ood_packaging/utils.rb', line 89 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
85 86 87 |
# File 'lib/ood_packaging/utils.rb', line 85 def gpg_passphrase File.join(ctr_scripts_dir, '.gpgpass') end |
#gpg_private_key ⇒ Object
81 82 83 |
# File 'lib/ood_packaging/utils.rb', line 81 def gpg_private_key File.join(ctr_scripts_dir, 'ondemand.sec') end |
#nodejs_version ⇒ Object
69 70 71 |
# File 'lib/ood_packaging/utils.rb', line 69 def nodejs_version '14' end |
#ondemand_repo_version ⇒ Object
57 58 59 |
# File 'lib/ood_packaging/utils.rb', line 57 def ondemand_repo_version '2.1' 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_version ⇒ Object
61 62 63 |
# File 'lib/ood_packaging/utils.rb', line 61 def ruby_version '3.0' end |
#scl_ruby ⇒ Object
65 66 67 |
# File 'lib/ood_packaging/utils.rb', line 65 def scl_ruby "rh-ruby#{ruby_version.tr('.', '')}" 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 |