Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#49460 - [systemd] add_systemd_unit should auto provision unit resources with help of ConditionPathExists

Attached to Project: Arch Linux
Opened by Andrei Pozolotin (random-archer) - Tuesday, 24 May 2016, 22:01 GMT
Last edited by Eli Schwartz (eschwartz) - Thursday, 04 January 2018, 04:18 GMT
Task Type Feature Request
Category Packages: Core
Status Assigned
Assigned To Dave Reisner (falconindy)
Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No


currently, add_systemd_unit can auto provision binaries:

similar logic can also be applied in order to auto provision unit resources:

1) first, check if service unit contains entry ConditionPathExists=/etc/initrd-release

that means it is a service that is expected to run only from initramfs

2) now look for other ConditionPathExists= entries
* if they are already provisioned into initramfs, then good
* else discover resource types and provision them from the host

sample implementation could be:

case $key in
# auto provision resources
local path="${values[0]}"
if [[ -e $BUILDROOT$path ]] ; then
plain "use existing path $path"
plain "use resolved path $path"
if [[ -e $path]] ; then
if [[ -d $path]] ; then
add_full_dir "$path"
add_file "$path"
error "missing path $path"
This task depends upon

Comment by Andrei Pozolotin (random-archer) - Tuesday, 24 May 2016, 22:40 GMT Comment by Andrei Pozolotin (random-archer) - Saturday, 28 May 2016, 00:29 GMT Comment by Dave Reisner (falconindy) - Saturday, 28 May 2016, 12:52 GMT
I have no idea what InitrdBinary, InitrdPath, InitrdBuild, and InitrdCall are... is this some proposed extension of the protocol within an X-$foo section to be littered around systemd units? I don't think it's reasonable to ask upstreams to include this (since it's arch-specific), and it's a maintenance burden for Arch developers which seems to be of questionable use (the idea of InitrdCall is particularly scary, and your implementation of it doesn't work). At a minimum, you'd need to document this somewhere to explain WTF is going on.

- Please don't use the AUR as a code hosting site, and please provide patches rather than code dumps, so that it's actually possible to see what the changes are.
- Your code doesn't follow style -- we always use [[ instead of [.
- Lines like "result=$($command 2>&1)" or "unit_list=$(grep -l "$tag" $dir/*.service)" are simply not safe due to word splitting and glob expansion. "code=$(echo "${values[@]}")" is entirely nonsense. You need to learn to use arrays.
Comment by Andrei Pozolotin (random-archer) - Saturday, 28 May 2016, 23:53 GMT
Dave: thank you for taking the time, here are my answers:

RE "I have no idea what InitrdBinary, InitrdPath, InitrdBuild, and InitrdCall are"

* yes, this is a new proposed feature for systemd mkinitcpio [add_systemd_unit()] function. if you are interested, I can elaborate more.

* no need to ask upstream, this will be arch-only X-$foo extension, for provisioning systemd resources in initrd with help of arch mkinitcpio

* the InitrdCall implementation actually works, I use it already

* I have documented this proposed extension here:

RE "Elsewhere:"

* I moved the source to github

* I applied your style request:

* I improved my understanding of arrays (a little), thank you :-)

* I do not know how to improve "result=$($command 2>&1)" or "unit_list=$(grep -l "$tag" $dir/*.service)", any pointers much appreciated.

Thank you.