Skip to content

Commit

Permalink
chore: pull all build scripts under build_files directory (#177)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Gospodnetich <[email protected]>
Co-authored-by: Jorge O. Castro <[email protected]>
Co-authored-by: Benjamin Sherman <[email protected]>
  • Loading branch information
4 people authored Jan 26, 2025
1 parent adc4bb6 commit 568e01d
Show file tree
Hide file tree
Showing 46 changed files with 63 additions and 147 deletions.
37 changes: 7 additions & 30 deletions Containerfile.common
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG RPMFUSION_MIRROR=""
ARG DUAL_SIGN="true"

COPY build*.sh dual-sign*.sh /tmp/
COPY build_files/common build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
COPY --from=kernel_cache /tmp/rpms /tmp/kernel_cache

# files for akmods
COPY ublue-os-akmods-addons.spec /tmp/ublue-os-akmods-addons/ublue-os-akmods-addons.spec
COPY ublue-os-ucore-addons.spec /tmp/ublue-os-ucore-addons/ublue-os-ucore-addons.spec
ADD https://copr.fedorainfracloud.org/coprs/ublue-os/akmods/repo/fedora-${FEDORA_MAJOR_VERSION}/ublue-os-akmods-fedora-${FEDORA_MAJOR_VERSION}.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/_copr_ublue-os-akmods.repo
ADD https://negativo17.org/repos/fedora-multimedia.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/negativo17-fedora-multimedia.repo

RUN --mount=type=cache,dst=/var/cache/dnf \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-prep.sh && \
if [[ "${KERNEL_FLAVOR}" =~ "coreos" ]]; then \
/tmp/build-ublue-os-ucore-addons.sh && \
Expand All @@ -41,11 +44,6 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-ublue-os-akmods-addons.sh && \
cp /tmp/ublue-os-akmods-addons/rpmbuild/RPMS/noarch/ublue-os-akmods-addons*.rpm \
/var/cache/rpms/ublue-os/ && \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-kmod-framework-laptop.sh && \
/tmp/build-kmod-kvmfr.sh && \
/tmp/build-kmod-openrazer.sh && \
Expand All @@ -54,28 +52,7 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-kmod-xpadneo.sh && \
/tmp/build-kmod-xone.sh && \
/tmp/dual-sign.sh && \
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
for RPM in $(find /root/rpmbuild/RPMS/"$(uname -m)"/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
find /var/cache/rpms

# Remove kernel version from kmod package names
# 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%%-${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
/tmp/build-post.sh

FROM scratch

Expand Down
28 changes: 3 additions & 25 deletions Containerfile.extra
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG RPMFUSION_MIRROR=""
ARG DUAL_SIGN="true"

COPY build*.sh dual-sign*.sh /tmp/
COPY build_files/extra build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
COPY --from=kernel_cache /tmp/rpms /tmp/kernel_cache

# files for akmods
COPY ublue-os-akmods-addons.spec /tmp/ublue-os-akmods-addons/ublue-os-akmods-addons.spec
ADD https://copr.fedorainfracloud.org/coprs/ublue-os/akmods/repo/fedora-${FEDORA_MAJOR_VERSION}/ublue-os-akmods-fedora-${FEDORA_MAJOR_VERSION}.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/_copr_ublue-os-akmods.repo
ADD https://negativo17.org/repos/fedora-multimedia.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/negativo17-fedora-multimedia.repo

RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-prep.sh && \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-prep.sh && \
if grep -qv "asus" <<< "${KERNEL_FLAVOR}"; then \
/tmp/build-kmod-zenergy.sh && \
/tmp/build-kmod-evdi.sh \
Expand All @@ -58,28 +57,7 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-kmod-vhba.sh && \
/tmp/build-kmod-VirtualBox.sh && \
/tmp/dual-sign.sh && \
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
for RPM in $(find /root/rpmbuild/RPMS/"$(uname -m)"/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
find /var/cache/rpms

# Remove kernel version from kmod package names
# 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%%-${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
/tmp/build-post.sh

FROM scratch

Expand Down
37 changes: 7 additions & 30 deletions Containerfile.nvidia
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG RPMFUSION_MIRROR=""
ARG DUAL_SIGN="true"

COPY build*.sh dual-sign*.sh /tmp/
COPY build_files/nvidia build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
COPY --from=kernel_cache /tmp/rpms /tmp/kernel_cache

# files for nvidia
COPY ublue-os-nvidia-addons.spec /tmp/ublue-os-nvidia-addons/ublue-os-nvidia-addons.spec
COPY ublue-os-ucore-nvidia.spec /tmp/ublue-os-ucore-nvidia/ublue-os-ucore-nvidia.spec
COPY files/etc/sway/environment /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/environment
COPY files/usr/lib/systemd/system/ublue-nvctk-cdi.service /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/ublue-nvctk-cdi.service
COPY files/usr/lib/systemd/system/ublue-nvctk-cdi.service /tmp/ublue-os-ucore-nvidia/rpmbuild/SOURCES/ublue-nvctk-cdi.service
Expand All @@ -34,6 +32,11 @@ COPY files/usr/lib/systemd/system-preset/70-ublue-nvctk-cdi.preset /tmp/ublue-os
COPY files/etc/udev/rules.d/60-nvidia-extra-devices-pm.rules /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/60-nvidia-extra-devices-pm.rules

RUN --mount=type=cache,dst=/var/cache/dnf \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-prep.sh && \
if [[ "${KERNEL_FLAVOR}" =~ "coreos" ]]; then \
/tmp/build-ublue-os-ucore-nvidia.sh && \
Expand All @@ -43,35 +46,9 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-ublue-os-nvidia-addons.sh && \
cp /tmp/ublue-os-nvidia-addons/rpmbuild/RPMS/noarch/ublue-os-nvidia-addons*.rpm \
/var/cache/rpms/ublue-os/ && \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-kmod-nvidia.sh kernel && \
/tmp/dual-sign.sh && \
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
for RPM in $(find /root/rpmbuild/RPMS/"$(uname -m)"/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
find /var/cache/rpms

# Remove kernel version from kmod package names
# 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%%-${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
/tmp/build-post.sh

FROM scratch

Expand Down
37 changes: 7 additions & 30 deletions Containerfile.nvidia-open
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG RPMFUSION_MIRROR=""
ARG DUAL_SIGN="true"

COPY build*.sh dual-sign*.sh /tmp/
COPY build_files/nvidia build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
COPY --from=kernel_cache /tmp/rpms /tmp/kernel_cache

# files for nvidia
COPY ublue-os-nvidia-addons.spec /tmp/ublue-os-nvidia-addons/ublue-os-nvidia-addons.spec
COPY ublue-os-ucore-nvidia.spec /tmp/ublue-os-ucore-nvidia/ublue-os-ucore-nvidia.spec
COPY files/etc/sway/environment /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/environment
COPY files/usr/lib/systemd/system/ublue-nvctk-cdi.service /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/ublue-nvctk-cdi.service
COPY files/usr/lib/systemd/system/ublue-nvctk-cdi.service /tmp/ublue-os-ucore-nvidia/rpmbuild/SOURCES/ublue-nvctk-cdi.service
Expand All @@ -34,6 +32,11 @@ COPY files/usr/lib/systemd/system-preset/70-ublue-nvctk-cdi.preset /tmp/ublue-os
COPY files/etc/udev/rules.d/60-nvidia-extra-devices-pm.rules /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/60-nvidia-extra-devices-pm.rules

RUN --mount=type=cache,dst=/var/cache/dnf \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-prep.sh && \
if [[ "${KERNEL_FLAVOR}" =~ "coreos" ]]; then \
/tmp/build-ublue-os-ucore-nvidia.sh && \
Expand All @@ -43,35 +46,9 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-ublue-os-nvidia-addons.sh && \
cp /tmp/ublue-os-nvidia-addons/rpmbuild/RPMS/noarch/ublue-os-nvidia-addons*.rpm \
/var/cache/rpms/ublue-os/ && \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-kmod-nvidia.sh kernel-open && \
/tmp/dual-sign.sh && \
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
for RPM in $(find /root/rpmbuild/RPMS/"$(uname -m)"/ -type f -name \*.rpm); do \
cp "${RPM}" /var/cache/rpms/kmods/; \
done && \
find /var/cache/rpms

# Remove kernel version from kmod package names
# 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%%-${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
/tmp/build-post.sh

FROM scratch

Expand Down
5 changes: 2 additions & 3 deletions Containerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG RPMFUSION_MIRROR=""
ARG DUAL_SIGN="true"

COPY test-prep.sh dual-sign-check.sh /tmp/
COPY check-signatures.sh /
COPY build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
Expand All @@ -37,4 +36,4 @@ RUN --mount=type=cache,dst=/var/cache/dnf \
; fi && \
/tmp/test-prep.sh

CMD ["/check-signatures.sh"]
CMD ["/tmp/check-signatures.sh"]
22 changes: 4 additions & 18 deletions Containerfile.zfs
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,23 @@ ARG DUAL_SIGN="true"
ARG RPMFUSION_MIRROR=""
ARG ZFS_MINOR_VERSION="${ZFS_MINOR_VERSION:-2.2}"

COPY build*.sh dual-sign*.sh /tmp/
COPY build_files/zfs build_files/shared /tmp/
COPY certs /tmp/certs

# cached kernel rpms
COPY --from=kernel_cache /tmp/rpms /tmp/kernel_cache

# Set kernel name
RUN --mount=type=cache,dst=/var/cache/dnf \
/tmp/build-prep.sh && \
if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
export KERNEL_NAME="kernel" \
; else \
export KERNEL_NAME="kernel-surface" \
; fi && \
/tmp/build-prep.sh && \
/tmp/build-kmod-zfs.sh && \
/tmp/dual-sign-zfs.sh

# Remove kernel version from kmod package names
# 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%%-${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
/tmp/dual-sign-zfs.sh && \
/tmp/build-post.sh

FROM scratch

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions build_files/shared/build-post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -oeux pipefail

# Ensure packages get copied to /var/cache/rpms
if [ -d /var/cache/akmods ]; then
for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do
cp "${RPM}" /var/cache/rpms/kmods/
done
fi

if [ -d /root/rpmbuild/RPMS/"$(uname -m)" ]; then
for RPM in $(find /root/rpmbuild/RPMS/"$(uname -m)"/ -type f -name \*.rpm); do
cp "${RPM}" /var/cache/rpms/kmods/
done
fi

# Remove kernel version from kmod package names
# FIXME: The sed is a gross hack, maybe PR upstream?
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_NAME}" | head -n 1)
for rpm in $(find /var/cache/rpms/kmods -type f -name \*.rpm); do
basename=$(basename ${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

find /var/cache/rpms
6 changes: 1 addition & 5 deletions build-prep.sh → build_files/shared/build-prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ mkdir -p /var/lib/alternatives
echo "Installing ${KERNEL_FLAVOR} kernel-cache RPMs..."
# fedora image has no kernel so this needs nothing fancy, just install
dnf install -y /tmp/kernel_cache/*.rpm
if [[ "${KERNEL_FLAVOR}" == "surface" ]]; then
KERNEL_VERSION=$(rpm -q kernel-surface|cut -d '-' -f2-)
else
KERNEL_VERSION=$(rpm -q kernel|cut -d '-' -f2-)
fi
KERNEL_VERSION=$(rpm -q "${KERNEL_NAME}" | cut -d '-' -f2-)

# enable more repos
RPMFUSION_MIRROR_RPMS="https://mirrors.rpmfusion.org"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions dual-sign-zfs.sh → build_files/zfs/dual-sign-zfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,3 @@ if [[ "${DUAL_SIGN}" == "true" ]]; then
done
mv -f /root/rpmbuild/RPMS/"$(uname -m)"/kmod-*.rpm /var/cache/rpms/kmods/zfs/
fi

for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do
cp "${RPM}" /var/cache/rpms/kmods/
done

find /var/cache/rpms

0 comments on commit 568e01d

Please sign in to comment.