aboutsummaryrefslogtreecommitdiff
path: root/state
diff options
context:
space:
mode:
Diffstat (limited to 'state')
-rwxr-xr-xstate/gen35
1 files changed, 25 insertions, 10 deletions
diff --git a/state/gen b/state/gen
index e14e337..ddaf9d1 100755
--- a/state/gen
+++ b/state/gen
@@ -2,26 +2,39 @@
# create files in the same directory as this script
cd "$(dirname "$0")"
+set_state () {
+ filename="$1"
+ condition="$2"
+ if [ "$condition" -eq 0 ] ; then
+ # echo "$filename = TRUE" >&2
+ if ! [ -e "$filename" ] ; then
+ touch "$filename"
+ fi
+ else
+ # echo "$filename = FALSE" >&2
+ rm -f "$filename"
+ fi
+}
+
# container image (initialized here, updated in makefile)
$CTR image exists "$CTR_IMG_TAG" 1> /dev/null 2> /dev/null
-if [ $? -eq 0 ] ; then
- ! [ -e container_img ] && touch container_img
-else
- rm -f container_img
-fi
+set_state container_img $?
# check if all the submodules are initialized
-touch submodules
+SUBMODULES_OK=0
MODULES="$(git config \
--file "$(git rev-parse --show-toplevel)/.gitmodules" \
--name-only --get-regexp path |\
sed -e 's/^submodule\./modules\//' -e 's/\.path$/\/HEAD/')"
for git_module in $MODULES ; do
git rev-parse "$git_module" 1> /dev/null 2> /dev/null && continue
- rm -f submodules
+ echo "$git_module is the culprit" >&2
+ SUBMODULES_OK=1
done
+set_state submodules $SUBMODULES_OK
-rm -f sdcard_part sdcard_fmt
+SDCARD_PART_OK=1
+SDCARD_FMT_OK=1
# if no explicit SDCARD_DISK is set, guess which device is the sd card by
# checking if it is removable AND has a size of approx. 8GB
if [ -z "$SDCARD_DISK" ] ; then
@@ -46,7 +59,7 @@ if [ -n "$SDCARD_DISK" ] ; then
$3 == "part" { parts += 1 }
NR == 1 { if ($4 != "dos") exit(1) }
NR == 2 { if ($2 != 64 * 2^20) exit(1) }
- END { if (parts != 2) exit(1) }' && touch sdcard_part
+ END { if (parts != 2) exit(1) }' && SDCARD_PART_OK=0
if [ $? -eq 0 ] ; then
SDCARD_PART_BOOT="$(echo "$PARTS" | awk 'NR == 2 { print $1 }')"
@@ -62,10 +75,12 @@ if [ -n "$SDCARD_DISK" ] ; then
NR == 3 {
if ($5 != "ext4") exit(1)
if ($6 != "ROOTFS") exit(1)
- }' && touch sdcard_fmt
+ }' && SDCARD_FMT_OK=0
fi
fi
fi
+set_state sdcard_part $SDCARD_PART_OK
+set_state sdcard_fmt $SDCARD_FMT_OK
cat << EOF
\$(eval SDCARD_DISK := $SDCARD_DISK)