git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/6] maintenance: use packaged systemd units

From
Max Gautier <mg@max.gautier.name>
Date
Mar 23, 2024, 09:52 UTC
Message-ID
<Zf6mcBhd31WYkwob@framework>
In-Reply-To
<CAPig+cS1YL1iOZFh5=b1+_P=KBST=DYRqp7TaD7uMVLJQjs1bA@mail.gmail.com>
On Sat, Mar 23, 2024 at 04:38:44AM -0400, Eric Sunshine wrote:
Show 37 quoted lines
> On Sat, Mar 23, 2024 at 4:21 AM Max Gautier <mg@max.gautier.name> wrote:
> > [...]
> > Package the systemd user units (timer and service) with git in
> > $(prefix)/lib/systemd/user (or $XDG_DATA_HOME for $HOME installation),
> > and remove code for writing and deleting the units from builtin/gc.c.
> > Determine the correct git path at install time by for the service unit.
> >
> > Detect systemd timers support (at install time) by relying on systemctl
> > presence, since we use it as the control interface for the systemd
> > scheduler.
> >
> > Signed-off-by: Max Gautier <mg@max.gautier.name>
> > ---
> > Notes:
> >     I'm not completely sure if it's ok to do install time templating like
> >     this, but I couldn't find a similar enough example in the Makefile. Any
> >     suggestion for a better way ?
> >
> > diff --git a/Makefile b/Makefile
> > @@ -3469,6 +3469,11 @@ install: all
> > +ifdef SYSTEMD_USER_UNIT_DIR
> > +       $(INSTALL) -Dm 644 -t '$(DESTDIR_SQ)$(SYSTEMD_USER_UNIT_DIR)' systemd/user/git-maintenance@.timer
> > +       sed 's+@BINDIR@+$(bindir_SQ)+' systemd/user/git-maintenance@.service.in | \
> > +               $(INSTALL) -Dm 644 /dev/stdin '$(DESTDIR_SQ)$(SYSTEMD_USER_UNIT_DIR)/git-maintenance@.service'
> > +endif
> 
> This is the first use of /dev/stdin in the project and I might worry a
> bit about portability. Granted, a system in which systemd is installed
> is likely to have /dev/stdin available, but it's often a good idea to
> be cautious when introducing something new into the project.
> 
> I would think it would be possible to instead generate the
> `git-maintenance@.service` file locally from the template
> `git-maintenance@.service.in` as part of the normal build process, and
> then install the built `git-maintenance@.service` at "install" time.
> That seems more in line with how other resources are handled, avoids
> the novel use of /dev/stdin, and answers the question you ask above.
Ok.  It's not completely obvious to me how the "Detect prefix change
logic" works, but using other rules as a model, I think I can do
something like that:
systemd/user/git-maintenance@.service: systemd/user/git-maintenance@.service.in GIT-PREFIX
    sed 's+@BINDIR@+$(bindir_SQ)+' $< > $@

and depending on GIT-PREFIX should regenerate the service when changing the prefix, correct ? I'll need to add that to .gitignore as well.

Show 7 quoted lines
> 
> > diff --git a/config.mak.uname b/config.mak.uname
> > @@ -68,6 +68,16 @@ ifeq ($(uname_S),Linux)
> > +       ifeq ($(shell command -v systemctl >/dev/null ?&& echo y),y)
> 
> What is "?&&"?
> 

Hum, a typo, sorry that slipped through. It apparently works regardless, because shell expansion does something with it I guess. Curious. I'll clean that up as well.

Show 6 quoted lines
> > +               XDG_DATA_HOME ?= $(HOME)/.local/share
> > +               # systemd user units of programm installed in the home directory
> > +               # (meaning prefix == $HOME) shall go in XDG_DATA_HOME
> > +               # (from man 5 systemd.unit)
> 
> s/programm/program/

Ack. That should even be 'programs' I think, that's a general rule.

-- 
Max Gautier
Previous: Eric SunshineNext: Max Gautier
Message 12 of 30 in “maintenance: use packaged systemd units”
  1. 0/6 maintenance: use packaged systemd unitsMax Gautier, Mar 22, 2024
  2. 4/6 maintenance: cleanup $XDG_CONFIG_HOME/systemd/userMax Gautier, Mar 22, 2024
  3. Kristoffer HaugsbakkMar 22, 2024
  4. Junio C HamanoMar 22, 2024
  5. Max GautierMar 23, 2024
  6. Phillip WoodMar 24, 2024
  7. Max GautierMar 25, 2024
  8. Phillip WoodMar 25, 2024
  9. Max GautierMar 27, 2024
  10. 2/6 maintenance: use packaged systemd unitsMax Gautier, Mar 22, 2024
  11. Eric SunshineMar 23, 2024
  12. Max GautierMar 23, 2024
  13. 3/6 maintenance: simplify systemctl callsMax Gautier, Mar 22, 2024
  14. Eric SunshineMar 22, 2024
  15. Max GautierMar 23, 2024
  16. 1/6 maintenance: use systemd timers builtin randomizationMax Gautier, Mar 22, 2024
  17. 5/6 maintenance: update systemd scheduler docsMax Gautier, Mar 22, 2024
  18. 6/6 maintenance: update tests for systemd schedulerMax Gautier, Mar 22, 2024
  19. Eric SunshineMar 22, 2024
  20. Max GautierMar 23, 2024
  21. Phillip WoodMar 24, 2024
  22. Eric SunshineMar 24, 2024
  23. phillip.wood123@gmail.comMar 25, 2024
  24. Max GautierMar 25, 2024
  25. phillip.wood123@gmail.comMar 25, 2024
  26. Max GautierMar 25, 2024
  27. Phillip WoodMar 25, 2024
  28. Max GautierMar 25, 2024
  29. Phillip WoodMar 25, 2024
  30. Max GautierMar 27, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.