All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Gautier <mg@max.gautier.name>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: git@vger.kernel.org, "Lénaïc Huard" <lenaic@lhuard.fr>,
	"Derrick Stolee" <stolee@gmail.com>,
	"Patrick Steinhardt" <ps@pks.im>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v2 2/6] maintenance: use packaged systemd units
Date: Sat, 23 Mar 2024 10:52:48 +0100	[thread overview]
Message-ID: <Zf6mcBhd31WYkwob@framework> (raw)
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:
> 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.

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

> > +               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

  reply	other threads:[~2024-03-23  9:55 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 15:31 [RFC PATCH 0/5] maintenance: use packaged systemd units Max Gautier
2024-03-18 15:31 ` [RFC PATCH 1/5] maintenance: package " Max Gautier
2024-03-21 12:37   ` Patrick Steinhardt
2024-03-21 13:07     ` Max Gautier
2024-03-21 13:22       ` Patrick Steinhardt
2024-03-21 13:38     ` Max Gautier
2024-03-21 14:44       ` Patrick Steinhardt
2024-03-21 14:49         ` Max Gautier
2024-03-21 14:48       ` Max Gautier
2024-03-18 15:31 ` [RFC PATCH 2/5] maintenance: add fixed random delay to systemd timers Max Gautier
2024-03-21 12:37   ` Patrick Steinhardt
2024-03-21 13:13     ` Max Gautier
2024-03-18 15:31 ` [RFC PATCH 3/5] maintenance: use packaged systemd units Max Gautier
2024-03-19 12:09   ` Max Gautier
2024-03-19 17:17     ` Eric Sunshine
2024-03-19 18:19       ` Junio C Hamano
2024-03-19 19:38       ` Max Gautier
2024-03-21 12:37   ` Patrick Steinhardt
2024-03-21 13:19     ` Max Gautier
2024-03-18 15:31 ` [RFC PATCH 4/5] maintenance: update systemd scheduler docs Max Gautier
2024-03-21 12:37   ` Patrick Steinhardt
2024-03-18 15:31 ` [RFC PATCH 5/5] DON'T APPLY YET: maintenance: remove cleanup code Max Gautier
2024-03-22 22:11 ` [PATCH v2 0/6] maintenance: use packaged systemd units Max Gautier
2024-03-22 22:11   ` [PATCH v2 1/6] maintenance: use systemd timers builtin randomization Max Gautier
2024-03-22 22:11   ` [PATCH v2 2/6] maintenance: use packaged systemd units Max Gautier
2024-03-23  8:38     ` Eric Sunshine
2024-03-23  9:52       ` Max Gautier [this message]
2024-03-22 22:11   ` [PATCH v2 3/6] maintenance: simplify systemctl calls Max Gautier
2024-03-22 23:09     ` Eric Sunshine
2024-03-23 10:25       ` Max Gautier
2024-03-22 22:11   ` [PATCH v2 4/6] maintenance: cleanup $XDG_CONFIG_HOME/systemd/user Max Gautier
2024-03-22 22:38     ` Kristoffer Haugsbakk
2024-03-22 22:43       ` Junio C Hamano
2024-03-23 11:07     ` Max Gautier
2024-03-24 15:45       ` Phillip Wood
2024-03-25  8:36         ` Max Gautier
2024-03-25 16:39           ` Phillip Wood
2024-03-27 16:20             ` Max Gautier
2024-03-22 22:11   ` [PATCH v2 5/6] maintenance: update systemd scheduler docs Max Gautier
2024-03-22 22:11   ` [PATCH v2 6/6] maintenance: update tests for systemd scheduler Max Gautier
2024-03-22 23:02     ` Eric Sunshine
2024-03-23 10:28       ` Max Gautier
2024-03-24 14:54   ` [PATCH v2 0/6] maintenance: use packaged systemd units Phillip Wood
2024-03-24 17:03     ` Eric Sunshine
2024-03-25 10:08       ` phillip.wood123
2024-03-25  8:32     ` Max Gautier
2024-03-25 10:06       ` phillip.wood123
2024-03-25 12:27         ` Max Gautier
2024-03-25 16:39           ` Phillip Wood
2024-03-25 13:45         ` Max Gautier
2024-03-25 16:39           ` Phillip Wood
2024-03-27 16:21             ` Max Gautier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zf6mcBhd31WYkwob@framework \
    --to=mg@max.gautier.name \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lenaic@lhuard.fr \
    --cc=ps@pks.im \
    --cc=stolee@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.