Skip to content

Commit c1bc9aa

Browse files
committed
docker: find RPM provides from symvers directly
Using the RPM macros to generate the symbols provided by the currently running kernel takes a lot of time: every module is manually unpacked, read and processed. However, the same information is already available in the "/lib/modules/*/symvers*" file. We just have to parse it to generate output compatible with the existing infrastructure. In a quick test, this reduces the load time for the DRBD module from minutes to one second.
1 parent d8214d4 commit c1bc9aa

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

docker/Dockerfile.rhel7

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Cri
2121
make \
2222
patch \
2323
perl \
24-
redhat-rpm-config \
2524
yum-utils \
2625
&& \
2726
yum clean all -y && \

docker/Dockerfile.rhel8

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM $EXTRAPKGS as extrapkgs
33
# by checking for /pkgs we can cache that step
44
# and prepare images that already contain the packages.
55
RUN mkdir /pkgs
6-
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel kernel-rpm-macros && rm -f *.i686.rpm # !lbbuild
6+
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild
77

88
FROM registry.access.redhat.com/ubi8/ubi
99
MAINTAINER Roland Kammerer <[email protected]>
@@ -39,7 +39,7 @@ RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Cri
3939
COPY --from=extrapkgs /pkgs /pkgs
4040
RUN yum install -y /pkgs/*.rpm # !lbbuild
4141
# or
42-
# =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel kernel-rpm-macros
42+
# =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel
4343

4444
RUN rm -rf /pkgs
4545

docker/Dockerfile.rhel9

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM $EXTRAPKGS as extrapkgs
33
# by checking for /pkgs we can cache that step
44
# and prepare images that already contain the packages.
55
RUN mkdir /pkgs
6-
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel kernel-rpm-macros && rm -f *.i686.rpm # !lbbuild
6+
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild
77

88
FROM registry.access.redhat.com/ubi9/ubi
99
MAINTAINER Roland Kammerer <[email protected]>
@@ -37,7 +37,7 @@ RUN dnf -y update-minimal --security --sec-severity=Important --sec-severity=Cri
3737
COPY --from=extrapkgs /pkgs /pkgs
3838
RUN dnf install -y /pkgs/*.rpm # !lbbuild
3939
# or
40-
# =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel kernel-rpm-macros
40+
# =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel
4141

4242
RUN rm -rf /pkgs
4343

docker/entry.sh

+20-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,26 @@ kos::rpm::bestbyrpmprovides() {
189189
local drbd_requires_file
190190
shift 1
191191

192-
sort > "$kernel_provides_file" \
193-
<(find "/lib/modules/$(uname -r)" -name "symvers*" | /lib/rpm/kabi.sh) \
194-
<(find "/lib/modules/$(uname -r)/kernel" -type f | /lib/rpm/redhat/find-provides.ksyms)
192+
local kernel_symvers
193+
local cat_prog
194+
if [ -e "/lib/modules/"$(uname -r)"/symvers" ]; then
195+
kernel_symvers="/lib/modules/"$(uname -r)"/symvers"
196+
cat_prog=cat
197+
elif [ -e "/lib/modules/"$(uname -r)"/symvers.gz" ]; then
198+
kernel_symvers="/lib/modules/"$(uname -r)"/symvers.gz"
199+
cat_prog=zcat
200+
elif [ -e "/lib/modules/"$(uname -r)"/symvers.xz" ]; then
201+
kernel_symvers="/lib/modules/"$(uname -r)"/symvers.xz"
202+
cat_prog=xzcat
203+
else
204+
debug "Failed to find kernel symvers file"
205+
return 1
206+
fi
207+
208+
"$cat_prog" "$kernel_symvers" \
209+
| awk -F"\t" '{ print "kernel(" $2 ") = " $1 }' \
210+
| sort \
211+
> "$kernel_provides_file"
195212

196213
if [ ! -s "$kernel_provides_file" ]; then
197214
debug "Failed to generate kernel provides"

0 commit comments

Comments
 (0)