This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first attempt to build zfs kmods into scratch image
- Loading branch information
Showing
4 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#Build from base, simpley because it's the smallest image | ||
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-fedora-coreos}" | ||
ARG BASE_IMAGE="quay.io/fedora/${SOURCE_IMAGE}" | ||
ARG COREOS_VERSION="${COREOS_VERSION:-stable}" | ||
|
||
FROM ${BASE_IMAGE}:${COREOS_VERSION} AS builder | ||
ARG COREOS_VERSION="${COREOS_VERSION:-stable}" | ||
|
||
#RUN ln -s /usr/bin/rpm-ostree /usr/bin/dnf | ||
COPY build*.sh /tmp | ||
COPY certs /tmp/certs | ||
|
||
|
||
RUN /tmp/build-prep.sh | ||
|
||
RUN /tmp/build-kmod-zfs.sh | ||
|
||
RUN for RPM in $(find /var/cache/akmods/ -type f -name \*.rpm); do \ | ||
cp "${RPM}" /var/cache/rpms/kmods/; \ | ||
done | ||
|
||
RUN find /var/cache/rpms | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /var/cache/rpms /rpms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
|
||
set -oeux pipefail | ||
|
||
|
||
ARCH="$(rpm -E '%_arch')" | ||
KERNEL="$(rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" | ||
RELEASE="$(rpm -E '%fedora')" | ||
|
||
cd /tmp | ||
|
||
# Use cURL to fetch the given URL, saving the response to `data.json` | ||
curl "https://api.github.com/repos/openzfs/zfs/releases" -o data.json | ||
ZFS_VERSION=$(jq -r '[ .[] | select(.prerelease==false and .draft==false) ][0].name' data.json|cut -f2- -d-) | ||
ZFS_PREVIOUS=$(jq -r '[ .[] | select(.prerelease==false and .draft==false) ][1].name' data.json|cut -f2- -d-) | ||
|
||
### zfs specific build deps | ||
rpm-ostree install libtirpc-devel libblkid-devel libuuid-devel libudev-devel openssl-devel zlib-devel libaio-devel libattr-devel elfutils-libelf-devel python3-devel libffi-devel libcurl-devel | ||
|
||
|
||
### BUILD zfs | ||
echo "getting zfs-${ZFS_VERSION}.tar.gz" | ||
curl -L -O https://github.com/openzfs/zfs/releases/download/zfs-${ZFS_VERSION}/zfs-${ZFS_VERSION}.tar.gz | ||
tar xzf zfs-${ZFS_VERSION}.tar.gz | ||
|
||
cd /tmp/zfs-${ZFS_VERSION} | ||
./configure \ | ||
-with-linux=/usr/src/kernels/${KERNEL}/ \ | ||
-with-linux-obj=/usr/src/kernels/${KERNEL}/ \ | ||
&& make -j 1 rpm-utils rpm-kmod \ | ||
|| (cat config.log && exit 1) | ||
|
||
|
||
# create a directory for later copying of resulting zfs specific artifacts | ||
mkdir -p /var/cache/rpms/kmods/zfs/{debug,devel,other,src} \ | ||
&& mv *src.rpm /var/cache/rpms/kmods/zfs/src/ \ | ||
&& mv *devel*.rpm /var/cache/rpms/kmods/zfs/devel/ \ | ||
&& mv *debug*.rpm /var/cache/rpms/kmods/zfs/debug/ \ | ||
&& mv zfs-dracut*.rpm /var/cache/rpms/kmods/zfs/other/ \ | ||
&& mv zfs-test*.rpm /var/cache/rpms/kmods/zfs/other/ \ | ||
&& mv *.rpm /var/cache/rpms/kmods/zfs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/sh | ||
|
||
set -oeux pipefail | ||
|
||
|
||
### PREPARE REPOS | ||
ARCH="$(rpm -E '%_arch')" | ||
RELEASE="$(rpm -E '%fedora')" | ||
|
||
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo | ||
|
||
mkdir /tmp/rpms | ||
curl -sL --output-dir /tmp/rpms --remote-name \ | ||
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-${RELEASE}.noarch.rpm | ||
curl -sL --output-dir /tmp/rpms --remote-name \ | ||
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-${RELEASE}.noarch.rpm | ||
|
||
# enable testing repos if not enabled on testing stream | ||
if [[ "testing" == "${COREOS_VERSION}" ]]; then | ||
for REPO in $(ls /etc/yum.repos.d/fedora-updates-testing{,-modular}.repo); do | ||
if [[ "$(grep enabled=1 ${REPO} > /dev/null; echo $?)" == "1" ]]; then | ||
echo "enabling $REPO" && \ | ||
sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' ${REPO}; | ||
fi; | ||
done; | ||
fi | ||
|
||
|
||
# enable RPMs with alternatives to create them in this image build | ||
mkdir -p /var/lib/alternatives | ||
|
||
find /tmp/ | ||
rpm-ostree install \ | ||
/tmp/rpms/*.rpm \ | ||
fedora-repos-archive | ||
|
||
|
||
### PREPARE BUILD ENV | ||
# stuff for akmods | ||
rpm-ostree install \ | ||
akmods \ | ||
mock | ||
|
||
# stuff for dkms | ||
rpm-ostree install \ | ||
autoconf \ | ||
automake \ | ||
dkms \ | ||
git \ | ||
libtool \ | ||
ncompress | ||
|
||
if [[ ! -s "/tmp/certs/private_key.priv" ]]; then | ||
echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds." | ||
cp /tmp/certs/private_key.priv{.test,} | ||
cp /tmp/certs/public_key.der{.test,} | ||
fi | ||
|
||
install -Dm644 /tmp/certs/public_key.der /etc/pki/akmods/certs/public_key.der | ||
install -Dm644 /tmp/certs/private_key.priv /etc/pki/akmods/private/private_key.priv | ||
|
||
# protect against incorrect permissions in tmp dirs which can break akmods builds | ||
chmod 1777 /tmp /var/tmp | ||
|
||
# create a directory for later copying of resulting artifacts | ||
mkdir -p /var/cache/rpms/kmods |