Skip to content

Build a custom pacman repository from a collection of PKGBUILD directories

License

Notifications You must be signed in to change notification settings

LizardByte/pacman-repo-builder

 
 

Repository files navigation

PacMan Repo Builder

GitHub stars GitHub Releases GitHub Workflow Status (CI) Codecov

Build a custom pacman repository from a collection of PKGBUILD directories.

Runtime Dependencies

  • pacman
  • makepkg
  • libalpm.so.13
  • libgit2.so

Usage

⚠ WARNING: This program is meant to be used within a docker container.

Manifest file

Manifest file is always named build-pacman-repo.yaml. It contains instruction to build a pacman repository.

Example Manifest File:

# build-pacman-repo.yaml
global-settings:
  repository: repo/repo.db.tar.gz
  container: container
  read-build-metadata: either
  record-failed-builds: failed-builds.yaml
  install-missing-dependencies: false
  clean-before-build: false
  clean-after-build: false
  force-rebuild: true
  pacman: pacman
  arch-filter: [x86_64]
  check: inherit
  packager: Bob <[email protected]>
  allow-failure: true
  dereference-database-symlinks: true
members:
  - directory: foo
  - directory: bar
    read-build-metadata: pkgbuild
    clean-before-build: false
    force-rebuild: true
    allow-failure: false
  - directory: bar
    install-missing-dependencies: true
    clean-after-build: false
    check: enabled
    pacman: yay
  - directory: baz
    read-build-metadata: srcinfo
    install-missing-dependencies: false
    clean-before-build: true
    clean-after-build: false
    force-rebuild: true
    check: disabled
    pacman: yay
    allow-failure: false

Field Explanations:

Top-Level:

Field Type Description
global-settings object Includes global settings from which all members inherit from.
Some settings can be overwritten by member customized properties.
member list List all members.

global-settings's own fields:

Field Type Required/Optional Description
repository string required Path to repository file (typically ends with .db.tar.gz).
It will be passed to repo-add command after each build.
container string optional, default = . Directory that contains all build directories (a.k.a. members).
record-failed-builds string optional If specified, old failed builds shall be skipped, and new failed builds shall be added to the file.
arch-filter "any" | string[] optional, default = any Specify all CPU architectures to build.
Either any or an array of strings (e.g. [x86_64, i686]).
packager string optional, default = Unknown Packager Identity of person or entity that produces the packages (i.e. the one who run this program).
dereference-database-symlinks boolean optional, default = false If true, all *.db and *.files symlinks will be converted to real files.

member's own fields:

Field Type Required/Optional Description
directory string required Path to build directory of each member (relative to global-settings.container).

Shared Fields: Fields that exist in both global-settings and member. If global-settings and member both contain a field, member's field will be prioritized.

Field Type Default
(global-settings)
Description
read-build-metadata either | srcinfo | pkgbuild either Where to read build metadata:
srcinfo: From .SRCINFO file.
pkgbuild: From output of makepkg --printsrcinfo.
either: From .SRCINFO file if it exists, otherwise execute makepkg --printsrcinfo.
install-missing-dependencies boolean false Install packages found in depends and makedepends before each build.
clean-before-build boolean false Clean $srcdir and $pkgdir before each build.
clean-after-build boolean false Clean up after each build.
force-rebuild boolean false Force build even if target package already exists.
check enabled | disabled | inherit inherit Whether to add --check or --nocheck to makepkg command.
pacman string pacman Package manager program to use.
The program must recognize pacman's CLI arguments and options.
allow-failure boolean false If false, exits immediately when a build fails.
If true, ignore build failure should one occurs.

Generate manifest file

Listing every member in a manifest file can be a chore. So when there are no members with customized properties, you can generate the manifest file to reflect the build directories instead:

build-pacman-repo print-config \
  --repository $repo_dir/$repo_name.db.tar.gz \
  --container build-directories \
  --require-pkgbuild \
  --require-srcinfo \
  --with-install-missing-dependencies true \
  > build-pacman-repo.yaml

Note: Replace $repo_dir with path of your repository directory. This directory will contain all built packages. Note: Replace $repo_name with name of your repository file. This file will be fetched by pacman to check for updates.

Replace /usr/bin/makepkg with one that allows running as root

The normal makepkg script does not allow running as root. While it may make sense in a user's machine, it inconveniences a Docker container.

build-pacman-repo patch-makepkg --replace

Build a pacman repositories

build-pacman-repo build

Note: Make sure that build-pacman-repo.yaml file exists in current working directory.

Print help message

build-pacman-repo help
build-pacman-repo --help
build-pacman-repo help $command
build-pacman-repo $command --help

Real-world applications

Frequently Asked Questions

What does this program do?

The main purpose is to build a pacman repository. When the build command is called, it will read all source infos from either .SRCINFO or PKGBUILD, sort them by their dependency relationship, then build them one by one.

Why does this need to be run inside a container?

In order for this program to function properly, it must make several changes to the host system, such as:

  • Replace /usr/bin/makepkg with one that allows running as root, so that it may be used in a CI environment.
  • Install every built package just in case it may be depended upon by another package.

About

Build a custom pacman repository from a collection of PKGBUILD directories

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 55.6%
  • Shell 44.3%
  • Dockerfile 0.1%