@@ -15,54 +15,80 @@ arch=$(uname -m)
1515destdir=/usr/share/rpm-ostree/extensions/
1616mkdir -p " ${destdir} "
1717
18- # ipsec extension
19- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
20- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
21- libreswan NetworkManager-libreswan openvswitch3.5-ipsec
18+ # Determine which extensions JSON file to use based on OS
19+ extensions_json=" extensions/${ID} -${VERSION_ID} .json"
2220
23- # usbguard extension
24- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
25- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
26- usbguard
21+ # Get kernel version for packages that need to match the base kernel
22+ # Include epoch (0:) so dnf can disambiguate name from version in NEVRA format
23+ kernel_evr=$( rpm -q --queryformat ' %{VERSION}-%{RELEASE}' kernel)
2724
28- # kerberos extension
29- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
30- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
31- krb5-workstation libkadm5
25+ # Export variables that will be substituted in package names
26+ export kernel_evr
3227
33- # sysstat extension
34- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
35- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
36- sysstat
28+ # Helper function to download packages for an extension
29+ download_extension () {
30+ local extension_name=$1
3731
38- # kernel-devel and kernel extensions (pinned to installed kernel version)
39- # Include epoch (0:) so dnf can disambiguate name from version in NEVRA format
40- kernel_evr=$( rpm -q --queryformat ' %{VERSION}-%{RELEASE}' kernel)
41- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
42- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
43- " kernel-devel-0:${kernel_evr} " " kernel-headers-0:${kernel_evr} " \
44- " kernel-0:${kernel_evr} " " kernel-core-0:${kernel_evr} " \
45- " kernel-modules-0:${kernel_evr} " " kernel-modules-extra-0:${kernel_evr} "
32+ # Get packages for this extension from JSON, performing variable substitution
33+ local packages
34+ packages=$( jq -r " .extensions[\" ${extension_name} \" ].packages[]" " $extensions_json " | while read -r pkg; do
35+ # Perform variable substitution
36+ eval " echo \" $pkg \" "
37+ done)
4638
47- # kernel-rt extension (x86_64 only, pinned to installed kernel version)
48- if [ " ${arch} " = " x86_64" ]; then
49- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
50- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
51- " kernel-rt-core-0:${kernel_evr} " " kernel-rt-modules-0:${kernel_evr} " \
52- " kernel-rt-modules-extra-0:${kernel_evr} " " kernel-rt-devel-0:${kernel_evr} "
53- fi
39+ # Download the packages
40+ if [ -n " $packages " ]; then
41+ echo " Downloading extension: ${extension_name} "
42+ dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
43+ --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
44+ ${packages}
45+ fi
46+ }
5447
55- # kernel-64k extension (aarch64 only)
56- if [ " ${arch} " = " aarch64" ]; then
57- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
58- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
59- " kernel-64k-core-0:${kernel_evr} " " kernel-64k-modules-0:${kernel_evr} " \
60- " kernel-64k-modules-core-0:${kernel_evr} " " kernel-64k-modules-extra-0:${kernel_evr} "
48+ # Check if the extensions JSON file exists
49+ if [ ! -f " $extensions_json " ]; then
50+ echo " Error: Extensions file not found: $extensions_json "
51+ exit 1
6152fi
6253
63- # two-node-ha extension (RHEL only)
64- if [ " $ID " = " rhel" ]; then
65- dnf --repo=" ${YUM_REPO_NAMES} " download --resolve --alldeps \
66- --arch=" ${arch} " --arch=noarch --destdir=" ${destdir} " \
67- pacemaker pcs fence-agents-all
68- fi
54+ # Loop through all extensions defined in the JSON file
55+ for extension in $( jq -r ' .extensions | keys[]' " $extensions_json " ) ; do
56+ echo " Processing extension: ${extension} "
57+
58+ # Check architecture constraints
59+ architectures=$( jq -r " .extensions[\" ${extension} \" ].architectures[]? // empty" " $extensions_json " )
60+ if [ -n " $architectures " ]; then
61+ # Extension has architecture constraints - check if current arch matches
62+ arch_match=false
63+ for ext_arch in $architectures ; do
64+ if [ " $arch " = " $ext_arch " ]; then
65+ arch_match=true
66+ break
67+ fi
68+ done
69+ if [ " $arch_match " = false ]; then
70+ echo " Skipping ${extension} (not for ${arch} )"
71+ continue
72+ fi
73+ fi
74+
75+ # Check variant constraints (e.g., RHEL only)
76+ variants=$( jq -r " .extensions[\" ${extension} \" ].variants[]? // empty" " $extensions_json " )
77+ if [ -n " $variants " ]; then
78+ # Extension has variant constraints - check if current OS ID matches
79+ variant_match=false
80+ for ext_variant in $variants ; do
81+ if [ " $ID " = " $ext_variant " ]; then
82+ variant_match=true
83+ break
84+ fi
85+ done
86+ if [ " $variant_match " = false ]; then
87+ echo " Skipping ${extension} (not for ${ID} )"
88+ continue
89+ fi
90+ fi
91+
92+ # Download the extension packages
93+ download_extension " $extension "
94+ done
0 commit comments