Skip to content

Add example systemd service files#6

Open
obbardc wants to merge 6 commits into
brgl:mainfrom
obbardc:wip/obbardc/add-systemd-service
Open

Add example systemd service files#6
obbardc wants to merge 6 commits into
brgl:mainfrom
obbardc:wip/obbardc/add-systemd-service

Conversation

@obbardc
Copy link
Copy Markdown

@obbardc obbardc commented Apr 21, 2026

Add the example systemd service files from the OpenEmbedded recipe[0].
The files are licenced under the same licence as the upstream project.

Link[0]: https://git.openembedded.org/meta-openembedded/tree/meta-filesystems/dynamic-layers/meta-python/recipes-support/gpiod-sysfs-proxy/gpiod-sysfs-proxy
Fixes: #3

obbardc added 2 commits April 21, 2026 13:52
Add the example systemd service files from the OpenEmbedded recipe[0].
The files are licenced under the same licence as the upstream project.

Link[0]: https://git.openembedded.org/meta-openembedded/tree/meta-filesystems/dynamic-layers/meta-python/recipes-support/gpiod-sysfs-proxy/gpiod-sysfs-proxy
Fixes: brgl#3
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
@brgl
Copy link
Copy Markdown
Owner

brgl commented Apr 21, 2026

Should we install the files too if we ship them? And how about dropping the sysv init script? I added it to yocto because sysv was the default at the time but I consider dropping it with systemd becoming the default.

obbardc added 4 commits April 21, 2026 17:27
The sysvinit script is no longer used and the systemd services is
preferred to be used. Remove the sysvinit script.

Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Assume the default target of /sys/class/gpio for the mountpoint so we
don't have to template the systemd service at install time.

Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Install the systemd service as part of the pyproject installation
process.

Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
@obbardc
Copy link
Copy Markdown
Author

obbardc commented Apr 21, 2026

Should we install the files too if we ship them? And how about dropping the sysv init script? I added it to yocto because sysv was the default at the time but I consider dropping it with systemd becoming the default.

Did that. I didn't check if pyproject actually installs all the files though.

I dropped the sysvinit script and set a default mountpoint of /sys/class/gpio as we can't do the templating really. I think we may need a different approach for the Yocto recipe? Maybe we could ship two service files or something.

@brgl
Copy link
Copy Markdown
Owner

brgl commented Apr 22, 2026

Should we install the files too if we ship them? And how about dropping the sysv init script? I added it to yocto because sysv was the default at the time but I consider dropping it with systemd becoming the default.

Did that. I didn't check if pyproject actually installs all the files though.

That's a question actually. If you can't test it (for instance: modify the yocto recipe to use it) then I'm fine with shipping them as an example and not installing them.

@obbardc
Copy link
Copy Markdown
Author

obbardc commented Apr 25, 2026

Should we install the files too if we ship them? And how about dropping the sysv init script? I added it to yocto because sysv was the default at the time but I consider dropping it with systemd becoming the default.

Did that. I didn't check if pyproject actually installs all the files though.

That's a question actually. If you can't test it (for instance: modify the yocto recipe to use it) then I'm fine with shipping them as an example and not installing them.

I think the services get installed properly.

I just checked this with:

docker run -it --rm -v $PWD:/mnt debian:unstable bash

apt update
apt install python3-pip pkgconf libfuse-dev build-essential

cd /mnt
python3 -m pip install \
  --break-system-packages \
  --force-reinstall \
  .

find /usr/local/lib/systemd/system/ | grep gpiod

it shows:

/usr/local/lib/systemd/system/gpiod-sysfs-proxy.service

and I think those files woukd go into /usr/lib/systemd/system if it was a Yocto/debian build...

Comment thread pyproject.toml
]
"lib/systemd/system/sysinit.target.wants" = [
"share/sysinit.target.wants/run-gpio-sys.mount",
"share/sysinit.target.wants/sys-class.mount",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installs these files unconditionally. In my meta-openembedded recipe I only do this if the user selected the - admittedly quite intrusive - sys-class-mount PACKAGECONFIG switch. Should we have a corresponding switch here as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installs these files unconditionally. In my meta-openembedded recipe I only do this if the user selected the - admittedly quite intrusive - sys-class-mount PACKAGECONFIG switch. Should we have a corresponding switch here as well?

Not sure if we can have a switch here without a lot of fudging around - that's why I made the python package install the most useful default service by default.

Do we really need to support both paths? I don't know enough about this really, but I suspect it'd make sense to support one by default in distros like debian etc?

Perhaps it'd make sense to install using a default path and push users to README for information to use alternate paths? again, I am not entirely sure here, but surely for modern installs there is a sensibe default? :-)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I never really considered this could be packaged in Debian. :) Is mounting an overlay over /sys/class something Debian would accept as the default? Sounds quite risky to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to me, if you install this you kind of need it to work :-)

Alternatively in the python install we could install 2x systemd services (one for each path, or a template and 2x services extending the template) to a doc dir (e.g. not install them), then in yocto/debian we could install the script by default and have the services as as separate packages, and let users choose which package they want to install (and in yocto you can keep the same var, just install different services to the right place) ?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or (for yocto) possibly two mutually-exclusive packages: gpiod-sysfs-proxy-systemd-overlay and gpiod-sysfs-proxy-systemd-tmp with the former installing the /sys/class overlay units?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, and in this python installer i should put the service files into a documentation dir.

Need to figure out how to make the services extend another service so we don't duplicate code.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be too much to ask to also update the yocto recipe if you're doing it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sample systemd service

2 participants