aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-02-04 11:36:57 +0100
committerlonkaars <loek@pipeframe.xyz>2024-02-04 11:36:57 +0100
commit8b13b14dfcd668c13df68d69c4d3b28027cd022e (patch)
tree9a96ee1e09d704aaedc2b10278b172eaa6465cab
parent4f8507ff8756cac446a01d7d3a28bdf4f963adf5 (diff)
update build environment after repartitioning sd card
-rw-r--r--makefile10
-rwxr-xr-xstate/gen16
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