Putting /etc Under Subversion (SVN)

Instructions taken from here: http://www.barryodonovan.com/index.php/2007/04/25/putting-etc-under-subversion-svn

A Google for the above took some work to locate the exact recipe I wanted for this. The problem is that one really needs to do an ‘in-place’ import. The solution was fromSubversion‘s own FAQs (specifically this) which is reproduced here with some changes:

# svn mkdir svn+ssh://user@host/srv/svn-repository/hosts/host1/etc \
         -m "Make a directory in the repository to correspond to /etc for this host"
# cd /etc
# svn checkout svn+ssh://user@host/srv/svn-repository/hosts/host1/etc .
# svn add *
# svn commit -m "Initial version of this host's config files"

The commit is failing due to propset eol-style errors.  To set the native svn properties for all files under etc you can run this command:

find . -type f -exec svn propset svn:eol-style native {} \;

There was a pre-commit script that was blocking uploading of files with svn:special property set.  Excluding svn:special files out of the check allowed me to commit! Sweet!

Here’s a handy script to add multiple new files to the svn repo by having installed many packages or something that would cause a bunch of files to be added to /etc.

svn st | grep "^?" | awk '{ print $2}' | while read f; do svn add $f; done
svn ci -m "Adding files after extracted tar from prod server"
svn st | grep "^A" | awk '{ print $2}' | while read f; do svn propset svn:eol-style native $f; done

To set svn:special property on a symbolic link:

svn propset svn:special native path/to/symlink

Do NOT set svn:special on actual directories or you will get an:

Svn error: .. has unexpectedly changed special status

To resolve this remove the svn:special property on all directories:

svn st | grep "^~" | awk '{print $2}' | while read f; do svn propdel svn:special $f; done

Remove a directory from subversion control

find /path/to/directory -name .svn -exec rm -rf {} \;
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s