generate_manifest.sh 1.6 KB

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