Setting up your own Ubuntu repository on Dreamhost

Posted on: Monday, Sep 17, 2007

Following up on my post about installing a receipt printer on Ubuntu, I mentioned that I would post my experiences setting up a Ubuntu repository. Most of the documentation out there only covers setting up a repo on your own local machine, for your own local use only. On top of that, the docs vary between how much they tell you about the specifics of a Ubuntu vs Debian setup. Since I am likely not the only one trying to make this kind of thing, I’m posting a step-by-step guide on how to do it yourself.

The Goal

We want to setup a publicly accessible Ubuntu repository so that we can distribute our own .deb packages to other users. Since we’re on a budget, we’re going to host this repo on our DreamHost account. Above all else, it needs to be easy to maintain, since we want this to make life easier, not harder.

The Plan

We’re going to create a local repository on our development machine using dput and mini-dinstall. Then we’ll sync it to the remote web server using rsync and ssh.

The Prerequisites

As always, this guide assumes that you are familiar with Linux and are comfortable doing things on the command line. If not, turn back now, before it is too late! This is not a guide for beginners.

We’re also going to assume that you’ve got a hosting package with DreamHost, and a domain name to which you can add sub-domains.

Lastly, we’ll assume that your development machine is running some form of Ubuntu Linux. I used Feisty (7.04) when writing this article. Adjust the steps as needed for your own setup.

The Process

1. Set up a domain

To keep your website clean, it’s a good idea to set up a sub-domain of your primary site on which to host your repo. Using my site as our example, we set up as our domain. On DreamHost, you want to set this up as a Fully Hosted Domain. If you know what you’re doing, you can customize the options on the setup screen, but the defaults are all fine.

2. Configure your SSH login to the new domain

To make life easier down the road, we’ll need a password-less SSH login to the site. I won’t go into the details of how to do this, as it has been documented far better in countless places. The DreamHost wiki, for example. I’ll assume from here on out that you can simply type “ssh” and get dropped into a bash shell.

Again, if you don’t understand that last sentence, stop now, before you hurt yourself.

3. Create a folder for the public repository

To keep things clean, I like to segment things a bit. This is an optional step, but one that I suggest doing unless you have a really good reason not to. Log into your server real quick and in the webroot, make a folder called ‘archive’. In the case of our example, this would go something like this:

mkdir archive

4. Set up your repository… locally

I know, I know, we don’t care about having a local repo, we want to share it with the world! Sit tight, junior. This is part of the process. On shared hosting, you likely won’t have access to the tools needed to easily maintain a repository, and for good reason. So we’re going to set it up (and yes, keep it there) on our development machine first.

Rather than rewrite it, I’ll point you to the excellent guide that I followed called LocalAptGetRepository, over at the Ubuntu Community site. Follow that all the way down to (but not including) the section called “Changing your systems apt-get sources.list“.

All done? Great! Let’s move forward.

5. What you should have so far

At this point, you should have a folder somewhere on your dev machine that looks something like this:


And in those folders should basically be everything you need for your repo, hopefully with one or more packages already imported. If not, I suggest getting to that point before you move on.

6. Copying your local repo to the remote webhost

We can simply type in the rsync command to get all our files up there, but we want this to be easy later on, remember? So let’s make a simple bash script that can do it all for us, so we don’t need to constantly retype the whole thing. I recommend calling it something simple like “sync-repo“. Stick the following into it, making sure to adjust for your setup.

A few notes about the script: WordPress messes up the display of the rsync command, so there are two things to pay attention to.

  1. The three lines, starting with the rsync one, should all be on one line.
  2. The long dashes in front of “stats”, “progress”, and “exclude” should actually be two normal dashes.
rsync -rlptvzh --stats --progress --exclude=mini-dinstall
-e "ssh -l user" /home/marc/archive/

Now save the script, chmod +x it, and run it! If all went well, you should be able to point your browser at the equivalent of and see the same folder tree as the one on your machine. You’ll notice that we excluded the mini-dinstall folder, because that should not be made public.

The Beautiful Finish

The final step is to add your brand new repository to your /etc/apt/sources.list. Open up the list in your favorite editor:

sudo vim /etc/apt/sources.list

Then add in the lines for your repo:

deb feisty/
deb-src feisty/

Update your cache and you’re done!

sudo apt-get update

The Conclusion

If you’ve followed along, you should now have your very own Ubuntu repository. To add new packages to it, just use dput on your local machine, then run your sync-repo script to update the online version. It’s that easy!



September 17th, 2007 at 11:01 pm
Permalink this comment


Just a note that WordPress isn’t nice to my pre formatting, so in the shell script in Step 6, the three lines, starting with thersync one, should all be on one line.



September 24th, 2007 at 8:27 am
Permalink this comment


Very nice! And not one day to early as I am looking for something like this the whole summer!

It should be noted that if you copy and paste the rsync command the “-“-char are not recognized as “normal” “-” (because of different UTF8 encoding i believe).

Actually there should be two “–” in front of “stats” “progress” and “exclude”.

If not, these error-messages will be shown:

rsync: link_stat stats failed: /-stats failed: No such file or directory (2)
rsync: link_stat progress failed: /-progress failed: No such file or directory (2)
rsync: link_stat exclude failed: /-exclude=mini-dinstall: No such file or directory (2)



September 24th, 2007 at 9:55 am
Permalink this comment


Thanks for pointing out that problem, Darsha! I hadn’t noticed that WordPress reformatted them. I’ve updated the guide with that info.



March 24th, 2008 at 4:58 am
Permalink this comment


thats for sure, man



August 20th, 2010 at 8:12 pm
Permalink this comment


Very useful. Thanks 🙂



October 7th, 2014 at 2:35 pm
Permalink this comment


hey there and thank you for your information – I’ve certainly
picked up anything new from right here. I did however expertise
some technical points using this web site, since I experienced to reload the web site many times previous to I
could get it to load properly. I had been wondering if your hosting is OK?
Not that I’m complaining, but slow loading instances times will often affect
your placement in google and could damage your high quality
score if advertising and marketing with Adwords. Well I’m
adding this RSS to my email and could look out for
a lot more of your respective interesting content. Ensure that you update this again soon.