
Several weeks back I wrote about setting up a local repository for .deb packages. Well we’re growing and adding machines, so it was time to move that local repository to a centralized location.
It shouldn’t be hard, but it did have a few more steps than I hoped. The essence was around building the repository through a framework, and for that, a number of posts led me to reprepro.
According to its man page and sparse documentation, reprepro is “a tool to handle local repositories of debian packages,” which sounded exactly like what I wanted.
The steps were fairly straightforward, albeit with one gotcha that took me about an hour to puzzle through.
Build the package
The first step is an obvious prerequisite. However, one step missing from what I described in Building Custom .deb Packages and Chroots was the requirement to specify Section (e.g. Main, non-free, etc.) and Priority sections. Without this, reprepro will give the cryptic (though, in retrospect, obvious) error “No section given.” (Maybe if the ‘s’ was capitalized I wouldn’t have assumed this was based on the reprepro config file, instead of the package itself). Oh well.
Create a repository
Joseph Ruscio explains this part pretty well; in essence, you:
- Generate the PGP key:
gpg --gen-keyshould get you pretty much all you need here. If you want the repository to be owned by another user, you’ll have to sudo into that account and ensure that user has a ~username directory (which system accounts will not, by default) - Create the repository control files: At the minimum, reprepro will need a subdirectory called
confunderneath wherever your repository will live. Inside that dir, create a filedistributionsthat contains the reprepro setup. Here’s mine, to diff against the other online examples:Origin: http://myhostname.path.com Label: Edge Apt Repository Codename: es Architectures: i386 amd64 Components: non-free Description: A generic description. SignWith: yes
Details of the various settings are in the man page; I think these are the only mandatory ones.
- Create an
optionsfile: If you want to save yourself some command-line time, you can create aconf/optionsfile like so:verbose ask-passphrase basedir .
- Run reprepro: The command is simple:
reprepro includedeb [codename] [path to .deb file]
- Make the repository available over http: The various articles linked above show how to set up a virtual host or path pointing to your new repository. For security purposes you should hide the
confanddbdirectories from the public, and depending on how broadly you’re allowing distribution, play with your webserver’s permissions to restrict by IP, domain, or password. Basically, you just need to make sure thatapton your client machine (where you’re installing to) can browse the directory you’ve created above. - Edit
/etc/apt/sources.liston the client machine(s): You’ll simply add a row to point to this new directory, the codename you specified, and the source you specified in the package (e.g.non-free). Here’s mine:deb http://myhostname.edgesentinel.com/
- apt-get update
And that’s it!
Happy distributing.
/m