generate_manifest.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$GLUON_IMAGEDIR" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" ] || exit 1
  4. default_sysupgrade_ext='.bin'
  5. output=
  6. aliases=
  7. manifest_aliases=
  8. sysupgrade_ext=
  9. SITE_CODE="$(scripts/site.sh site_code)"
  10. get_filename() {
  11. local name="$1"
  12. echo -n "gluon-${SITE_CODE}-${GLUON_RELEASE}-${name}-sysupgrade${sysupgrade_ext}"
  13. }
  14. get_filepath() {
  15. local filename="$1"
  16. echo -n "${GLUON_IMAGEDIR}/sysupgrade/${filename}"
  17. }
  18. generate_line() {
  19. local model="$1"
  20. local filename="$2"
  21. local filesize="$3"
  22. local filepath="$(get_filepath "$filename")"
  23. [ -e "$filepath" ] || return 0
  24. local file256sum="$(scripts/sha256sum.sh "$filepath")"
  25. local file512sum="$(scripts/sha512sum.sh "$filepath")"
  26. echo "$model $GLUON_RELEASE $file256sum $filesize $filename"
  27. echo "$model $GLUON_RELEASE $file256sum $filename"
  28. echo "$model $GLUON_RELEASE $file512sum $filename"
  29. }
  30. generate() {
  31. [ "${output}" ] || return 0
  32. [ "$sysupgrade_ext" ] || return 0
  33. local filename="$(get_filename "$output")"
  34. local filepath="$(get_filepath "$filename")"
  35. [ -e "$filepath" ] || return 0
  36. local filesize="$(scripts/filesize.sh "$filepath")"
  37. generate_line "$output" "$filename" "$filesize"
  38. for alias in $aliases; do
  39. generate_line "$alias" "$(get_filename "$alias")" "$filesize"
  40. done
  41. for alias in $manifest_aliases; do
  42. generate_line "$alias" "$filename" "$filesize"
  43. done
  44. }
  45. . scripts/common.inc.sh
  46. device() {
  47. generate
  48. output="$1"
  49. aliases=
  50. manifest_aliases=
  51. sysupgrade_ext="$default_sysupgrade_ext"
  52. }
  53. sysupgrade_image() {
  54. generate
  55. output="$1"
  56. aliases=
  57. manifest_aliases=
  58. if [ "$3" ]; then
  59. sysupgrade_ext="$3"
  60. else
  61. sysupgrade_ext="$2"
  62. fi
  63. }
  64. alias() {
  65. aliases="$aliases $1"
  66. }
  67. manifest_alias() {
  68. manifest_aliases="$manifest_aliases $1"
  69. }
  70. sysupgrade() {
  71. if [ "$2" ]; then
  72. sysupgrade_ext="$2"
  73. else
  74. sysupgrade_ext="$1"
  75. fi
  76. if [ -z "$output" ]; then
  77. default_sysupgrade_ext="$sysupgrade_ext"
  78. fi
  79. }
  80. . targets/"$1"; generate