Module: OodPackaging::Utils

Included in:
Build, BuildBox, Package, RakeTask
Defined in:
lib/ood_packaging/utils.rb

Overview

Shared utility functions

Instance Method Summary collapse

Instance Method Details

#container_runtimeObject



33
34
35
# File 'lib/ood_packaging/utils.rb', line 33

def container_runtime
  podman_runtime? ? 'podman' : 'docker'
end

#ctr_gems_dirObject



77
78
79
# File 'lib/ood_packaging/utils.rb', line 77

def ctr_gems_dir
  File.join(ctr_scripts_dir, 'gems')
end

#ctr_gpg_dirObject



101
102
103
# File 'lib/ood_packaging/utils.rb', line 101

def ctr_gpg_dir
  File.join(ctr_home, '.gnupg')
end

#ctr_homeObject



93
94
95
# File 'lib/ood_packaging/utils.rb', line 93

def ctr_home
  File.join('/home', ctr_user)
end

#ctr_rpmmacrosObject



97
98
99
# File 'lib/ood_packaging/utils.rb', line 97

def ctr_rpmmacros
  File.join(ctr_home, '.rpmmacros')
end

#ctr_scripts_dirObject



73
74
75
# File 'lib/ood_packaging/utils.rb', line 73

def ctr_scripts_dir
  '/ondemand-packaging'
end

#ctr_userObject



89
90
91
# File 'lib/ood_packaging/utils.rb', line 89

def ctr_user
  'ood'
end

#docker_runtime?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ood_packaging/utils.rb', line 29

def docker_runtime?
  !podman_runtime?
end

#gpg_passphraseObject



85
86
87
# File 'lib/ood_packaging/utils.rb', line 85

def gpg_passphrase
  File.join(ctr_scripts_dir, '.gpgpass')
end

#gpg_private_keyObject



81
82
83
# File 'lib/ood_packaging/utils.rb', line 81

def gpg_private_key
  File.join(ctr_scripts_dir, 'ondemand.sec')
end

#nodejs_versionObject



69
70
71
# File 'lib/ood_packaging/utils.rb', line 69

def nodejs_version
  '14'
end

#ondemand_repo_versionObject



57
58
59
# File 'lib/ood_packaging/utils.rb', line 57

def ondemand_repo_version
  '2.1'
end

#podman_runtime?Boolean

Returns:

  • (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_rootObject



7
8
9
# File 'lib/ood_packaging/utils.rb', line 7

def proj_root
  File.expand_path(File.join(File.dirname(__FILE__), '../..'))
end

#rt_specific_flagsObject



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_versionObject



61
62
63
# File 'lib/ood_packaging/utils.rb', line 61

def ruby_version
  '3.0'
end

#scl_rubyObject



65
66
67
# File 'lib/ood_packaging/utils.rb', line 65

def scl_ruby
  "rh-ruby#{ruby_version.tr('.', '')}"
end

#sedObject



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

#tarObject



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.expand_path(__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