Skip to content

Commit 5e3212b

Browse files
committed
rhel8 changes
1 parent a01756f commit 5e3212b

File tree

5 files changed

+84
-2
lines changed

5 files changed

+84
-2
lines changed

lib/travis/build/addons/yum.rb

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
require 'travis/build/addons/base'
2+
require 'shellwords'
3+
4+
module Travis
5+
module Build
6+
class Addons
7+
class Yum < Base
8+
SUPPORTED_OPERATING_SYSTEMS = %w[
9+
linux
10+
/^linux.*/
11+
].freeze
12+
13+
SUPPORTED_DISTS = %w(
14+
rhel
15+
).freeze
16+
17+
def before_prepare?
18+
SUPPORTED_OPERATING_SYSTEMS.any? do |os_match|
19+
data[:config][:os].to_s == os_match
20+
end
21+
end
22+
23+
def before_prepare
24+
return if config_yum.empty?
25+
sh.newline
26+
sh.fold('yum') do
27+
install_yum
28+
end
29+
sh.newline
30+
end
31+
32+
def before_configure?
33+
config
34+
end
35+
36+
def before_configure
37+
sh.echo "Configuring default yum options", ansi: :yellow
38+
tmp_dest = "${TRAVIS_TMPDIR}/99-travis-yum-conf"
39+
sh.file tmp_dest, <<~YUM_CONF
40+
assumeyes=1
41+
retries=5
42+
timeout=30
43+
YUM_CONF
44+
sh.cmd %Q{su -m root -c "mv #{tmp_dest} ${TRAVIS_ROOT}/usr/local/etc/yum.conf"}
45+
end
46+
47+
def config
48+
@config ||= Hash(super)
49+
end
50+
51+
def install_yum
52+
sh.echo "Installing #{config_yum.count} packages", ansi: :yellow
53+
54+
packages = config_yum.map{|v| Shellwords.escape(v)}.join(' ')
55+
sh.cmd "su -m root -c 'yum install -y #{packages}'", echo: true, timing: true, assert: true
56+
end
57+
58+
def config_yum
59+
@config_yum ||= Array(config[:packages]).flatten.compact
60+
rescue TypeError => e
61+
if e.message =~ /no implicit conversion of Symbol into Integer/
62+
raise Travis::Build::YumConfigError.new
63+
end
64+
end
65+
end
66+
end
67+
end
68+
end

lib/travis/build/appliances/disable_initramfs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Build
55
module Appliances
66
class DisableInitramfs < Base
77
def apply
8-
sh.raw "if [ ! $(uname|egrep 'Darwin|FreeBSD') ]; then echo update_initramfs=no | sudo tee -a /etc/initramfs-tools/update-initramfs.conf > /dev/null; fi"
8+
sh.raw "if [[ ! $(uname|egrep 'Darwin|FreeBSD') && ! -f /etc/redhat-release ]]; then echo update_initramfs=no | sudo tee -a /etc/initramfs-tools/update-initramfs.conf > /dev/null; fi"
99
end
1010
end
1111
end

lib/travis/build/bash/travis_setup_postgresql.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ travis_setup_postgresql() {
1919
focal)
2020
version='12'
2121
;;
22+
rhel8)
23+
version='12'
24+
;;
2225
*)
2326
echo -e "${ANSI_RED}Unrecognized operating system.${ANSI_CLEAR}"
2427
;;

lib/travis/build/errors.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ def doc_path
8181
'/user/installing-dependencies'
8282
end
8383
end
84+
85+
86+
class YumConfigError < CompilationError
87+
def initialize(msg = "\\`yum\\` should be a list.")
88+
super
89+
end
90+
91+
def doc_path
92+
'/user/installing-dependencies'
93+
end
94+
end
8495

8596
class GithubAppsTokenFetchError < CompilationError
8697
def initialize(msg = "Unable to fetch GitHub Apps Token. GitHub may be unavailable. " \

spec/build/script/shared/appliances/disable_initramfs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
shared_examples_for 'disables updating initramfs' do
2-
let(:disable_initramfs) { %(if [ ! $(uname|egrep 'Darwin|FreeBSD') ]; then echo update_initramfs=no | sudo tee -a /etc/initramfs-tools/update-initramfs.conf > /dev/null; fi) }
2+
let(:disable_initramfs) { %(if [[ ! $(uname|egrep 'Darwin|FreeBSD') && ! -f /etc/redhat-release ]]; then echo update_initramfs=no | sudo tee -a /etc/initramfs-tools/update-initramfs.conf > /dev/null; fi) }
33

44
it 'disables updating initramfs' do
55
should include_sexp [:raw, disable_initramfs]

0 commit comments

Comments
 (0)