Skip to content

Commit f05be9d

Browse files
author
Marcin Godzina
committed
[#3247] add rocky linux 9
1 parent 27fdd04 commit f05be9d

File tree

1 file changed

+78
-33
lines changed

1 file changed

+78
-33
lines changed

hammer.py

Lines changed: 78 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
'8': True,
7474
'9': True,
7575
},
76+
'rocky': {
77+
'9': True,
78+
},
7679
'ubuntu': {
7780
'16.04': False,
7881
'18.04': True,
@@ -275,6 +278,8 @@ def get_system_revision():
275278
elif system == 'redhat':
276279
system = 'rhel'
277280
revision = revision[0]
281+
elif system == 'rocky':
282+
revision = revision[0]
278283
elif system == 'centos':
279284
revision = revision[0]
280285
if not system or not revision:
@@ -290,10 +295,14 @@ def get_system_revision():
290295

291296
for i in ['ID', 'ID_LIKE']:
292297
if i in vals:
293-
system_candidate=vals[i].strip('"')
294-
if system_candidate in SYSTEMS:
295-
system = system_candidate
296-
break
298+
system_candidates=vals[i].strip('"').split()
299+
for system_candidate in system_candidates:
300+
if system_candidate in SYSTEMS:
301+
system = system_candidate
302+
break
303+
else:
304+
continue
305+
break
297306
if system is None:
298307
raise Exception('cannot determine system')
299308

@@ -304,7 +313,7 @@ def get_system_revision():
304313
if revision is None:
305314
raise Exception('cannot determine revision')
306315

307-
if system in ['alpine', 'rhel']:
316+
if system in ['alpine', 'rhel', 'rocky']:
308317
revision = revision.rsplit('.', 1)[0]
309318
else:
310319
raise Exception('cannot determine system or its revision')
@@ -496,8 +505,8 @@ def install_pkgs(pkgs, timeout=60, env=None, check_times=False, pkg_cache=None):
496505
pkg_cache = {}
497506

498507
# prepare cache if needed
499-
if not pkg_cache and system in ['centos', 'rhel', 'fedora', 'debian', 'ubuntu']:#, 'alpine']: # TODO: complete caching support for alpine
500-
if system in ['centos', 'rhel', 'fedora']:
508+
if not pkg_cache and system in ['centos', 'rhel', 'fedora', 'debian', 'ubuntu', 'rocky']:#, 'alpine']: # TODO: complete caching support for alpine
509+
if system in ['centos', 'rhel', 'fedora', 'rocky']:
501510
pkg_cache.update(_prepare_installed_packages_cache_for_rpms())
502511
elif system in ['debian', 'ubuntu']:
503512
pkg_cache.update(_prepare_installed_packages_cache_for_debs())
@@ -521,7 +530,7 @@ def install_pkgs(pkgs, timeout=60, env=None, check_times=False, pkg_cache=None):
521530
log.info('all packages already installed')
522531
return
523532

524-
if system in ['centos', 'fedora', 'rhel']:
533+
if system in ['centos', 'fedora', 'rhel', 'rocky']:
525534
if system in ['centos', 'rhel'] and revision == '7':
526535
execute('sudo yum install -y dnf')
527536
cmd = 'sudo dnf -y install'
@@ -892,7 +901,7 @@ def run_build_and_test(self, tarball_path, jobs, pkg_version, pkg_isc_version, u
892901
upload_cmd += ' -X POST -H "Content-Type: multipart/form-data" --data-binary "@%s" '
893902
file_ext = 'deb' # include both '.deb' and '.ddeb' files
894903

895-
elif self.system in ['fedora', 'centos', 'rhel']:
904+
elif self.system in ['fedora', 'centos', 'rhel', 'rocky']:
896905
upload_cmd += ' --upload-file %s '
897906
file_ext = '.rpm'
898907

@@ -1026,7 +1035,7 @@ def prepare_system(self):
10261035

10271036
# RPM-based distributions install libraries in /usr/local/lib64, but they
10281037
# tend to not look there at runtime without explicit mention in ld.so.conf.d.
1029-
if self.system in ['centos', 'fedora', 'rhel']:
1038+
if self.system in ['centos', 'fedora', 'rhel', 'rocky']:
10301039
self.execute('sudo echo /usr/local/lib64 > /etc/ld.so.conf.d/kea.conf')
10311040
# ldconfig only in case the change above was not there before system startup
10321041
self.execute('sudo ldconfig')
@@ -1058,7 +1067,7 @@ def prepare_system(self):
10581067
log.info('')
10591068

10601069
def prepare_for_boxing(self):
1061-
if self.system in ['debian', 'ubuntu', 'fedora', 'centos', 'rhel']:
1070+
if self.system in ['debian', 'ubuntu', 'fedora', 'centos', 'rhel', 'rocky']:
10621071
# setup a script that on first boot will set machine-id
10631072
cmd = 'bash -c \'cat <<EOF | sudo tee /usr/lib/systemd/system/systemd-firstboot.service\n'
10641073
cmd += '[Unit]\n'
@@ -1107,11 +1116,11 @@ def _install_gtest_sources():
11071116
def _install_libyang_from_sources(ignore_errors = False):
11081117
"""Install libyang from sources."""
11091118
for prefix in ['/usr', '/usr/local']:
1110-
libyang_so = f'{prefix}/lib/libyang.so'
1119+
libyang_so_candidates = [f'{prefix}/lib/libyang.so', f'{prefix}/lib64/libyang.so']
11111120
libyang_header = f'{prefix}/include/libyang/version.h'
1112-
if (os.path.exists(libyang_so) and os.path.exists(libyang_header) and
1121+
if (any(os.path.exists(i) for i in libyang_so_candidates) and os.path.exists(libyang_header) and
11131122
execute(f"grep -F '#define LY_VERSION_MAJOR 2' '{libyang_header}'", raise_error=False) == 0):
1114-
log.info(f'libyang is already installed at {libyang_so}.')
1123+
log.info(f'libyang is already installed at {libyang_header}.')
11151124
return
11161125

11171126
version='v2.1.4'
@@ -1139,11 +1148,11 @@ def _install_libyang_from_sources(ignore_errors = False):
11391148
def _install_sysrepo_from_sources(ignore_errors = False):
11401149
"""Install sysrepo from sources."""
11411150
for prefix in ['/usr', '/usr/local']:
1142-
sysrepo_so = f'{prefix}/lib/libsysrepo.so'
1151+
sysrepo_so_candidates = [f'{prefix}/lib/libsysrepo.so', f'{prefix}/lib64/libsysrepo.so']
11431152
sysrepo_header = f'{prefix}/include/sysrepo/version.h'
1144-
if (os.path.exists(sysrepo_so) and os.path.exists(sysrepo_header) and
1153+
if (any(os.path.exists(i) for i in sysrepo_so_candidates) and os.path.exists(sysrepo_header) and
11451154
execute(f"grep -F '#define SR_VERSION_MAJOR 7' '{sysrepo_header}'", raise_error=False) == 0):
1146-
log.info(f'sysrepo is already installed at {sysrepo_so}.')
1155+
log.info(f'sysrepo is already installed at {sysrepo_header}.')
11471156
return
11481157

11491158
version='v2.2.12'
@@ -1174,9 +1183,9 @@ def _install_sysrepo_from_sources(ignore_errors = False):
11741183

11751184
def _install_libyang_cpp_from_sources(ignore_errors = False):
11761185
"""Install libyang-cpp from sources."""
1177-
for prefix in ['/usr', '/usr/local']:
1178-
libyang_cpp_so = f'{prefix}/lib/libyang-cpp.so'
1179-
libyang_cpp_pc = f'{prefix}/lib/pkgconfig/libyang-cpp.pc'
1186+
for prefix_lib in ['/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/local/lib64']:
1187+
libyang_cpp_so = f'{prefix_lib}/libyang-cpp.so'
1188+
libyang_cpp_pc = f'{prefix_lib}/pkgconfig/libyang-cpp.pc'
11801189
if (os.path.exists(libyang_cpp_so) and os.path.exists(libyang_cpp_pc) and
11811190
execute(f"grep -F 'Version: 1.1.0' '{libyang_cpp_pc}'", raise_error=False) == 0):
11821191
log.info(f'libyang-cpp is already installed at {libyang_cpp_so}.')
@@ -1206,9 +1215,9 @@ def _install_libyang_cpp_from_sources(ignore_errors = False):
12061215

12071216
def _install_sysrepo_cpp_from_sources(ignore_errors = False):
12081217
"""Install sysrepo-cpp from sources."""
1209-
for prefix in ['/usr', '/usr/local']:
1210-
sysrepo_cpp_so = f'{prefix}/lib/libsysrepo-cpp.so'
1211-
sysrepo_cpp_pc = f'{prefix}/lib/pkgconfig/sysrepo-cpp.pc'
1218+
for prefix_lib in ['/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/local/lib64']:
1219+
sysrepo_cpp_so = f'{prefix_lib}/libsysrepo-cpp.so'
1220+
sysrepo_cpp_pc = f'{prefix_lib}/pkgconfig/sysrepo-cpp.pc'
12121221
if (os.path.exists(sysrepo_cpp_so) and os.path.exists(sysrepo_cpp_pc) and
12131222
execute(f"grep -F 'Version: 1.1.0' '{sysrepo_cpp_pc}'", raise_error=False) == 0):
12141223
log.info(f'sysrepo-cpp is already installed at {sysrepo_cpp_so}.')
@@ -1331,7 +1340,7 @@ def _configure_mysql(system, revision, features):
13311340
# For all added files and directories, change owner to mysql.
13321341
execute('sudo chown -R mysql:mysql {} {}'.format(cert_dir, kea_cnf))
13331342

1334-
if system in ['debian', 'fedora', 'centos', 'rhel']:
1343+
if system in ['debian', 'fedora', 'centos', 'rhel', 'rocky']:
13351344
execute('sudo systemctl enable mariadb.service')
13361345
exit_code = execute('sudo systemctl restart mariadb.service', raise_error=False)
13371346
if exit_code != 0:
@@ -1476,7 +1485,7 @@ def _configure_pgsql(system, revision, features):
14761485
# avoid the error:
14771486
# could not change as postgres user directory to "/home/jenkins": Permission denied
14781487

1479-
if system in ['fedora', 'centos', 'rhel']:
1488+
if system in ['fedora', 'centos', 'rhel', 'rocky']:
14801489
# https://fedoraproject.org/wiki/PostgreSQL
14811490
exitcode = execute('sudo ls /var/lib/pgsql/data/postgresql.conf', raise_error=False)
14821491
if exitcode != 0:
@@ -1589,8 +1598,8 @@ def _get_package_version(package: str):
15891598
cmd = "apk search --exact {0} | sed 's/{0}-//g'"
15901599
elif system in ['debian', 'ubuntu']:
15911600
cmd = "apt-cache show {} | grep -F 'Version:' | cut -d ' ' -f 2"
1592-
elif system in ['centos', 'fedora', 'rhel']:
1593-
cmd = "dnf list {} | tr -s ' ' | cut -d ' ' -f 2 | tail -n 1"
1601+
elif system in ['centos', 'fedora', 'rhel', 'rocky']:
1602+
cmd = "dnf list {} -y | tr -s ' ' | cut -d ' ' -f 2 | tail -n 1"
15941603
elif system == 'freebsd':
15951604
cmd = "pkg search {0} | grep -Eo '^{0}-[0-9_,\.]+' | sed 's/{0}-//g'"
15961605
elif system == 'arch':
@@ -1791,6 +1800,42 @@ def link_pg_config():
17911800

17921801
install_pkgs(packages, env=env, timeout=120, check_times=check_times)
17931802

1803+
# prepare rocky
1804+
elif system == 'rocky':
1805+
install_pkgs('epel-release', env=env, check_times=check_times)
1806+
1807+
packages = ['autoconf', 'automake', 'bison', 'boost-devel', 'flex', 'gcc-c++',
1808+
'libtool', 'log4cplus-devel', 'make',
1809+
'openssl-devel']
1810+
1811+
if 'docs' in features:
1812+
packages.extend(['python3-sphinx', 'python3-sphinx_rtd_theme'])
1813+
1814+
if 'native-pkg' in features:
1815+
packages.extend(['bison', 'flex', 'python3-devel', 'rpm-build'])
1816+
1817+
if 'mysql' in features:
1818+
packages.extend(['mariadb', 'mariadb-server', 'mariadb-connector-c-devel'])
1819+
1820+
if 'pgsql' in features:
1821+
packages.extend(['postgresql', 'postgresql-server', 'postgresql-server-devel'])
1822+
1823+
if 'gssapi' in features:
1824+
packages.extend(['krb5-devel'])
1825+
1826+
if 'ccache' in features:
1827+
packages.extend(['ccache'])
1828+
1829+
if 'netconf' in features:
1830+
packages.extend(['cmake', 'git', 'pcre2-devel'])
1831+
1832+
if 'unittest' in features:
1833+
packages.append('wget')
1834+
deferred_functions.append(_install_gtest_sources)
1835+
1836+
execute('sudo dnf config-manager --set-enabled crb')
1837+
install_pkgs(packages, env=env, timeout=120, check_times=check_times)
1838+
17941839
# prepare ubuntu
17951840
elif system == 'ubuntu':
17961841
_apt_update(system, revision, env=env, check_times=check_times, attempts=3, sleep_time_after_attempt=10)
@@ -2037,7 +2082,7 @@ def _prepare_ccache_if_needed(system, ccache_dir, env):
20372082
if ccache_dir is not None:
20382083
if system in ['debian', 'ubuntu']:
20392084
ccache_bin_path = '/usr/lib/ccache/'
2040-
elif system in ['centos', 'rhel', 'fedora']:
2085+
elif system in ['centos', 'rhel', 'fedora', 'rocky']:
20412086
ccache_bin_path = '/usr/lib64/ccache'
20422087
env['CC'] = 'ccache gcc'
20432088
env['CXX'] = 'ccache g++'
@@ -2071,7 +2116,7 @@ def _build_binaries_and_run_ut(system, revision, features, tarball_path, env, ch
20712116
cmd += ' --with-pgsql'
20722117
if 'unittest' in features:
20732118
# prepare gtest switch - use downloaded gtest sources only if it is not present as native package
2074-
if system in ['centos', 'fedora', 'rhel', 'freebsd', 'alpine']:
2119+
if system in ['centos', 'fedora', 'rhel', 'freebsd', 'alpine', 'rocky']:
20752120
cmd += ' --with-gtest-source=/usr/src/googletest-release-1.10.0/googletest/'
20762121
elif system == 'debian' and revision == '8':
20772122
cmd += ' --with-gtest-source=/usr/src/googletest-release-1.10.0/googletest/'
@@ -2390,7 +2435,7 @@ def _build_native_pkg(system, revision, features, tarball_path, env, check_times
23902435
repo_url = _get_full_repo_url(repository_url, system, revision, pkg_version)
23912436
assert repo_url is not None
23922437

2393-
if system in ['fedora', 'centos', 'rhel']:
2438+
if system in ['fedora', 'centos', 'rhel', 'rocky']:
23942439
_build_rpm(system, revision, features, tarball_path, env, check_times, dry_run,
23952440
pkg_version, pkg_isc_version, repo_url)
23962441

@@ -2411,7 +2456,7 @@ def _build_native_pkg(system, revision, features, tarball_path, env, check_times
24112456
if system in ['ubuntu', 'debian']:
24122457
execute('mv kea-src/isc-kea_* %s' % pkgs_dir)
24132458
execute('mv kea-src/*deb %s' % pkgs_dir)
2414-
elif system in ['fedora', 'centos', 'rhel']:
2459+
elif system in ['fedora', 'centos', 'rhel', 'rocky']:
24152460
execute('mv pkgs/* %s' % pkgs_dir)
24162461
elif system in ['alpine']:
24172462
# Don't move files if the source and the target locations are the same.
@@ -2529,7 +2574,7 @@ def ssh(provider, system, revision):
25292574

25302575
def _install_vagrant(ver=RECOMMENDED_VAGRANT_VERSION, upgrade=False):
25312576
system, _ = get_system_revision()
2532-
if system in ['fedora', 'centos', 'rhel']:
2577+
if system in ['fedora', 'centos', 'rhel', 'rocky']:
25332578
if upgrade:
25342579
execute('sudo yum remove -y vagrant')
25352580
execute('mkdir -p ~/.hammer-tmp')
@@ -2960,7 +3005,7 @@ def upload_to_repo(args, pkgs_dir):
29603005
upload_cmd += ' -X POST -H "Content-Type: multipart/form-data" --data-binary "@%s" '
29613006
file_ext = 'deb' # include both '.deb' and '.ddeb' files
29623007

2963-
elif system in ['fedora', 'centos', 'rhel']:
3008+
elif system in ['fedora', 'centos', 'rhel', 'rocky']:
29643009
upload_cmd += ' --upload-file %s '
29653010
file_ext = '.rpm'
29663011

0 commit comments

Comments
 (0)