# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: target/share/functions.in
|
|
# Copyright (C) 2006 The OpenSDE Project
|
|
# Copyright (C) 2004 - 2006 The T2 SDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
# copy, with special files
|
|
# from to file-list
|
|
copy_with_list_from_file ()
|
|
{
|
|
( cd $1 ; tar cSp --no-recursion --files-from=$3 ) |
|
|
( cd $2 ; tar xvSP ) |
|
|
( x=`wc -l` ; echo "$x files transfered." )
|
|
}
|
|
|
|
# copy out of T2 source without .svn files
|
|
# from to
|
|
copy_from_source ()
|
|
{
|
|
list=`mktemp`
|
|
# the sed is a work around for a find issue, outputting empty rows
|
|
# in some versions ...
|
|
find $1 -name '.svn' -prune -o -printf "%P\n" | sed '/^$/d' > $list
|
|
cat $list
|
|
copy_with_list_from_file $1 $2 $list
|
|
rm -f $list
|
|
}
|
|
|
|
|
|
# copy out of T2 source without .svn files and does honor special files to
|
|
# apply patches, change owner:group or permissions
|
|
# from to
|
|
copy_and_parse_from_source ()
|
|
{
|
|
# the sed is a work around for a find issue, outputting empty rows
|
|
# in some versions ...
|
|
find $1 -name '.svn' -prune -o -printf "%P\n" | sed '/^$/d' | sort |
|
|
while read file; do
|
|
if [ -d $1/$file ]; then
|
|
echo "Dir: $file"
|
|
mkdir -p $2/$file
|
|
else
|
|
cmd=`sed 2q $1/$file`
|
|
if [[ $cmd = \#\![a-y]* ]]; then
|
|
cmd=${cmd#\#\!};
|
|
code=${cmd%% *}
|
|
echo "Code $code Command: $cmd File: $file"
|
|
args=`echo $cmd | wc -w`
|
|
dirname=${file%/*}
|
|
basename=${file##*/}
|
|
|
|
pushd $2/$dirname > /dev/null #; set -x
|
|
case $code in
|
|
ln|cp)
|
|
if [ $args -le 3 ]; then
|
|
eval $cmd $basename
|
|
else
|
|
eval $cmd
|
|
fi ;;
|
|
chmod|chown|rm)
|
|
if [ $args -le 2 ]; then
|
|
eval $cmd $basename
|
|
else
|
|
eval $cmd
|
|
fi ;;
|
|
patch) patch -f < $1/$file
|
|
;;
|
|
*) echo "Code: $code unknown" ; exit 1 ;;
|
|
esac #; set +x ;
|
|
popd > /dev/null
|
|
elif [[ $cmd = \#\!* ]]; then
|
|
echo Script $file
|
|
cp -afv $1/$file $2/$file
|
|
chmod +x $2/$file
|
|
else
|
|
echo File $file
|
|
cp -afv $1/$file $2/$file
|
|
fi
|
|
fi
|
|
done
|
|
}
|
|
|
|
# link indentical files to save space
|
|
link_identical_files()
|
|
{
|
|
(
|
|
while read ck fn ; do
|
|
if [ "$oldck" = "$ck" -a -s $fn ] ; then
|
|
echo "\"$fn -> $oldfn\""
|
|
rm $fn ; ln $oldfn $fn
|
|
else
|
|
oldck=$ck ; oldfn=$fn
|
|
fi
|
|
done < <( find -type f | xargs md5sum | sort )
|
|
) | ( x=`wc -l` ; echo "$x links created." )
|
|
}
|
|
|