How to Create a Private Debian Repository with Reprepro

Last week, I built a Debian package for Dynamsoft Barcode Reader. Installing .deb file is apparently more efficient than using the .tar file on Linux OS based on Debian. Despite this, I believe most of Linux developers will give priority to the command-line package tool apt-get, unless the software repository is out of date. This is why I decided to create a private Debian repository to simplify the process of downloading and installing Dynamsoft Barcode Reader SDK for Linux.

Environment

Use the following command to check Ubuntu version:

lsb_release -a
  • Ubuntu 14.04 for building Debian repository in a virtual machine:

      No LSB modules are available.
        
      Distributor ID:   Ubuntu
        
      Description:      Ubuntu 14.04.5 LTS
        
      Release:    14.04
        
      Codename:   trusty
    
  • Ubuntu on Windows for testing the private Debian repository:

      No LSB modules are available.
        
      Distributor ID: Ubuntu
        
      Description:    Ubuntu 16.04.2 LTS
        
      Release:        16.04
        
      Codename:       xenial
    

Creating Debian Repository

To set up a Debian repository, we can follow the article - SetupWithReprepro.

Generating and exporting GPG keys

Use the following command to generate the key:

gpg --gen-key

I got the following error message after running the command:

Not enough random bytes available.  Please do some other work to give

the OS a chance to collect more entropy!

If you suffered from this issue, use the solution from StackOverflow:

find / > /dev/null

The location of the generated keys:

ls ~/.gnupg/
gpg.conf  pubring.gpg  pubring.gpg~  random_seed  secring.gpg  trustdb.gpg

Check the key-id (the subkey):

gpg --list-keys

Export the public part of your GnuPG keypair from the keychain:

gpg --armor --output dbr.gpg.key --export <key-id>

Configuring Apache

Install Apache:

sudo apt-get install apache2

Create a directory for the apt repository:

sudo mkdir -p /var/www/repos/apt/debian

Create a configuration file:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000- debian.conf

Edit the file:

# /etc/apache2/sites-available/debian.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <Directory /var/www/repos/ >
        # We want the user to be able to browse the directory manually
        # Options Indexes FollowSymLinks Multiviews
        Order allow,deny
        Allow from all
        </Directory>

        <Directory "/var/www/repos/apt/*/db/">
                Order deny,allow
                Deny from all
        </Directory>

        <Directory "/var/www/repos/apt/*/conf/">
                Order deny,allow
                Deny from all
        </Directory>

        <Directory "/var/www/repos/apt/*/incoming/">
                Order allow,deny
                Deny from all
        </Directory>

</VirtualHost>

Enable the site:

sudo a2ensite /etc/apache2/sites-available/debian.conf

I also changed the DocumentRoot to /var/www/ in default configuration file.

Copy the GPG key to /var/www/repos/apt/Debian/dbr.gpg.key.

Check the configuration and reload Apache server:

sudo apache2ctl configtest
sudo service apache2 reload

Configuring reprepro

Create a configuration folder:

sudo mkdir -p /var/www/repos/apt/debian/conf

Create the conf/distributions file:

Origin: Dynamsoft

Label: dbr_5.2

Codename: dbr

Architectures: amd64 armel

Components: main non-free

Description: Dynamsoft Barcode SDK for Linux

SignWith: 80F43A5E

DebOverride: override.dbr

How to get the Debian release name If you want to use it as the Codename? Run:

cat /etc/debian_version

The architectures here include amd64 for 64-bit Intel CPUs and armel for ARM processors.

Create the conf/override.dbr file:

dbr Priority optional
dbr Section net

Generate all index files:

sudo reprepro --ask-passphrase export

Add packages to the repository:

sudo reprepro --ask-passphrase includedeb dbr ~/package/dbr_5.2.deb

Here is my repository:

Debian repository

Now, in addition to Apache, I can copy the Debian folder and deploy it to other web servers, such as Nginx, IIS and so on.

Installing Dynamsoft Barcode Reader on Ubuntu and Raspberry Pi

Download and add GPG key to your key chains:

wget -O - http://labs.dynamsoft.com/debian/conf/dbr.gpg.key | sudo apt-key add -

Add the source to your source list:

sudo vim /etc/apt/sources.list
deb http://labs.dynamsoft.com/debian/ dbr main non-free

Install Dynamsoft Barcode Reader with apt-get:

sudo apt-get update && apt-get install dbr

Check the software:

Debian repository apt install

Remove Dynamsoft Barcode Reader:

sudo apt-get remove dbr