Skip to content

Commit 282120f

Browse files
authored
Merge pull request #2010 from craigcomstock/ENT-13016-buildhost
Adjust build host policy for Redhat 10 and Debian 13
2 parents d952455 + 87f475a commit 282120f

3 files changed

Lines changed: 83 additions & 31 deletions

File tree

build-scripts/functions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ func_which() {
562562
# Uses:
563563
# $SECONDARY_PATHS - Additional directories to search
564564
func_whereis() {
565+
args="$*"
565566
while [ x"$1" != x ]; do
566567
# First, search in PATH
567568
if command -v "$1" 2>/dev/null; then
@@ -578,6 +579,7 @@ func_whereis() {
578579
# Command $1 not found, search for next argument
579580
shift
580581
done
582+
log_error "func_whereis() could not find commands: $args"
581583
return 1
582584
}
583585

ci/cfengine-build-host-setup.cf

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ bundle agent cfengine_build_host_setup
1414
ubuntu_20::
1515
"autoconf" comment => "because on arm ubuntu-20 we need to reconfigure the debian-9 bootstrapped configure scripts.";
1616
"shellcheck" comment => "not sure why only ubuntu-20 needed this.";
17-
debian.(!debian_12.!ubuntu_22.!ubuntu_24)::
17+
debian.(!debian_13.!debian_12.!ubuntu_22.!ubuntu_24.!ubuntu_25)::
1818
"python" comment => "debian>=12 and ubuntu>=22 only has python3";
1919

20+
debian_13|ubuntu_25::
21+
"ntpsec";
22+
23+
debian.(!debian_13.!ubuntu_25)::
24+
"ntp";
25+
2026
debian|ubuntu::
2127
"libltdl7" package_policy => "delete";
2228
"libltdl-dev" package_policy => "delete";
@@ -33,10 +39,9 @@ bundle agent cfengine_build_host_setup
3339
"libexpat1-dev";
3440
"libmodule-load-conditional-perl";
3541
"libpam0g-dev";
36-
"ntp";
3742
"pkg-config";
3843
"psmisc";
39-
"python3-pip";
44+
"python3-pip" comment => "this will bring in python3 if needed on debian>=12 and ubuntu>=22";
4045
"python3-psycopg2";
4146
"rsync" comment => "added for debian-10";
4247
"systemd-coredump" comment => "added step to jenkins testing-pr job to query for coredumps on failures";
@@ -114,10 +119,10 @@ bundle agent cfengine_build_host_setup
114119
"perl-Data-Dumper";
115120
"perl-Digest-MD5";
116121

117-
(redhat_7|centos_7|redhat_9).(yum_dnf_conf_ok)::
122+
(redhat_7|centos_7|redhat_9|redhat_10).(yum_dnf_conf_ok)::
118123
"python3-pip";
119124

120-
(redhat_7|centos_7|redhat_8|centos_8|redhat_9).(yum_dnf_conf_ok)::
125+
(redhat_7|centos_7|redhat_8|centos_8|redhat_9|redhat_10).(yum_dnf_conf_ok)::
121126
"perl-ExtUtils-MakeMaker";
122127
"perl-IO-Compress" comment => "provides perl(IO::Uncompress::Gunzip) needed by lcov dependency package";
123128
"psmisc";
@@ -133,16 +138,20 @@ bundle agent cfengine_build_host_setup
133138
"libopenssl-devel" -> { "ENT-12528" }
134139
comment => "like redhat, suse 15+ needs to build with system openssl.";
135140

136-
(redhat_8|centos_8|redhat_9).(yum_dnf_conf_ok)::
141+
(redhat_8|centos_8|redhat_9|redhat_10).(yum_dnf_conf_ok)::
137142
"java-1.8.0-openjdk-headless" package_policy => "delete",
138143
comment => "Installing Development Tools includes this jdk1.8 which we do not want.";
139144
"pkgconf" comment => "pkgconfig renamed to pkgconf in rhel8";
140145
"selinux-policy-devel" comment => "maybe add to _7 and _6?";
141146
"openssl-devel";
142147

143-
(redhat_9).(yum_dnf_conf_ok)::
148+
(redhat_9|redhat_10).(yum_dnf_conf_ok)::
144149
"perl-Sys-Hostname" comment => "Needed by __04_examples_outputs_check_outputs_cf";
145150

151+
redhat_10.(yum_dnf_conf_ok)::
152+
"patch";
153+
"perl-FindBin" comment => "Needed by postgresql 18";
154+
146155
suse|opensuse|sles::
147156
"binutils";
148157
"gdb";
@@ -167,25 +176,25 @@ bundle agent cfengine_build_host_setup
167176
linux::
168177
"have_tmp_mount" expression => returnszero("mount | grep '/tmp'", "useshell");
169178
"have_coredumpctl" expression => returnszero("command -v coredumpctl", "useshell");
170-
"missing_opt_jdk21" expression => not(fileexists("/opt/jdk-21.0.1"));
179+
"missing_opt_jdk21" expression => not(fileexists("/opt/jdk-21.0.8"));
171180
(redhat|centos).!(redhat_6|centos_6|redhat_7|centos_7)::
172-
"yum_conf_ok" expression => returnszero("grep best=False /etc/yum.conf", "useshell");
181+
"yum_conf_ok" expression => returnszero("grep best=False /etc/yum.conf >/dev/null", "useshell");
173182
redhat_6|centos_6|redhat_7|centos_7::
174183
"yum_conf_ok" expression => "any"; # rhel/centos-6 and 7 do not support --nobest or best property in yum.conf
175184
redhat_8|centos_8::
176185
"have_fakeroot" expression => returnszero("command -v fakeroot >/dev/null", "useshell");
177-
redhat_8|centos_8|redhat_9::
186+
redhat_8|centos_8|redhat_9|redhat_10::
178187
"redhat_has_python3" expression => returnszero("command -v python3 >/dev/null", "useshell");
179-
"dnf_conf_ok" expression => returnszero("grep best=False /etc/dnf/dnf.conf", "useshell");
180-
redhat_8|centos_8|redhat_9::
188+
"dnf_conf_ok" expression => returnszero("grep best=False /etc/dnf/dnf.conf >/dev/null", "useshell");
189+
redhat_8|centos_8|redhat_9|redhat_10::
181190
"have_perl_package_installed" expression => returnszero("rpm -q perl >/dev/null", "useshell");
182-
redhat_9::
191+
redhat_9|redhat_10::
183192
"have_python3_pip_package_installed" expression => returnszero("rpm -q python3-pip >/dev/null", "useshell");
184193
!(redhat_6|centos_6|redhat_7|centos_7).(yum_conf_ok.dnf_conf_ok)::
185194
"yum_dnf_conf_ok" expression => "any";
186195
(redhat_6|centos_6|redhat_7|centos_7).(yum_conf_ok)::
187196
"yum_dnf_conf_ok" expression => "any";
188-
(redhat_7|centos_7|redhat_8|centos_8|redhat_9).(yum_dnf_conf_ok)::
197+
(redhat_7|centos_7|redhat_8|centos_8|redhat_9|redhat_10).(yum_dnf_conf_ok)::
189198
"have_development_tools" expression => returnszero("yum groups list installed | grep 'Development Tools' >/dev/null", "useshell"),
190199
comment => "note: centos-7 has installed instead of --installed argument, and that works on rhel-8 and rhel-9 so go with the sub-command instead of option";
191200

@@ -200,18 +209,18 @@ bundle agent cfengine_build_host_setup
200209
contain => in_shell;
201210
missing_opt_jdk21::
202211
"sh $(this.promise_dirname)/linux-install-jdk21.sh" contain => in_shell;
203-
(redhat_7|centos_7|redhat_8|centos_8|redhat_9).(!have_development_tools).(yum_dnf_conf_ok)::
212+
(redhat_7|centos_7|redhat_8|centos_8|redhat_9|redhat_10).(!have_development_tools).(yum_dnf_conf_ok)::
204213
"yum groups install -y 'Development Tools'" contain => in_shell;
205214
(redhat_8|centos_8).!have_fakeroot:: # special fakeroot, missing from _8 an d up?
206215
"sudo rpm -iv https://kojipkgs.fedoraproject.org//packages/fakeroot/1.23/1.fc29/x86_64/fakeroot-1.23-1.fc29.x86_64.rpm https://kojipkgs.fedoraproject.org//packages/fakeroot/1.23/1.fc29/x86_64/fakeroot-libs-1.23-1.fc29.x86_64.rpm"
207216
contain => in_shell;
208-
(redhat_8|centos_8|redhat_9).!redhat_has_python3::
217+
(redhat_8|centos_8|redhat_9|redhat_10).!redhat_has_python3::
209218
"yum install -y python3" -> { "CFE-4313" }
210219
contain => in_shell,
211220
comment => "workaround for yum package_method trying to install python3-*.* which causes conflicts.";
212-
(redhat_8|centos_8|redhat_9).!yum_conf_ok::
221+
(redhat_8|centos_8|redhat_9|redhat_10).!yum_conf_ok::
213222
"sed -i '/best=True/s/True/False/' /etc/yum.conf" contain => in_shell;
214-
(redhat_8|centos_8|redhat_9).!dnf_conf_ok::
223+
(redhat_8|centos_8|redhat_9|redhat_10).!dnf_conf_ok::
215224
"sed -i '/best=True/s/True/False/' /etc/dnf/dnf.conf" contain => in_shell;
216225

217226

@@ -241,7 +250,7 @@ root - core unlimited
241250
* - core unlimited
242251
");
243252

244-
ubuntu_16|ubuntu_18|redhat_9::
253+
ubuntu_16|ubuntu_18|redhat_9|redhat_10::
245254
"/etc/hosts" -> { "ENT-12437" }
246255
edit_line => regex_replace("127.0.0.1 localhost localhost.localdomain","127.0.0.1 localhost.localdomain"),
247256
comment => "In order for some check_outputs peers related tests to work, hostname -f must match sys.fqhost so remove localhost and leave localhost.localdomain";
@@ -279,19 +288,25 @@ jenkins_builds ALL=NOPASSWD: /usr/bin/podman
279288
create => "true",
280289
perms => mog("400", "root", "root");
281290

291+
redhat_10::
292+
"/usr/lib/rpm/redhat/macros"
293+
edit_line => insert_lines("%_empty_manifest_terminate_build 0"),
294+
depends_on => { "rpm_build_installed" };
295+
redhat_8|centos_8|redhat_9|centos_9|redhat_10::
296+
"/usr/lib/rpm/redhat/macros"
297+
edit_line => comment_lines_matching("%_enable_debug_packages 0", "#"),
298+
depends_on => { "rpm_build_installed" };
299+
282300
commands:
283301
sles_15::
284302
"zypper --non-interactive install --allow-downgrade ncurses-devel"
285303
comment => "Special case mentioned elsewhere in this policy. ncurses-devel requires a downgrade as of July 25 2025",
286304
contain => in_shell;
287-
(redhat_8|centos_8|redhat_9).(!have_perl_package_installed).(yum_dnf_conf_ok)::
305+
(redhat_8|centos_8|redhat_9|redhat_10).(!have_perl_package_installed).(yum_dnf_conf_ok)::
288306
"yum install -y perl" contain => in_shell,
289307
comment => "even though rhel8/9 come with /bin/perl perl >= 5.8.8 is needed by cfbuild-lcov-1.16-1.noarch. So the package must be installed.";
290-
redhat_9.!have_python3_pip_package_installed.(yum_dnf_conf_ok)::
308+
redhat_9|redhat_10.!have_python3_pip_package_installed.(yum_dnf_conf_ok)::
291309
"yum install -y python3-pip" contain => in_shell;
292-
redhat_8|centos_8|redhat_9|centos_9::
293-
"sudo sed -ri 's/^%_enable_debug_packages/#\0/' /usr/lib/rpm/redhat/macros" contain => in_shell,
294-
depends_on => { "rpm_build_installed" };
295310

296311
mingw_build_host.!have_i386_architecture::
297312
"${paths.dpkg} --add-architecture i386";

ci/setup-cfengine-build-host.sh

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ chown -R jenkins /home/jenkins
5656

5757
echo "checking for CFEngine install..."
5858
if [ -d /var/cfengine ]; then
59-
echo "Error: CFEngine already installed on this host. Will not proceed trying to setup build host with CFEngine temporary install."
60-
exit 1
59+
echo "Found CFEngine install at /var/cfengine"
60+
if ! /var/cfengine/bin/cf-agent -V; then
61+
echo "Failed to run cf-agent -V, will exit."
62+
exit 1
63+
fi
64+
echo "Found working cf-agent. Will proceed."
6165
fi
6266

6367
function cleanup()
@@ -76,9 +80,14 @@ function cleanup()
7680
echo "No supported package manager to uninstall cfengine."
7781
exit 1
7882
fi
79-
echo "Ensuring CFEngine fully uninstalled/cleaned up"
80-
# keep these logs around for debugging failed setup runs
81-
# rm -rf /var/cfengine /opt/cfengine /var/log/CFE* /var/log/postgresql.log || true
83+
echo "Cleaning up CFEngine install by moving to /var/bak.cfengine and /opt/bak.cfengine"
84+
rm -rf /var/bak.cfengine
85+
mv /var/cfengine /var/bak.cfengine || true
86+
rm -rf /opt/bak.cfengine
87+
mv /opt/cfengine /opt/bak.cfengine || true
88+
mv /var/log/CFE* /var/bak.cfengine/ ||| true
89+
mv /var/log/postgresql.log /var/bak.cfengine || true
90+
8291
if command -v pkill; then
8392
pkill -9 cf-agent || true
8493
pkill -9 cf-serverd || true
@@ -116,17 +125,21 @@ cd ..
116125
echo "Install any distribution upgrades"
117126
if [ -f /etc/os-release ]; then
118127
if grep rhel /etc/os-release; then
119-
yum upgrade --assumeyes
128+
yum update --assumeyes
129+
alias software='yum install --assumeyes'
120130
elif grep debian /etc/os-release; then
121131
DEBIAN_FRONTEND=noninteractive apt upgrade --yes && DEBIAN_FRONTEND=noninteractive apt autoremove --yes
132+
alias software='DEBIAN_FRONTEND=noninteractive apt install --yes'
122133
elif grep suse /etc/os-release; then
123134
zypper -n update
135+
alias software='zypper install -y'
124136
else
125137
echo "Unknown platform ID $ID. Need this information in order to update/upgrade distribution packages."
126138
exit 1
127139
fi
128140
elif [ -f /etc/redhat-release ]; then
129-
yum upgrade --assumeyes
141+
yum update --assumeyes
142+
alias software='yum install --assumeyes'
130143
else
131144
echo "No /etc/os-release or /etc/redhat-release so cant determine platform."
132145
exit 1
@@ -168,6 +181,28 @@ else
168181
bash ./quick-install-cfengine-enterprise.sh agent
169182
fi
170183

184+
# if cf-agent not installed, try cf-remote --version master
185+
if [ ! -x /var/cfengine/bin/cf-agent ]; then
186+
echo "quick install didn't install cf-agent, try cf-remote"
187+
# could try pipx or various package names for different distributions, or uv
188+
if software pipx; then
189+
pipx install cf-remote
190+
export PATH=$HOME/.local/bin:$PATH
191+
cf-remote --version master install --clients localhost
192+
fi
193+
fi
194+
195+
if [ ! -x /var/cfengine/bin/cf-agent ]; then
196+
echo "quickinstall and cf-remote didn't install cf-agent, try from source"
197+
CFE_VERSION=3.26.0 # need to use an actualy release which has a checksum for masterfiles download
198+
rm -rf core # just in case we are repeating the script
199+
git clone --recursive --depth 1 https://github.com/cfengine/core
200+
(
201+
cd core
202+
./ci/install.sh
203+
)
204+
fi
205+
171206
# get masterfiles
172207
urlget https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-"$CFE_VERSION"/misc/cfengine-masterfiles-"$CFE_VERSION"-1.pkg.tar.gz
173208

0 commit comments

Comments
 (0)