Skip to content

Commit

Permalink
Makefile: add | build dep for output files and remove build on clean (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
osresearch committed Jul 23, 2021
1 parent 4ac8812 commit 5d583be
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ $(LINUX)/.patched: $(LINUX_TAR)
tar xf $(LINUX_TAR)
touch $@

build/vmlinuz: build/$(LINUX)/.config
build:
mkdir -p $@

build/vmlinuz: build/$(LINUX)/.config | build
$(MAKE) \
KBUILD_HOST=safeboot \
KBUILD_BUILD_USER=builder \
Expand All @@ -205,7 +208,7 @@ linux-menuconfig: build/$(LINUX)/.config
#
# Extra package building requirements
#
requirements:
requirements: | build
DEBIAN_FRONTEND=noninteractive \
apt install -y \
devscripts \
Expand Down Expand Up @@ -247,9 +250,9 @@ requirements:
libelf-dev \


# Remove the temporary files
# Remove the temporary files and build stuff
clean:
rm -rf bin $(SUBMODULES)
rm -rf bin $(SUBMODULES) build
mkdir $(SUBMODULES)
#git submodule update --init --recursive --recommend-shallow

Expand Down Expand Up @@ -353,7 +356,7 @@ build/initrd.cpio.bz: build/initrd.cpio
sha256sum $@


build/signing.key:
build/signing.key: | build
openssl req \
-new \
-x509 \
Expand Down Expand Up @@ -387,6 +390,7 @@ $(BOOTX64): build/vmlinuz initramfs/cmdline.txt bin/sbsign.safeboot build/signin
sha256sum "$@"

build/boot/PK.auth: signing.crt
mkdir -p $(dir $@)
-./sbin/safeboot uefi-sign-keys
cp signing.crt PK.auth KEK.auth db.auth "$(dir $@)"

Expand All @@ -396,7 +400,7 @@ build/esp.bin: $(BOOTX64) build/boot/PK.auth
build/hda.bin: build/esp.bin build/luks.bin
./sbin/mkgpt "$@" $^

build/key.bin:
build/key.bin: | build
echo -n "abcd1234" > "$@"

build/luks.bin: build/key.bin
Expand All @@ -422,7 +426,7 @@ TPMSOCK=$(TPMDIR)/sock
# Setup a new TPM and
# Extract the EK from a tpm state; wish swtpm_setup had a way
# to do this instead of requiring this many hoops
$(TPMDIR)/ek.pub: | $(SWTPM) bin/tpm2
$(TPMDIR)/ek.pub: | $(SWTPM) bin/tpm2 build
mkdir -p "$(TPMDIR)"
PATH=$(dir $(SWTPM)):$(PATH) \
swtpm/src/swtpm_setup/swtpm_setup \
Expand Down Expand Up @@ -454,15 +458,15 @@ $(TPMDIR)/ek.pub: | $(SWTPM) bin/tpm2
# Convert an EK PEM formatted public key into the hash of the modulus,
# which is used by the quote and attestation server to identify the machine
# none of the tools output this easily, so do lots of text manipulation to make it
$(TPMDIR)/ek.hash: $(TPMDIR)/ek.pub
$(TPMDIR)/ek.hash: $(TPMDIR)/ek.pub | build
sha256sum $< \
| cut -d\ -f1 \
> $@

# Register the virtual TPM in the attestation server logs with the
# expected value for the kernel that will be booted

$(TPMDIR)/.ekpub.registered: $(TPMDIR)/ek.pub initramfs/response/* initramfs/response/rootfs.enc.key initramfs/response/img.hash
$(TPMDIR)/.ekpub.registered: $(TPMDIR)/ek.pub initramfs/response/* initramfs/response/rootfs.enc.key initramfs/response/img.hash | build
tar \
-zcf - \
-C initramfs/response \
Expand Down Expand Up @@ -551,7 +555,7 @@ qemu: build/hda.bin $(SWTPM) $(TPMSTATE)

server-hda.bin:
qemu-img create -f qcow2 $@ 4G
build/OVMF_VARS.fd:
build/OVMF_VARS.fd: | build
cp /usr/share/OVMF/OVMF_VARS.fd $@

UBUNTU_REPO = https://cloud-images.ubuntu.com/focal/current
Expand Down

0 comments on commit 5d583be

Please sign in to comment.