Creating a Package Repository for APT

First off, what is APT? Well, if you’re using Linux (which I assume you are since we’re talking about package repositories), then chances are you’ve heard of this little guy before. It stands for “Advanced Package Tool,” and it’s basically a fancy way to install software on your computer without having to download and compile everything yourself.

So, how do we create our own APT repository? Well, first things first: we need some packages to put in there! Let’s say you want to share your favorite cat video player with the world (because who doesn’t love watching cats play with string?) Here are the steps:

1. Create a new directory for your package repository. This could be anywhere on your computer, but let’s just call it “myrepo” for simplicity’s sake.

2. Inside that directory, create a subdirectory called “debian.” This is where all of our packages will live.

3. In the debian folder, create another subfolder named “mycatvideoplayer.” (Replace “mycatvideoplayer” with whatever name you’ve chosen for your package.)

4. Inside that folder, create a new file called “control.” This is where we’ll add some important information about our package, like its version number and dependencies. Here’s what it might look like:


# This is a script for creating a package for a cat video player
# Replace "mycatvideoplayer" with your chosen package name

Source: mycatvideoplayer
Version: 1.0 # Specifies the version number of the package
Architecture: all # Specifies the architecture of the package
Maintainer: Your Name <your@email> # Specifies the maintainer of the package
Description: This is a cat video player that lets you watch cats play with string! # Provides a brief description of the package
Depends: libsdl2-dev, ffmpeg # Specifies the dependencies required for the package to function properly

5. Next, create another file called “mycatvideoplayer_1.0.deb.” (Replace the version number with your own.) This is where we’ll put our actual package files.

6. Inside that folder, add a new subfolder named “usr,” and inside that folder, create two more folders called “bin” and “share/applications.”

7. In the bin folder, copy over your cat video player executable file (let’s call it “mycatvideoplayer”). This is what will actually run when someone installs our package.

8. In the share/applications folder, create a new file called “mycatvideoplayer.desktop.” Here’s what that might look like:


[Desktop Entry] # This is a desktop entry file, used to create a shortcut for the application
Name=My Cat Video Player # This is the name of the application that will be displayed in the shortcut
Exec=/usr/bin/mycatvideoplayer # This is the path to the executable file that will run the application
Icon=/path/to/your/icon # This is the path to the icon that will be displayed in the shortcut
Terminal=false # This specifies whether the application should be run in a terminal or not
Type=Application # This specifies the type of the application
Categories=Video;Player; # This specifies the categories that the application belongs to, separated by semicolons

9. Save all of your files, and then zip them up into a single archive called “mycatvideoplayer_1.0.zip.” (Again, replace the version number with your own.)

10. Upload that archive to some kind of web server or cloud storage service like Dropbox or Google Drive. This is where our package repository will live!

11. Now, let’s create a new file called “sources.list” inside the debian folder we created earlier. Here’s what it might look like:

# This script is used to add a package repository to a Debian-based system.
# It assumes that you have already created a debian folder and uploaded it to a web server or cloud storage service.

# Add the repository to the sources list, allowing for trusted packages.
# The URL should point to the location of the debian folder on the web server.
# The "." at the end indicates that the repository is located in the current directory.
deb [trusted=yes] http://your-web-server/myrepo ./

Replace “http://your-web-server/myrepo” with the URL where you uploaded your package archive, and “./” tells APT to use this repository instead of its default one.

12. Save that file, and then create another new file called “Release.” This is what will tell APT which version of our packages it should be using. Here’s an example:


# This script creates a repository for APT to use, allowing users to install packages from this repository instead of the default one.

# Set the origin of the repository to "My Repository"
Origin: My Repository

# Set the label of the repository to "myrepo"
Label: myrepo

# Specify that the repository is compatible with all architectures
Architectures: all

# Set the version of the repository to 1.0
Version: 1.0

# Specify that the repository only contains packages in the "main" component
Components: main

# Set the type of signer to RSA
Signer-Type: RSA

# Set the name and email of the signer
Signer-Name: Your Name <your@email>

# Set the key ID of the signer
Signer-KeyId: YOUR_KEY_ID

# Specify the file containing the MD5 checksums for the packages in the repository
Md5Sum: md5sums.txt

# Specify the file containing the SHA256 checksums for the packages in the repository
Sha256Sum: sha256sums.txt

Replace “Your Name” and “YOUR_KEY_ID” with your own information, and then create two new files called “md5sums.txt” and “sha256sums.txt.” These will contain the MD5 and SHA-256 checksums for all of our packages.

13. Save everything, and then test out your package repository by running this command in a terminal:


# This script adds a new package repository to the system and installs a package from it.

# Add the repository to the sources list, with the "trusted" flag set to "yes" to avoid any warnings.
echo 'deb [trusted=yes] http://your-web-server/myrepo ./' | sudo tee -a /etc/apt/sources.list > /dev/null

# Update the list of available packages and install the specified package.
sudo apt update && sudo apt install mycatvideoplayer

# Note: The following steps are not included in the original script, but are necessary for the repository to function properly.

# Replace "your-web-server" with the actual URL of your web server.
# Replace "myrepo" with the name of your repository.
# Replace "mycatvideoplayer" with the name of the package you want to install.

# Create two new files to store the MD5 and SHA-256 checksums for all packages.
touch md5sums.txt
touch sha256sums.txt

# Save the changes and test the repository by running the following command in a terminal:
# sudo apt update && sudo apt install mycatvideoplayer

Replace “http://your-web-server/myrepo” with the URL where you uploaded your package archive, and then run those commands in a terminal to see if everything works!

And that’s it! You now have your very own APT repository for sharing cat video players (or whatever else you want) with the world.

SICORPS