From 8b13b14dfcd668c13df68d69c4d3b28027cd022e Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 4 Feb 2024 11:36:57 +0100 Subject: update build environment after repartitioning sd card --- makefile | 10 +++++----- state/gen | 16 +++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/makefile b/makefile index bd6754f..e3a1564 100644 --- a/makefile +++ b/makefile @@ -24,8 +24,7 @@ export # create dummy files to represent non-file targets (container image build # status, sd card partition status, git submodule initialization, etc.) -$(shell state/gen) --include state/auto.mk +$(eval $(shell state/gen)) # read environment variables from ./env include ./env @@ -51,6 +50,7 @@ state/sdcard_part: touch $@ state/sdcard_fmt: state/sdcard_part + $(eval $(shell state/gen)) $(AS_ROOT) mkfs.vfat -n BOOT -F 32 $(SDCARD_PART_BOOT) $(AS_ROOT) mkfs.ext4 -L ROOTFS -F $(SDCARD_PART_ROOTFS) touch $@ @@ -91,8 +91,8 @@ load_rootfs: .PHONY: status status: @echo '### STATUS REPORT' - @echo '# DETECTED SD CARD' - @cat state/auto.mk - @echo '# DETECTED STATE' + @echo '# ENVIRONMENT' + state/gen + @echo '# TARGETS' @ls state | awk '$$0 == "gen" || $$0 == "auto.mk" { next } { print }' diff --git a/state/gen b/state/gen index da89125..b55096d 100755 --- a/state/gen +++ b/state/gen @@ -1,10 +1,6 @@ #!/bin/sh -# redirect stdout to stderr (stdout gets interpreted by make) -exec 1>&2 # create files in the same directory as this script cd "$(dirname "$0")" -# do not run anything if make was run with -n (dry run) -[ "${MAKEFLAGS#*n}" != "$MAKEFLAGS" ] && exit # container image (initialized here, updated in makefile) $CTR image exists "$CTR_IMG_TAG" 1> /dev/null 2> /dev/null @@ -41,7 +37,8 @@ if [ -n "$SDCARD_DISK" ] ; then # variables are set if [ -z "$SDCARD_PART_BOOT" ] || [ -z "$SDCARD_PART_ROOTFS" ] ; then PARTS="$(lsblk "$SDCARD_DISK" --bytes --noheadings \ - --output PATH,SIZE,TYPE,PTTYPE,FSTYPE,LABEL,PARTFLAGS)" + --output PATH,SIZE,TYPE,PTTYPE,FSTYPE,LABEL,PARTFLAGS \ + 2> /dev/null)" # check if the disk is partitioned correctly echo "$PARTS" | awk ' @@ -69,9 +66,10 @@ if [ -n "$SDCARD_DISK" ] ; then fi fi -cat << EOF > auto.mk -SDCARD_DISK ?= $SDCARD_DISK -SDCARD_PART_BOOT ?= $SDCARD_PART_BOOT -SDCARD_PART_ROOTFS ?= $SDCARD_PART_ROOTFS +cat << EOF +\$(eval SDCARD_DISK := $SDCARD_DISK) +\$(eval SDCARD_PART_BOOT := $SDCARD_PART_BOOT) +\$(eval SDCARD_PART_ROOTFS := $SDCARD_PART_ROOTFS) +\$(eval export) EOF -- cgit v1.2.3