symlink-tree.sh 820 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. feeds.conf.default
  13. include
  14. package
  15. rules.mk
  16. scripts
  17. target
  18. toolchain
  19. tools"
  20. OPTIONAL_FILES="
  21. .git"
  22. if [ -f feeds.conf ] ; then
  23. FILES="$FILES feeds.conf"
  24. fi
  25. if [ -z "$1" ]; then
  26. echo "Syntax: $0 <destination>" >&2
  27. exit 1
  28. fi
  29. if [ -e "$1" ]; then
  30. echo "Error: $1 already exists" >&2
  31. exit 1
  32. fi
  33. set -e # fail if any commands fails
  34. mkdir -p dl "$1"
  35. for file in $FILES; do
  36. [ -e "$PWD/$file" ] || {
  37. echo "ERROR: $file does not exist in the current tree" >&2
  38. exit 1
  39. }
  40. ln -s "$PWD/$file" "$1/"
  41. done
  42. for file in $OPTIONAL_FILES; do
  43. [ -e "$PWD/$file" ] && ln -s "$PWD/$file" "$1/"
  44. done
  45. exit 0