head 1.28; access; symbols SHTOOL_2_0_8:1.28 SHTOOL_2_0_7:1.27 SHTOOL_2_0_6:1.26 SHTOOL_2_0_5:1.26 SHTOOL_2_0_4:1.26 SHTOOL_2_0_3:1.25 SHTOOL_2_0_2:1.25 SHTOOL_2_0_1:1.24 SHTOOL_2_0_0:1.24 SHTOOL_2_0b3:1.24 SHTOOL_2_0b2:1.24 SHTOOL_2_0b1:1.24 SHTOOL_1_6:1.20.0.2 SHTOOL_1_6_2:1.20 SHTOOL_1_6_1:1.20 SHTOOL_1_6_0:1.20 SHTOOL_1_5:1.18.0.2 SHTOOL_1_5_4:1.18 SHTOOL_1_5_3:1.18 SHTOOL_1_5_2:1.18 SHTOOL_1_5_1:1.17 SHTOOL_1_5_0:1.17 SHTOOL_1_4_9:1.17 SHTOOL_1_4_8:1.16 SHTOOL_1_4_7:1.13 SHTOOL_1_4_6:1.11 SHTOOL_1_4_5:1.11 SHTOOL_1_4_4:1.11 SHTOOL_1_4_3:1.11 SHTOOL_1_4_2:1.11 SHTOOL_1_4_1:1.11 SHTOOL_1_4_0:1.11 SHTOOL_1_3_3:1.10 SHTOOL_1_3_2:1.8 SHTOOL_1_3_1:1.7 SHTOOL_1_3_0:1.6 SHTOOL_1_2_9:1.2 SHTOOL_1_2_8:1.2 SHTOOL_1_2_7:1.2 SHTOOL_1_2_6:1.2 SHTOOL_1_2_5:1.2 SHTOOL_1_2_4:1.1.1.2 SHTOOL_1_2_3:1.1.1.2 SHTOOL_1_2_2:1.1.1.2 SHTOOL_1_2_1:1.1.1.2 SHTOOL_1_2_0:1.1.1.2 SHTOOL_1_1_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.28 date 2008.04.02.20.13.43; author rse; state Exp; branches; next 1.27; commitid eB5Wirx8MdMyDzXs; 1.27 date 2007.05.19.19.09.39; author rse; state Exp; branches; next 1.26; commitid OPUF1UBbllBTwzis; 1.26 date 2006.02.04.09.43.25; author rse; state Exp; branches; next 1.25; commitid oWk7BmnyAitJtfkr; 1.25 date 2005.06.15.08.14.35; author rse; state Exp; branches; next 1.24; 1.24 date 2004.02.12.16.06.27; author rse; state Exp; branches; next 1.23; 1.23 date 2004.01.01.16.54.20; author rse; state Exp; branches; next 1.22; 1.22 date 2003.02.11.13.00.50; author rse; state Exp; branches; next 1.21; 1.21 date 2003.02.11.12.56.40; author rse; state Exp; branches; next 1.20; 1.20 date 2001.12.31.15.06.04; author rse; state Exp; branches; next 1.19; 1.19 date 2001.09.23.10.58.10; author rse; state Exp; branches; next 1.18; 1.18 date 2001.01.17.09.55.11; author rse; state Exp; branches; next 1.17; 1.17 date 2000.03.24.15.22.51; author rse; state Exp; branches; next 1.16; 1.16 date 2000.03.12.13.28.24; author rse; state Exp; branches; next 1.15; 1.15 date 2000.03.12.12.46.42; author rse; state Exp; branches; next 1.14; 1.14 date 2000.03.12.11.12.21; author rse; state Exp; branches; next 1.13; 1.13 date 99.12.24.14.51.15; author rse; state Exp; branches; next 1.12; 1.12 date 99.12.24.14.10.30; author rse; state Exp; branches; next 1.11; 1.11 date 99.07.01.14.54.40; author rse; state Exp; branches; next 1.10; 1.10 date 99.07.01.11.55.53; author rse; state Exp; branches; next 1.9; 1.9 date 99.06.29.17.37.34; author rse; state Exp; branches; next 1.8; 1.8 date 99.06.28.15.18.44; author rse; state Exp; branches; next 1.7; 1.7 date 99.06.28.07.10.54; author rse; state Exp; branches; next 1.6; 1.6 date 99.06.17.15.08.18; author rse; state Exp; branches; next 1.5; 1.5 date 99.06.17.07.35.08; author rse; state Exp; branches; next 1.4; 1.4 date 99.06.12.14.46.37; author rse; state Exp; branches; next 1.3; 1.3 date 99.06.12.14.08.49; author rse; state Exp; branches; next 1.2; 1.2 date 99.05.12.15.41.41; author rse; state Exp; branches; next 1.1; 1.1 date 99.04.29.11.19.50; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.04.29.11.19.50; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 99.04.29.11.20.00; author rse; state Exp; branches; next ; desc @@ 1.28 log @adjust copyright for year 2008 @ text @## ## mkshadow -- Make a shadow tree through symbolic links ## Copyright (c) 1998-2008 Ralf S. Engelschall ## ## This file is part of shtool and 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; either version ## 2 of the License, or (at your option) any later version. ## ## This file is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ## USA, or contact Ralf S. Engelschall . ## str_tool="mkshadow" str_usage="[-v|--verbose] [-t|--trace] [-a|--all] " arg_spec="2=" opt_spec="v.t.a." opt_alias="v:verbose,t:trace,a:all" opt_v=no opt_t=no opt_a=no . ./sh.common # source and destination directory src=`echo "$1" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'` dst=`echo "$2" | sed -e 's:/$::' -e 's:^\./\(.\):\1:'` # check whether source exists if [ ! -d $src ]; then echo "$msgprefix:Error: source directory not found: \`$src'" 1>&2 shtool_exit 1 fi # determine if one of the paths is an absolute path, # because then we have to use an absolute symlink oneisabs=0 case $src in /* ) oneisabs=1 ;; esac case $dst in /* ) oneisabs=1 ;; esac # determine reverse directory for destination directory dstrevdir='' if [ $oneisabs = 0 ]; then # derive reverse path from forward path pwd=`pwd` OIFS="$IFS"; IFS='/' for pe in $dst; do if [ "x$pe" = "x.." ]; then OIFS2="$IFS"; IFS="$DIFS" eval `echo "$pwd" |\ sed -e 's:\([^/]*\)$:; dir="\1":' \ -e 's:^\(.*\)/[^/]*;:pwd="\1";:'\ -e 's:^;:pwd="";:'` dstrevdir="$dir/$dstrevdir" IFS="$OIFS2" else dstrevdir="../$dstrevdir" fi done IFS="$OIFS" else src="`cd $src; pwd`"; fi # create directory tree at destination if [ ! -d $dst ]; then if [ ".$opt_t" = .yes ]; then echo "mkdir $dst" 1>&2 fi mkdir $dst fi if [ ".$opt_a" = .yes ]; then DIRS=`cd $src; find . -type d -print |\ sed -e '/^\.$/d' -e 's:^\./::'` else DIRS=`cd $src; find . -type d -print |\ sed -e '/\/CVS/d' -e '/^\.$/d' -e 's:^\./::'` fi for dir in $DIRS; do if [ ".$opt_t" = .yes ]; then echo "mkdir $dst/$dir" 1>&2 fi mkdir $dst/$dir done # fill directory tree with symlinks to files if [ ".$opt_a" = .yes ]; then FILES="`cd $src; find . -depth -print |\ sed -e 's/^\.\///'`" else FILES="`cd $src; find . -depth -print |\ sed -e '/\.o$/d' -e '/\.a$/d' -e '/\.so$/d' \ -e '/\.cvsignore$/d' -e '/\/CVS/d' \ -e '/\/\.#/d' -e '/\.orig$/d' \ -e 's/^\.\///'`" fi for file in $FILES; do # don't use `-type f' above for find because of symlinks if [ -d "$src/$file" ]; then continue fi basename=`echo $file | sed -e 's:^.*/::'` dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'` from=`echo "$src/$file" | sed -e 's/^\.\///'` to="$dst/$dir$basename" if [ $oneisabs = 0 ]; then if [ ".$dir" != . ]; then subdir=`echo $dir | sed -e 's:/$::'` # derive reverse path from forward path revdir='' OIFS="$IFS"; IFS='/' for pe in $subdir; do revdir="../$revdir" done IFS="$OIFS" # finalize from from="$revdir$from" fi from="$dstrevdir$from" fi if [ ".$opt_v" = .yes ]; then echo " $to" 1>&2 fi if [ ".$opt_t" = .yes ]; then echo "ln -s $from $to" 1>&2 fi ln -s $from $to done shtool_exit 0 ## ## manual page ## =pod =head1 NAME B - B create shadow tree using symlinks =head1 SYNOPSIS B [B<-v>|B<--verbose>] [B<-t>|B<--trace>] [B<-a>|B<--all>] I I =head1 DESCRIPTION This command creates a shadow tree of I under I by recreating the directory hierarchy of I under I and by creating the files of I by linking them into the corresponding directories under I via symbolic links. When I can be reached via relative paths from I, relative symbolic links are used, too. This high-level functionality is originally designed for developers to create copies of source trees. =head1 OPTIONS The following command line options are available. =over 4 =item B<-v>, B<--verbose> Display some processing information. =item B<-t>, B<--trace> Enable the output of the essential shell commands which are executed. =item B<-a>, B<--all> Really shadow all files and directories in I. Default is to skip CVS related files and directories, backup files, object files, etc. =head1 EXAMPLE # shell script shtool mkshadow -v -a . /tmp/shadow =head1 HISTORY The B B command was originally written by Ralf S. Engelschall Erse@@engelschall.comE in 1998 for B. It was later revised and taken over into B. =head1 SEE ALSO shtool(1), ln(1). =cut @ 1.27 log @Adjust copyright for year 2007. @ text @d3 1 a3 1 ## Copyright (c) 1998-2007 Ralf S. Engelschall @ 1.26 log @Adjust copyright for year 2006 @ text @d3 1 a3 1 ## Copyright (c) 1998-2006 Ralf S. Engelschall @ 1.25 log @Adjust copyright for year 2005 @ text @d3 1 a3 1 ## Copyright (c) 1998-2005 Ralf S. Engelschall @ 1.24 log @Embedded the command documentation from shtool.pod into the individual sh.xxxx scripts and this way split the large shtool(1) manual page into individual manual pages shtool-xxxx(1). Submitted partly by: Thomas Lotterer @ text @d3 1 a3 1 ## Copyright (c) 1998-2004 Ralf S. Engelschall @ 1.23 log @Bump copyright year for 2004 @ text @a3 1 ## Originally written for Apache d140 67 @ 1.22 log @Bump year in copyright messages to cover new year 2003. @ text @d3 1 a3 1 ## Copyright (c) 1998-2003 Ralf S. Engelschall @ 1.21 log @Fixed error exit in all commands by introducing an "shtool_exit" function (which correctly cleans up temporary files) and replacing all "exit" calls with "shtool_exit". THIS THE FIRST TIME INTRODUCED THE USAGE OF A SHELL FUNCTION TO THE SHTOOL CODE. This is known to break on _very_ anchient and broken Bourne-Shell implementations and is considered to be no longer a real problem in the year 2003. Especially there is no alternative way anyway. @ text @d3 1 a3 1 ## Copyright (c) 1998-2002 Ralf S. Engelschall @ 1.20 log @bump copyright years @ text @d40 1 a40 1 exit 1 @ 1.19 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1998-2001 Ralf S. Engelschall @ 1.18 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] [-t] [-a] " d26 1 @ 1.17 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1998-2000 Ralf S. Engelschall @ 1.16 log @*** empty log message *** @ text @d2 1 a2 1 ## mkshadow -- Make a shadow tree @ 1.15 log @*** empty log message *** @ text @d25 4 a28 1 opt_spec="vta" @ 1.14 log @*** empty log message *** @ text @d24 1 a24 1 arg_spec="2" @ 1.13 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1998-1999 Ralf S. Engelschall @ 1.12 log @*** empty log message *** @ text @d30 2 a31 2 src=`echo "$1" | sed -e 's:/$::'` dst=`echo "$2" | sed -e 's:/$::'` d53 1 d56 11 a66 1 dstrevdir="../$dstrevdir" @ 1.11 log @*** empty log message *** @ text @d52 1 a52 1 # (inlined fp2rp) d106 1 a106 1 # (inlined fp2rp) @ 1.10 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] [-d] [-a] " d25 1 a25 1 opt_spec="vda" d64 1 a64 1 if [ ".$opt_d" = .yes ]; then d77 1 a77 1 if [ ".$opt_d" = .yes ]; then d121 1 a121 1 if [ ".$opt_d" = .yes ]; then @ 1.9 log @*** empty log message *** @ text @a28 4 # default IFS DIFS=' ' a75 1 OIFS="$IFS" IFS="$DIFS" a81 1 IFS="$OIFS" a93 1 OIFS="$IFS" IFS="$DIFS" d108 1 a108 1 OIFS2="$IFS"; IFS='/' d112 1 a112 1 IFS="$OIFS2" a125 1 IFS="$OIFS" @ 1.8 log @*** empty log message *** @ text @d30 1 a30 1 DIFS=' @ 1.7 log @*** empty log message *** @ text @d27 1 a27 1 . sh.common @ 1.6 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] " d25 1 a25 1 opt_spec="v" d39 1 a39 1 echo "$msgprefix:Error: source directory not found" 1>&2 d68 3 d73 7 a79 5 DIRS="`cd $src find . -type d -print |\ sed -e '/\/CVS/d' \ -e '/^\.$/d' \ -e 's:^\./::'`" d82 3 d90 10 a99 10 FILES="`cd $src find . -depth -print |\ sed -e '/\.o$/d' \ -e '/\.a$/d' \ -e '/\.so$/d' \ -e '/\.cvsignore$/d' \ -e '/\/CVS/d' \ -e '/\/\.#/d' \ -e '/\.orig$/d' \ -e 's/^\.\///'`" d103 1 a103 1 if [ -d $file ]; then d127 3 @ 1.5 log @*** empty log message *** @ text @d100 1 a100 1 from="$src/$file" @ 1.4 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] " @ 1.3 log @*** empty log message *** @ text @d6 15 @ 1.2 log @*** empty log message *** @ text @a0 1 #!/bin/sh d2 1 a2 1 ## mkshadow -- Create a shadow tree d4 1 a4 1 ## Usage: mkshadow d7 7 a17 6 # command line check if [ $# -ne 2 ]; then echo "$0:Error: Invalid aruments" 1>&2 exit 1 fi d19 2 a20 2 src=`echo $1 | sed -e 's:/$::'` dst=`echo $2 | sed -e 's:/$::'` d24 1 a24 1 echo "$0:Error: source directory not found" 1>&2 d102 3 a104 1 echo " $to" @ 1.1 log @Initial revision @ text @d42 1 a42 1 OIFS2="$IFS"; IFS='/' d46 1 a46 1 IFS="$OIFS2" a71 1 -e '/\.so-o$/d' \ a73 3 -e '/\.indent\.pro$/d' \ -e '/\.apaci.*/d' \ -e '/Makefile$/d' \ @ 1.1.1.1 log @Import of shtool 1.1.0 @ text @@ 1.1.1.2 log @Import of shtool 1.2.0 @ text @d42 1 a42 1 OIFS="$IFS"; IFS='/' d46 1 a46 1 IFS="$OIFS" @