Repo
This project contains a personal Debian package repository that could be served on GitHub Page. It also contains guides on how to build a Debian package, create repository, and use the repository.
Using This Repository
- Add the public key of this repository to the local system.
$ curl -s https://threeal.github.io/repo/threeal.asc | sudo apt-key add -
- Add this repository to the source list.
$ sudo sh -c 'echo "deb [arch=amd64] https://threeal.github.io/repo $(lsb_release -sc) main" > /etc/apt/sources.list.d/threeal.list'
- Update the package list in repositories.
$ sudo apt update
Creating a Debian Package
Structuring the Package
- Create a directory using name that follow standard Debian notation for package name.
usually it is all lowercase with the following format
<PROJECT>_<MAJOR-VER>.<MINOR-VER>-<PKG-REVISION>_<ARCHITECTURE>
. (example:libsomething_1.0-1_amd64
) - Pretend the directory you just created to be the root of the system file.
- Put files that will be installed correspond to their install path. (example: put file that will be installed on
/usr/lib/libsomething.so
tolibsomething_1.0-1_amd64/usr/lib/libsomething.so
) - Create a
DEBIAN
directory inside the project directory. This directory will be used to put metadata and configuration files of the package. - The configuration files are optional, but the metadata file is a must.
For more information about the configuration files, please refer here.
- Create
DEBIAN/control
for the metadata file. The metadata file atleast must contains information like the following example:Package: libsomething Version: 1.0-1 Section: base Priority: optional Architecture: i386 Depends: somepackage (>= 1.0.0), someotherpackage (>= 1.2.5) Maintainer: Your Name <your@email.com> Description: short description very long description
For more information about the metadata files, please refer here
- Watch for the file permission (read, write, and execute permission). Make sure executable files in the package already have an execute permission.
- After the package already structured, continue to build the package as a Debian package.
Building the Package
- Build the directory as a Debian package:
$ dpkg-deb --build <package_directory>
If the
dpkg-deb
has not been installed, install it using$ sudo apt install dpkg
.
Creating a Debian Package Repository
Structuring the Repository
- The repository consists of 2 main directory,
dists
that contains package lists andpool
that contains the package files.- The
dists
directory should be structured using the following formatdists/<OS-RELEASE>/main/binary-<ARCHITECTURE>/
. (example:dists/bionic/main/binary-amd64
) - The
pool
directory should be structured using the following formatpool/main/<PACKAGE>/<PACKAGE-DEB>
. (example:pool/main/libsomething/libsomething_1.0-1_amd64.deb
)
- The
- Create a
Distributions
metadata file underdists/<OS-RELEASE>
. The metadata file atleast must contains information like the following example:Origin: threeal.github.io/repo Label: threeal bionic Suite: bionic Codename: bionic Architectures: amd64 i386 Components: main Description: Threeal's Bionic Debian repository
Note: End the metadata file with an empty line, as it will be appended with the package list to create
Release
file.
Making the Repository to be Signed
- Create a new gpg key for this repository.
$ gpg --gen-key
Note: Make sure to export the key so it could be used later by other user to update the repository. To export the key, use the following command
$ gpg --export-secret-keys <NAME> > <PATH-TO>/<KEYNAME>.key
- Export the public key for the repository and put it to the project root.
$ gpg --armor --export <NAME> > <KEYNAME>.asc
Adding a New Package to the Repository
- Put all new release of Debian packages inside their corresponding package in
pool
directory. (example: putlibsomething_1.0-1_amd64.deb
insidepool/main/libsomething
) - Remove older version of the Debian package release, if there is any. (example: with
libsomething_1.0-1_amd64.deb
, removelibsomething_0.9-3_amd64.deb
)Note: for alternative, you can run the
update.sh
script to apply the new package to the repository after put the Debian package file. - Update the package list for each architecture under
dists/<OS-RELEASE>/main
directory.$ apt-ftparchive --arch <ARCHITECTURE> packages pool > <PATH-TO>/binary-<ARCHITECTURE>/Packages
If the
apt-ftparchive
has not been installed, install it using$ sudo apt install apt-utils
. - Also update the gzip version of the package list for every new package list.
$ gzip -kf <PATH-TO>/Packages
- Update the release files for each os release under
dists/<OS-RELEASE>
directory.$ cd dists/<OS-RELEASE> $ cat Distributions > Release $ apt-ftparchive release . >> Release $ gpg --clearsign -o InRelease Release $ gpg -abs -o Release.gpg Release
Serving the Repository on GitHub Page
- Clone this project to your GitHub repository as
repo
. - On the repository settings, under the
GitHub Page
, Set theSource
to be the branch that will be served on the GitHub Page. - The repository later could be accessed under
<USER>.github.io/repo
.
Using The Repository
Adding the Public Key
- Public key is used to sign this repository, so it could be accepted by the Debian packaging system in the client computer.
- Add the public key of the repository to the local system.
$ curl -s <ADDRESS-TO>/repo/<KEYNAME>.asc | sudo apt-key add -
Adding the Repository to the Source List
- Add the repository to the source list.
$ sudo sh -c 'echo "deb [arch=<ARCHITECTURE>] <ADDRESS-TO>/repo $(lsb_release -sc) main" > /etc/apt/sources.list.d/<REPOSITORY-NAME>.list'
- Update the package list in repositories.
$ sudo apt update