Making Your Own Arch Linux Repository

I now have my own Arch Linux repository. I plan on sharing this repository soon, but…you know…sleep.

The script relies heavily upon the AUR, which does 95% of the work for you. It also requires you to add your own repository to pacman for the times when AUR packages depend on other AUR packages.

SigLevel = TrustAll
Server = file:///repo/aurpb/$arch

UPDATE 2013-02-03: Implemented package signing.

  1. Follow the directions at ArchWiki’s GnuPG page to set up and register a key.
  2. Use pacman-key --import ~/.gnupg to import the key you just created into pacman on your build machine.
  3. Use pacman-key -lsign [key-id] so that pacman will trust the key.
  4. You’re going to get sick and tired of entering your key’s passphrase as your package list grows, so set up the gpg-agent.

By default, the script instructs makepkg to remove all packages that had to be installed to build the package. If you are running a dedicated box (or a virtual machine) to build packages and want to keep the build and run-time dependencies, change makepkg -src to makepkg -sc and save yourself some time

As mentioned earlier, AUR packages sometimes rely on other AUR packages. In these instances, you just have to make sure you list the dependencies first. The script will update the repo database upon a successful build and refresh pacman, allowing the dependency to be installed from your own repository.

The problems left over after that usually stem from lesser-maintained packages not keeping up with changes to Arch or Linux in general. For that, you can create a shell script that, if found, will allow you to make changes to the files found in the tar.gz file before sicking makepkg on it. I had to do this for avant-window-navigator-bzr and awn-extras-applets-bzr.

UPDATE 2013-02-04: There was a slight bug in my logic. I assumed that only numbers would be found for version-related info inside PKGBUILDs. Turns out some PKGBUILDs use variables, and that threw off everything. Scoured packer’s source code and found out about AUR’s RPC.

UPDATE 2013-02-13: Script now tells you what version you currently have built. Now has nicer-looking output. Fixed incorrect usage of repo-remove. Fixed bug where packages were removed in error (e.g. rm lightdm-* removes all packages that begin with lightdm, not just lightdm itself.) If package is not found in the AUR, a pacman search (pacman -Ss) is performed to let you know if the package got moved to the official repos.

UPDATE 2013-02-16: Broke some functionality off into functions for easier reading. Script will now delete packages and remove them from the repo database if it detects that a package is not in the AUR but present in the official repos.

UPDATE 2013-02-24: Added architecture detection. Added ability to compile for multiple arches without changing config. Added precaution to not attempt compilation of lib32 packages when target arch is i686. Changed expected directory structure. Under $repdir should be $repnms and under $repnms should be build and arch (i686, x86_64) directories. Added rsync to remote host. TODO: Allow for multiple repos in one go (hence reponms and not reponam).

UPDATE 2013-03-02: Code now posted to GitHub. The First Real Commit adds a skip to package moving and repo database addition if the package is never successfully built. (These commands would just fail harmlessly before.) Also added a check to to see if the PKGBUILD can be built for the target arch. (Again, commands would just fail harmlessly if the package couldn’t be built.)