symlink-tree.sh 707 B

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