How To Create a Debian/Ubuntu Repository for DEB Packages

Initial Setup

Required Debian packages: reprepro
  1. Create a directory for the repository and its configuration:
    $ mkdir -p repo/conf
    
  2. Create a conf/distributions configuration file like this:
  3. Put my putinrepo script into the repo or next to it:
  4. "Export" the repo to create the metadata files for the empty repo:
    $ repo/putinrepo.sh
    $ tree repo
    repo
    ├── putinrepo.sh
    ├── conf
    │   └── distributions
    ├── db
    │   ├── checksums.db
    │   ├── contents.cache.db
    │   ├── packages.db
    │   ├── references.db
    │   ├── release.caches.db
    │   └── version
    └── dists
        ├── precise
        │   ├── main
        │   │   ├── binary-amd64
        │   │   │   ├── Packages
        │   │   │   ├── Packages.gz
        │   │   │   └── Release
        │   │   ├── binary-armel
        │   │   │   ├── Packages
        │   │   │   ├── Packages.gz
        │   │   │   └── Release
        │   │   └── binary-i386
        │   │       ├── Packages
        │   │       ├── Packages.gz
        │   │       └── Release
        │   └── Release
        ├── quantal
        │   ├── main
        │   │   ├── binary-amd64
        │   │   │   ├── Packages
        │   │   │   ├── Packages.gz
        │   │   │   └── Release
        │   │   ├── binary-armel
        │   │   │   ├── Packages
        │   │   │   ├── Packages.gz
        │   │   │   └── Release
        │   │   └── binary-i386
        │   │       ├── Packages
        │   │       ├── Packages.gz
        │   │       └── Release
        │   └── Release
        └── raring
            ├── main
            │   ├── binary-amd64
            │   │   ├── Packages
            │   │   ├── Packages.gz
            │   │   └── Release
            │   ├── binary-armel
            │   │   ├── Packages
            │   │   ├── Packages.gz
            │   │   └── Release
            │   └── binary-i386
            │       ├── Packages
            │       ├── Packages.gz
            │       └── Release
            └── Release
    
    18 directories, 37 files
    
Now the repo is ready for usage. To add the repo to the local system (assuming you use quantal):
$ sudo tee /etc/apt/sources.list.d/my_repo.list <<EOF
deb file:///$(pwd)/repo quantal main
EOF

Adding Packages

putinrepo.sh <deb-files> is used to add packages to a distribution in the repo. It will automatically add the package to all codenames. Set REPREPRO_CODENAMES to an array of codenames if you want to select the targets.

Signing the Repository

apt complains if you don't sign the repo. Luckily that is really simple: Just add SignWith: yes to each section in the conf/distributions file to sign the repo with your default GPG key.

Adding a new Distribution

Adding a new distribution, e.g. wheezy, is simple:
  1. Create a new block in conf/distributions
  2. Run reprepro copymatched wheezy raring \* to copy all packages from raring to wheezy or use one of the other copy* functions to populate the new codename with content
  3. Run putinrepo.sh to export and sign the repo

See Also

These links were useful for me:

Comments

Like this content? You could send me something from my Amazon Wishlist. Need commercial support? Contact me for Consulting Services.

Popular posts from this blog

Overriding / Patching Linux System Serial Number

A Login Security Architecture Without Passwords

The Demise of KaiOS - Alcatel 3088X