Browse Source

build: add file size field to manifest lines

We would like to check the file size instead of downloading indefinitely.
The file size is added in another copy of the manifest lines, which is
ignored by older autoupdater implementations.
Matthias Schiffer 6 years ago
parent
commit
21b3dd3259
2 changed files with 32 additions and 2 deletions
  1. 16 0
      scripts/filesize.sh
  2. 16 2
      scripts/generate_manifest.sh

+ 16 - 0
scripts/filesize.sh

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+check_command() {
+	which "$1" >/dev/null 2>&1
+}
+
+if check_command gnustat; then
+	gnustat -c%s "$@"
+elif check_command gstat; then
+	gstat -c%s "$@"
+elif check_command stat; then
+	stat -c%s "$@"
+else
+	echo "$0: no suitable stat implementation was found" >&2
+	exit 1
+fi

+ 16 - 2
scripts/generate_manifest.sh

@@ -21,8 +21,22 @@ generate_line() {
 	local model="$1"
 	local file="$2"
 
-	[ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo "$model" "$GLUON_RELEASE" "$(scripts/sha256sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" "$file"
-	[ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo "$model" "$GLUON_RELEASE" "$(scripts/sha512sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" "$file"
+	[ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo \
+		"$model" \
+		"$GLUON_RELEASE" \
+		"$(scripts/sha256sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" \
+		"$(scripts/filesize.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" \
+		"$file"
+	[ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo \
+		"$model" \
+		"$GLUON_RELEASE" \
+		"$(scripts/sha256sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" \
+		"$file"
+	[ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo \
+		"$model" \
+		"$GLUON_RELEASE" \
+		"$(scripts/sha512sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" \
+		"$file"
 }
 
 generate() {