Tutorial | Linux

How to Create a Custom Repository in Arch Linux

How to Create a Custom Repository in Arch Linux

Hey everyone, how are you? I hope you’re doing well. In this post, I am going to show how to make an Arch Linux repository. More than just being useful for creating a custom repo, this post will help us understand how Arch repositories work under the hood.

Procedure

Preparation

The first thing to do is create a folder. Inside it, it’s best to create a subfolder where all the PKGBUILD files will go. This isn’t strictly necessary, but it allows for:

  1. Better organization and easier package updates.
  2. Showing how packages are built to the public, providing greater security to third parties, especially if the repository is shared.

Once you have that set up, the next step is to create some packages. In this example, I will compile:

  • The sakura terminal emulator
  • The spacefm file manager
  • The pico text editor

There is no minimum number of packages required, but I’ll start with two and then add the third to show how additions work.

At this point, the directory tree should look like this:

ItsZariep@PC~/duckverse-> tree
.
└── PKGBUILDS
    ├── pico
    │   └── PKGBUILD
    ├── sakura
    │   └── PKGBUILD
    └── spacefm
        └── PKGBUILD

4 directories, 3 files

Creating a PKGBUILD

This process is quite widespread; you can look at example PKGBUILDs in the AUR or read the PKGBUILD documentation.


Configuring makepkg and Building the Package

To build the packages, go to the folder where the PKGBUILD is located and run:

makepkg

Before doing that, you might want to configure makepkg. To do so, copy the configuration file:

cp /etc/makepkg.conf ~/.makepkg.conf

Configure the following according to your needs:

  • MAKEFLAGS: To compile faster using multiple threads.
MAKEFLAGS="-j8"  # If you have 8 threads
  • PKGEXT: To change the package extension.
PKGEXT='.pkg.tar.zst'
  • PACKAGER: To customize the packager’s name.
PACKAGER="ItsZariep"

Adding the Package to the Repository

Once you have your packages, place them in a folder named after the target architecture (for example, x86_64), then run inside that folder:

repo-add name.db.tar.gz *.pkg.tar.zst

Note: Change the extension if you used a different one. I recommend saving this command in a script to make future updates easier.

The directory tree should now look like this:

ItsZariep@PC~/duckverse-> tree
.
├── pkgbuilds
│   ├── sakura
│   │   └── PKGBUILD
│   ├── pico
│   │   └── PKGBUILD
│   └── spacefm
│       └── PKGBUILD
└── x86_64
    ├── db
    ├── duckverse.db -> duckverse.db.tar.gz
    ├── duckverse.db.tar.gz
    ├── duckverse.files -> duckverse.files.tar.gz
    ├── duckverse.files.tar.gz
    └── sakura-3.8.7-1-x86_64.pkg.tar.zst

5 directories, 9 files

Note: db is the name of the script where the repo-add command was saved.


Adding the Repository to Pacman

Edit /etc/pacman.conf and add:

[duckverse]
SigLevel = Never
Server = file:///home/itszariep/.local/share/duckverse/$arch

If you uploaded your repository to GitHub (and enabled GitHub Pages), you can also use it remotely:

[duckverse]
SigLevel = Never
Server = https://itzselenux.github.io/$repo/$arch

Adding or Updating Packages

To add more packages to the repo:

  1. Create the new .pkg.tar.zst package as before.
  2. Add it to the corresponding directory.
  3. Update the database using repo-add.

To update a package:

  1. Recompile it.
  2. Replace the old file.
  3. Run repo-add again.

Conclusion

Creating a repository for pacman is relatively easy. However, if you plan to make something public and formal, be very careful with licenses, as many do not allow redistribution. Failing to respect them can lead to legal issues.

Other than that, as I mentioned, it doesn’t take rocket science to create and update a repository, but it does take time to maintain it.

I also recommend using GPG keys to sign the files and provide greater security.


Avatar

ItsZariep

Youtuber and programmer, using Linux since 2015

About me


© 2026 ItsZariep

Powered by Tessera for Hugo