How to Create a Deb Package Repository on Sourceforge with Reprepro

Creating a Deb package repository on SourceForge is a great way to distribute your Debian or Ubuntu packages to users in a structured and easy-to-manage way.

In this guide, we will use Reprepro, a powerful tool that helps manage repositories for Debian-based distributions.

Prerequisites

Before we begin, you need to have the following:

  • A Debian or Ubuntu-based system.
  • An account on SourceForge.
  • Reprepro is installed on your local machine.
  • Your Deb packages are ready to be uploaded.

Step 1: Create a Project on SourceForge

If you don’t already have a project on SourceForge, then create one by visiting SourceForge and clicking on Create and fill in the required details for your new project, such as the name, description, and category.

Create SourceForge Project
Create SourceForge Project
Create Project at SourceForge
Create a Project at SourceForge

Once the project is created, SourceForge will give you access to a file repository where you can upload your files.

TecMint SourceForge Project
TecMint SourceForge Project

Next, you need to add your SSH public key to SourceForge to enable SSH access for uploading files. First, generate an SSH public key on your system using the following command.

ssh-keygen -t rsa -b 4096
Generate SSH Public Key
Generate SSH Public Key

After generating the SSH key, copy the contents of your public key (~/.ssh/id_rsa.pub) and paste it into the SSH settings in SourceForge under My Account –> SSH Settings.

Add SSH Public Key to SourceForge
Add SSH Public Key to SourceForge

Step 2: Install Reprepro and Generate Key

On your local system, install the Reprepro and gnupg packages by running the following command.

sudo apt update
sudo apt install reprepro gnupg
Install Reprepro in Ubuntu
Install Reprepro in Ubuntu

Now you need to generate a gpg key using the gnupg command.

gpg --gen-key

It will ask you some questions, like the kind of key you want, and how long the key should be valid, if you don’t know what to answer, just click Enter for the default options (recommended).

Of course, it will ask you for a username and a password, keep those in mind, because we will need them later.

Generate GPG Key for Signing
Generate GPG Key for Signing

Once the key is generated, you can verify it by running the following command with root privileges.

sudo gpg --list-keys
List GPG Key
List GPG Key

Step 3: Create a Directory Structure for Repository

You need to create a directory structure to store your repository files. Let’s assume you’re setting up a repository for both Ubuntu and Debian packages. Create a directory and the necessary subdirectories:

mkdir -p ~/deb-repo/{conf,dists,incoming,pool}

Here’s what these directories are for:

  • conf: This directory holds the configuration files for your repository.
  • dists: Contains the distribution-specific files (like bionic, focal, etc.).
  • incoming: Temporary folder for incoming packages.
  • pool: Stores the actual package files.

Now, create a configuration file in the conf directory.

nano ~/deb-repo/conf/distributions

Add the following content:

Origin: Ravi Saive
Label: My Awesome Repo
Suite: stable
Codename: focal
Architectures: amd64 source
Components: main
Description: A repository of custom Debian packages for my projects
SignWith: yes

You can replace focal with the name of the Ubuntu or Debian distribution you’re targeting, like focal or bullseye. The SignWith option is used to sign your repository with a GPG key.

Next, create another configuration file called reprepro.conf.

nano ~/deb-repo/conf/reprepro.conf

Add the following lines to reprepro.conf.

verbose
basedir .

This file tells Reprepro where to find its files.

Step 4: Add Packages to the Newly Created Repository

Now it’s time to add Debian packages (.deb files) to your repository. You can either create your own packages or download existing ones.

For this example, let’s assume you have a package named fastfetch-linux-amd64.deb, let’s move this .deb package to the packages directory.

mv /home/ravi/fastfetch-linux-amd64.deb ~/mydebrepo/packages/

Now, you will add this package to your repository using the following command.

cd mydebrepo
reprepro -b . includedeb focal ~/mydebrepo/packages/fastfetch-linux-amd64.deb

Step 5: Publish Your Repository on Sourceforge

To upload the mydebrepo repository to Sourceforge.net, you need to have a running account there of course, and a running project, let’s assume that you want to upload the repository to http://sourceforge.net/projects/tecmint/ where tecmint is your project name, you can use the following rsync command.

rsync -avz -e "ssh" ~/mydebrepo [email protected]:/home/frs/project/tecmint/
Upload Repository to Sourceforge
Upload Repository to Sourceforge

Make sure to replace your username with your username on sourceforge.net and tecmint with your project UNIX-name and mydebrepo with the folder you want to store the files in.

Step 6: Adding Your Repository to Client Machines

ow that your repository is set up, you can add it to client machines so users can download packages from it. On any Ubuntu machine where you want to use your repository, open the terminal and run:

echo "deb [trusted=yes] http://sourceforge.net/projects/tecmint/mydebrepo focal main" | sudo tee /etc/apt/sources.list.d/mydebrepo.list

Next, update the package list:

sudo apt update

Now your repository is ready to use! Users can install the packages you’ve added by using the standard apt install command.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Hanny Helal
A Linux & Foss user since 2010, working on many projects in the field of Free Software.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

8 Comments

Leave a Reply
      • Thanks Ravi,

        I think I am almost there…

        On step 3, when adding my deb package to my repo, reprepro asks for a passphrase for a key I created months ago and I do not remember it and it is not the key I exported to my repo.

        Do I really need it to ask for a passphrase ? What is the risk ? How do I delete the old key ?

        When pushing to github, I guess I push everything except .git and ignored files, am I right ?

        Best regards

        Reply
  1. why in my distribution nor work. In step 2, when I export the key, it’s not work, It’s OutPut :
    # gpg –armor –export asrilmarhamah [email protected] >> /var/www/apt/key/deb.gpg.key
    gpg: WARNING: nothing exported
    whats wrong?
    Thanks before.

    Reply
  2. Once repository is uploaded to sourceforge, how do you add new packages to that repsitory ? or how do you sync new packages to that repository ?

    Reply
    • nvm, figured it out. However, sourceforge takes quite a long time to generate links for the files … much longer than they used to.

      Reply
  3. I comment when I appreciate a article on a blog or I have something
    to valuable to contribute to the conversation. It’s caused by the
    fire communicated in the article I read. And on this post Create A “.deb Package Repository” at Sourceforge.net Using
    “Reprepro” Tool in Ubuntu. I was moved enough to create a thought :-) I
    do have some questions for you if it’s okay. Could it be only me or
    do a few of these responses appear like written by brain dead folks?
    :-P And, if you are posting on other online social sites, I’d
    like to follow you. Could you list all of your public
    pages like your Facebook page, twitter feed, or linkedin profile?

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.