zzz-gluon-upgrade 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. UPGRADE_DIR=/lib/gluon/upgrade
  3. VERSION_DIR=/lib/gluon/version
  4. mkdir -p "$VERSION_DIR"
  5. version_of() {
  6. opkg status "gluon-$1" | grep '^Version: ' | cut -d' ' -f 2
  7. }
  8. oldversion_of() {
  9. cat "$VERSION_DIR"/"$1" 2>/dev/null
  10. }
  11. do_dir() {
  12. [ -d "$1" ] || return
  13. local s
  14. for s in "$1"/*; do "$s"; done
  15. }
  16. do_component() {
  17. local component="$1"
  18. local version="$(version_of "$component")"
  19. [ "$version" ] || continue
  20. (
  21. cd "$component"
  22. local oldversion="$(oldversion_of "$component")"
  23. if [ -z "$oldversion" ]; then
  24. do_dir initial
  25. else
  26. local v
  27. for v in *; do
  28. [ "$v" != initial -a "$v" != invariant ] || continue
  29. # The return value of opkg compare-versions is negated
  30. if ! opkg compare-versions "$v" '>>' "$oldversion"; then
  31. do_dir "$v"
  32. fi
  33. done
  34. fi
  35. do_dir invariant
  36. echo "$version" > "$VERSION_DIR"/"$component"
  37. )
  38. }
  39. cd "$UPGRADE_DIR"
  40. do_component core
  41. for component in *; do
  42. [ "$component" != 'core' ] || continue
  43. do_component "$component"
  44. done