summaryrefslogtreecommitdiffstats
path: root/src/rpm (follow)
Commit message (Collapse)AuthorAgeFilesLines
* rpm: mark udevd for reloading when an rules file is installed/updatedYu Watanabe8 days2-6/+2
| | | | | Then, we can avoid using udevadm (especially udev control socket) in processing rpm.
* systemd-update-helper: Show executed commands if debug logging is enabledDaan De Meyer2024-10-111-0/+4
|
* rpm/systemd-update-helper: Use systemctl reload to reexec/reload user managersDaan De Meyer2024-10-111-16/+4
| | | | | | | Let's always use systemctl reload to reexec and reload user managers now that it always implies a reexec. This moves all the job management logic to pid 1 instead of bash and reduces the complexity of the logic as we remove systemd-run, pam and systemd-stdio-bridge from the equation.
* Add %posttrans versions of the systemd %postun scriptletsDaan De Meyer2024-10-011-0/+32
| | | | | | | | | | | | | | | On upgrades, only the %postun scriptlets of the old package version run. This means that any changes related to restarting daemons require two releases before they're actually used. %postun is used because it runs after the old package has been removed, which is important as it means any lingering dropins from the old package will have been removed as well. To allow deploying fixes in just a single release while still running after the old package has been removed, let's introduce %posttrans versions of these scriptlets as %posttrans of the new package runs on upgrade and install after the old package has been removed.
* rpm/macros: add %_kernel_install_dirZbigniew Jędrzejewski-Szmek2024-02-291-0/+1
| | | | | | | | | | This makes it easier for people packaging kernel-install plugins to get the path right. E.g. https://src.fedoraproject.org/rpms/python-virt-firmware/pull-request/3 fixes an issue where %{_libdir}/kernel/install.d was used, which gives incorrect results on 64-bit architectures. %_kernel_install_dir will make this even easier.
* rpm/macros: drop compat define with a typoZbigniew Jędrzejewski-Szmek2024-02-291-4/+0
| | | | | | Search on sourcegraph.com doesn't yield any users. And each use would emit a warning, so I think it's safe to assume that it has no users.
* rpm: add %systemd_user_daemon_reexecZbigniew Jędrzejewski-Szmek2023-08-071-0/+7
| | | | | | | | | | This macros wraps the call to daemon-reexec in all user managers. It would be called for example from systemd %post right after the call to systemctl daemon-reexec. This will be used in the Fedora systemd package to fix a long-standing FIXME. Tested via building and reinstalling the systemd package with the patches.
* rpm: use rpm.execute() in more casesZbigniew Jędrzejewski-Szmek2023-08-071-48/+8
| | | | | | 7bde8293a4f4ccfe4b5c5000869068e3c1ac45c6 converted all the posix.execp() calls, but I do not see why we shouldn't also convert the posix.exec() calls.
* rpm: add %systemd_postun_with_reload and %systemd_user_postun_with_reloadZbigniew Jędrzejewski-Szmek2023-08-072-0/+38
| | | | | | | | | | | | | | | | | | | For some units, the package would like to issue a reload. The machinery was already in place since c9615f73521986b3607b852c139036d58973043c: systemctl reload-or-restart --marked Enqueues restart jobs for all units that have the 'needs-restart' mark, and reload jobs for units that have the 'needs-reload' mark. When a unit marked for reload does not support reload, restart will be queued. The new macros allow a reload to be issued instead of a restart. Based on the discussion on fedora-devel: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/IJSUGIEJNYZZRE53FF4YFUEBRHRAVIXR/ Tested using dummy package https://github.com/keszybz/rpm-test-reload.
* Drop split-usr and unmerged-usr supportLuca Boccassi2023-07-284-9/+9
| | | | | | | | | | As previously announced, execute order 66: https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html The meson options split-usr, rootlibdir and rootprefix become no-ops that print a warning if they are set to anything other than the default values. We can remove them in a future release.
* rpm: fix lua trigger priority for sysusersFranck Bui2023-06-221-1/+1
| | | | | Commit cd621954ed643c6ee0d869132293e26056a48826 probably forgot to fix the lua implementation.
* core: split system/user job timeouts and make them configurableZbigniew Jędrzejewski-Szmek2023-02-011-5/+5
| | | | | | | | | | | | | | | | Config options are -Ddefault-timeout-sec= and -Ddefault-user-timeout-sec=. Existing -Dupdate-helper-user-timeout= is renamed to -Dupdate-helper-user-timeout-sec= for consistency. All three options take an integer value in seconds. The renaming and type-change of the option is a small compat break, but it's just at compile time and result in a clear error message. I also doubt that anyone was actually using the option. This commit separates the user manager timeouts, but keeps them unchanged at 90 s. The timeout for the user manager is set to 4/3*user-timeout, which means that it is still 120 s. Fedora wants to experiment with lower timeouts, but doing this via a patch would be annoying and more work than necessary. Let's make this easy to configure.
* rpm/systemd-update-helper: use --no-warn when disabling unitsMike Yuan2022-12-031-4/+4
| | | | Suppress the "empty [Install] section" warning (see #25437).
* pkgconfig,rpm: expose vars for user-tmpfiles.d locationZbigniew Jędrzejewski-Szmek2022-06-211-0/+1
| | | | Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2098553.
* rpm: adjust lua trigger for udevadmTomasz Paweł Gajc2022-05-281-1/+1
|
* rpm: use rpm.execute() instead of fork() and execp() for trigger scripletsTomasz Paweł Gajc2022-05-281-32/+5
|
* rpm: remove check if systemd is running in a few casesZbigniew Jędrzejewski-Szmek2022-05-162-30/+18
| | | | | | | | | | | | | | | | | | | | | | | | | rpms can be installed in two different modes: into a chroot, where the system is not running, and onto a live system. In the first mode, where should create all changes that are "permanent", and in the second mode, all changes which are "permanent" but also those which only affect the running system. Thus, changes like new modprobe rules, tmpfiles rules, binfmt rules, udev rules, etc., are guarded by 'test -d "/run/systemd/system"' which is the official way to check if systemd is running, so that they are *not* executed when installed into a chroot. But the same logic does not apply to sysusers, hwdb, and the journal catalog: all those files can and should result in changes being performed immediately to the system. This makes the creation of immutable images possible (because there are no permanent changes to executed after a reboot), and allows other packages to depend on the the effect of those changes. Thus, the guard to check if we're not in a chroot is dropped from triggers for sysusers, hwdb, and the journal catalog. This means that those triggers will execute, and no subsequent work is needed. systemd-sysusers.service, systemd-journal-catalog-update.service, and systemd-hwdb-update.service.in all have ConditionNeedsUpdate= so they they generally won't be invoked after a reboot. (systemd.rpm does not touch /usr to trigger the condition, because the %transfiletriggers make that unnecessary.) https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2085481
* meson: also allow setting GIT_VERSION via templatesZbigniew Jędrzejewski-Szmek2022-04-051-1/+1
| | | | | | | | | GIT_VERSION is not available as a config.h variable, because it's rendered into version.h during builds. Let's rework jinja2 rendering to also parse version.h. No functional change, the new variable is so far unused. I guess this will make partial rebuilds a bit slower, but it's useful to be able to use the full version string.
* Change all fixed-path bash shebangs to /u/b/env bash outside test/наб2021-12-121-1/+1
|
* meson: drop mode setting on systemd-update-helperZbigniew Jędrzejewski-Szmek2021-11-141-2/+1
| | | | | With a6d1760024d0884efb343e1c739f303619f7c8b9, this shouldn't be necessary anymore.
* build: preserve correct mode when generating files via jinja2Christian Brauner2021-11-081-2/+1
| | | | | | | | | When using "capture : true" in custom_target()s the mode of the source file is not preserved when the generated file is not installed and so needs to be tweaked manually. Switch from output capture to creating the target file and copy the permissions from the input file. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
* update-helper: add missing loop over user unitsZbigniew Jędrzejewski-Szmek2021-11-041-2/+4
| | | | | | | Noticed by Luca. shellcheck doens't catch this, and somehow it was missed in review and testing ;(
* licensing: add forgotten spdx headersZbigniew Jędrzejewski-Szmek2021-10-011-0/+1
| | | | | Those are all "our" files, but we forgot to add the headers, most likely because of non-standard file extensions.
* update-helper: also add "user-reexec" verbZbigniew Jędrzejewski-Szmek2021-07-241-1/+9
| | | | | | | | This is not called from the systemd.triggers or systemd.macros files. Instead, it would be called from the scriptlets in systemd rpm package itself, at the place where we call systemctl daemon-reexec. See https://github.com/systemd/systemd/pull/20289#issuecomment-885622200 .
* rpm: restart user services at the end of the transactionZbigniew Jędrzejewski-Szmek2021-07-244-3/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This closes an important gap: so far we would reexecute the system manager and restart system services that were configured to do so, but we wouldn't do the same for user managers or user services. The scheme used for user managers is very similar to the system one, except that there can be multiple user managers running, so we query the system manager to get a list of them, and then tell each one to do the equivalent operations: daemon-reload, disable --now, set-property Markers=+needs-restart, reload-or-restart --marked. The total time that can be spend on this is bounded: we execute the commands in parallel over user managers and units, and additionally set SYSTEMD_BUS_TIMEOUT to a lower value (15 s by default). User managers should not have too many units running, and they should be able to do all those operations very quickly (<< 1s). The final restart operation may take longer, but it's done asynchronously, so we only wait for the queuing to happen. The advantage of doing this synchronously is that we can wait for each step to happen, and for example daemon-reloads can finish before we execute the service restarts, etc. We can also order various steps wrt. to the phases in the rpm transaction. When this was initially proposed, we discussed a more relaxed scheme with bus property notifications. Such an approach would be more complex because a bunch of infrastructure would have to be added to system manager to propagate appropriate notifications to the user managers, and then the user managers would have to wait for them. Instead, now there is no new code in the managers, all new functionality is contained in src/rpm/. The ability to call 'systemctl --user user@' makes this approach very easy. Also, it would be very hard to order the user manager steps and the rpm transaction steps. Note: 'systemctl --user disable' is only called for a user managers that are running. I don't see a nice way around this, and it shouldn't matter too much: we'll just leave a dangling symlink in the case where the user enabled the service manually. A follow-up for https://bugzilla.redhat.com/show_bug.cgi?id=1792468 and fa97d2fcf64e0558054bee673f734f523373b146.
* rpm: call +needs-restart in parallelZbigniew Jędrzejewski-Szmek2021-07-241-1/+2
| | | | | | Some rpms install a bunch of units… It seems nicer to invoke them all in parallel. In particular, timeouts in systemctl also run in parallel, so if there's some communication mishap, we will wait less.
* rpm: use a helper script to actually invoke systemctl commandsZbigniew Jędrzejewski-Szmek2021-07-245-57/+102
| | | | | | | | | | | | | | | | | | | | | | | Instead of embedding the commands to invoke directly in the macros, let's use a helper script as indirection. This has a couple of advantages: - the macro language is awkward, we need to suffix most commands by "|| :" and "\", which is easy to get wrong. In the new scheme, the macro becomes a single simple command. - in the script we can use normal syntax highlighting, shellcheck, etc. - it's also easier to test the invoked commands by invoking the helper manually. - most importantly, the logic is contained in the helper, i.e. we can update systemd rpm and everything uses the new helper. Before, we would have to rebuild all packages to update the macro definition. This raises the question whether it makes sense to use the lua scriptlets when the real work is done in a bash script. I think it's OK: we still have the efficient lua scripts that do the short scripts, and we use a single shared implementation in bash to do the more complex stuff. The meson version is raised to 0.47 because that's needed for install_mode. We were planning to raise the required version anyway…
* rpm: don't specify the full path for systemctl and other commandsZbigniew Jędrzejewski-Szmek2021-07-213-30/+30
| | | | | | | | | We can make things a bit simpler and more readable by not specifying the path. Since we didn't specify the full path for all commands (including those invoked recursively by anythign we invoke), this didn't really privide any security or robustness benefits. I guess that full paths were used because this style of rpm packagnig was popular in the past, with macros used for everything possible, with special macros for common commands like %{__ln} and %{__mkdir}.
* meson: use jinja2 for rpm templatesZbigniew Jędrzejewski-Szmek2021-05-194-74/+78
| | | | | | | The naming of variables is very inconsistent. I tried to use more modern style naming (UNDERSCORED_TITLE_CASE), but I didn't change existing names too much. Only SYSTEM_DATA_UNIT_PATH is renamed to SYSTEM_DATA_UNIT_DIR to match SYSTEM_CONFIG_UNIT_DIR.
* rpm: use %_bindir not @bindir@Zbigniew Jędrzejewski-Szmek2021-05-191-12/+12
| | | | | We were using both in various places. To keep things simple, let rpm do the substitution.
* rpm: when disabling a unit, do not complain if systemd is not runningZbigniew Jędrzejewski-Szmek2021-03-311-10/+14
| | | | | | | | | | | | | | | | | | | | | | $ sudo dnf remove --installroot=/var/tmp/img1 systemd-networkd ... Running scriptlet: systemd-networkd-248~rc4-4.fc32.x86_64 1/1 Removed /etc/systemd/system/multi-user.target.wants/systemd-networkd.service. Removed /etc/systemd/system/sockets.target.wants/systemd-networkd.socket. Removed /etc/systemd/system/dbus-org.freedesktop.network1.service. Removed /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service. System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down (Another option would be make --now do nothing if systemd is not running. But I think that's not too good. 'disable --now' doing nothing would be OK, since if systemd is not running, the service is not running either, so we are in the desired state. But that argument doesn't work for 'enable --now'. And accepting 'disable --now' but not 'enable --now' seems overly complex. So I think it is better to make the scriptlet handle this case explicitly.) Also, let's reindent the file to 4 spaces. Very deeply nested scriptlets are harder to read, and the triggers file is indented to 4 spaces already.
* rpm: restart services in %posttransZbigniew Jędrzejewski-Szmek2021-02-153-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes a long-standing issue in packaging scriptlets: daemon-reload was moved to the end of the transaction, but restarting services was still straightaway after package installation. https://bugzilla.redhat.com/show_bug.cgi?id=1614751 Note that daemon-reload is called twice. This wouldn't be hardly noticable, except that now a bunch of units (at least in Fedora) generate very verbose warnings about deprecated features. So we get those warnings twice… reload-or-restart --needing-restart is also called twice, but the second call is usually a noop, because the first clears the flag for restarted units. The second call is necessary for the case where we only uninstall packages, and the %transfiletriggerpostun trigger fires, but not the %transfiletriggerin scriptlet. Also note that this assumes that units are marked only for restart if paths under @systemunitdir@ or /etc/systemd/system have been touched. I would prefer make the trigger that does 'restart --needing-restart' fire always, but it seems rpm doesn't have such functionality. (Except as a %transfiletrigger that would trigger on "/*" to catch all transactions, but that seems ineffiecient and ugly.)
* rpm: order sysctl/sysusers/tmpfiles execution before package scriptletsZbigniew Jędrzejewski-Szmek2021-02-152-47/+47
| | | | | | | | | | | | | | P>1000000 is *before* "normal" scriptlets, P<1000000 is *after*. I think it makes sense to do stuff like execution of sysctl/sysusers/tmpfiles configuration before package scriptlets. I think that was the intent, but a single digit got dropped ;( Also, let's reorder the scriptlets in the file to match execution order, to make it easier to see what is going on. Most of those may happen in any order, but there are some exceptions: tmpfiles should be after sysusers, udevadm --reload should be after hwdb.
* rpm: simplify daemon-reload triggerZbigniew Jędrzejewski-Szmek2021-02-152-42/+8
| | | | | | | | The trigger was initially written to use %transfiletriggerun instead of %transfiletriggerpostun because the latter would not fire. It turned out to a buffer overread in rpm that since has been long fixed: https://bugzilla.redhat.com/show_bug.cgi?id=1284645 https://github.com/rpm-software-management/rpm/commit/f6521c50f6836374a0f7995f8f393aaf36e178ea
* rpm: sync the shell version of triggers.systemd with the lua versionZbigniew Jędrzejewski-Szmek2021-02-152-48/+34
| | | | | | | | Note that this goes both ways: in particular the lua version had udev scriptlets in the wrong package, fixed in https://src.fedoraproject.org/rpms/systemd/c/3c9433d7cf4afc8d76660402f6c3d9d991596b83. Add missing "|| :" so the scriptlets never fail.
* rpm: pull in the alternative trigger implementation in shZbigniew Jędrzejewski-Szmek2021-02-152-2/+117
| | | | | | | | | | | | | | | | | | From https://src.fedoraproject.org/rpms/systemd/blob/master/f/triggers.systemd. In 12dde791d519bc80d5cca4ab6f088763cd481015 scriptlets were converted to lua. This is not only faster and cleaner, but also avoids a nasty dependency loop: rpm implements the lua scripting internally, so we don't need a working shell for the scriplets. This is nice and all, but unfortunately ostree wants to capture scriptlets and execute them at a later time and does not support lua. So in Fedora we ended up with a revert back to a shell-based implementation [1]. At the time I hoped this would only be a temporary workaround, but three years later I think it's fair to assume that this will not happen any time soon. But carrying the upstream lua version and the downstream sh version is error prone. So let's import the other version into our tree too so that they can be kept in sync. [1] https://src.fedoraproject.org/rpms/systemd/c/8e6b39457b3e2660793821e0524855226e33e306
* Move rpm stuff into a separate src/rpm/ directoryZbigniew Jędrzejewski-Szmek2021-02-153-0/+322
It is only of interest to rpm-based distros, we can move it out of src/core/ which is pretty busy.