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 Toolybird (Toolybird) - Saturday, 03 June 2023, 02:35 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
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 100%
Votes 1
Private No

Details

currently, add_systemd_unit can auto provision binaries:
https://git.archlinux.org/svntogit/packages.git/tree/trunk/initcpio-install-systemd?h=packages/systemd#n48

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
https://www.freedesktop.org/software/systemd/man/systemd.unit.html

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
ConditionPathExists)
# auto provision resources
local path="${values[0]}"
if [[ -e $BUILDROOT$path ]] ; then
plain "use existing path $path"
else
plain "use resolved path $path"
if [[ -e $path]] ; then
if [[ -d $path]] ; then
add_full_dir "$path"
else
add_file "$path"
fi
else
error "missing path $path"
fi
fi
;;
This task depends upon

Closed by  Toolybird (Toolybird)
Saturday, 03 June 2023, 02:35 GMT
Reason for closing:  None
Additional comments about closing:  Old and stale. It seems mkinitcpio-systemd-tool ended up in the official repos, and there exists a push to integrate it further into the Arch GitLab instance under the mkinitcpio umbrella.
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.

Elsewhere:
- 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:
https://github.com/random-archer/mkinitcpio-systemd-tool/blob/master/README.md
https://wiki.archlinux.org/index.php/Dm-crypt/Specialties#Remote_unlocking_of_the_root_.28or_other.29_partition

RE "Elsewhere:"

* I moved the source to github https://github.com/random-archer/mkinitcpio-systemd-tool

* I applied your style request: https://github.com/random-archer/mkinitcpio-systemd-tool/blob/master/mkinitcpio-install.sh

* 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.

Loading...