Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

releng/make-binary.sh: build images for all installed kernels #710

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 49 additions & 30 deletions releng/make-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,71 @@ else
mkdir -p "${assets}"
fi

kernels="$(podman run --rm --entrypoint /bin/sh "${buildtag}" -c \
"xbps-query -p pkgver -s '^linux[0-9]+\.[0-9]+' --regex \
| sed 's/: .*//' | xargs -n1 xbps-uhelper getpkgversion | sort | uniq")" || kernels=

for style in release recovery; do
echo "Building style: ${style}"

# Always start with a fresh configuration tree
mkdir -p "${buildtmp}/build/dracut.conf.d" || error "cannot create config tree"

# Copy style-specific configuration components in place;
# build container sets up standard configuration elements
cp "./etc/zfsbootmenu/${style}.yaml" "${buildtmp}/build/config.yaml"
cp "./etc/zfsbootmenu/${style}.conf.d/"*.conf "${buildtmp}/build/dracut.conf.d"

# Make sure there is an output directory for this asset style
zbmtriplet="zfsbootmenu-${style}-${arch}-v${release}"

outdir="${buildtmp}/${zbmtriplet}"
mkdir -p "${outdir}" || error "cannot create output directory"

# Copy style-specific configuration components in place;
# build container sets up standard configuration elements
cp "./etc/zfsbootmenu/${style}.yaml" "${buildtmp}/build/config.yaml"
cp "./etc/zfsbootmenu/${style}.conf.d/"*.conf "${buildtmp}/build/dracut.conf.d"
for kern in ${kernels}; do
kern_args=()
if [ -n "${kern}" ]; then
echo "Building style ${style} for kernel ${kern}"
kern_args=( "--" "--kver" "${kern}" )
fi

# In addition to common mounts which expose source repo and build configs,
# make sure a writable output directory is available for this style and
# build the EFI bundle if it is supported for this arch
if ! podman run --rm \
"${volmounts[@]}" -v "${outdir}:/out" \
"${buildtag}" -o /out -e ".EFI.Enabled = ${BUILD_EFI}"; then
error "failed to create image"
fi
# In addition to common mounts which expose source repo and build configs,
# make sure a writable output directory is available for this style and
# build the EFI bundle if it is supported for this arch
if ! podman run --rm \
"${volmounts[@]}" -v "${outdir}:/out" \
"${buildtag}" -o /out -e ".EFI.Enabled = ${BUILD_EFI}" "${kern_args[@]}"; then
error "failed to create image"
fi

# EFI file is currently only built on x86_64
if [ "${BUILD_EFI}" = "true" ]; then
if ! cp "${outdir}/vmlinuz.EFI" "${assets}/${zbmtriplet}-vmlinuz.EFI"; then
error "failed to copy UEFI bundle"
if [ "${BUILD_EFI}" = "true" ]; then
# If EFI file was produced, copy it
efibase="${zbmtriplet}-vmlinuz"
[ -n "${kern}" ] && efibase="${efibase}-${kern}"
if ! cp "${outdir}/vmlinuz.EFI" "${assets}/${efibase}.EFI"; then
error "failed to copy UEFI bundle"
fi
rm -f "${outdir}/vmlinuz.EFI"
fi
rm -f "${outdir}/vmlinuz.EFI"
fi

have_components=
for f in "${outdir}"/*; do
[ -e "${f}" ] || continue
have_components="yes"
break
done
have_components=
for f in "${outdir}"/*; do
[ -e "${f}" ] || continue
have_components="yes"
break
done

if [ -n "${have_components}" ]; then
# If components were produced, archive them
tarbase="${zbmtriplet}"
[ -n "${kern}" ] && tarbase="${tarbase}-${kern}"
( cd "${buildtmp}" && \
tar -czvf "${assets}/${tarbase}.tar.gz" "${zbmtriplet}"
) || error "failed to pack components"
fi

if [ -n "${have_components}" ]; then
# If components were produced, archive them
( cd "${buildtmp}" && \
tar -czvf "${assets}/${zbmtriplet}.tar.gz" "${zbmtriplet}"
) || error "failed to pack components"
fi
rm -f "${outdir}/*"
done

# Clean up the style-specific build components
rm -rf "${buildtmp}/build" "${outdir}"
Expand Down
21 changes: 11 additions & 10 deletions releng/tag-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ mkdir -p "releng/assets/${release}"

asset_dir="$( realpath -e "releng/assets/${release}" )"
asset_files=()
assets=()

# Create binary assets
if ! releng/make-binary.sh "${release}"; then
Expand All @@ -153,18 +152,20 @@ if ! releng/sign-assets.sh "${release}"; then
fi

for style in release recovery; do
assets+=( "zfsbootmenu-${style}-${arch}-v${release}-vmlinuz.EFI" )
assets+=( "zfsbootmenu-${style}-${arch}-v${release}.tar.gz" )
done

for asset in "${assets[@]}" ; do
f="${asset_dir}/${asset}"
[ -f "${f}" ] || error "ERROR: missing release asset ${f}"
asset_files+=( "${f}" )
asset_base="zfsbootmenu-${style}-${arch}-v${release}"
for f in "${asset_dir}/${asset_base}"*.EFI; do
[ -f "${f}" ] || error "ERROR: missing EFI ${style} asset"
asset_files+=( "${f}" )
done

for f in "${asset_dir}/${asset_base}"*.tar.gz; do
[ -f "${f}" ] || error "ERROR: missing component ${style} asset"
asset_files+=( "${f}" )
done
done

for f in sha256.{txt,sig}; do
[ -f "${asset_dir}/${f}" ] || error "ERROR: missng sum file ${asset_dir}/${f}"
[ -f "${asset_dir}/${f}" ] || error "ERROR: missing sum file ${asset_dir}/${f}"
asset_files+=( "${asset_dir}/${f}" )
done

Expand Down
Loading