Hosting Apt Repo’s With Freight

If you ever wanted to know how to host your own apt repository on Debian or Ubuntu then this article is for you. We’ve tested multiple solutions and have found that using Freight is by far the easiest way to get a private repository up and running quick. Freight is a modern take on Debian archive management. It is written and maintained by Richard Crowley and is available on GitHub. This article has been copied and slightly modified from Richard Crowley’s GitHub page. First we will want to setup the Freight archive in apt with the commands below.

Note: Richard Crowley’s Freight GitHub repository is no longer being actively maintained, so the instructions are being updated to use the new Freight-Team repository.

# download the GPG key of the repository and add it to apt
wget -O - | sudo apt-key add -
# create apt sources file for freight repo
echo "deb $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/freight.sources.list
# update apt & install package
apt-get update & apt-get -y install freight

Once Freight is installed, we will need to create the /etc/freight.conf file by running the command below. Once you have created the config file, edit the GPG variable with the email address you will use when creating your gpg key, also seen below.

# create freight.conf
mv /etc/freight.conf.example /etc/freight.conf
# update /etc/freight.conf
nano /etc/freight.conf
# set gpg email address

Now we have the base install of Freight complete and all that is left to do is create a gpg key for signing packages in your new apt repository. In order to create your key run the command below.

# create gpg key for freight repo
gpg --gen-key
Note: If your machine complains about not having enough entropy to generate your key, you can refer to Falko Timme’s article on How to Forge for the solution.

Adding Packages to Freight

Next, we will want to add a package to our newly created Freight repository using the commands below. In this example, we are adding a Postfix package that has been compiled with the VDA patch. Note, the package has been copied to the /tmp directory prior to running the commands below.

# navigate to package directory
cd /tmp
# add postfix package
freight add postfix_2.11.2-1~oitibs+1_amd64.deb apt/wheezy
# update freight cache
freight cache

The last thing we will need to do is setup Nginx to host our newly created repository. This can be accomplished by adding a simple location statement to out main site as seen below. Once this configuration is complete, we will be hosting out repository at InĀ  our follow up article Remove Package From Freight we have detailed how to remove packages from your Freight repository.

Did you find this article useful? Why not share it with your friends?

2 thoughts on “Hosting Apt Repo’s With Freight

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.