-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RPM triggers: rewrite in shell #8550
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAK.
You should really just implement a Lua subprocess thing in rpm-ostree.
src/core/triggers.systemd.in
Outdated
# upgraded. We care about the case where a package is initially | ||
# installed, because other cases are covered by the *un scriptlets, | ||
# so sometimes we will reload needlessly. | ||
if test -d /run/systemd/system; then %{_bindir}/systemctl daemon-reload; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any benefit in doing this one line? why not break this the way people would expect, i.e. in three lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine doing that if you prefer. I thought the one-liner emphasized just how much simpler shell is over Lua, but again I can easily change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we tend to prefer readability over density
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated to be multi-line ⬇️
src/core/triggers.systemd.in
Outdated
# This script will process files installed in @sysusersdir@ to create | ||
# specified users automatically. The priority is set such that it | ||
# will run before the tmpfiles file trigger. | ||
if test -d /run/systemd/system; then %{_bindir}/systemd-sysusers; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, why compress this into one line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mean, if you want to compress this into one line, why not do:
test -d … && …?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test -d … && …?
I actually did it that way to start, but then remember in shell that will result in exit 1
and hence RPM complaining about script failures... (and on a related note, in rpm-ostree by default script failures are fatal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Does rpm even have hooks for that? |
@poettering As rpm-ostree doesn't actually use librpm for most of its work, it's really up to @cgwalters to actually implement the functionality he's replacing. I'm not inclined to entertain this because the rewrite to Lua was deliberate to make the scriptlet execution safer and more predictable. |
b806a6a
to
0a458af
Compare
If we're talking about safety I think rpm-ostree provides more value to the FOSS ecosystem than having scripts written in Lua. We've written and maintain a system that allows you to always safely pull the power while preparing a system update. And you can still install packages. We go to a lot of effort to have Anyways, at some point we probably will do the "lua as external subprocess", but bear in mind that things were working fine for Fedora Atomic {Host,Workstation} before this code landed in systemd. |
src/core/triggers.systemd.in
Outdated
# installed, because other cases are covered by the *un scriptlets, | ||
# so sometimes we will reload needlessly. | ||
if test -d /run/systemd/system; then | ||
%{_bindir}/systemctl daemon-reload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other shell code uses 4ch indenting, no? please stick to the same across the whole file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, fixed ⬇️
src/core/triggers.systemd.in
Outdated
# specified users automatically. The priority is set such that it | ||
# will run before the tmpfiles file trigger. | ||
if test -d /run/systemd/system; then | ||
%{_bindir}/systemd-sysusers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
I might consider that, if it weren't for the fact it can't handle large classes of RPMs as it is. Nothing with |
This is compatible with rpm-ostree, which implements offline and transactional updates by creating a new root, sandboxing each RPM script in a bwrap container: coreos/rpm-ostree#749 Further, the "test for a directory and run a binary" pattern is significantly shorter and more obvious in shell script. Discussion in: systemd#8090 (comment) One counter was that this causes systemd to depend on `/bin/sh`, but that's true today in Fedora at least, and I'd be extremely surprised if there were a distribution where that wasn't the case. Down the line RPM could probably learn to omit `Requires` for `%transfiletrigger` on `/bin/sh`. Downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1559141
0a458af
to
9274509
Compare
I didn't notice this immediately, but as I read this now, I realize that what you're asking for is nuts. You realize that I can technically set any scriptlet to any interpreter I want, right? I can even set it to Perl, Python, or any other heavyweight interpreters. I could even set it to PowerShell! It would be asinine to even consider not exporting the interpreter requires for scriptlets... |
Do note the last two words in the (offhand) proposal: "on `/bin/sh". |
Hmm, so, I understand that the late landing of this feature in Fedora causes an issue for rpm-ostree. It would be reasonable to use your patch in Fedora for some time. (But note that the version in Fedora is already slightly different than the one upstream, since the upstream version does not support the split of systemd-udev subpackage). I'm not convinced that we want to replace lua with shell. I think that since it's legal (and encouraged) to use lua in Fedora, there will be more and more scriptlets using lua. Right now there aren't that many, but there are some. And right now we have a bazillion useless scriptlets, so a single one is barely noticeable. But the efforts to prune the useless ones significantly have already begun, and then the remaining scriptlets will be more visible, and the benefit from rewriting them in lua to reduce the dependencies a bit will be stronger. In the longer run, I expect that rpm-ostree will need to learn to run lua scriptlets too. And actually this shouldn't be too onerous: I know that the lua environment in rpm is a bit special, but afaik it differers primarily in the list of modules that are available, so it should be possible to recreate the same environment. What about doing this just in Fedora for the time beeing? |
That's OK with me. |
This was done with some urgency to un-break f28 beta for Atomic Host. |
Well, OK. Let's continue the discussion in the Fedora bugtracker. |
This fixes compatibility with rpm-ostree.
This fixes compatibility with rpm-ostree.
This is compatible with rpm-ostree, which implements offline and
transactional updates by creating a new root, sandboxing each RPM script
in a bwrap container: coreos/rpm-ostree#749
Further, the "test for a directory and run a binary" pattern is significantly
shorter and more obvious in shell script.
Discussion in: #8090 (comment)
One counter was that this causes systemd to depend on
/bin/sh
, but that'strue today in Fedora at least, and I'd be extremely surprised if there were a
distribution where that wasn't the case. Down the line RPM could probably
learn to omit
Requires
for%transfiletrigger
on/bin/sh
.Downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1559141