mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 08:30:16 +00:00
move dev stuff to hack/dev
This commit is contained in:
@@ -19,6 +19,8 @@ if command -v docker >/dev/null 2>&1; then
|
||||
delete_image sprout-utils-copy-polyfill || true
|
||||
delete_image sprout-ovmf-x86_64 || true
|
||||
delete_image sprout-ovmf-aarch64 || true
|
||||
delete_image sprout-initramfs-x86_64 || true
|
||||
delete_image sprout-initramfs-aarch64 || true
|
||||
delete_image sprout-kernel-x86_64 || true
|
||||
delete_image sprout-kernel-aarch64 || true
|
||||
delete_image sprout-kernel-build-x86_64 || true
|
||||
|
||||
|
Before Width: | Height: | Size: 3.6 MiB After Width: | Height: | Size: 3.6 MiB |
@@ -1,12 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd "$(dirname "${0}")/.." || exit 1
|
||||
cd "$(dirname "${0}")/../.." || exit 1
|
||||
|
||||
. "hack/common.sh"
|
||||
|
||||
if [ "${SKIP_BUILD}" != "1" ]; then
|
||||
./hack/build.sh "${TARGET_ARCH}" "${RUST_PROFILE}"
|
||||
./hack/dev/build.sh "${TARGET_ARCH}" "${RUST_PROFILE}"
|
||||
fi
|
||||
|
||||
clear
|
||||
30
hack/dev/boot/Dockerfile
Normal file
30
hack/dev/boot/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
FROM --platform=$BUILDPLATFORM debian:trixie@sha256:fd8f5a1df07b5195613e4b9a0b6a947d3772a151b81975db27d47f093f60c6e6 AS build
|
||||
ARG BUILDPLATFORM
|
||||
ARG EFI_NAME
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y \
|
||||
parted dosfstools mtools && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /work
|
||||
COPY sprout.efi /work/${EFI_NAME}.EFI
|
||||
COPY sprout.toml /work/SPROUT.TOML
|
||||
COPY kernel.efi /work/KERNEL.EFI
|
||||
COPY shell.efi /work/SHELL.EFI
|
||||
COPY initramfs /work/INITRAMFS
|
||||
COPY edera-splash.png /work/EDERA-SPLASH.PNG
|
||||
RUN truncate -s128MiB sprout.img && \
|
||||
parted --script sprout.img mklabel gpt > /dev/null 2>&1 && \
|
||||
parted --script sprout.img mkpart primary fat32 1MiB 100% > /dev/null 2>&1 && \
|
||||
parted --script sprout.img set 1 esp on > /dev/null 2>&1 && \
|
||||
mkfs.vfat -F32 -n EFI sprout.img && \
|
||||
mmd -i sprout.img ::/EFI && \
|
||||
mmd -i sprout.img ::/EFI/BOOT && \
|
||||
mcopy -i sprout.img ${EFI_NAME}.EFI ::/EFI/BOOT/ && \
|
||||
mcopy -i sprout.img KERNEL.EFI ::/EFI/BOOT/ && \
|
||||
mcopy -i sprout.img SHELL.EFI ::/EFI/BOOT/ && \
|
||||
mcopy -i sprout.img SPROUT.TOML ::/ && \
|
||||
mcopy -i sprout.img EDERA-SPLASH.PNG ::/ && \
|
||||
mcopy -i sprout.img INITRAMFS ::/ && \
|
||||
mv sprout.img /sprout.img
|
||||
|
||||
FROM scratch AS final
|
||||
COPY --from=build /sprout.img /sprout.img
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
cd "$(dirname "${0}")/.." || exit 1
|
||||
cd "$(dirname "${0}")/../.." || exit 1
|
||||
|
||||
. "hack/common.sh"
|
||||
|
||||
@@ -29,7 +29,7 @@ fi
|
||||
mkdir -p "${FINAL_DIR}"
|
||||
|
||||
if [ "${SKIP_KERNEL_BUILD}" != "1" ] || [ "${SKIP_VM_BUILD}" != "1" ] || [ "${SKIP_SPROUT_BUILD}" != "1" ]; then
|
||||
docker build -t "${DOCKER_PREFIX}/sprout-utils-copy-direct:${DOCKER_TAG}" -f hack/utils/Dockerfile.copy-direct hack
|
||||
docker build -t "${DOCKER_PREFIX}/sprout-utils-copy-direct:${DOCKER_TAG}" -f hack/dev/utils/Dockerfile.copy-direct hack
|
||||
fi
|
||||
|
||||
copy_from_image_direct() {
|
||||
@@ -47,8 +47,7 @@ copy_from_image_polyfill() {
|
||||
SOURCE="${2}"
|
||||
TARGET="${3}"
|
||||
|
||||
docker build -t "${IMAGE}-copy-polyfill:${DOCKER_TAG}" --build-arg "TARGET_IMAGE=${IMAGE}:${DOCKER_TAG}" \
|
||||
-f hack/utils/Dockerfile.copy-polyfill hack
|
||||
docker build -t "${IMAGE}-copy-polyfill:${DOCKER_TAG}" --build-arg "TARGET_IMAGE=${IMAGE}:${DOCKER_TAG}" -f hack/dev/utils/Dockerfile.copy-polyfill hack
|
||||
# note: the -w '//' is a workaround for Git Bash where / is magically rewritten.
|
||||
docker run --rm -i -w '//' "${IMAGE}-copy-polyfill:${DOCKER_TAG}" cat "image/${SOURCE}" >"${TARGET}"
|
||||
}
|
||||
@@ -62,24 +61,23 @@ copy_from_image() {
|
||||
|
||||
if [ "${SKIP_KERNEL_BUILD}" != "1" ]; then
|
||||
echo "[kernel build] ${TARGET_ARCH} ${RUST_PROFILE}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-kernel-${TARGET_ARCH}:${DOCKER_TAG}" -f kernel/Dockerfile kernel
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-kernel-${TARGET_ARCH}:${DOCKER_TAG}" -f hack/dev/kernel/Dockerfile hack/dev/kernel
|
||||
|
||||
if [ "${KERNEL_BUILD_TAG}" = "1" ]; then
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-kernel-build-${TARGET_ARCH}:${DOCKER_TAG}" -f kernel/Dockerfile --target
|
||||
build kernel
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-kernel-build-${TARGET_ARCH}:${DOCKER_TAG}" -f hack/dev/kernel/Dockerfile --target build hack/dev/kernel
|
||||
fi
|
||||
|
||||
copy_from_image "${DOCKER_PREFIX}/sprout-kernel-${TARGET_ARCH}" "kernel.efi" "${FINAL_DIR}/kernel.efi"
|
||||
cp "hack/configs/${SPROUT_CONFIG_NAME}.sprout.toml" "${FINAL_DIR}/sprout.toml"
|
||||
cp "hack/assets/edera-splash.png" "${FINAL_DIR}/edera-splash.png"
|
||||
cp "hack/dev/configs/${SPROUT_CONFIG_NAME}.sprout.toml" "${FINAL_DIR}/sprout.toml"
|
||||
cp "hack/dev/assets/edera-splash.png" "${FINAL_DIR}/edera-splash.png"
|
||||
fi
|
||||
|
||||
if [ "${SKIP_VM_BUILD}" != "1" ]; then
|
||||
echo "[vm build] ${TARGET_ARCH} ${RUST_PROFILE}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}:${DOCKER_TAG}" -f vm/Dockerfile.ovmf "${FINAL_DIR}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}:${DOCKER_TAG}" -f hack/dev/vm/Dockerfile.ovmf "${FINAL_DIR}"
|
||||
copy_from_image "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}" "ovmf.fd" "${FINAL_DIR}/ovmf.fd"
|
||||
copy_from_image "${DOCKER_PREFIX}/sprout-ovmf-${TARGET_ARCH}" "shell.efi" "${FINAL_DIR}/shell.efi"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-initramfs-${TARGET_ARCH}:${DOCKER_TAG}" -f vm/Dockerfile.initramfs "${FINAL_DIR}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-initramfs-${TARGET_ARCH}:${DOCKER_TAG}" -f hack/dev/vm/Dockerfile.initramfs "${FINAL_DIR}"
|
||||
copy_from_image "${DOCKER_PREFIX}/sprout-initramfs-${TARGET_ARCH}" "initramfs" "${FINAL_DIR}/initramfs"
|
||||
fi
|
||||
|
||||
@@ -109,6 +107,6 @@ fi
|
||||
|
||||
if [ "${SKIP_BOOT_BUILD}" != "1" ]; then
|
||||
echo "[boot build] ${TARGET_ARCH} ${RUST_PROFILE}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-boot-${TARGET_ARCH}:${DOCKER_TAG}" --build-arg "EFI_NAME=${EFI_NAME}" -f boot/Dockerfile "${FINAL_DIR}"
|
||||
docker build --platform="${DOCKER_TARGET}" -t "${DOCKER_PREFIX}/sprout-boot-${TARGET_ARCH}:${DOCKER_TAG}" --build-arg "EFI_NAME=${EFI_NAME}" -f hack/dev/boot/Dockerfile "${FINAL_DIR}"
|
||||
copy_from_image "${DOCKER_PREFIX}/sprout-boot-${TARGET_ARCH}" "sprout.img" "${FINAL_DIR}/sprout.img"
|
||||
fi
|
||||
37
hack/dev/kernel/Dockerfile
Normal file
37
hack/dev/kernel/Dockerfile
Normal file
@@ -0,0 +1,37 @@
|
||||
ARG KERNEL_SOURCE_URL=https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.17.2.tar.xz
|
||||
ARG KERNEL_CHECKSUM=sha256:fdebcb065065f5c1b8dc68a6fb59cda50cdddbf9103d207c2196d55ea764f57f
|
||||
|
||||
FROM --platform=$BUILDPLATFORM debian:trixie@sha256:fd8f5a1df07b5195613e4b9a0b6a947d3772a151b81975db27d47f093f60c6e6 AS buildenv
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y \
|
||||
build-essential squashfs-tools python3-yaml \
|
||||
patch diffutils sed mawk findutils zstd \
|
||||
python3 python3-packaging curl rsync cpio \
|
||||
flex bison pahole libssl-dev libelf-dev bc kmod && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
ARG BUILDPLATFORM
|
||||
RUN if [ "${BUILDPLATFORM}" = "linux/amd64" ] || [ "${BUILDPLATFORM}" = "linux/x86_64" ]; then \
|
||||
apt-get update && apt-get install -y linux-headers-amd64 gcc-aarch64-linux-gnu && rm -rf /var/lib/apt/lists/*; fi
|
||||
RUN if [ "${BUILDPLATFORM}" = "linux/arm64" ] || [ "${BUILDPLATFORM}" = "linux/aarch64" ]; then \
|
||||
apt-get update && apt-get install -y linux-headers-arm64 gcc-x86-64-linux-gnu && rm -rf /var/lib/apt/lists/*; fi
|
||||
RUN useradd -ms /bin/sh build
|
||||
COPY --chown=build:build docker-build.sh /build/docker-build.sh
|
||||
USER build
|
||||
WORKDIR /build
|
||||
|
||||
FROM scratch AS source
|
||||
ARG KERNEL_SOURCE_URL
|
||||
ARG KERNEL_CHECKSUM
|
||||
ADD --checksum=${KERNEL_CHECKSUM} ${KERNEL_SOURCE_URL} /src.tar.xz
|
||||
|
||||
FROM --platform=$BUILDPLATFORM buildenv AS build
|
||||
COPY --from=source --chown=build:build /src.tar.xz /build/src.tar.xz
|
||||
RUN mkdir /build/src && tar -C /build/src --strip-components=1 -xf /build/src.tar.xz && rm /build/src.tar.xz
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETPLATFORM
|
||||
ENV BUILDPLATFORM=${BUILDPLATFORM}
|
||||
ENV TARGETPLATFORM=${TARGETPLATFORM}
|
||||
WORKDIR /build/src
|
||||
RUN /build/docker-build.sh
|
||||
|
||||
FROM scratch AS final
|
||||
COPY --from=build /build/src/kernel.image /kernel.efi
|
||||
42
hack/dev/kernel/docker-build.sh
Executable file
42
hack/dev/kernel/docker-build.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
TARGET_KARCH=""
|
||||
TARGET_SARCH=""
|
||||
|
||||
MAYBE_CROSS_COMPILE=""
|
||||
|
||||
CURRENT_SARCH="$(uname -m)"
|
||||
|
||||
[ "${CURRENT_SARCH}" = "amd64" ] && CURRENT_SARCH="x86_64"
|
||||
[ "${CURRENT_SARCH}" = "arm64" ] && CURRENT_SARCH="aarch64"
|
||||
|
||||
if [ "${TARGETPLATFORM}" = "linux/aarch64" ] || [ "${TARGETPLATFORM}" = "linux/arm64" ]; then
|
||||
TARGET_KARCH="arm64"
|
||||
TARGET_SARCH="aarch64"
|
||||
if [ "${CURRENT_SARCH}" != "${TARGET_SARCH}" ]; then
|
||||
MAYBE_CROSS_COMPILE="aarch64-linux-gnu-"
|
||||
fi
|
||||
elif [ "${TARGETPLATFORM}" = "linux/x86_64" ] || [ "${TARGETPLATFORM}" = "linux/amd64" ]; then
|
||||
TARGET_KARCH="x86_64"
|
||||
TARGET_SARCH="x86_64"
|
||||
if [ "${CURRENT_SARCH}" != "${TARGET_SARCH}" ]; then
|
||||
MAYBE_CROSS_COMPILE="x86_64-linux-gnu-"
|
||||
fi
|
||||
else
|
||||
echo "Unknown platform: ${TARGETPLATFORM}" >/dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
make CROSS_COMPILE="${MAYBE_CROSS_COMPILE}" ARCH="${TARGET_KARCH}" defconfig
|
||||
make CROSS_COMPILE="${MAYBE_CROSS_COMPILE}" ARCH="${TARGET_KARCH}" mod2yesconfig
|
||||
|
||||
./scripts/config -e DRM_VIRTIO_GPU
|
||||
./scripts/config -e FRAMEBUFFER_CONSOLE
|
||||
./scripts/config -e FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
|
||||
|
||||
make "-j$(nproc)" CROSS_COMPILE="${MAYBE_CROSS_COMPILE}" ARCH="${TARGET_KARCH}"
|
||||
|
||||
[ -f "arch/x86/boot/bzImage" ] && cp "arch/x86/boot/bzImage" kernel.image
|
||||
[ -f "arch/arm64/boot/Image.gz" ] && gzip -d < "arch/arm64/boot/Image.gz" > kernel.image
|
||||
exit 0
|
||||
11
hack/dev/vm/Dockerfile.initramfs
Normal file
11
hack/dev/vm/Dockerfile.initramfs
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM alpine:3.22@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 AS build
|
||||
RUN apk --no-cache add busybox-static
|
||||
RUN mkdir -p /tmp/initramfs/bin && cp /bin/busybox.static /tmp/initramfs/bin/busybox && \
|
||||
chroot /tmp/initramfs /bin/busybox --install -s /bin && \
|
||||
chroot /tmp/initramfs ln -s /bin/init /init && \
|
||||
cd /tmp/initramfs && \
|
||||
find . | cpio -R 0:0 --ignore-devno --renumber-inodes -o -H newc --quiet > /initramfs && \
|
||||
rm -rf /tmp/initramfs
|
||||
|
||||
FROM scratch AS final
|
||||
COPY --from=build /initramfs /initramfs
|
||||
10
hack/dev/vm/Dockerfile.ovmf
Normal file
10
hack/dev/vm/Dockerfile.ovmf
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM alpine:3.22@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 AS build
|
||||
ARG TARGETPLATFORM
|
||||
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] || [ "${TARGETPLATFORM}" = "linux/x86_64" ]; then \
|
||||
apk --no-cache add ovmf edk2-shell; cp /usr/share/ovmf/bios.bin /ovmf.fd; fi
|
||||
RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ] || [ "${TARGETPLATFORM}" = "linux/aarch64" ]; then \
|
||||
apk --no-cache add aavmf edk2-shell; cp /usr/share/AAVMF/QEMU_EFI.fd /ovmf.fd; fi
|
||||
|
||||
FROM scratch AS final
|
||||
COPY --from=build /ovmf.fd /ovmf.fd
|
||||
COPY --from=build /usr/share/edk2-shell/ShellFull.efi /shell.efi
|
||||
Reference in New Issue
Block a user