MatterLinux

Wiki: Packages

04/08/24

by ngn

On this page, you will find information about MatterLinux packages.

Format

MatterLinux packages uses the MatterLinux Packaging Format, MPF. Don’t let fancy name mislead you, a basic MPF file is just a renamed Gunziped TAR archive. The reason that packages use the .mpf extension and not the .tar.gz extension is to make it easier to recognize and easier to work with in the scripts and the tools.

Naming

A package is named after the software and the version of that software that it provides. For example package containing bash version 5.2.15 is named bash_5.2.15.mpf.

Structure

File structure of a package follows this format:

package_1.0.mpf
├── DATA
├── CHANGES
├── INSTALL
├── HASHES 
└── files.tar.gz

Let’s break this down:

File structure of the files.tar.gz archive matches with the MatterLinux root file structure. This is important as this archive will most likely be extracted in a MatterLinux root file system.

For example, we can take a look at the which package, to do this you can download the MPF file, extract it in a temporary folder, and list the contents of files.tar.gz with the tar tf files.tar.gz command:

usr/
usr/share/
usr/share/man/
usr/share/man/man1/
usr/share/man/man1/which.1
usr/share/info/
usr/share/info/dir
usr/share/info/which.info
usr/bin/
usr/bin/which

Install scripts

Some packages may contain an non-empty install script, INSTALL, this shell script is ran by the MatterLinux Package Manager (matt) using the bash shell, right after the extraction of files.tar.gz, in the package installation directory (usually /).

This script is used to do post-install actions, such as adding users, groups etc.

Working with packages

While installing a package using the MatterLinux Package Manager (matt), matt downloads the target package(s) from the pools, these packages are in the format discussed above. After downloading and verifying the target package(s), matt extracts the packages using libarchive. To learn more about this process see the page for package management.

Building packages

Package are built with the mp-build tool. In order to build a package, you will need the source of the package, which can be found in the source tree of the pool which contains the package.

After obtaining the source, package can be simply built by running:

$ mp-build <package dir>

To learn more about building and creating packages, please see this page.

Package scripts

Each package source contains a pkg.sh shell script. This is the source script that is used to build the package. In the build process, this shell script gets sourced by the mp-build tool using the source command.

Let’s take a closer look at a pkg.sh file:

NAME="which"
DESC="Shows the full path of (shell) commands"
VERSION="2.21"

FILES=("https://ftp.gnu.org/gnu/which/which-${VERSION}.tar.gz")
HASHES=("097ff1a324ae02e0a3b0369f07a7544a")

DEPENDS=()

PACKAGE() {
  tar xf "${NAME}-${VERSION}.tar.gz"
  cd "${NAME}-${VERSION}"

  ./configure --prefix=/usr && make
  make DESTDIR="${ROOTDIR}" install

  cd .. && rm -r "${NAME}-${VERSION}"
}

This pkg.sh file is for the which package (version 2.21). Let’s start by breaking down the variables:

There are also other options that are not present in this example:

Now let’s take a look at the PACKAGE function. Each package needs a PACKAGE function, this function is called by mp-build after downloading and verifying all the files. It will be called in the $ROOTDIR. This directory will contain all the downloaded files, any files in this directory will be included into the build, so don’t forget to cleanup.

Note

You don’t need to cleanup the downloaded files in the package script, they will be cleaned by the mp-build.

Check out base and desktop pool sources for more example package scripts.