switch-target 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. checkAndRm () {
  3. lines=`find . -mindepth 1 -maxdepth 1 -name "_*" -print | sed 's/\.\///'`
  4. for line in $lines; do
  5. find "${line}" \( -type f -o -type l \) -print |
  6. while read l; do
  7. to=`echo $l | sed "s/^${line}\///"`
  8. if [ -h "${to}" ]; then
  9. rm -f "${to}"
  10. fi
  11. done
  12. done
  13. }
  14. none() {
  15. checkAndRm || exit 2
  16. rm -rf *.exe *.so loader blackbox blackboxc dev0
  17. # System/Code/Kernel.ocf System/Sym/Kernel.osf Code/Kernel.ocf Sym/Kernel.osf \
  18. # System/Code/Init.ocf System/Sym/Init.osf Code/Init.ocf Sym/Init.osf \
  19. # System/Code/Config.ocf System/Sym/Config.osf Code/Config.ocf Sym/Config.osf \
  20. # Host/Code/*.ocf Host/Sym/*.osf Lin/Code/*.ocf Lin/Sym/*.osf
  21. }
  22. mklinks () {
  23. find "${1}" -mindepth ${2} -maxdepth ${2} \( -type f -o -type l \) -print |
  24. while read l; do
  25. to=`echo $l | sed "s/^${line}\///"`
  26. mkdir -p `dirname "${to}"`
  27. ln -s "${3}"/${l} "${to}"
  28. done
  29. }
  30. dolinks () {
  31. lines1=`find . -mindepth 1 -maxdepth 1 -name "_*${1}*_" -print | sed 's/\.\///'`
  32. lines2=`find . -mindepth 1 -maxdepth 1 -name "__*${2}*" -print | sed 's/\.\///'`
  33. lines3=`find . -mindepth 1 -maxdepth 1 -name "_*"${1}"*_*${2}*" -print | sed 's/\.\///'`
  34. for line in $lines1 $lines2 $lines3; do
  35. find "${line}" -mindepth 1 -maxdepth 1 \( -type f -o -type l \) -print |
  36. while read l; do
  37. ln -s $l
  38. done
  39. mklinks "${line}" 2 ..
  40. mklinks "${line}" 3 ../..
  41. mklinks "${line}" 4 ../../..
  42. done
  43. }
  44. if [ $# -eq 1 ]; then
  45. if [ "${1}" = "none" ]; then
  46. none
  47. else
  48. none || exit 2
  49. dolinks "${1}" Interp
  50. fi
  51. elif [ $# -eq 2 ]; then
  52. none || exit 2
  53. dolinks "${1}" "${2}"
  54. else
  55. echo "usage: `basename $0` ( none | OS [ configuration ] )"
  56. echo " OS: Linux | OpenBSD | FreeBSD | Windows"
  57. echo " configuration: GUI | Interp"
  58. echo " (default configuration: Interp)"
  59. exit 1
  60. fi