Skip to content

Commit

Permalink
Generate release and recovery image builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zdykstra committed Jan 23, 2022
1 parent 914a3cd commit 4b836f3
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 43 deletions.
16 changes: 16 additions & 0 deletions etc/zfsbootmenu/recovery.conf.d/recovery.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
zfsbootmenu_teardown+=" /zbm/contrib/xhci-teardown.sh "
install_optional_items+=" /etc/zbm-commit-hash /bin/gdisk /bin/parted /bin/mkfs.vfat /bin/mkfs.ext4 /bin/curl /bin/efibootmgr"
omit_drivers+=" amdgpu radeon nvidia nouveau i915 "

# Network related modules
add_dracutmodules+=" network network-legacy kernel-network-modules "
omit_dracutmodules+=" crypt-ssh nfs lunmask "

# qemu drivers
omit_dracutmodules+=" qemu qemu-net "

# filesystem and other related bits
omit_dracutmodules+=" nvdimm fs-lib rootfs-block dm dmraid crypt "

embedded_kcl="rd.hostonly=0"
release_build=1
1 change: 1 addition & 0 deletions etc/zfsbootmenu/recovery.yaml
4 changes: 3 additions & 1 deletion releng/docker/image-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ EOF
buildah run "${container}" \
sh -c 'xbps-query -Rp run_depends zfsbootmenu | xargs xbps-install -y'
buildah run "${container}" xbps-install -y \
linux5.10 linux5.10-headers gummiboot-efistub curl yq-go bash kbd terminus-font
linux5.10 linux5.10-headers gummiboot-efistub curl yq-go bash kbd terminus-font \
gptfdisk dracut-network iproute2 iputils parted curl dosfstools e2fsprogs \
efibootmgr

# Remove headers and development toolchain, but keep binutils for objcopy
buildah run "${container}" sh -c 'echo "ignorepkg=dkms" > /etc/xbps.d/10-nodkms.conf'
Expand Down
80 changes: 43 additions & 37 deletions releng/make-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,16 @@ if ! podman inspect "${buildtag}" >/dev/null 2>&1; then
fi
fi

buildtmp="$( mktemp -d )" || error "cannot create build directory"
mkdir -p "${buildtmp}/out" || error "cannot create output directory"
mkdir -p "${buildtmp}/etc/dracut.conf.d" || error "cannot create config tree"

# Copy configuration components in place
cp ./etc/zfsbootmenu/release.yaml "${buildtmp}/etc"
cp ./etc/zfsbootmenu/dracut.conf.d/*.conf "${buildtmp}/etc/dracut.conf.d"

# Files in release.conf.d are allowed to shadow regular defaults
cp ./etc/zfsbootmenu/release.conf.d/*.conf "${buildtmp}/etc/dracut.conf.d"

arch="$( uname -m )"
case "${arch}" in
x86_64) BUILD_EFI="true" ;;
*) BUILD_EFI="false" ;;
esac

buildtmp="$( mktemp -d )" || error "cannot create build directory"
mkdir -p "${buildtmp}/out" || error "cannot create output directory"
mkdir -p "${buildtmp}/etc/dracut.conf.d" || error "cannot create config tree"

# Volume mounts for the container; make sure stock config tree, with release
# addendum, is available in-container at /etc/zfsbootmenu
volmounts=(
Expand All @@ -62,19 +55,6 @@ volmounts=(
"-v" "${buildtmp}/out:/out"
)

# Specify options for the build st
buildopts=(
"-o" "/out"
"-e" ".EFI.Enabled = ${BUILD_EFI}"
"-c" "/etc/zfsbootmenu/release.yaml"
)

# For the containerized build, use current repo by mounting at /zbm
# Custom configs and outputs will be in the temp dir, mounted at /build
if ! podman run --rm "${volmounts[@]}" "${buildtag}" "${buildopts[@]}"; then
error "failed to create image"
fi

if ! assets="$( realpath -e releng )/assets/${release}"; then
error "unable to define path to built assets"
fi
Expand All @@ -85,20 +65,46 @@ else
mkdir -p "${assets}"
fi

zbmtriplet="zfsbootmenu-vmlinuz-${arch}-v${release}"
for style in release recovery; do
echo "Building style: ${style}"
# Copy configuration components in place
cp "./etc/zfsbootmenu/${style}.yaml" "${buildtmp}/etc"
cp ./etc/zfsbootmenu/dracut.conf.d/*.conf "${buildtmp}/etc/dracut.conf.d"

# Files in release.conf.d are allowed to shadow regular defaults
cp ./etc/zfsbootmenu/"${style}".conf.d/*.conf "${buildtmp}/etc/dracut.conf.d"

# Specify options for the build st
buildopts=(
"-o" "/out"
"-e" ".EFI.Enabled = ${BUILD_EFI}"
"-c" "/etc/zfsbootmenu/${style}.yaml"
)

# For the containerized build, use current repo by mounting at /zbm
# Custom configs and outputs will be in the temp dir, mounted at /build
if ! podman run --rm "${volmounts[@]}" "${buildtag}" "${buildopts[@]}"; then
error "failed to create image"
fi

zbmtriplet="zfsbootmenu-${style}-vmlinuz-${arch}-v${release}"

# EFI file is currently only built on x86_64
if [ "${BUILD_EFI}" = "true" ]; then
if ! cp "${buildtmp}/out/vmlinuz.EFI" "${assets}/${zbmtriplet}.EFI"; then
error "failed to copy UEFI bundle"
# EFI file is currently only built on x86_64
if [ "${BUILD_EFI}" = "true" ]; then
if ! cp "${buildtmp}/out/vmlinuz.EFI" "${assets}/${zbmtriplet}.EFI"; then
error "failed to copy UEFI bundle"
fi
fi
fi

# Nothing to archive if no components were produced
[ -d "${buildtmp}/out/components" ] || exit 0
# Nothing to archive if no components were produced
[ -d "${buildtmp}/out/components" ] || exit 0

zbmtriplet="zfsbootmenu-${style}-${arch}-v${release}"
# If components were produced, archive them
( cd "${buildtmp}/out" && mv components "${zbmtriplet}" && \
tar czvf "${assets}/${zbmtriplet}.tar.gz" "${zbmtriplet}"
) || error "failed to pack components"

zbmtriplet="zfsbootmenu-${arch}-v${release}"
# If components were produced, archive them
( cd "${buildtmp}/out" && mv components "${zbmtriplet}" && \
tar czvf "${assets}/${zbmtriplet}.tar.gz" "${zbmtriplet}"
) || error "failed to pack components"
rm "${buildtmp}"/etc/*.yaml
rm "${buildtmp}"/etc/dracut.conf.d/*.conf
done
15 changes: 10 additions & 5 deletions releng/tag-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,23 @@ if ! releng/sign-assets.sh "${release}"; then
error "ERROR: unable to sign release assets, exiting!"
fi

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

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

for asset in "${assets[@]}" ; do
f="${asset_dir}/${asset}"
[ -f "${f}" ] || error "ERROR: missing boot image ${f}"
asset_files+=( "${f}" )
done

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

# github-cli does not automatically strip header that hub uses for a title
Expand Down

0 comments on commit 4b836f3

Please sign in to comment.