Skip to content

Commit

Permalink
chore: refactor package rename script to support all kernel versions (#…
Browse files Browse the repository at this point in the history
…259)

Co-authored-by: Benjamin Sherman <benjamin@holyarmy.org>
  • Loading branch information
p5 and bsherman authored Oct 22, 2024
1 parent 3516e7b commit 27e72cc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
10 changes: 7 additions & 3 deletions Containerfile.common
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
find /var/cache/rpms

# Remove kernel version from kmod package names
# FIXME: This will only work for 6.* kernels unfortunately
# FIXME: The sed is a gross hack, maybe PR upstream?
RUN set -e; \
sed -i -e 's/args = \["rpmbuild", "-bb"\]/args = \["rpmbuild", "-bb", "--buildroot", "#{build_path}\/BUILD"\]/g' /usr/local/share/gems/gems/fpm-*/lib/fpm/package/rpm.rb; \
kernel_version=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel-core | head -n 1); \
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do \
basename=$(basename ${rpm}); \
name=${basename%%-6*}; \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
name=${basename%%-${kernel_version}*}; \
if [[ "$basename" == *"$kernel_version"* ]]; then \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
else \
echo "Skipping $basename rebuild as its name does not contain $kernel_version"; \
fi; \
done

FROM scratch
Expand Down
11 changes: 7 additions & 4 deletions Containerfile.extra
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,20 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
find /var/cache/rpms

# Remove kernel version from kmod package names
# FIXME: This will only work for 6.* kernels unfortunately
# FIXME: The sed is a gross hack, maybe PR upstream?
RUN set -e; \
sed -i -e 's/args = \["rpmbuild", "-bb"\]/args = \["rpmbuild", "-bb", "--buildroot", "#{build_path}\/BUILD"\]/g' /usr/local/share/gems/gems/fpm-*/lib/fpm/package/rpm.rb; \
kernel_version=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel-core | head -n 1); \
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do \
basename=$(basename ${rpm}); \
name=${basename%%-6*}; \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
name=${basename%%-${kernel_version}*}; \
if [[ "$basename" == *"$kernel_version"* ]]; then \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
else \
echo "Skipping $basename rebuild as its name does not contain $kernel_version"; \
fi; \
done

FROM scratch

COPY --from=builder /var/cache/rpms /rpms

10 changes: 7 additions & 3 deletions Containerfile.nvidia
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
find /var/cache/rpms

# Remove kernel version from kmod package names
# FIXME: This will only work for 6.* kernels unfortunately
# FIXME: The sed is a gross hack, maybe PR upstream?
RUN set -e; \
sed -i -e 's/args = \["rpmbuild", "-bb"\]/args = \["rpmbuild", "-bb", "--buildroot", "#{build_path}\/BUILD"\]/g' /usr/local/share/gems/gems/fpm-*/lib/fpm/package/rpm.rb; \
kernel_version=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel-core | head -n 1); \
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do \
basename=$(basename ${rpm}); \
name=${basename%%-6*}; \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
name=${basename%%-${kernel_version}*}; \
if [[ "$basename" == *"$kernel_version"* ]]; then \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
else \
echo "Skipping $basename rebuild as its name does not contain $kernel_version"; \
fi; \
done

FROM scratch
Expand Down
10 changes: 7 additions & 3 deletions Containerfile.nvidia-open
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
find /var/cache/rpms

# Remove kernel version from kmod package names
# FIXME: This will only work for 6.* kernels unfortunately
# FIXME: The sed is a gross hack, maybe PR upstream?
RUN set -e; \
sed -i -e 's/args = \["rpmbuild", "-bb"\]/args = \["rpmbuild", "-bb", "--buildroot", "#{build_path}\/BUILD"\]/g' /usr/local/share/gems/gems/fpm-*/lib/fpm/package/rpm.rb; \
kernel_version=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel-core | head -n 1); \
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do \
basename=$(basename ${rpm}); \
name=${basename%%-6*}; \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
name=${basename%%-${kernel_version}*}; \
if [[ "$basename" == *"$kernel_version"* ]]; then \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
else \
echo "Skipping $basename rebuild as its name does not contain $kernel_version"; \
fi; \
done

FROM scratch
Expand Down
10 changes: 7 additions & 3 deletions Containerfile.zfs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/dual-sign-zfs.sh

# Remove kernel version from kmod package names
# FIXME: This will only work for 6.* kernels unfortunately
# FIXME: The sed is a gross hack, maybe PR upstream?
RUN set -e; \
sed -i -e 's/args = \["rpmbuild", "-bb"\]/args = \["rpmbuild", "-bb", "--buildroot", "#{build_path}\/BUILD"\]/g' /usr/local/share/gems/gems/fpm-*/lib/fpm/package/rpm.rb; \
kernel_version=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel-core | head -n 1); \
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do \
basename=$(basename ${rpm}); \
name=${basename%%-6*}; \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
name=${basename%%-${kernel_version}*}; \
if [[ "$basename" == *"$kernel_version"* ]]; then \
fpm --verbose -s rpm -t rpm -p ${rpm} -f --name ${name} ${rpm}; \
else \
echo "Skipping $basename rebuild as its name does not contain $kernel_version"; \
fi; \
done

FROM scratch
Expand Down

0 comments on commit 27e72cc

Please sign in to comment.