symlink-tree.sh 826 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env bash
  2. # Create a new openwrt tree with symlinks pointing at the current tree
  3. # Usage: ./scripts/symlink-tree.sh <destination>
  4. FILES="
  5. BSDmakefile
  6. config
  7. Config.in
  8. LICENSE
  9. Makefile
  10. README
  11. dl
  12. docs
  13. feeds.conf.default
  14. include
  15. package
  16. rules.mk
  17. scripts
  18. target
  19. toolchain
  20. tools"
  21. OPTIONAL_FILES="
  22. .git"
  23. if [ -f feeds.conf ] ; then
  24. FILES="$FILES feeds.conf"
  25. fi
  26. if [ -z "$1" ]; then
  27. echo "Syntax: $0 <destination>" >&2
  28. exit 1
  29. fi
  30. if [ -e "$1" ]; then
  31. echo "Error: $1 already exists" >&2
  32. exit 1
  33. fi
  34. set -e # fail if any commands fails
  35. mkdir -p dl "$1"
  36. for file in $FILES; do
  37. [ -e "$PWD/$file" ] || {
  38. echo "ERROR: $file does not exist in the current tree" >&2
  39. exit 1
  40. }
  41. ln -s "$PWD/$file" "$1/"
  42. done
  43. for file in $OPTIONAL_FILES; do
  44. [ -e "$PWD/$file" ] && ln -s "$PWD/$file" "$1/"
  45. done
  46. exit 0