Skip to content

Instantly share code, notes, and snippets.

@ikbelkirasan
Last active September 21, 2024 02:30
Show Gist options
  • Save ikbelkirasan/57e60bbcaecd0bd5cf2cbf441e744159 to your computer and use it in GitHub Desktop.
Save ikbelkirasan/57e60bbcaecd0bd5cf2cbf441e744159 to your computer and use it in GitHub Desktop.
Host an APT repository on Github

Host an APT repository on Github

This guide will help you host an APT repository on Github.

Prerequisites

You need to install the following packages.

  • reprepro
    $ sudo apt install -y reprepro

Setup

Create a new folder containing the repo.

# Change <repo-name> to the repo folder
$ mkdir -p <repo-name>/{conf,incoming}

# Create the distributions file
$ cat <<EOF >> conf/distributions
Origin: Foo
Label: Foo Github
Suite: stable
Codename: bionic
Architectures: amd64
Components: main
Description: Debian x64 github repository
EOF

Add the GPG key to Github

Get the key using the following command, then copy the output and add it to GPG keys in Github settings.

# List secret keys on your machine and copy your key id
$ gpg --list-secret-keys --keyid-format LONG

# Export the key and copy the output
$ gpg --armor --export <key-id>

Add the repository to APT

Open the file /etc/apt/sources.list and add the following line. Make sure to fill in the fields <repo-owner>, <repo-name>, <Codename> and <Component> with your own values.

deb [arch=amd64] https://raw.githubusercontent.com/<repo-owner>/<repo-name>/master <Codename> <Component>

Or run this command:

$ sudo add-apt-repository -y "deb [arch=amd64] https://raw.githubusercontent.com/<repo-owner>/<repo-name>/master <Codename> <Component>"

Add the key to APT using apt-key.

$ gpg --armor --export <key-id> | sudo apt-key add -

Add a deb package to the repo

First, copy the deb file to incoming folder.

$ cd <repo-name>

# You may to change the section, component and priority to the values you want.

# The deb file should follow this format: <package-name>_<version>_<architecture>.deb

$ reprepro -V \
    --section utils \
    --component main \
    --priority 0 \
    includedeb bionic incoming/<package-name>_<version>_<architecture>.deb

Push the repo to Github

Push your repository to Github then update your APT cache.

$ sudo apt update

# Now you can try to install a package from your repository :)
$ sudo apt install <package-name>
@ikbelkirasan
Copy link
Author

@ikbelkirasan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment