home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk1.iso
/
altsrc
/
articles
/
11349
< prev
next >
Wrap
Text File
|
1994-10-17
|
3KB
|
75 lines
Newsgroups: alt.sources
Path: wupost!gumby!newsxfer.itd.umich.edu!zip.eecs.umich.edu!yeshua.marcam.com!usc!math.ohio-state.edu!caen!hearst.acc.Virginia.EDU!murdoch!recycle.cebaf.gov!doolitt
From: doolitt@recycle.cebaf.gov (Larry Doolittle)
Subject: clonedir - clone a directory, using symbolic links
Message-ID: <CxtMsE.tq@murdoch.acc.Virginia.EDU>
Followup-To: alt.sources.d
Summary: Helps to track site-specific changes to net.software
Sender: usenet@murdoch.acc.Virginia.EDU
Reply-To: doolittle@cebaf.gov
Organization: CEBAF
X-Newsreader: TIN [version 1.2 PL2]
Date: Mon, 17 Oct 1994 14:26:38 GMT
Lines: 60
Hi!
Perhaps other poeple are in the same situation as me -- trying to
keep track of how I have adapted net.software to work on my machine.
Here is one script I have used with some success to help me with that
process. I untar a package, clone the tree, and "chmod -R u-w" the
original. Now I can edit/patch/adapt the clone to my purposes, and
it's always clear what I have done. I can even reclaim disk space by
deleting the original tree, without losing any information. I just have
to re-untar it if I want to work on the package again.
If anyone wants to tell me a "better" way (in general, or specific
improvements to the script below), let me know by e-mail or discussion.
Followups set to alt.sources.d .
- Larry Doolittle doolittle@cebaf.gov
-- cut here --
#!/bin/sh
# clonedir - clone a directory, using symbolic links
# Larry Doolittle doolittle@cebaf.gov October 16, 1994
# Use and distribute freely
# Tested and used in a GNU environment: i.e., bash, gnu find, gawk, etc.
# YMMV.
temp=/tmp/.temp_clone_script
if [ $# -ne 2 ]; then
echo "usage: "`basename $0`" old_dir new_dir"
echo " new_dir is created, and is a clone of old_dir"
exit
fi
if [ -e $2 ]; then
echo `basename $0`": $2 already exists, not overwritten"
exit
fi
if [ ! -d $1 ]; then
echo `basename $0`": $1 is not a directory"
exit
fi
if [ -e $temp ]; then
echo "Warning: overwriting stale $temp file"
fi
mkdir $2
(cd $1;find . -type d -mindepth 1 -exec mkdir ../$2/\{\} \;)
# Ugly, but it works.
find $1 -type f -printf "%d %p\n" | awk -v old_dir=$1 -v new_dir=$2 '{sub("^"old_dir"/","",$2);i=$1;h="";while (i--) h=h"../";print "ln -s "h old_dir"/"$2" "new_dir"/"$2}' >$temp
source $temp
rm $temp
-- cut here --
P.S. If that long line above got chopped by your news reader (or my posting
software), here it is again in pieces:
find $1 -type f -printf "%d %p\n" | awk -v old_dir=$1 -v new_dir=$2\
'{sub("^"old_dir"/","",$2);i=$1;h="";while (i--) h=h"../";print "ln\
-s "h old_dir"/"$2" "new_dir"/"$2}' >$temp