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