DeveloperWiki:pac-build

From PacBSD Wiki
Jump to: navigation, search

Introduction[edit]

This article will cover building in clean chroots or jails with pac-build.

Why[edit]

Packages built in clean chroots will prevent unwanted dependencies which may be automatically included in the build if the build system detects an installed package on your system. It also allows to build against packages in certain repositories. So packages build in a chroot that only consist of the core packages, can be pushed to the stable repositories, while a chroot that has testing enable would build and link against those packages.

Installing pac-build[edit]

To install pac-build the devel repository should be enabled in /etc/pacman.conf, and the following added to the config

# nano /etc/pacman.conf
[devel]
Include /etc/pacman.d/mirrorlist


You can proceed to sync and install pac-build

 # pacman -Syu pac-build

File System[edit]

Depending on which filesystem is being used. Setup can be a little different. pac-build can be configured to use zfs snapshots for the base, while ufs will create a clean base each time a package is built.

Tip: Using zfs is much quicker as the base doesn't need to be created each time and is recommended

Profile Configuration[edit]

Profiles can be used to create multiple zfs subvolumes to easilly switch between building for different arches and repositories. To make things easy, it's recommended to use /etc/pacman.conf.<profile> to keep track of profiles. For example, if we wanted to create a profile to build for i686, the following could be done. i686 Can be replaced with any profile name.

Firstly we create /etc/pacman.conf.i686

 # cp /etc/pacman.conf /etc/pacman.conf.i686


The naming should reflect what that profile is for such as /etc/pacman.conf.i686.unstable or /etc/pacman.conf.x86_64-stable.

If running on x86_64, /etc/pacman.conf.i686 should have the Architecture set to i686 instead of auto.

nano /etc/pacman.conf.i686
[...]
Architecture = i686
[...]

After the file has been configured, /etc/pac-build.conf should be configured to use these files.

nano /etc/pac-build.conf
[...]
# pacman.conf by build profile:
pacman_conf_i686=/etc/pacman.conf.i686
[...]

The naming convention in the file for specifying should be

nano /etc/pac-build.conf
[...]
pacman_conf_<profile>=/etc/pacman.conf.<profile>
[...]

To use the profile the -a option should be used.

 # pac-build -a <profile> update

Or alternatively you can set the profile to use by default

nano /etc/pac-build.conf
[...]
# default_profile: The default build profile
default_profile=i686
[...]

Configuring zfs Usage[edit]

pac-build will need to be configured to use zfs by default. This can be set in /etc/pac-build.conf by toggling the zfs to 1.

# nano /etc/pac-build.conf
# ZFS settings
# to enable ZFS by default, set this to 1

opt_zfs=1

This will cause pac-build to default to zfs usage each run. Although the default subvolume might need to be changed to reflect your zfs setup. Different profiles can be used and named accordingly

# nano /etc/pac-build.conf
# subvol_$build_profile:
#   The name of the subvolume to maintain with pac-build
#   When set to INVALID ZFS support will be disabled.
#   'pac-init' will initialize the pool with mountpoint=legacy
# Example: zpool/build_base

subvol_x86_64=tank/build_base_64
#subvol_i686=zpool/build_base_32

Before any building can be started. The base must first be created after configuration. Once configuration is complete you can use pac-build to create the subvolumes

 # pac-build init

Also remember to specify the profile if not using it by default.

 # pac-build -a i686 init

Updating ZFS base[edit]

To keep the base updated the follow command must be ran for pac-build to sync and update the zfs volume.

 # pac-build update

If you're using an alternative profile, where i686 is the profile name.

 # pac-build -a i686 update
Tip: You can create an alias so pac-build does this automatically when called but this varies on the shell used.

Removing ZFS base[edit]

In the event you need to delete the ZFS base for any reason.

 # pac-build remove

Removing a specified profile.

 # pac-build -a i686 remove

Configuring ABS location[edit]

pac-build needs to know the location of the ABS tree before it can build the packages.

nano /etc/pac-build.conf
# abstree: Path to the ABS git clone
abstree=/var/abs

Building a Package[edit]

Before building the package a source Tarball must first be created with makepkg. The following command should be run in the PKGBUILD directory. e.g /var/abs/core/openrc

 # makepkg -S

After the creation of the source tarball, you can have pac-build build this package in a clean chroot by providing the repo it's in and the package name.

 # pac-build <repo> <package>

If we were to build openrc which is in the core repository we would use.

 # pac-build core openrc

If you don't have a default profile, you can specify the profile to use for the build.

 # pac-build -a i686 core openrc

Cleaning ZFS pools[edit]

When using pac-build with ZFS it will keep all create subvolumes so that they may be entered, repackaged and other tasks. When you are sure you no longer need those, pac-build can remove them.

 # pac-build -k <repo> <package>

or

 # pac-build -a i686 -k <repo> <package>

You can get a complete list of all create subvolumes with.

 # zfs list

Entering the ZFS base[edit]

Occasionally you will need to enter the ZFS base to merge and tidy op dot pac.new files.

with a default profile:

 # pac-build enter

With an alternative profile:

 # pac-build -a i686 enter