generate_manifest.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. sysupgrade_ext=
  8. SITE_CODE="$(scripts/site.sh site_code)"
  9. generate_line() {
  10. local model="$1"
  11. local file="$2"
  12. [ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo "$model" "$GLUON_RELEASE" "$(scripts/sha256sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" "$file"
  13. [ ! -e "${GLUON_IMAGEDIR}/sysupgrade/$file" ] || echo "$model" "$GLUON_RELEASE" "$(scripts/sha512sum.sh "${GLUON_IMAGEDIR}/sysupgrade/$file")" "$file"
  14. }
  15. generate() {
  16. [ "${output}" ] || return 0
  17. if [ "$sysupgrade_ext" ]; then
  18. generate_line "$output" "gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}-sysupgrade${sysupgrade_ext}"
  19. for alias in $aliases; do
  20. generate_line "$alias" "gluon-${SITE_CODE}-${GLUON_RELEASE}-${alias}-sysupgrade${sysupgrade_ext}"
  21. done
  22. fi
  23. }
  24. . scripts/common.inc.sh
  25. device() {
  26. generate
  27. output="$1"
  28. aliases=
  29. sysupgrade_ext="$default_sysupgrade_ext"
  30. }
  31. sysupgrade_image() {
  32. generate
  33. output="$1"
  34. aliases=
  35. if [ "$3" ]; then
  36. sysupgrade_ext="$3"
  37. else
  38. sysupgrade_ext="$2"
  39. fi
  40. }
  41. alias() {
  42. aliases="$aliases $1"
  43. }
  44. sysupgrade() {
  45. if [ "$2" ]; then
  46. sysupgrade_ext="$2"
  47. else
  48. sysupgrade_ext="$1"
  49. fi
  50. if [ -z "$output" ]; then
  51. default_sysupgrade_ext="$sysupgrade_ext"
  52. fi
  53. }
  54. . targets/"$1"; generate