- Arch Build System
- Contents
- Overview
- Repository tree
- Use cases
- Usage
- Retrieve PKGBUILD source
- Retrieve PKGBUILD source using Git
- Retrieve PKGBUILD source using SVN
- Build package
- Tips and tricks
- Preserve modified packages
- Dynamic Kernel Module Support
- Contents
- Installation
- Upgrades
- Usage
- List modules
- Rebuild modules
- Remove modules
- DKMS package creation
- Initial ramdisk
- Kernel module
- Contents
- Obtaining information
- Automatic module loading with systemd
- Manual module handling
- Setting module options
- Manually at load time using modprobe
- Using files in /etc/modprobe.d/
- Using kernel command line
- Aliasing
- Blacklisting
- Using files in /etc/modprobe.d/
- Using kernel command line
- Troubleshooting
- Modules do not load
Arch Build System
The Arch build system is a ports-like system for building and packaging software from source code. While pacman is the specialized Arch tool for binary package management (including packages built with the ABS), ABS is a collection of tools for compiling source into installable .pkg.tar.zst packages.
Ports is a system used by *BSD to automate the process of building software from source code. The system uses a port to download, unpack, patch, compile, and install the given software. A port is merely a small directory on the user’s computer, named after the corresponding software to be installed, that contains a few files with the instructions for building and installing the software from source. This makes installing software as simple as typing make or make install clean within the port’s directory.
ABS is a similar concept. A part of ABS is a SVN repository and an equivalent Git repository. The repository contains a directory corresponding to each package available in Arch Linux. The directories of the repository contain a PKGBUILD file (and sometimes other files), and do not contain the software source nor binary. By issuing makepkg inside a directory, the software sources are downloaded, the software is compiled, and then packaged within the build directory. Then you can use pacman to install the package.
Contents
Overview
This article or section needs expansion.
‘ABS’ may be used as an umbrella term since it includes and relies on several other components; therefore, though not technically accurate, ‘ABS’ can refer to the following tools as a complete toolkit:
Repository tree The directory structure containing files needed to build all official packages but not the packages themselves nor the source files of the software. It is available in svn and git repositories. See the section #Repository tree for more information. PKGBUILD A Bash script that contains the URL of the source code along with the compilation and packaging instructions. makepkg A shell command tool which reads the PKGBUILDs, automatically downloads and compiles the sources and creates a .pkg.tar* according to the PKGEXT array in makepkg.conf . You may also use makepkg to make your own custom packages from the AUR or third-party sources. See Creating packages for more information. pacman pacman is completely separate, but is necessarily invoked either by makepkg or manually, to install and remove the built packages and for fetching dependencies. AUR The Arch User Repository is separate from ABS but AUR (unsupported) PKGBUILDs are built using makepkg to compile and package up software. In contrast to the ABS tree which is simply a bare git repository, the AUR exists as a polished website interface with various interactive features. It contains many thousands of user-contributed PKGBUILDs for software which is unavailable as an official Arch package. If you need to build a package outside the official Arch tree, chances are it is in the AUR.
Repository tree
The core, extra, and testing official repositories are in the packages repository for checkout. The community and multilib repositories are in the community repository.
Each package has its own subdirectory. Within it there are repos and trunk directories. repos is further broken down by repository name (e.g., core) and architecture. PKGBUILDs and files found in repos are used in official builds. Files found in trunk are used by developers in preparation before being copied to repos .
For example, the tree for acl looks like this:
The source code for the package is not present in the ABS directory. Instead, the PKGBUILD contains a URL that will download the source code when the package is built.
Use cases
ABS automates certain tasks related to compilation from source. Its use cases are:
- Any use case that requires you to compile or recompile a package.
- Make and install new packages from source of software for which no packages are yet available (see Creating packages) .
- Customize existing packages to fit your needs (e.g. enabling or disabling options, patching).
- Rebuild your entire system using your compiler flags, «à la FreeBSD».
- Cleanly build and install your own custom kernel (see Kernel compilation).
- Get kernel modules working with a custom kernel.
- Easily compile and install a newer, older, beta, or development version of an Arch package by editing the version number in the PKGBUILD.
Usage
Retrieve PKGBUILD source
To retrieve the PKGBUILD required to build a certain package from source, you can either use SVN or a Git-based approach using the asp package which is a thin wrapper around the svntogit repositories. In the following, the svn-based method as well as the git-based method are described.
Retrieve PKGBUILD source using Git
As a precondition, install the asp package. Asp is a tool to retrieve the build source files for Arch Linux packages using the Git interface. Also see the Arch Linux BBS forum thread [1].
To clone the svntogit-repository for a specific package, use:
This will clone the git repository for the given package into a directory named like the package.
To update the cloned git repository, run asp update followed by git pull inside the git repository.
Furthermore, you can use all other git commands to checkout an older version of the package or to track custom changes. For more information on git usage, see the git page.
If you just want to copy a snapshot of the current PKGBUILD for a specific package, use:
Retrieve PKGBUILD source using SVN
Prerequisites
Checkout a repository
To checkout the community and multilib repositories:
In both cases, it simply creates an empty directory, but it does know that it is an svn checkout.
Checkout a package
In the directory containing the svn repository you checked out (i.e., packages or community), do:
This will pull the package you requested into your checkout. From now on, any time you svn update at the top level, this will be updated as well.
If you specify a package that does not exist, svn will not warn you. It will just print something like «At revision 115847», without creating any files. If that happens:
- check your spelling of the package name
- check that the package has not been moved to another repository (i.e. from community to the main repository)
- check https://archlinux.org/packages to see if the package is built from another base package (for example, python-tensorflow is built from the tensorflow PKGBUILD)
You should periodically update all of your checked out packages if you wish to perform rebuilds on more recent revisions of the repositories. To do so, do:
Checkout an older version of a package
Within the svn repository you checked out as described in #Checkout a repository (i.e. «packages» or «community»), first examine the log:
Find out the revision you want by examining the history, then specify the revision you wish to checkout. For example, to checkout revision r1729 you would do:
This will update an existing working copy of package-name to the chosen revision.
You can also specify a date. If no revision on that day exists, svn will grab the most recent package before that time. The following example checks out the revision from 2009-03-03:
It is possible to checkout packages at versions before they were moved to another repository as well; check the logs thoroughly for the date they were moved or the last revision number.
Build package
Configure makepkg for building packages from the PKGBUILDs you have checked out, as explained in makepkg#Configuration.
Then, copy the directory containing the PKGBUILD you wish to modify to a new location. Make the desired modifications there and use makepkg there as described in makepkg#Usage to create and install the new package.
Tips and tricks
Preserve modified packages
Updating the system with pacman will replace a modified package from ABS with the package of the same name from the official repositories. See the following instructions for how to avoid this.
Insert a group array into the PKGBUILD, and add the package to a group called modified .
Add this group to the section IgnoreGroup in /etc/pacman.conf .
If new versions are available in the official repositories during a system update, pacman prints a note that it is skipping this update because it is in the IgnoreGroup section. At this point the modified package should be rebuilt from ABS to avoid partial upgrades.
Источник
Dynamic Kernel Module Support
Dynamic Kernel Module Support (DKMS) is a program/framework that enables generating Linux kernel modules whose sources generally reside outside the kernel source tree. The concept is to have DKMS modules automatically rebuilt when a new kernel is installed.
This means that a user does not have to wait for a company, project, or package maintainer to release a new version of the module. Since the introduction of pacman hooks, the rebuild of the modules is handled automatically when a kernel is upgraded.
Contents
Installation
Install the dkms package and the headers for the target kernel/kernels. For example, for the default linux kernel this would be linux-headers . Other kernels have their own respective headers packages.
A good number of modules that lie outside the kernel source tree have a DKMS variant; a few are hosted in the official repositories, most are found in the AUR.
Upgrades
Though the rebuild of the DKMS modules is usually seamless during a kernel upgrade, it may still happen that the rebuild fails. You should pay extra attention to the pacman output. This applies in particular if the system relies on the DKMS module to boot successfully and/or if you use DKMS with a custom kernel not in the official repositories.
To deal with changes in the kernel, fix bugs, or add necessary features consider upgrading the DKMS package before rebooting.
Usage
Usage for invoking DKMS manually.
Tab-completion is available by doing:
List modules
To list the current status of modules, versions and kernels within the tree:
Rebuild modules
Rebuild all modules for the currently running kernel:
or for a specific kernel:
To build a specific module for the currently running kernel:
To build a module for all kernels:
Remove modules
To remove a module (old ones are not automatically removed):
If the package dkms is removed the information regarding previous module build files is lost. If this is the case, go through /usr/lib/modules/kernel_release and /var/lib/dkms/package_name and delete all files and directories no longer in use.
DKMS package creation
Initial ramdisk
In case you have got any kernel modules installed via DKMS that are used in initial ramdisk, e.g. zfs-dkms AUR , you may want to write a pacman hook to automate the process of regenerating initramfs image(s).
For example, when using linux and mkinitcpio, to update ZFS module after each zfs-dkms AUR upgrade,
You may add more targets to the hook and make additional copies of the hook if you have installed other kernels. Note the 90- prefix is necessary to make sure it runs after the DKMS hooks.
Источник
Kernel module
Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system.
To create a kernel module, you can read The Linux Kernel Module Programming Guide. A module can be configured as built-in or loadable. To dynamically load or remove a module, it has to be configured as a loadable module in the kernel configuration (the line related to the module will therefore display the letter M ).
Contents
Obtaining information
Modules are stored in /usr/lib/modules/kernel_release . You can use the command uname -r to get your current kernel release version.
To show what kernel modules are currently loaded:
To show information about a module:
To list the options that are set for a loaded module:
To display the comprehensive configuration of all the modules:
To display the configuration of a particular module:
List the dependencies of a module (or alias), including the module itself:
Automatic module loading with systemd
Today, all necessary modules loading is handled automatically by udev, so if you do not need to use any out-of-tree kernel modules, there is no need to put modules that should be loaded at boot in any configuration file. However, there are cases where you might want to load an extra module during the boot process, or blacklist another one for your computer to function properly.
Kernel modules can be explicitly listed in files under /etc/modules-load.d/ for systemd to load them during boot. Each configuration file is named in the style of /etc/modules-load.d/program.conf . Configuration files simply contain a list of kernel modules names to load, separated by newlines. Empty lines and lines whose first non-whitespace character is # or ; are ignored.
See modules-load.d(5) for more details.
Manual module handling
Kernel modules are handled by tools provided by kmod package. You can use these tools manually.
To load a module:
To load a module by filename (i.e. one that is not installed in /usr/lib/modules/$(uname -r)/ ):
To unload a module:
Setting module options
To pass a parameter to a kernel module, you can pass them manually with modprobe or assure certain parameters are always applied using a modprobe configuration file or by using the kernel command line.
Manually at load time using modprobe
The basic way to pass parameters to a module is using the modprobe command. Parameters are specified on command line using simple key=value assignments:
Using files in /etc/modprobe.d/
Files in /etc/modprobe.d/ directory can be used to pass module settings to udev, which will use modprobe to manage the loading of the modules during system boot. Configuration files in this directory can have any name, given that they end with the .conf extension. The syntax is:
Using kernel command line
If the module is built into the kernel, you can also pass options to the module using the kernel command line. For all common bootloaders, the following syntax is correct:
Simply add this to your bootloader’s kernel-line, as described in Kernel Parameters.
Aliasing
Aliases are alternate names for a module. For example: alias my-mod really_long_modulename means you can use modprobe my-mod instead of modprobe really_long_modulename . You can also use shell-style wildcards, so alias my-mod* really_long_modulename means that modprobe my-mod-something has the same effect. Create an alias:
Some modules have aliases which are used to automatically load them when they are needed by an application. Disabling these aliases can prevent automatic loading but will still allow the modules to be manually loaded.
Blacklisting
Blacklisting, in the context of kernel modules, is a mechanism to prevent the kernel module from loading. This could be useful if, for example, the associated hardware is not needed, or if loading that module causes problems: for instance there may be two kernel modules that try to control the same piece of hardware, and loading them together would result in a conflict.
Some modules are loaded as part of the initramfs. mkinitcpio -M will print out all automatically detected modules: to prevent the initramfs from loading some of those modules, blacklist them in a .conf file under /etc/modprobe.d and it shall be added in by the modconf hook during image generation. Running mkinitcpio -v will list all modules pulled in by the various hooks (e.g. filesystems hook, block hook, etc.). Remember to add that .conf file to the FILES array in /etc/mkinitcpio.conf if you do not have the modconf hook in your HOOKS array (e.g. you have deviated from the default configuration), and once you have blacklisted the modules regenerate the initramfs, and reboot afterwards.
Using files in /etc/modprobe.d/
Create a .conf file inside /etc/modprobe.d/ and append a line for each module you want to blacklist, using the blacklist keyword. If for example you want to prevent the pcspkr module from loading:
However, there is a workaround for this behaviour; the install command instructs modprobe to run a custom command instead of inserting the module in the kernel as normal, so you can force the module to always fail loading with:
This will effectively blacklist that module and any other that depends on it.
Using kernel command line
You can also blacklist modules from the bootloader.
Simply add module_blacklist=modname1,modname2,modname3 to your bootloader’s kernel line, as described in Kernel parameters.
Troubleshooting
Modules do not load
In case a specific module does not load and the boot log (accessible by running journalctl -b as root) says that the module is blacklisted, but the directory /etc/modprobe.d/ does not show a corresponding entry, check another modprobe source folder at /usr/lib/modprobe.d/ for blacklisting entries.
A module will not be loaded if the «vermagic» string contained within the kernel module does not match the value of the currently running kernel. If it is known that the module is compatible with the current running kernel the «vermagic» check can be ignored with modprobe —force-vermagic .
Источник