forked from flatcar/sysext-bakery
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
5,814 additions
and
0 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,66 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export ARCH="${ARCH-amd64}" | ||
SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")" | ||
|
||
if [ $# -lt 3 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | ||
echo "Usage: $0 VERSION SYSEXTNAME FLATCARVERSION" | ||
echo "The script will build ZFS modules and tooling and create a sysext squashfs image with the name SYSEXTNAME.raw in the current folder." | ||
echo "A temporary directory named SYSEXTNAME in the current folder will be created and deleted again." | ||
echo "All files in the sysext image will be owned by root." | ||
echo "To use arm64 pass 'ARCH=arm64' as environment variable (current value is '${ARCH}')." | ||
"${SCRIPTFOLDER}"/bake.sh --help | ||
exit 1 | ||
fi | ||
|
||
VERSION="$1" | ||
SYSEXTNAME="$2" | ||
FLATCARVERSION="$3" | ||
if [ "${ARCH}" = aarch64 ]; then | ||
ARCH=arm64 | ||
fi | ||
rm -f ${SYSEXTNAME} | ||
|
||
# base | ||
echo "========== Prepare base" | ||
emerge-gitclone | ||
echo 'FEATURES="-network-sandbox -pid-sandbox -ipc-sandbox -usersandbox -sandbox"' >>/etc/portage/make.conf | ||
cp files/zfs/repos.conf /etc/portage/repos.conf/zfs.conf | ||
cp -r files/zfs/${FLATCARVERSION}/overlay/ /var/lib/portage/zfs-overlay/ | ||
|
||
# build zfs | ||
echo "========== Build ZFS" | ||
kernel=$(ls /lib/modules) && KBUILD_OUTPUT=/lib/modules/${kernel}/build KERNEL_DIR=/lib/modules/${kernel}/source emerge -j$(nproc) --getbinpkg --onlydeps zfs | ||
emerge -j$(nproc) --getbinpkg --buildpkgonly zfs squashfs-tools | ||
|
||
# install deps | ||
echo "========== Install deps" | ||
emerge --getbinpkg --usepkg squashfs-tools | ||
|
||
# flatcar layout compat | ||
echo "========== Create Flatcar layout" | ||
mkdir -p ${SYSEXTNAME} ; for dir in lib lib64 bin sbin; do mkdir -p ${SYSEXTNAME}/usr/$dir; ln -s usr/$dir ${SYSEXTNAME}/$dir; done | ||
echo "========== Copy kernel modules to workdir" | ||
mkdir -p ${SYSEXTNAME}/lib/modules | ||
rsync -a /lib/modules/${kernel} ${SYSEXTNAME}/lib/modules/ | ||
echo "========== Emerge packages" | ||
pkgs=$(emerge 2>/dev/null --usepkgonly --pretend zfs| awk -F'] ' '/binary/{ print $ 2 }' | awk '{ print "="$1 }'); emerge --usepkgonly --root=${SYSEXTNAME} --nodeps $pkgs | ||
echo "========== Create sysext metadata file" | ||
mkdir -p ${SYSEXTNAME}/usr/lib/extension-release.d && echo -e 'ID=flatcar\nSYSEXT_LEVEL=1.0' >${SYSEXTNAME}/usr/lib/extension-release.d/extension-release.zfs | ||
mv ${SYSEXTNAME}/etc ${SYSEXTNAME}/usr/etc | ||
echo "========== Copy static files (systemd) to workdir" | ||
rsync -a files/zfs/usr/ ${SYSEXTNAME}/usr/ | ||
|
||
# clean uneeded files | ||
echo "========== Cleaning" | ||
rm -rf ${SYSEXTNAME}/var/db | ||
rm -rf ${SYSEXTNAME}/var/cache | ||
rm -rf ${SYSEXTNAME}/usr/share | ||
rm -rf ${SYSEXTNAME}/usr/src | ||
rm -rf ${SYSEXTNAME}/usr/include | ||
|
||
|
||
|
||
"${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}" | ||
rm -rf "${SYSEXTNAME}" |
201 changes: 201 additions & 0 deletions
201
files/zfs/3510.2.6/overlay/eclass/dist-kernel-utils.eclass
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,201 @@ | ||
# Copyright 2020-2023 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
# @ECLASS: dist-kernel-utils.eclass | ||
# @MAINTAINER: | ||
# Distribution Kernel Project <[email protected]> | ||
# @AUTHOR: | ||
# Michał Górny <[email protected]> | ||
# @SUPPORTED_EAPIS: 7 8 | ||
# @BLURB: Utility functions related to Distribution Kernels | ||
# @DESCRIPTION: | ||
# This eclass provides various utility functions related to Distribution | ||
# Kernels. | ||
|
||
# @ECLASS_VARIABLE: KERNEL_IUSE_SECUREBOOT | ||
# @PRE_INHERIT | ||
# @DEFAULT_UNSET | ||
# @DESCRIPTION: | ||
# If set to a non-null value, inherits secureboot.eclass | ||
# and allows signing of generated kernel images. | ||
|
||
if [[ ! ${_DIST_KERNEL_UTILS} ]]; then | ||
|
||
case ${EAPI} in | ||
7|8) ;; | ||
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; | ||
esac | ||
|
||
if [[ ${KERNEL_IUSE_SECUREBOOT} ]]; then | ||
inherit secureboot | ||
fi | ||
|
||
# @FUNCTION: dist-kernel_build_initramfs | ||
# @USAGE: <output> <version> | ||
# @DESCRIPTION: | ||
# Build an initramfs for the kernel. <output> specifies the absolute | ||
# path where initramfs will be created, while <version> specifies | ||
# the kernel version, used to find modules. | ||
# | ||
# Note: while this function uses dracut at the moment, other initramfs | ||
# variants may be supported in the future. | ||
dist-kernel_build_initramfs() { | ||
debug-print-function ${FUNCNAME} "${@}" | ||
|
||
[[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments" | ||
local output=${1} | ||
local version=${2} | ||
|
||
local rel_image_path=$(dist-kernel_get_image_path) | ||
local image=${output%/*}/${rel_image_path##*/} | ||
|
||
local args=( | ||
--force | ||
# if uefi=yes is used, dracut needs to locate the kernel image | ||
--kernel-image "${image}" | ||
|
||
# positional arguments | ||
"${output}" "${version}" | ||
) | ||
|
||
ebegin "Building initramfs via dracut" | ||
dracut "${args[@]}" | ||
eend ${?} || die -n "Building initramfs failed" | ||
} | ||
|
||
# @FUNCTION: dist-kernel_get_image_path | ||
# @DESCRIPTION: | ||
# Get relative kernel image path specific to the current ${ARCH}. | ||
dist-kernel_get_image_path() { | ||
case ${ARCH} in | ||
amd64|x86) | ||
echo arch/x86/boot/bzImage | ||
;; | ||
arm64) | ||
echo arch/arm64/boot/Image.gz | ||
;; | ||
arm) | ||
echo arch/arm/boot/zImage | ||
;; | ||
hppa|ppc|ppc64|sparc) | ||
# https://www.kernel.org/doc/html/latest/powerpc/bootwrapper.html | ||
# ./ is required because of ${image_path%/*} | ||
# substitutions in the code | ||
echo ./vmlinux | ||
;; | ||
riscv) | ||
echo arch/riscv/boot/Image.gz | ||
;; | ||
*) | ||
die "${FUNCNAME}: unsupported ARCH=${ARCH}" | ||
;; | ||
esac | ||
} | ||
|
||
# @FUNCTION: dist-kernel_install_kernel | ||
# @USAGE: <version> <image> <system.map> | ||
# @DESCRIPTION: | ||
# Install kernel using installkernel tool. <version> specifies | ||
# the kernel version, <image> full path to the image, <system.map> | ||
# full path to System.map. | ||
dist-kernel_install_kernel() { | ||
debug-print-function ${FUNCNAME} "${@}" | ||
|
||
[[ ${#} -eq 3 ]] || die "${FUNCNAME}: invalid arguments" | ||
local version=${1} | ||
local image=${2} | ||
local map=${3} | ||
|
||
# if dracut is used in uefi=yes mode, initrd will actually | ||
# be a combined kernel+initramfs UEFI executable. we can easily | ||
# recognize it by PE magic (vs cpio for a regular initramfs) | ||
local initrd=${image%/*}/initrd | ||
local magic | ||
[[ -s ${initrd} ]] && read -n 2 magic < "${initrd}" | ||
if [[ ${magic} == MZ ]]; then | ||
einfo "Combined UEFI kernel+initramfs executable found" | ||
# install the combined executable in place of kernel | ||
image=${initrd%/*}/uki.efi | ||
mv "${initrd}" "${image}" || die | ||
# We moved the generated initrd, prevent dracut from running again | ||
# https://github.com/dracutdevs/dracut/pull/2405 | ||
shopt -s nullglob | ||
local plugins=() | ||
for file in "${EROOT}"/etc/kernel/install.d/*.install; do | ||
plugins+=( "${file}" ) | ||
done | ||
for file in "${EROOT}"/usr/lib/kernel/install.d/*.install; do | ||
if ! has "${file##*/}" 50-dracut.install 51-dracut-rescue.install "${plugins[@]##*/}"; then | ||
plugins+=( "${file}" ) | ||
fi | ||
done | ||
shopt -u nullglob | ||
export KERNEL_INSTALL_PLUGINS="${KERNEL_INSTALL_PLUGINS} ${plugins[@]}" | ||
fi | ||
|
||
if [[ ${KERNEL_IUSE_SECUREBOOT} ]]; then | ||
# Kernel-install requires uki's are named uki.efi, sign in-place | ||
secureboot_sign_efi_file "${image}" "${image}" | ||
fi | ||
|
||
ebegin "Installing the kernel via installkernel" | ||
# note: .config is taken relatively to System.map; | ||
# initrd relatively to bzImage | ||
installkernel "${version}" "${image}" "${map}" | ||
eend ${?} || die -n "Installing the kernel failed" | ||
} | ||
|
||
# @FUNCTION: dist-kernel_reinstall_initramfs | ||
# @USAGE: <kv-dir> <kv-full> | ||
# @DESCRIPTION: | ||
# Rebuild and install initramfs for the specified dist-kernel. | ||
# <kv-dir> is the kernel source directory (${KV_DIR} from linux-info), | ||
# while <kv-full> is the full kernel version (${KV_FULL}). | ||
# The function will determine whether <kernel-dir> is actually | ||
# a dist-kernel, and whether initramfs was used. | ||
# | ||
# This function is to be used in pkg_postinst() of ebuilds installing | ||
# kernel modules that are included in the initramfs. | ||
dist-kernel_reinstall_initramfs() { | ||
debug-print-function ${FUNCNAME} "${@}" | ||
|
||
[[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments" | ||
local kernel_dir=${1} | ||
local ver=${2} | ||
|
||
local image_path=${kernel_dir}/$(dist-kernel_get_image_path) | ||
local initramfs_path=${image_path%/*}/initrd | ||
if [[ ! -f ${image_path} ]]; then | ||
eerror "Kernel install missing, image not found:" | ||
eerror " ${image_path}" | ||
eerror "Initramfs will not be updated. Please reinstall your kernel." | ||
return | ||
fi | ||
if [[ ! -f ${initramfs_path} && ! -f ${initramfs_path%/*}/uki.efi ]]; then | ||
einfo "No initramfs or uki found at ${image_path}" | ||
return | ||
fi | ||
|
||
dist-kernel_build_initramfs "${initramfs_path}" "${ver}" | ||
dist-kernel_install_kernel "${ver}" "${image_path}" \ | ||
"${kernel_dir}/System.map" | ||
} | ||
|
||
# @FUNCTION: dist-kernel_PV_to_KV | ||
# @USAGE: <pv> | ||
# @DESCRIPTION: | ||
# Convert a Gentoo-style ebuild version to kernel "x.y.z[-rcN]" version. | ||
dist-kernel_PV_to_KV() { | ||
debug-print-function ${FUNCNAME} "${@}" | ||
|
||
[[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments" | ||
local pv=${1} | ||
|
||
local kv=${pv%%_*} | ||
[[ -z $(ver_cut 3- "${kv}") ]] && kv+=".0" | ||
[[ ${pv} == *_* ]] && kv+=-${pv#*_} | ||
echo "${kv}" | ||
} | ||
|
||
_DIST_KERNEL_UTILS=1 | ||
fi |
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,4 @@ | ||
masters = portage-stable | ||
thin-manifests = true | ||
sign-commits = false | ||
sign-manifests = false |
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 @@ | ||
zfs-overlay |
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,2 @@ | ||
DIST udev-init-scripts-34.tar.gz 3660 BLAKE2B 954b003c78b31649fef69213a5424098f40e17e7ed11f4ec1443247950ea60db8536f37ca603caa06e5c9f8bab07b5ac3cb8c9435144532a97ff04836c24da49 SHA512 ed48bcd0815e235b2b3fa38f857cd97f164aac7c6ea805be87890eb06a0d52064bd733da240c6e2a34c8c73e10fd047b5e53096de06f17bc81d8266d70c0cc9d | ||
DIST udev-init-scripts-35.tar.gz 3666 BLAKE2B fddae466428605ea930519e8a47e0ea91f89f9eacc1fd97c137d175142125b12c3d045aec68db35a463de444ac6d8c037cca55f9628f10576c968259d566a9e4 SHA512 da9d2093149967e2e1b9bc7190ddfd55a87c9ae2177e3216f7cb2694fc9b64037eb6f2599ad8a4b7594ef32ced88fbb319c92904bc72a81ea5404945f8a8378a |
7 changes: 7 additions & 0 deletions
7
files/zfs/3510.2.6/overlay/sys-fs/udev-init-scripts/metadata.xml
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> | ||
<pkgmetadata> | ||
<maintainer type="project"> | ||
<email>[email protected]</email> | ||
</maintainer> | ||
</pkgmetadata> |
50 changes: 50 additions & 0 deletions
50
files/zfs/3510.2.6/overlay/sys-fs/udev-init-scripts/udev-init-scripts-34.ebuild
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,50 @@ | ||
# Copyright 1999-2021 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=7 | ||
OLD_PN=udev-gentoo-scripts | ||
OLD_P=${OLD_PN}-${PV} | ||
|
||
if [ "${PV}" = "9999" ]; then | ||
EGIT_REPO_URI="git://anongit.gentoo.org/proj/${OLD_PN}.git" | ||
inherit git-r3 | ||
else | ||
SRC_URI="https://gitweb.gentoo.org/proj/${OLD_PN}.git/snapshot/${OLD_P}.tar.gz -> ${P}.tar.gz" | ||
S="${WORKDIR}/${OLD_P}" | ||
KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86" | ||
fi | ||
|
||
DESCRIPTION="udev startup scripts for openrc" | ||
HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage" | ||
|
||
LICENSE="GPL-2" | ||
SLOT="0" | ||
|
||
RESTRICT="test" | ||
|
||
RDEPEND=">=virtual/udev-217 | ||
!<sys-apps/openrc-0.14" | ||
|
||
src_install() { | ||
local -x SYSCONFDIR="${EPREFIX}/etc" | ||
default | ||
} | ||
|
||
pkg_postinst() { | ||
# Add udev and udev-trigger to the sysinit runlevel automatically. | ||
for f in udev udev-trigger; do | ||
if [[ -x "${EROOT}/etc/init.d/${f}" && | ||
-d "${EROOT}/etc/runlevels/sysinit" && | ||
! -L "${EROOT}/etc/runlevels/sysinit/${f}" ]]; then | ||
ln -snf "${EPREFIX}/etc/init.d/${f}" "${EROOT}/etc/runlevels/sysinit/${f}" | ||
ewarn "Adding ${f} to the sysinit runlevel" | ||
fi | ||
done | ||
|
||
if ! has_version "sys-fs/eudev[rule-generator]" && \ | ||
[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qs 'boot\|default\|sysinit'; then | ||
ewarn "The udev-postmount service has been removed because the reasons for" | ||
ewarn "its existance have been removed upstream." | ||
ewarn "Please remove it from your runlevels." | ||
fi | ||
} |
50 changes: 50 additions & 0 deletions
50
files/zfs/3510.2.6/overlay/sys-fs/udev-init-scripts/udev-init-scripts-35.ebuild
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,50 @@ | ||
# Copyright 1999-2021 Gentoo Authors | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=8 | ||
OLD_PN=udev-gentoo-scripts | ||
OLD_P=${OLD_PN}-${PV} | ||
|
||
if [ "${PV}" = "9999" ]; then | ||
EGIT_REPO_URI="https://anongit.gentoo.org/proj/${OLD_PN}.git" | ||
inherit git-r3 | ||
else | ||
SRC_URI="https://gitweb.gentoo.org/proj/${OLD_PN}.git/snapshot/${OLD_P}.tar.gz -> ${P}.tar.gz" | ||
S="${WORKDIR}/${OLD_P}" | ||
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" | ||
fi | ||
|
||
DESCRIPTION="udev startup scripts for openrc" | ||
HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage" | ||
|
||
LICENSE="GPL-2" | ||
SLOT="0" | ||
|
||
RESTRICT="test" | ||
|
||
RDEPEND=">=virtual/udev-217 | ||
!<sys-apps/openrc-0.14" | ||
|
||
src_install() { | ||
local -x SYSCONFDIR="${EPREFIX}/etc" | ||
default | ||
} | ||
|
||
pkg_postinst() { | ||
# Add udev and udev-trigger to the sysinit runlevel automatically. | ||
for f in udev udev-trigger; do | ||
if [[ -x "${EROOT}/etc/init.d/${f}" && | ||
-d "${EROOT}/etc/runlevels/sysinit" && | ||
! -L "${EROOT}/etc/runlevels/sysinit/${f}" ]]; then | ||
ln -snf "${EPREFIX}/etc/init.d/${f}" "${EROOT}/etc/runlevels/sysinit/${f}" | ||
ewarn "Adding ${f} to the sysinit runlevel" | ||
fi | ||
done | ||
|
||
if ! has_version "sys-fs/eudev[rule-generator]" && \ | ||
[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qs 'boot\|default\|sysinit'; then | ||
ewarn "The udev-postmount service has been removed because the reasons for" | ||
ewarn "its existance have been removed upstream." | ||
ewarn "Please remove it from your runlevels." | ||
fi | ||
} |
Oops, something went wrong.