systemd.eclass: use it in your packages!

Although systemd is not officially supported by Gentoo and it is not even in the tree yet, some of our packages already provide support for installing systemd units. This is because a few upstreams already supply and install systemd units in their packages.

I think it is important to support installing those units even before systemd is committed to gx86. This way, we can ensure users switching to systemd will have at least minimal working system without hacking packages around to get the necessary units. That’s why I’ve already committed the systemd.eclass.

My point here is that every package for which upstream officially supports systemd (and thus the configure script supports --with-systemdsystemunitdir) should use the systemd eclass. This way, we’re able to globally and universally control whether, where and how systemd units are installed.

Devs often refuse to use the eclass because it installs the units unconditionally. As I said earlier, and as I repeat now — that can be changed. Just take a part in the discussion that I tried to raise on the mailing list. The point of using the eclass is that we can change that and then have a way to let our users handle the change gracefully.

And please do not try to enforce your own conditionals on the eclass functions. Adding local USE=systemd is no solution. It just makes things harder for users for relatively small benefit.

PMS Test Suite: the project design

As the GSoC coding period starts tomorrow, today seems like the last good day to write a little about the project design. For that reason, I created a little diagram in dia:

PMS Test Suite design diagram

As you can see there, the project code is currently broken down into three repositories. The main code repository, called pms-test-suite.git is going to hold the core project code — main scripts, library-handling Python modules and so on. The pms-test-suite-library.git repository is going to contain the bundled test library, and pms-test-suite-overlay.git holds temporary test ebuilds and the eclass.

Looking from the left hand side, you can see a greyed out part with the test-generator script in the middle of it. This module is not a part of GSoC design goals but a possible future guideline. It is supposed to read the human-readable definitions from the Package Manager Specification, match them with helper data and create a complete test library. However, right now the project will simple use a bundled test library.

The test library will consist of modules describing various tests for PMS compliance. Each of these modules, called a test case will provide at least the following information:

  1. A human-readable test description (which will be reused in program output and ebuild DESCRIPTIONs,
  2. a list of relevant EAPIs for which ebuilds will be generated,
  3. definitions of ebuild-specific variables and phase functions necessary to perform the test,
  4. a test result checking function, possibly EAPI-conditional.

Those test cases will be reused by two other PMS Test Suite scripts. The ebuild-generator module will use them to generate the ebuilds resembling the particular tests, and the test-runner module will use them to check the test results.

The test-runner script will perform the most important task of testing a particular Package Manager. It is supposed to match the test cases with generated ebuilds (or even call ebuild-generator internally), run the Package Manager on them and collect the results. The results will be used then to determine whether the test case succeeded, failed or its result is ambiguous.

The test ebuilds will use an PM-independent method of exchanging information with the test-runner module. The internal details of this communication will be handled in the pms-test.eclass. Right now, this code uses D-Bus for this task.

PMS Test Suite: choosing the test library format

The main purpose of the PMS Test Suite project is to test Package Managers for compliance with the PMS. In order to do that, the suite has to supply a particular PM with test ebuilds, run it and check the test results.

Test ebuilds are often very similar one to another. Many of the common tests require running with more than a single EAPI — resulting in ebuilds differing only in a single EAPI line. Considering that, writing test ebuilds manually and maintaining them in that form doesn’t seem like a good idea. That’s why PMS Test Suite will come with a custom test library format.

The test library will be the heart of the whole project. It will supply it with all the test case details necessary to create an appropriate ebuild, run the PM on it and parse the results. That’s why it is very important to choose an elegant and efficient format for the test cases in the library.

Right now, I’m considering using one of the following scripting languages for the test cases:

1. Bash

(bash test case example)

Pros:

  • simple syntax,
  • same solution as used in ebuilds,
  • lazy code parsing — it is possible to declare phase functions as actual functions and grab their code afterwards.

Cons:

  • requires a lot of effort to parse,
  • slow and CPU-intensive execution,
  • limited datatypes,
  • more complex operations rely on external utilities.

2. Lua

(lua test case example)

Pros:

  • simple yet powerful,
  • fast.

Cons:

  • introduces another language in the workflow,
  • requires installing additional packages.

3. Python

(python test case example)

Pros:

  • ability to use class inheritance,
  • no additional tools required,
  • byte-compiled code.

Cons:

  • more complex syntax,
  • requirement of fixed namespace or hacks in order to load libraries efficiently.

Summary

Considering that the core PMS Test Suite will be written in Python, using the same language for the test library seems to be the way to go. The test cases can subclass an appropriate, common PMSTest class and then the whole library parsing would be limited to loading the modules and instantiating the classes providing by them.

A few words of introduction

Hello everyone. My name’s Michał Górny, and I’m a Gentoo dev since October last year. This year I’m working in a GSoC project called the PMS Test Suite and this is the most important topic which will be covered by this blog right now.

You can expect me to write about my other Gentoo involvements too, including the set of app-portage/ tools I’m author of, and the intended but long delayed systemd ebuilds introduction.