Archive

Archive for August, 2009

svn2bzr and symlinks

August 26th, 2009 admin No comments

I used svn2bzr to import an Subversion repository (via dump file) to a Bazaar repository. My code has some places where symlinks are used. After the import, the symlinks were converted from links to files with the contents:

link ../path/to/link

I ran this snippet to find all locations of this event so I could fix them:

find . -size 1k -exec grep -E "^link" '{}' \; -print

Hope that helps.

Update: Wrote a script that will remove the old links and replace them for you.

#!/bin/bash

if [ $# -eq 1 ]
then
DIRNAME=$1
else
DIRNAME=`pwd`
fi

broken_links=`find $DIRNAME -size 1k -exec grep -Es "^link" '{}' \; -print \
| xargs -l2 echo -e "" | awk '{print $2 " " $3}'`

echo -e "$broken_links" | while read line; do
link=`echo "$line" | cut -d ' ' -f2`;
target=`echo "$line" | cut -d ' ' -f1`;
relative_dir=`dirname $link`

cd $relative_dir; rm $link; ln -s $target $link
done
Categories: System Admin Tags: