Set up a Debian Private Repository with Reprepro
In this post, we will set up a minimal Debian private repository with Reprepro and Apache. To keep everything simple, we will not use GPG keys.
1 Set up Apache Web Server
To serve the package files over HTTP, we need a Web Server. Here we use Apache.
1.1 Install Apache
As root, run
1 | $ apt install apache2 |
1.2 Configure Apache
Assume we will set up a repository in /var/www/repos/apt/debian
.
As root, edit /etc/apache2/sites-enabled/000-default.conf
configuration file.
1 | $ nano /etc/apache2/sites-enabled/000-default.conf |
Add the following configuration to the <VirtualHost>
block,
1 | <Directory /var/www/repos/ > |
and change DocumentRoot
.
1 | DocumentRoot /var/www/repos |
Now save the file with Ctrl+O
Enter
and exit the editor with Ctrl+X
.
Test the syntax of the configuration file with
1 | $ apache2ctl configtest |
You should see Syntax OK
. If not, check the configuration file you just edit.
1.3 Reload Apache
As root, reload Apache to apply the configuration.
1 | $ systemctl reload apache2 |
2 Set up Reprepro
2.1 Install Reprepro
As root, run
1 | $ apt install reprepro |
2.2 Configure Reprepro
Create the configuration directory with
1 | $ mkdir -p /var/www/repos/apt/debian/conf |
Create and edit file distributions
with
1 | $ nano distributions |
and copy-paste the following contents
1 | Origin: Your project name |
Change the relevant fields based on your needs. Save the file and exit the editor.
If you are working with Loongson CPUs, change the architecture
amd64
tomips64el
.
Create and edit file options
with
1 | $ nano options |
and copy-paste the following contents
1 | verbose |
We also need to set up the environment variable REPREPRO_BASE_DIR
so that reprepro knows our base directory is /var/www/repos/apt/debian
.
Edit your ~/.bashrc
if you are using Bash, or ~/.zshrc
if you are using Zsh. Add the following line to the tail of the file.
1 | export REPREPRO_BASE_DIR=/var/www/repos/apt/debian |
To apply the change, run
1 | $ source ~/.bashrc # for Bash |
Now your reprepro is ready to go!
3 Add the first package to the repo
Suppose we have a package socat_1.7.3.2-2_mips64el.deb
.
Add it to the repo with
1 | $ reprepro includedeb buster socat_1.7.3.2-2_mips64el.deb |
Open your web browser, visit http://localhost/apt/debian/pool/main , you should see your new package.
4 Install your new package
Now the repository server is set up, you can now install packages. You might wish switch to another machine.
4.1 Add your private source to /etc/apt/sources.list.d
1 | $ echo 'deb http://repo-server/repos/apt/debian buster main' > /etc/apt/sources.list.d/myrepo.list |
Replace repo-server
with the IP address (or the hostname) of the repository server you just set up.
4.2 Prioritize the private source
Create and edit a apt preferences configuration file with
1 | $ nano /etc/apt/preferences.d/99-myrepo |
and copy-paste the following contents
1 | Package: * |
Replace repo-server
with the IP address you used in step 4.1.
Ideally, I think the repository prioritiy should be set by the server instead of the client, but I can’t figure out where to set it in a
reprepro
setup. Please let me know if you have an idea.
4.3 Update apt package list
Update the package list with
1 | $ apt -o "Acquire::AllowInsecureRepositories=true" update |
Note the option
-o "Acquire::AllowInsecureRepositories=true"
. In our setup, since we do not sign the repository (and packages in it), we need to explicitly allow it.
4.4 Verify the new priority works
Run
1 | $ apt-cache policy |
Check if the your new repository precedes all other sources except /var/lib/dpkg/status
.
A valid example output may look like this:
1 | 100 /var/lib/dpkg/status |
4.5 Install the test package
Install the test package socat
with
1 | $ apt install socat |
During the installation, apt will warn us (again) of the insecurity of the package we are going to install. Enter y
to proceed anyway.
1 | WARNING: The following packages cannot be authenticated! |
Now the socat
from your own repository is ready to go!