Today we’re going to go thru the process of turning your Raspberry Pi into an SVN server. While this may not be the most practical use of your Pi, it’s an excellent learning experience. SVN is a pretty good way to manage your code, especially if you’re juggling lots of projects.
This isn’t going to be a “how to use SVN” tutorial but more of a guide for setting it up on a Raspberry Pi. If you’re not familiar with SVN Here is an excellent free guide to get you started.
Getting Started
The first thing we want to do is ssh into the Raspberry Pi or open up a terminal. We’re going to do all of this from the Linux prompt.
Then, we’ll install Subversion:
sudo apt-get install subversion
Now let’s create a folder to put our repositories in:
mkdir -p /home/pi/repos
Now, we need to create a project:
svnadmin create /home/pi/repos/helloworld
With that created, you should see a folder that looks like this:
Let’s create a project that we’ll add to SVN.
mkdir /home/pi/projects/helloworld cd /home/pi/projects/helloworld
create a file called main.cpp:
sudo nano main.cpp
add the following to the file:
And save it.
Now we’ll want to import it into svn:
sudo svn import /home/pi/projects/helloworld/ file://localhost/home/pi/repos/helloworld/
You should see a screen that looks like this.
Enter a message for committing this file. CTRL+X exits this screen.
You should see:
Adding /home/pi/projects/helloworld/main.cpp Committed revision 1.
Set up Remote Access
Now, we’ll need to set up the server part of it so you can access it remotely:
sudo apt-get install apache2 libapache2-svn
(If you already have Apache installed you won’t need to reinstall it)
Now let’s edit the dav_svn.conf:
sudo nano /etc/apache2/mods-available/dav_svn.conf
Add this to the bottom of the file:
Quit and save the file, then restart apache:
sudo /etc/init.d/apache2 restart
Now we need to change the permissions of this folder:
sudo chown -R www-data:www-data /home/pi/repos
We’re changing this so the SVN server can access these files. Don’t modify these files by hand anymore! Always use SVN.
Now you need to create an SVN user:
sudo htpasswd -c /etc/apache2/dav_svn.passwd jeremy
Remember only use -c the first time you add a user. If you run this with -c again it will delete existing users! This is for the first time only!
Now you can check your repo thru a web browser on your machine using the IP of your Raspberry Pi (probably different than mine)
http://192.168.254.18/svn/helloworld/
You should see a screen like this:
Go back to your main computer and check out the repo.
Check out the repository in Linux
Open up a terminal window, and type the following:
svn co --username jeremy http://192.168.254.18/svn/helloworld
You should see:
A helloworld/main.cpp Checked out revision 1.
Now go into that folder and edit the file again:
cd helloworld nano main.cpp
And make the following changes:
Quit and save the file.
Now do a diff on the file:
svn diff main.cpp
A diff shows you the difference between the file you’re editing, and what’s stored in SVN.
You will see a screen that looks like this:
Now, let’s commit that file with the message “version 2”
sudo svn commit -m "version 2" main.cpp
You should see:
Sending main.cpp Transmitting file data . Committed revision 2.
Now, if you check your repo browser again:
You will see that your change has been committed. It’s that easy!
Check out the repository in Windows
Let’s say you’re a Windows user (not that there’s anything wrong with that) and you want to connect to your Pi from Windows. I recommend using Tortiose SVN for the task. It’s a great free program that works well.
Once it’s installed, create a folder on your Desktop called “repos”. Then, right click inside that box and select “SVN Checkout”.
In that window, put in the URL to your repository:
For me it is http://192.168.254.18/svn/helloworld but yours may be different.
Click OK, and you should see the main.cpp file in there.
Edit it and make the following changes:
Save the file. Then right click on the file and select “SVN Commit”.
Enter a message and commit the file. It will ask for your login, then you You will see the following screen:
And you’re done!
Conclusion
I hope this has helped you with setting up an SVN server on your Raspberry Pi. It’s not incredibly practical but it seems to work well for me, as I’m the only developer using it. I also store my repos on an external drive, as the SD cards seem to flake out quite a bit.
If you have any questions, leave me a comment!
I was searching for loan to sort out my bills& debts, then i saw comments about Blank ATM Credit Card that can be hacked to withdraw money from any ATM machines around you . I doubted thus but decided to give it a try by contacting {skylinktechnes@yahoo.com} they responded with their guidelines on how the card works. I was assured that the card can withdraw $5,000 instant per day & was credited with $50,000 so i requested for one & paid the delivery fee to obtain the card, i was shock to see the UPS agent in my resident with a parcel{card} i signed and went back inside and confirmed the card work's after the agent left. This is no doubts because i have the card & has made used of the card. This hackers are USA based hackers set out to help people with financial freedom!! Contact these email if you wants to get rich with this Via email skylinktechnes@yahoo.com whatsapp/t: +1(213)785-1553
ReplyDelete