This guide will walk you through the steps to create your own DEB packages and host them in a custom APT repository. This allows you to easily distribute software to Debian-based systems (like Ubuntu) in a manageable way.
- Prerequisites
- Creating a DEB Package
- Setting Up an APT Repository
- Adding Your Repository to APT Sources
- Installing Packages from Your Repository
- A Debian-based operating system (Ubuntu, Debian, etc.)
gcc
,dpkg-dev
,gpg
package installed:sudo apt-get install -y gcc dpkg-dev gpg
- Sample app can be found in app
- To build
deb
package:This will crete a file namecd app make build
hello-world_<version>-1_amd64.deb
-
Initial setup:
-
Generate GPG signing key:
make gen-key
gpg (GnuPG) 2.2.27; Copyright (C) 2021 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) (7) DSA (set your own capabilities) (8) RSA (set your own capabilities) (9) ECC and ECC (10) ECC (sign only) (11) ECC (set your own capabilities) (13) Existing key (14) Existing key from card Your selection? 9 Please select which elliptic curve you want: (1) Curve 25519 (3) NIST P-256 (4) NIST P-384 (5) NIST P-521 (6) Brainpool P-256 (7) Brainpool P-384 (8) Brainpool P-512 (9) secp256k1 Your selection? 1 Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) y GnuPG needs to construct a user ID to identify your key. Real name: dg6repo Email address: [email protected] Comment: You selected this USER-ID: "dg6repo <[email protected]>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
-
Export gpg public key:
make exp-gpgkey
-
-
Release package:
- Move your
.deb
file into apt-repo/pool/main - Update repo Packages:
make gen-packages
- Update repo Release:
make release
- Upload the repository apt-repo and gpgkey to your server.
- Move your
-
Configure Source List:
# Add GPG key curl -fsSL https://raw.githubusercontent.com/dev6699/dg6-repo/refs/heads/master/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/dg6-repo-keyring.gpg # Add repo echo "deb [arch=amd64 signed-by=/usr/share/keyrings/dg6-repo-keyring.gpg] https://raw.githubusercontent.com/dev6699/dg6-repo/refs/heads/master/apt-repo stable main" | sudo tee /etc/apt/sources.list.d/dg6-repo.list
NOTE: replace
https://raw.githubusercontent.com/dev6699/dg6-repo/refs/heads/master/
with your own host -
Update APT:
sudo apt-get update
sudo apt-get install hello-world