OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.7 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: target/share/functions.in
  5. # Copyright (C) 2006 The OpenSDE Project
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. # copy, with special files
  16. # from to file-list
  17. copy_with_list_from_file ()
  18. {
  19. ( cd $1 ; tar cSp --no-recursion --files-from=$3 ) |
  20. ( cd $2 ; tar xvSP ) |
  21. ( x=`wc -l` ; echo "$x files transfered." )
  22. }
  23. # copy out of T2 source without .svn files
  24. # from to
  25. copy_from_source ()
  26. {
  27. list=`mktemp`
  28. # the sed is a work around for a find issue, outputting empty rows
  29. # in some versions ...
  30. find $1 -name '.svn' -prune -o -printf "%P\n" | sed '/^$/d' > $list
  31. cat $list
  32. copy_with_list_from_file $1 $2 $list
  33. rm -f $list
  34. }
  35. # copy out of T2 source without .svn files and does honor special files to
  36. # apply patches, change owner:group or permissions
  37. # from to
  38. copy_and_parse_from_source ()
  39. {
  40. # the sed is a work around for a find issue, outputting empty rows
  41. # in some versions ...
  42. find $1 -name '.svn' -prune -o -printf "%P\n" | sed '/^$/d' | sort |
  43. while read file; do
  44. if [ -d $1/$file ]; then
  45. echo "Dir: $file"
  46. mkdir -p $2/$file
  47. else
  48. cmd=`sed 2q $1/$file`
  49. if [[ $cmd = \#\![a-y]* ]]; then
  50. cmd=${cmd#\#\!};
  51. code=${cmd%% *}
  52. echo "Code $code Command: $cmd File: $file"
  53. args=`echo $cmd | wc -w`
  54. dirname=${file%/*}
  55. basename=${file##*/}
  56. pushd $2/$dirname > /dev/null #; set -x
  57. case $code in
  58. ln|cp)
  59. if [ $args -le 3 ]; then
  60. eval $cmd $basename
  61. else
  62. eval $cmd
  63. fi ;;
  64. chmod|chown|rm)
  65. if [ $args -le 2 ]; then
  66. eval $cmd $basename
  67. else
  68. eval $cmd
  69. fi ;;
  70. patch) patch -f < $1/$file
  71. ;;
  72. *) echo "Code: $code unknown" ; exit 1 ;;
  73. esac #; set +x ;
  74. popd > /dev/null
  75. elif [[ $cmd = \#\!* ]]; then
  76. echo Script $file
  77. cp -afv $1/$file $2/$file
  78. chmod +x $2/$file
  79. else
  80. echo File $file
  81. cp -afv $1/$file $2/$file
  82. fi
  83. fi
  84. done
  85. }
  86. # link indentical files to save space
  87. link_identical_files()
  88. {
  89. (
  90. while read ck fn ; do
  91. if [ "$oldck" = "$ck" -a -s $fn ] ; then
  92. echo "\"$fn -> $oldfn\""
  93. rm $fn ; ln $oldfn $fn
  94. else
  95. oldck=$ck ; oldfn=$fn
  96. fi
  97. done < <( find -type f | xargs md5sum | sort )
  98. ) | ( x=`wc -l` ; echo "$x links created." )
  99. }