Skip to content

Commit

Permalink
docker: find RPM provides from symvers directly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
WanzenBug committed Jan 28, 2025
1 parent d8214d4 commit c1bc9aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
1 change: 0 additions & 1 deletion docker/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Cri
make \
patch \
perl \
redhat-rpm-config \
yum-utils \
&& \
yum clean all -y && \
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM $EXTRAPKGS as extrapkgs
# by checking for /pkgs we can cache that step
# and prepare images that already contain the packages.
RUN mkdir /pkgs
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel kernel-rpm-macros && rm -f *.i686.rpm # !lbbuild
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild

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

RUN rm -rf /pkgs

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.rhel9
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM $EXTRAPKGS as extrapkgs
# by checking for /pkgs we can cache that step
# and prepare images that already contain the packages.
RUN mkdir /pkgs
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel kernel-rpm-macros && rm -f *.i686.rpm # !lbbuild
RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild

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

RUN rm -rf /pkgs

Expand Down
23 changes: 20 additions & 3 deletions docker/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,26 @@ kos::rpm::bestbyrpmprovides() {
local drbd_requires_file
shift 1

sort > "$kernel_provides_file" \
<(find "/lib/modules/$(uname -r)" -name "symvers*" | /lib/rpm/kabi.sh) \
<(find "/lib/modules/$(uname -r)/kernel" -type f | /lib/rpm/redhat/find-provides.ksyms)
local kernel_symvers
local cat_prog
if [ -e "/lib/modules/"$(uname -r)"/symvers" ]; then
kernel_symvers="/lib/modules/"$(uname -r)"/symvers"
cat_prog=cat
elif [ -e "/lib/modules/"$(uname -r)"/symvers.gz" ]; then
kernel_symvers="/lib/modules/"$(uname -r)"/symvers.gz"
cat_prog=zcat
elif [ -e "/lib/modules/"$(uname -r)"/symvers.xz" ]; then
kernel_symvers="/lib/modules/"$(uname -r)"/symvers.xz"
cat_prog=xzcat
else
debug "Failed to find kernel symvers file"
return 1
fi

"$cat_prog" "$kernel_symvers" \
| awk -F"\t" '{ print "kernel(" $2 ") = " $1 }' \
| sort \
> "$kernel_provides_file"

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

0 comments on commit c1bc9aa

Please sign in to comment.