Skip to content

Commit

Permalink
Merge pull request #6 from product-os/kyle/flatten-root
Browse files Browse the repository at this point in the history
Separate patches and configs, and move Makefile to root
  • Loading branch information
flowzone-app[bot] authored Apr 24, 2024
2 parents 571c28a + 79d592c commit 1ea37fd
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
.balena
vmlinux/out
vmlinux/
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ ARG KERNEL_BRANCH=5.10
RUN git clone --depth 1 -c advice.detachedHead=false \
--branch "v${KERNEL_BRANCH}" https://github.com/torvalds/linux.git .

COPY vmlinux/${KERNEL_BRANCH}/*.patch ./
COPY patches/${KERNEL_BRANCH}/*.patch ./

RUN git apply -v ./*.patch

COPY vmlinux/${KERNEL_BRANCH}/*.config ./
COPY config/${KERNEL_BRANCH}/*.config ./

RUN ln -sf "microvm-kernel-$(uname -m)-${KERNEL_BRANCH}.config" .config

Expand Down
22 changes: 12 additions & 10 deletions vmlinux/Makefile → Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
MACHINE ?= $(shell uname -m)
ARCH ?= $(shell uname -m)
KERNEL_BRANCH ?= 5.10
MAKEFILE_DIR := $(realpath $(shell dirname $(firstword $(MAKEFILE_LIST))))

# normalize machine to docker platform
ifeq ($(MACHINE),x86_64)
ifeq ($(ARCH),x86_64)
PLATFORM := linux/amd64
MACHINE ?= x86_64
else
PLATFORM := linux/arm64
MACHINE ?= aarch64
endif

IMAGE_TAG ?= linux.git:$(MACHINE)-$(KERNEL_BRANCH)
CONFIG_FILE ?= $(KERNEL_BRANCH)/microvm-kernel-$(MACHINE)-$(KERNEL_BRANCH).config
CONFIG_FILE ?= config/$(KERNEL_BRANCH)/microvm-kernel-$(MACHINE)-$(KERNEL_BRANCH).config

linux.git:
docker build .. \
docker build . \
--platform $(PLATFORM) \
--build-arg KERNEL_BRANCH=$(KERNEL_BRANCH) \
--tag $(IMAGE_TAG) \
--target linux.git
--target linux.git \
--output type=image,name=$(IMAGE_TAG)

# vmlinux is a build target that is not interactive, so we can run it directly
vmlinux:
docker build .. \
docker build . \
--platform $(PLATFORM) \
--build-arg KERNEL_BRANCH=$(KERNEL_BRANCH) \
--mount type=bind,src=$(MAKEFILE_DIR)/out,dst=/out \
--target vmlinux-out
--target vmlinux-out \
--output type=local,dest=vmlinux

# vmconfig targets are interactive, so we need to run them in a container
vmconfig: linux.git
-docker rm -f linux.git
docker run -it --name linux.git --platform $(PLATFORM) $(IMAGE_TAG) make $(TARGET)
docker run --name linux.git --platform $(PLATFORM) $(IMAGE_TAG) make $(TARGET)
docker cp linux.git:/src/.config $(CONFIG_FILE)

menuconfig:
Expand Down
File renamed without changes.

0 comments on commit 1ea37fd

Please sign in to comment.