Skip to content

Commit 7c217f1

Browse files
committed
Additional checks & resilience in rebuild scripts
1 parent f046657 commit 7c217f1

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

internal/lib/distro_info.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,25 @@ def numeric(distro)
2323
def latest_nginx_available_parts(release, distro)
2424
arch = "x86_64"
2525
url = case distro
26-
when :rocky then "https://dl.rockylinux.org/pub/rocky/#{numeric(release)}/AppStream/#{arch}/os/Packages/n/"
27-
when :alma then "https://repo.almalinux.org/almalinux/#{numeric(release)}/AppStream/#{arch}/os/Packages/"
28-
when :rhel then "https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi#{numeric(release)}/#{numeric(release)}/#{arch}/appstream/os/Packages/n/"
26+
when :rocky then "https://dl.rockylinux.org/pub/rocky/#{numeric(release)}"
27+
when :alma then "https://repo.almalinux.org/almalinux/#{numeric(release)}"
28+
when :rhel then "https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi#{numeric(release)}/#{numeric(release)}"
2929
end
30+
31+
if release < 10
32+
url += case distro
33+
when :rocky then "/AppStream/#{arch}/os/Packages/n/"
34+
when :alma then "/AppStream/#{arch}/os/Packages/"
35+
when :rhel then "/#{arch}/appstream/os/Packages/n/"
36+
end
37+
else
38+
url += case distro
39+
when :rocky then "/devel/#{arch}/os/Packages/n/"
40+
when :alma then "/CRB/#{arch}/os/Packages/"
41+
when :rhel then "/#{arch}/appstream/os/Packages/n/" # path for nginx-mod-stream because nginx-mod-devel not in ubi10
42+
end
43+
end
44+
3045
cache_file = "/tmp/#{distro}_#{release}_nginx_version.txt"
3146
if !File.exist?(cache_file) || ((Time.now - 60*60*24) > File.mtime(cache_file))
3247
if RUBY_VERSION >= '2.5'
@@ -39,7 +54,7 @@ def latest_nginx_available_parts(release, distro)
3954
end
4055
end
4156
version_parts = doc
42-
.css('a[href^="nginx-"]')
57+
.css('a[href^="nginx-mod-"]') # cannot use full nginx-mod-devel name because ubi10 doesn't include that package for some reason
4358
.map { |el| el['href'] }
4459
.reject { |s| [ "-mod-", ".noarch.", "-core-" ].any? { |p| s.include?(p) } }
4560
.map { |url| URI.decode_uri_component(url).delete_suffix(".#{arch}.rpm").split('-').slice(1..) }

internal/rebuild/update-source-rpm.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ require_envvar ROCKY_NGINX_VERSION "$ROCKY_NGINX_VERSION"
1818
require_envvar ALMA_NGINX_VERSION "$ALMA_NGINX_VERSION"
1919
require_envvar RHEL_NGINX_VERSION "$RHEL_NGINX_VERSION"
2020

21+
# Being the upstream, RHEL should always update first. (Alma is based on CentOS Stream so that might not be true, but we can't help that)
22+
if [[ "$RHEL_NGINX_VERSION" =~ (\.[0-9]+)$ ]]; then
23+
SUFFIX="${BASH_REMATCH[1]}"
24+
if [[ "$ALMA_NGINX_VERSION" == *"$SUFFIX" ]] && [[ "$ROCKY_NGINX_VERSION" == *"$SUFFIX" ]]; then
25+
# fine
26+
else
27+
echo "RHEL, Rocky, & Alma packages out of sync." >&2
28+
echo "RHEL: $RHEL_NGINX_VERSION" >&2
29+
echo "Alma: $ALMA_NGINX_VERSION" >&2
30+
echo "Rocky: $ROCKY_NGINX_VERSION" >&2
31+
exit 1
32+
fi
33+
fi
34+
2135
declare spec_target_dir="${RPM_SPECS_DIR}/${DISTRO_ID}"
2236
declare spec_target_file="${spec_target_dir}/${PASSENGER_RPM_NAME}.spec"
2337
readarray -t OLD_PASSENGER_RPM_NAME < <(find "${RPM_SOURCES_DIR}" -name "${PASSENGER_RPM_NAME}*${DISTRO_ID}*.src.rpm" -printf '%f\n')

0 commit comments

Comments
 (0)