**Reprepro** is a small command-line tool to create and manage **.deb** repositories easily, Today we’ll be showing how to create a Debian package repositories easily using reprepro and how to upload it to Sourceforge.net using **rsync** command.
![Create Deb Package Repository](http://www.tecmint.com/wp-content/uploads/2014/06/Create-Debian-Package-Repository1.png)
### Step 1: Install Reprepro and Generate Key ###
First, install all the necessary packages, using the following apt-get command.
$ sudo apt-get install reprepro gnupg
Now you need to generate a gpg key using gnupg, to do this, apply this command.
$ gpg --gen-key
It will ask you some questions, like the kind of the key you want, 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.
gpg (GnuPG) 1.4.14; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
= key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) Y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
Now your key will be generated, to Check if so, run this command as a root privileges.
$ sudo gpg --list-keys
#### Sample Output ####
/home/ravisaive/.gnupg/pubring.gpg
----------------------------------
pub 2048R/2EB446DD 2014-06-24
uid ravisaive (tecmint) <tecmint.com@gmail.com>
sub 2048R/7EF2F750 2014-06-24
### Step 2: Create a Package Repository and Export Key ###
We’ll start the work now to create the repository, first you have to create some folders, our repository will be in **/var/www/apt** directory, so let’s create some folders.
$ sudo su
# cd /var/www
# mkdir apt
# mkdir -p ./apt/incoming
# mkdir -p ./apt/conf
# mkdir -p ./apt/key
You have now to export the key you created to the repository folder, run.
Created directory "/var/www/apt/dists/Trusty/universe"
Created directory "/var/www/apt/dists/Trusty/universe/binary-i386"
FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
Please enter passphrase:
Successfully created '/var/www/apt/dists/Trusty/InRelease.new'
### Step 3: Add Packages to Newly Created Repository ###
Now prepare your **.deb** packages to be added to the repository. Go to the **/var/www/apt** directory, you have to do this each time you want to add packages.
**Note**: Replace **trusty** with the codename you entered for the repository in the distributions file, and replace **/home/username/package.deb** with the path to the package, you will be asked for the passphrase to enter.
#### Sample Output ####
/home/ravisaive/packages.deb : component guessed as 'universe'
Created directory "./pool"
Created directory "./pool/universe"
Created directory "./pool/universe/o"
Created directory "./pool/universe/o/ojuba-personal-lock"
Exporting indices...
FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/Release.gpg.new'
FF5097B479C8220C ravisaive (tecmint) <tecmint.com@gmail.com> needs a passphrase
Please enter passphrase:
Successfully created './dists/Trusty/InRelease.new'
Your package is added to the repository, to remove it.
And of course, you need to modify the command with your package name and the repository codename.
### Step 4: Upload Repository to Sourceforge.net ###
To upload the 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/myfoo/testrepository** where myfoo is your project name (UNIX name, not URL, not the Title), and testrepository is the folder where you want to upload the files into, We will do this using [rsync command][1].
**Note**: Replace username with your username on sourceforge.net and myfoo with your project UNIX-name and testrepository with the folder you want to store the files in.
Now thats your repository is uploaded to **http://sourceforge.net/projects/myfoo/testrepository**, to add it to your installed system, first you have to import the repository key, it will be in **/var/www/apt/key/deb.gpg.key**, but that’s a local path and the users for your repository won’t be able to add it to their systems, thats why we’ll be importing the key from sourceforge.net.
You can add the repository easily now to your system, open **/etc/apt/sources.list** and add this line.
deb http://sourceforge.net/projects/myfoo/testrepository/apt/key/deb.gpg.key trusty main
**Note**: Replace myfoo with your project UNIX-Name, trusty with your repository codename, testrepository with the folder you uploaded the files into, and main with repository components you added to the distributions file.
Next, run following to update the repositories list.
$ sudo apt-get update
**Congratulations**! Your repository is active! You can now install packages easily from it if you want.