Bläddra i källkod

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 år sedan
förälder
incheckning
21b3dd3259
2 ändrade filer med 32 tillägg och 2 borttagningar
  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() {