2022-10-19 07:10:15 -04:00
|
|
|
SHELL = /bin/bash
|
|
|
|
SRC_PATH = $(CURDIR)
|
|
|
|
BASE_PATH ?= $(SRC_PATH)
|
2022-10-21 04:11:53 -04:00
|
|
|
BOOTSTRAPPER_BINARY ?= $(BASE_PATH)/../build/bootstrapper
|
|
|
|
DISK_MAPPER_BINARY ?= $(BASE_PATH)/../build/disk-mapper
|
2022-12-29 11:50:11 -05:00
|
|
|
UPGRADE_AGENT_BINARY ?= $(BASE_PATH)/../build/upgrade-agent
|
2023-01-20 04:28:09 -05:00
|
|
|
DEBUGD_BINARY ?= $(BASE_PATH)/../build/debugd
|
2022-10-19 07:10:15 -04:00
|
|
|
PKI ?= $(BASE_PATH)/pki
|
|
|
|
MKOSI_EXTRA ?= $(BASE_PATH)/mkosi.extra
|
2022-11-16 09:45:10 -05:00
|
|
|
IMAGE_VERSION ?= v0.0.0
|
2023-01-20 04:28:09 -05:00
|
|
|
DEBUG ?= false
|
2023-01-16 06:20:01 -05:00
|
|
|
AUTOLOGIN ?= false
|
|
|
|
AUTOLOGIN_ARGS := $(if $(filter true,$(AUTOLOGIN)),--autologin) # set "--autologin" if AUTOLOGIN is true
|
2023-01-20 04:28:09 -05:00
|
|
|
export INSTALL_DEBUGD ?= $(DEBUG)
|
2023-01-16 06:20:01 -05:00
|
|
|
export CONSOLE_MOTD = $(AUTOLOGIN)
|
2022-10-19 07:10:15 -04:00
|
|
|
-include $(CURDIR)/config.mk
|
2022-10-17 11:39:49 -04:00
|
|
|
csps := aws qemu gcp azure
|
2022-10-19 07:10:15 -04:00
|
|
|
certs := $(PKI)/PK.cer $(PKI)/KEK.cer $(PKI)/db.cer
|
|
|
|
|
2023-02-15 09:00:05 -05:00
|
|
|
AZURE_FIXED_KERNEL_RPMS := kernel-6.1.12-200.fc37.x86_64.rpm kernel-core-6.1.12-200.fc37.x86_64.rpm kernel-modules-6.1.12-200.fc37.x86_64.rpm
|
2022-12-09 07:20:00 -05:00
|
|
|
GCP_FIXED_KERNEL_RPMS := kernel-5.19.17-300.fc37.x86_64.rpm kernel-core-5.19.17-300.fc37.x86_64.rpm kernel-modules-5.19.17-300.fc37.x86_64.rpm
|
2023-01-04 11:48:27 -05:00
|
|
|
PREBUILT_RPMS_AZURE := $(addprefix prebuilt/rpms/azure/,$(AZURE_FIXED_KERNEL_RPMS))
|
|
|
|
PREBUILT_RPMS_GCP := $(addprefix prebuilt/rpms/gcp/,$(GCP_FIXED_KERNEL_RPMS))
|
2022-12-09 07:20:00 -05:00
|
|
|
|
2022-10-19 07:10:15 -04:00
|
|
|
.PHONY: all clean inject-bins $(csps)
|
|
|
|
|
|
|
|
all: $(csps)
|
|
|
|
|
2022-11-17 06:12:00 -05:00
|
|
|
$(csps): %: mkosi.output.%/fedora~37/image.raw
|
2022-10-19 07:10:15 -04:00
|
|
|
|
2023-01-04 11:48:27 -05:00
|
|
|
prebuilt/rpms/gcp/%.rpm:
|
2022-12-09 07:20:00 -05:00
|
|
|
@echo "Downloading $*"
|
|
|
|
@mkdir -p $(@D)
|
2023-01-19 05:22:31 -05:00
|
|
|
@curl -fsSL -o $@ https://kojipkgs.fedoraproject.org/packages/kernel/5.19.17/300.fc37/x86_64/$*.rpm
|
2022-12-09 07:20:00 -05:00
|
|
|
|
2023-01-04 11:48:27 -05:00
|
|
|
prebuilt/rpms/azure/%.rpm:
|
|
|
|
@echo "Downloading $*"
|
|
|
|
@mkdir -p $(@D)
|
2023-02-15 09:00:05 -05:00
|
|
|
@curl -fsSL -o $@ https://kojipkgs.fedoraproject.org/packages/kernel/6.1.12/200.fc37/x86_64/$*.rpm
|
2023-01-04 11:48:27 -05:00
|
|
|
|
2022-11-17 06:12:00 -05:00
|
|
|
mkosi.output.%/fedora~37/image.raw: mkosi.files/mkosi.%.conf inject-bins inject-certs
|
2023-01-20 04:28:09 -05:00
|
|
|
mkosi --config mkosi.files/mkosi.$*.conf \
|
|
|
|
--image-version=$(IMAGE_VERSION) \
|
|
|
|
$(AUTOLOGIN_ARGS) \
|
|
|
|
--environment=INSTALL_DEBUGD \
|
|
|
|
--environment=CONSOLE_MOTD \
|
|
|
|
build
|
2022-10-19 07:10:15 -04:00
|
|
|
secure-boot/signed-shim.sh $@
|
|
|
|
@if [ -n $(SUDO_UID) ] && [ -n $(SUDO_GID) ]; then \
|
|
|
|
chown -R $(SUDO_UID):$(SUDO_GID) mkosi.output.$*; \
|
|
|
|
fi
|
|
|
|
@echo "Image is ready: $@"
|
|
|
|
|
2023-01-04 11:48:27 -05:00
|
|
|
inject-bins: $(PREBUILT_RPMS_AZURE) $(PREBUILT_RPMS_GCP)
|
2022-10-19 07:10:15 -04:00
|
|
|
mkdir -p $(MKOSI_EXTRA)/usr/bin
|
|
|
|
mkdir -p $(MKOSI_EXTRA)/usr/sbin
|
2022-12-29 11:50:11 -05:00
|
|
|
cp $(UPGRADE_AGENT_BINARY) $(MKOSI_EXTRA)/usr/bin/upgrade-agent
|
2022-10-19 07:10:15 -04:00
|
|
|
cp $(DISK_MAPPER_BINARY) $(MKOSI_EXTRA)/usr/sbin/disk-mapper
|
2023-01-20 04:28:09 -05:00
|
|
|
if [ "$(DEBUG)" = "true" ]; then \
|
|
|
|
cp $(DEBUGD_BINARY) $(MKOSI_EXTRA)/usr/bin/debugd; \
|
|
|
|
rm -f $(MKOSI_EXTRA)/usr/bin/bootstrapper; \
|
|
|
|
else \
|
|
|
|
cp $(BOOTSTRAPPER_BINARY) $(MKOSI_EXTRA)/usr/bin/bootstrapper; \
|
|
|
|
rm -f $(MKOSI_EXTRA)/usr/bin/debugd; \
|
|
|
|
fi
|
2022-10-19 07:10:15 -04:00
|
|
|
|
|
|
|
inject-certs: $(certs)
|
|
|
|
# for auto enrollment using systemd-boot (not working yet)
|
|
|
|
mkdir -p "$(MKOSI_EXTRA)/boot/loader/keys/auto"
|
|
|
|
cp $(PKI)/{PK,KEK,db}.cer "$(MKOSI_EXTRA)/boot/loader/keys/auto"
|
|
|
|
cp $(PKI)/{MicWinProPCA2011_2011-10-19,MicCorUEFCA2011_2011-06-27,MicCorKEKCA2011_2011-06-24}.crt "$(MKOSI_EXTRA)/boot/loader/keys/auto"
|
|
|
|
cp $(PKI)/{PK,KEK,db}.esl "$(MKOSI_EXTRA)/boot/loader/keys/auto"
|
|
|
|
cp $(PKI)/{PK,KEK,db}.auth "$(MKOSI_EXTRA)/boot/loader/keys/auto"
|
|
|
|
# for manual enrollment using sbkeysync
|
|
|
|
mkdir -p $(MKOSI_EXTRA)/etc/secureboot/keys/{db,dbx,KEK,PK}
|
|
|
|
cp $(PKI)/db.auth "$(MKOSI_EXTRA)/etc/secureboot/keys/db/"
|
|
|
|
cp $(PKI)/KEK.auth "$(MKOSI_EXTRA)/etc/secureboot/keys/KEK/"
|
|
|
|
cp $(PKI)/PK.auth "$(MKOSI_EXTRA)/etc/secureboot/keys/PK/"
|
|
|
|
|
|
|
|
clean-cache:
|
|
|
|
rm -rf mkosi.cache/*
|
|
|
|
|
|
|
|
clean-%:
|
|
|
|
mkosi --config mkosi.files/mkosi.$*.conf clean
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf mkosi.output.*
|
2023-01-04 11:48:27 -05:00
|
|
|
rm -rf prebuilt/rpms
|
2022-10-19 07:10:15 -04:00
|
|
|
rm -rf $(MKOSI_EXTRA)
|
|
|
|
mkdir -p $(MKOSI_EXTRA)
|