zzz-gluon-upgrade 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. UPGRADE_DIR=/lib/gluon/upgrade
  3. VERSION_DIR=/lib/gluon/version
  4. if [ -x /lib/gluon/legacy/legacy-upgrade ] && /lib/gluon/legacy/legacy-upgrade; then
  5. HAS_LEGACY=1
  6. else
  7. HAS_LEGACY=
  8. fi
  9. # Temporary fix for broken upgrades (happened between 20140225 and 20140226, remove next week)
  10. if [ -f "$VERSION_DIR" ]; then rm "$VERSION_DIR"; fi
  11. mkdir -p "$VERSION_DIR"
  12. version_of() {
  13. opkg status "gluon-$1" | awk '/^Version: / { print $2 }'
  14. }
  15. oldversion_of() {
  16. cat "$VERSION_DIR"/"$1" 2>/dev/null
  17. }
  18. do_dir() {
  19. [ -d "$1" ] || return
  20. local s
  21. for s in "$1"/*; do "$s"; done
  22. }
  23. do_component() {
  24. local component="$1"
  25. local version="$(version_of "$component")"
  26. [ "$version" ] || continue
  27. (
  28. cd "$component"
  29. local oldversion="$(oldversion_of "$component")"
  30. if [ -z "$oldversion" ]; then
  31. if [ "$HAS_LEGACY" ]; then
  32. do_dir legacy
  33. else
  34. do_dir initial
  35. fi
  36. fi
  37. do_dir invariant
  38. echo "$version" > "$VERSION_DIR"/"$component"
  39. )
  40. }
  41. cd "$UPGRADE_DIR"
  42. do_component core
  43. for component in *; do
  44. [ "$component" != 'core' ] || continue
  45. do_component "$component"
  46. done
  47. if [ "$HAS_LEGACY" ]; then
  48. /lib/gluon/legacy/legacy-upgrade-late
  49. fi