views:

463

answers:

4

I am trying to use an automated script, which would login to SVN, update my sources, create a tarball with these and scp them to a remote host.

The problem here is that, for every login to SVN (even for checkout or update), we require to enter our password. Automation of password entry, the only way that I could find, was using expect to work on this.

Is there any script in expect, which can take care of SVN and scp for detecting and giving the password to SVN and then to SCP?

I am using the following:

spawn svn [lindex $argv 0]
expect " password: $"
send "$password\r"
expect { 
    " password: $"    send "$password\r"
    "^At revision "
    "^Updated to revision "
}

The password and up command i pass from the command line, but there is a security threat there if someone has access to the history. The answers mentioned below do not satisfy my pre-requisites, also i am not able to do an export for now [some other security concerns :-(]

+1  A: 

If you're using the svn+ssh protocol to access your SVN repo than you can use SSH keys and ssh-agent to manage the handshaking so you dont need to involve passwords.

Cody Caughlan
+1  A: 

Personally I would use ANT to do all those tasks and then you can call your ant script as needed. Ant has preconfigured tasks for svn and scp as well as many other build automation type tasks.

+2  A: 

linuxbashscript.sh

svn up /path/to/local/copy
tar -cf backup.tar /path/to/local/copy
scp backup.tar [email protected]:/path/on/remote/host

or even better user svn export which will exclude all of the .svn directories.

svn export /path/to/repo /path/to/exported
tar -cf backup.tar /path/to/local/copy
scp backup.tar [email protected]:/path/on/remote/host
zodeus
A: 

If (like Dave suggested), you would use Ant, you would have the following tasks at your disposition:

  • SvnAnt to do check outs, check ins and all the things in between
  • Ant TAR task to create the archive
  • Ant SCP task to publish it

you can save the passwords into a separate property file if you're concern about security.

Vladimir