3 # This file is part of the aMule project.
5 # Copyright (c) 2004-2008 aMule Project ( admin@amule.org / http://www.amule.org )
6 # Copyright (c) 2004-2008 Jacobo Vilella (Jacobo221)
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 ###################################################################
25 # linkcvs will link the whole cvs tree to the given path #
26 # allowing keeping several compilations from a single cvs tree #
28 # Warning: This script overwrites old files in target_path #
30 ###################################################################
32 # Script valid as of 4rd June 2004 aMule CVS #
33 # Suggestions go to Jacobo221 at @amule dot .org #
35 ###################################################################
37 # This code is distributed under terms of the GPL License #
38 # http://www.gnu.org/copyleft/gpl.html #
40 ###################################################################
42 # EXEC is a list of the files which will be called as scripts #
43 # EXEC_NUMBER is the amount of EXEC files in the list #
44 # EXEC_PREFIX is the command to prefix the call of the EXEC #
45 # EXEC_POSTFIX is the command to postfix the call of the EXEC #
46 # COPY is a list of files which will be copies, not linked #
47 # Priviledge order (max to min): EXEC, COPY, CVS #
49 ###################################################################
52 # The follwing four lines were needed for aMule versions previous to 2.0.0
55 # EXEC_PREFIX=("original=\`readlink src/SharedFileList.h\` && cp -d --remove-destination \"\$original\" src/ && ")
56 # EXEC_POSTFIX=("ln -sf \"\$original\" src/SharedFileList.h")
60 echo "`basename $0`: invalid number of arguments"
61 echo "Try \``basename $0` <cvs_tree_path> <target_path>'"
63 elif [ ! -e "$1" ]; then
64 echo "`basename $0`: $1 doesn't exist!"
66 elif [ ! -d "${1}/CVS" ]; then
67 echo "`basename $0`: $1 isn't a CVS tree!"
69 elif [ ! -e "${1}/CVS/Entries" ]; then
70 echo "`basename $0`: $1 has no Entries file!"
77 if [ "`echo \"$SOURCE\" | cut -c 1`" != "/" ] && [ "`echo \"$SOURCE\" | cut -c 1`" != "~" ]; then
78 SOURCE
="`pwd`/$SOURCE"
80 if [ "`echo \"$TARGET\" | cut -c 1`" != "/" ] && [ "`echo \"$TARGET\" | cut -c 1`" != "~" ]; then
81 TARGET
="`pwd`/$TARGET"
86 local FILES
=`cat "${SOURCE}/$1"/CVS/Entries | cut -f 2 -d "/" -s`
87 # Alternative option would be to place `grep "^D/"` and `grep "^"`
88 for file in $FILES; do
89 if [ -d "${SOURCE}/${1}/$file" ]; then
90 mkdir
-p "${TARGET}/${1}/$file"
93 target
="${TARGET}/${subfile/$SOURCE}/${1}"
94 if [ ! -e "${SOURCE}/${1}/$file" ]; then
95 echo "${SOURCE}/${1}/$file not found!"
97 ln -sf "${SOURCE}/${1}/$file" "$target"
103 if [ ! -e "$TARGET" ]; then
104 echo -n "$TARGET doesn't exist. Should I create it? [y/n]"
106 if [ $opt = Y
-o $opt = y
]; then
110 echo "`basename $0`: target_path invalid"
117 for file in $COPY; do
118 mkdir
-p "${TARGET}/`dirname $file`"
119 for subfile
in ${SOURCE}/$file; do
120 if [ ! -e "$subfile" ]; then
121 echo "$subfile not found!"
123 # -d --remove-destination is esential for links handling
124 cp -d --remove-destination "$subfile" "${TARGET}/${subfile/$SOURCE}"
130 while [ "$i" -lt "$EXEC_NUMBER" ]; do
131 mkdir
-p "${TARGET}/`dirname $file`"
132 for subfile
in "${SOURCE}"/${EXEC[$i]}; do
133 if [ ! -e "$subfile" ]; then
134 echo "$subfile not found!"
136 target
="${TARGET}/${subfile/$SOURCE}"
137 rm -f "$target" # Necessary in case $target is a link
138 echo ${EXEC_PREFIX[$i]} > "$target"
139 echo -n "$subfile && " >> "$target"
140 echo ${EXEC_POSTFIX[$i]} >> "$target"