1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

meson: use jinja2 for rpm templates

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-05-16 16:44:47 +02:00 committed by Yu Watanabe
parent d0f8006993
commit 835cf75aef
16 changed files with 102 additions and 87 deletions

View File

@ -221,9 +221,13 @@ status_unit_format_default = get_option('status-unit-format-default')
conf.set_quoted('PKGSYSCONFDIR', pkgsysconfdir)
conf.set_quoted('SYSTEM_CONFIG_UNIT_DIR', join_paths(pkgsysconfdir, 'system'))
conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
conf.set_quoted('SYSTEM_DATA_UNIT_DIR', systemunitdir)
conf.set_quoted('SYSTEM_PRESET_DIR', systempresetdir)
conf.set_quoted('USER_PRESET_DIR', userpresetdir)
conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
conf.set_quoted('UDEV_HWDB_DIR', udevhwdbdir)
conf.set_quoted('UDEV_RULES_DIR', udevrulesdir)
conf.set_quoted('RC_LOCAL_PATH', get_option('rc-local'))
conf.set('ANSI_OK_COLOR', 'ANSI_' + get_option('ok-color').underscorify().to_upper())
@ -259,6 +263,13 @@ conf.set_quoted('SYSTEMD_KBD_MODEL_MAP', join_paths(pkgdata
conf.set_quoted('SYSTEMD_LANGUAGE_FALLBACK_MAP', join_paths(pkgdatadir, 'language-fallback-map'))
conf.set_quoted('SYSTEMD_TEST_DATA', join_paths(testsdir, 'testdata'))
conf.set_quoted('SYSTEMD_CATALOG_DIR', catalogdir)
conf.set_quoted('BINFMT_DIR', binfmtdir)
conf.set_quoted('SYSCTL_DIR', sysctldir)
conf.set_quoted('SYSUSERS_DIR', sysusersdir)
conf.set_quoted('TMPFILES_DIR', tmpfilesdir)
conf.set_quoted('ENVIRONMENT_DIR', environmentdir)
conf.set_quoted('MODULESLOAD_DIR', modulesloaddir)
conf.set_quoted('MODPROBE_DIR', modprobedir)
conf.set_quoted('UDEVLIBEXECDIR', udevlibexecdir)
conf.set_quoted('POLKIT_AGENT_BINARY_PATH', join_paths(bindir, 'pkttyagent'))
conf.set_quoted('LIBDIR', libdir)

View File

@ -622,7 +622,7 @@ int lookup_paths_init(
STRV_IFNOTNULL(runtime_attached),
STRV_IFNOTNULL(generator),
"/usr/local/lib/systemd/system",
SYSTEM_DATA_UNIT_PATH,
SYSTEM_DATA_UNIT_DIR,
"/usr/lib/systemd/system",
STRV_IFNOTNULL(flags & LOOKUP_PATHS_SPLIT_USR ? "/lib/systemd/system" : NULL),
STRV_IFNOTNULL(generator_late));

View File

@ -62,7 +62,7 @@ int main(int argc, char *argv[]) {
* even emergency.target. */
p = strjoina(arg_dest, "/" SPECIAL_BASIC_TARGET ".wants/systemd-bless-boot.service");
(void) mkdir_parents(p, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-bless-boot.service", p) < 0) {
if (symlink(SYSTEM_DATA_UNIT_DIR "/systemd-bless-boot.service", p) < 0) {
log_error_errno(errno, "Failed to create symlink '%s': %m", p);
return EXIT_FAILURE;
}

View File

@ -134,7 +134,7 @@ static int generate_wants_symlinks(void) {
if (!p)
return log_oom();
f = path_join(SYSTEM_DATA_UNIT_PATH, *u);
f = path_join(SYSTEM_DATA_UNIT_DIR, *u);
if (!f)
return log_oom();

View File

@ -881,7 +881,7 @@ static int add_volatile_root(void) {
return 0;
return generator_add_symlink(arg_dest, SPECIAL_INITRD_ROOT_FS_TARGET, "requires",
SYSTEM_DATA_UNIT_PATH "/" SPECIAL_VOLATILE_ROOT_SERVICE);
SYSTEM_DATA_UNIT_DIR "/" SPECIAL_VOLATILE_ROOT_SERVICE);
}
static int add_volatile_var(void) {

View File

@ -28,7 +28,7 @@ static int add_symlink(const char *fservice, const char *tservice) {
assert(fservice);
assert(tservice);
from = strjoina(SYSTEM_DATA_UNIT_PATH "/", fservice);
from = strjoina(SYSTEM_DATA_UNIT_DIR "/", fservice);
to = strjoina(arg_dest, "/getty.target.wants/", tservice);
mkdir_parents_label(to, 0755);

View File

@ -85,7 +85,7 @@ static int process_resume(void) {
return log_oom();
mkdir_parents_label(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0)
if (symlink(SYSTEM_DATA_UNIT_DIR "/systemd-hibernate-resume@.service", lnk) < 0)
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
r = unit_name_from_path(arg_resume_device, ".device", &device_unit);

View File

@ -325,7 +325,7 @@ static int get_path(uint64_t type, char **buffer, const char **ret) {
return 0;
case SD_PATH_SYSTEMD_SYSTEM_UNIT:
*ret = SYSTEM_DATA_UNIT_PATH;
*ret = SYSTEM_DATA_UNIT_DIR;
return 0;
case SD_PATH_SYSTEMD_SYSTEM_PRESET:

View File

@ -24,7 +24,7 @@ static int add_symlink(const char *service, const char *where) {
assert(service);
assert(where);
from = strjoina(SYSTEM_DATA_UNIT_PATH "/", service);
from = strjoina(SYSTEM_DATA_UNIT_DIR "/", service);
to = strjoina(arg_dest, "/", where, ".wants/", service);
(void) mkdir_parents_label(to, 0755);

View File

@ -5,25 +5,25 @@
# RPM macros for packages installing systemd unit files
%_systemd_util_dir @rootlibexecdir@
%_unitdir @systemunitdir@
%_userunitdir @userunitdir@
%_presetdir @systempresetdir@
%_userpresetdir @userpresetdir@
%_udevhwdbdir @udevhwdbdir@
%_udevrulesdir @udevrulesdir@
%_journalcatalogdir @catalogdir@
%_binfmtdir @binfmtdir@
%_sysctldir @sysctldir@
%_sysusersdir @sysusersdir@
%_tmpfilesdir @tmpfilesdir@
%_environmentdir @environmentdir@
%_modulesloaddir @modulesloaddir@
%_modprobedir @modprobedir@
%_systemdgeneratordir @systemgeneratordir@
%_systemdusergeneratordir @usergeneratordir@
%_systemd_system_env_generator_dir @systemenvgeneratordir@
%_systemd_user_env_generator_dir @userenvgeneratordir@
%_systemd_util_dir {{ROOTLIBEXECDIR}}
%_unitdir {{SYSTEM_DATA_UNIT_DIR}}
%_userunitdir {{USER_DATA_UNIT_DIR}}
%_presetdir {{SYSTEM_PRESET_DIR}}
%_userpresetdir {{USER_PRESET_DIR}}
%_udevhwdbdir {{UDEV_HWDB_DIR}}
%_udevrulesdir {{UDEV_RULES_DIR}}
%_journalcatalogdir {{SYSTEMD_CATALOG_DIR}}
%_binfmtdir {{BINFMT_DIR}}
%_sysctldir {{SYSCTL_DIR}}
%_sysusersdir {{SYSUSERS_DIR}}
%_tmpfilesdir {{TMPFILES_DIR}}
%_environmentdir {{ENVIRONMENT_DIR}}
%_modulesloaddir {{MODULESLOAD_DIR}}
%_modprobedir {{MODPROBE_DIR}}
%_systemdgeneratordir {{SYSTEM_GENERATOR_DIR}}
%_systemdusergeneratordir {{USER_GENERATOR_DIR}}
%_systemd_system_env_generator_dir {{SYSTEM_ENV_GENERATOR_DIR}}
%_systemd_user_env_generator_dir {{USER_ENV_GENERATOR_DIR}}
# Because we had one release with a typo...
# This is temporary (Remove after systemd 240 is released)
@ -162,10 +162,10 @@ SYSTEMD_INLINE_EOF\
%sysctl_apply() \
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysctl_apply}} \
[ -x @rootlibexecdir@/systemd-sysctl ] && @rootlibexecdir@/systemd-sysctl %{?*} || : \
[ -x {{ROOTLIBEXECDIR}}/systemd-sysctl ] && {{ROOTLIBEXECDIR}}/systemd-sysctl %{?*} || : \
%{nil}
%binfmt_apply() \
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# binfmt_apply}} \
[ -x @rootlibexecdir@/systemd-binfmt ] && @rootlibexecdir@/systemd-binfmt %{?*} || : \
[ -x {{ROOTLIBEXECDIR}}/systemd-binfmt ] && {{ROOTLIBEXECDIR}}/systemd-binfmt %{?*} || : \
%{nil}

View File

@ -1,18 +1,22 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
configure_file(
input : 'macros.systemd.in',
output : 'macros.systemd',
configuration : substs,
install_dir : rpmmacrosdir == 'no' ? '' : rpmmacrosdir)
in_files = [
['macros.systemd', rpmmacrosdir != 'no'],
['triggers.systemd', false],
['triggers.systemd.sh', false]]
# Those doesn't get installed anywhere, one of them needs to included in the
# rpm spec file definition.
configure_file(
input : 'triggers.systemd.in',
output : 'triggers.systemd',
configuration : substs)
configure_file(
input : 'triggers.systemd.sh.in',
output : 'triggers.systemd.sh',
configuration : substs)
# The last two don't get installed anywhere, one of them needs to included in
# the rpm spec file definition instead.
foreach tuple : in_files
file = tuple[0]
custom_target(
file,
input : file + '.in',
output : file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
install : tuple[1],
install_dir : rpmmacrosdir,
build_by_default : true)
endforeach

View File

@ -8,7 +8,7 @@
#
# Minimum rpm version supported: 4.14.0
%transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
%transfiletriggerin -P 900900 -p <lua> -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
-- This script will run after any package is initially installed or
-- upgraded. We care about the case where a package is initially
-- installed, because other cases are covered by the *un scriptlets,
@ -29,7 +29,7 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
%transfiletriggerpostun -P 1000100 -p <lua> -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
-- On removal, we need to run daemon-reload after any units have been
-- removed.
-- On upgrade, we need to run daemon-reload after any new unit files
@ -44,7 +44,7 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerpostun -P 10000 -p <lua> -- @systemunitdir@ /etc/systemd/system
%transfiletriggerpostun -P 10000 -p <lua> -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
-- We restart remaining services that should be restarted here.
if posix.access("/run/systemd/system") then
pid = posix.fork()
@ -55,8 +55,8 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
-- This script will process files installed in @sysusersdir@ to create
%transfiletriggerin -P 100700 -p <lua> -- {{SYSUSERS_DIR}}
-- This script will process files installed in {{SYSUSERS_DIR}} to create
-- specified users automatically. The priority is set such that it
-- will run before the tmpfiles file trigger.
if posix.access("/run/systemd/system") then
@ -68,9 +68,9 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 1000700 udev -p <lua> -- @udevhwdbdir@
%transfiletriggerin -P 1000700 udev -p <lua> -- {{UDEV_HWDB_DIR}}
-- This script will automatically invoke hwdb update if files have been
-- installed or updated in @udevhwdbdir@.
-- installed or updated in {{UDEV_HWDB_DIR}}.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
@ -80,9 +80,9 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 1000700 -p <lua> -- @catalogdir@
%transfiletriggerin -P 1000700 -p <lua> -- {{SYSTEMD_CATALOG_DIR}}
-- This script will automatically invoke journal catalog update if files
-- have been installed or updated in @catalogdir@.
-- have been installed or updated in {{SYSTEMD_CATALOG_DIR}}.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
@ -92,20 +92,20 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 1000700 -p <lua> -- @binfmtdir@
%transfiletriggerin -P 1000700 -p <lua> -- {{BINFMT_DIR}}
-- This script will automatically apply binfmt rules if files have been
-- installed or updated in @binfmtdir@.
-- installed or updated in {{BINFMT_DIR}}.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))
assert(posix.exec("{{ROOTLIBEXECDIR}}/systemd-binfmt"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -P 1000600 -p <lua> -- @tmpfilesdir@
-- This script will process files installed in @tmpfilesdir@ to create
%transfiletriggerin -P 1000600 -p <lua> -- {{TMPFILES_DIR}}
-- This script will process files installed in {{TMPFILES_DIR}} to create
-- tmpfiles automatically. The priority is set such that it will run
-- after the sysusers file trigger, but before any other triggers.
if posix.access("/run/systemd/system") then
@ -117,9 +117,9 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 1000600 udev -p <lua> -- @udevrulesdir@
%transfiletriggerin -P 1000600 udev -p <lua> -- {{UDEV_RULES_DIR}}
-- This script will automatically update udev with new rules if files
-- have been installed or updated in @udevrulesdir@.
-- have been installed or updated in {{UDEV_RULES_DIR}}.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
@ -129,13 +129,13 @@ if posix.access("/run/systemd/system") then
end
end
%transfiletriggerin -P 1000500 -p <lua> -- @sysctldir@
%transfiletriggerin -P 1000500 -p <lua> -- {{SYSCTL_DIR}}
-- This script will automatically apply sysctl rules if files have been
-- installed or updated in @sysctldir@.
-- installed or updated in {{SYSCTL_DIR}}.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
assert(posix.exec("{{ROOTLIBEXECDIR}}/systemd-sysctl"))
elseif pid > 0 then
posix.wait(pid)
end

View File

@ -9,7 +9,7 @@
#
# Minimum rpm version supported: 4.14.0
%transfiletriggerin -P 900900 -- @systemunitdir@ /etc/systemd/system
%transfiletriggerin -P 900900 -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
# This script will run after any package is initially installed or
# upgraded. We care about the case where a package is initially
# installed, because other cases are covered by the *un scriptlets,
@ -19,7 +19,7 @@ if test -d "/run/systemd/system"; then
%{_bindir}/systemctl reload-or-restart --marked || :
fi
%transfiletriggerpostun -P 1000100 -- @systemunitdir@ /etc/systemd/system
%transfiletriggerpostun -P 1000100 -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
# On removal, we need to run daemon-reload after any units have been
# removed.
# On upgrade, we need to run daemon-reload after any new unit files
@ -29,61 +29,61 @@ if test -d "/run/systemd/system"; then
%{_bindir}/systemctl daemon-reload || :
fi
%transfiletriggerpostun -P 10000 -- @systemunitdir@ /etc/systemd/system
%transfiletriggerpostun -P 10000 -- {{SYSTEM_DATA_UNIT_DIR}} /etc/systemd/system
# We restart remaining services that should be restarted here.
if test -d "/run/systemd/system"; then
%{_bindir}/systemctl reload-or-restart --marked || :
fi
%transfiletriggerin -P 1000700 -- @sysusersdir@
# This script will process files installed in @sysusersdir@ to create
%transfiletriggerin -P 1000700 -- {{SYSUSERS_DIR}}
# This script will process files installed in {{SYSUSERS_DIR}} 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
%transfiletriggerin -P 1000700 udev -- @udevhwdbdir@
%transfiletriggerin -P 1000700 udev -- {{UDEV_HWDB_DIR}}
# This script will automatically invoke hwdb update if files have been
# installed or updated in @udevhwdbdir@.
# installed or updated in {{UDEV_HWDB_DIR}}.
if test -d "/run/systemd/system"; then
%{_bindir}/systemd-hwdb update || :
fi
%transfiletriggerin -P 1000700 -- @catalogdir@
%transfiletriggerin -P 1000700 -- {{SYSTEMD_CATALOG_DIR}}
# This script will automatically invoke journal catalog update if files
# have been installed or updated in @catalogdir@.
# have been installed or updated in {{SYSTEMD_CATALOG_DIR}}.
if test -d "/run/systemd/system"; then
%{_bindir}/journalctl --update-catalog || :
fi
%transfiletriggerin -P 1000700 -- @binfmtdir@
%transfiletriggerin -P 1000700 -- {{BINFMT_DIR}}
# This script will automatically apply binfmt rules if files have been
# installed or updated in @binfmtdir@.
# installed or updated in {{BINFMT_DIR}}.
if test -d "/run/systemd/system"; then
# systemd-binfmt might fail if binfmt_misc kernel module is not loaded
# during install
@rootlibexecdir@/systemd-binfmt || :
{{ROOTLIBEXECDIR}}/systemd-binfmt || :
fi
%transfiletriggerin -P 1000600 -- @tmpfilesdir@
# This script will process files installed in @tmpfilesdir@ to create
%transfiletriggerin -P 1000600 -- {{TMPFILES_DIR}}
# This script will process files installed in {{TMPFILES_DIR}} to create
# tmpfiles automatically. The priority is set such that it will run
# after the sysusers file trigger, but before any other triggers.
if test -d "/run/systemd/system"; then
%{_bindir}/systemd-tmpfiles --create || :
fi
%transfiletriggerin -P 1000600 udev -- @udevrulesdir@
%transfiletriggerin -P 1000600 udev -- {{UDEV_RULES_DIR}}
# This script will automatically update udev with new rules if files
# have been installed or updated in @udevrulesdir@.
# have been installed or updated in {{UDEV_RULES_DIR}}.
if test -e /run/udev/control; then
%{_bindir}/udevadm control --reload || :
fi
%transfiletriggerin -P 1000500 -- @sysctldir@
%transfiletriggerin -P 1000500 -- {{SYSCTL_DIR}}
# This script will automatically apply sysctl rules if files have been
# installed or updated in @sysctldir@.
# installed or updated in {{SYSCTL_DIR}}.
if test -d "/run/systemd/system"; then
@rootlibexecdir@/systemd-sysctl || :
{{ROOTLIBEXECDIR}}/systemd-sysctl || :
fi

View File

@ -185,7 +185,7 @@ int generator_write_fsck_deps(
lnk = strjoina(dir, "/" SPECIAL_LOCAL_FS_TARGET ".wants/" SPECIAL_FSCK_ROOT_SERVICE);
(void) mkdir_parents(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/" SPECIAL_FSCK_ROOT_SERVICE, lnk) < 0)
if (symlink(SYSTEM_DATA_UNIT_DIR "/" SPECIAL_FSCK_ROOT_SERVICE, lnk) < 0)
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
} else {
@ -561,7 +561,7 @@ int generator_hook_up_growfs(
int generator_enable_remount_fs_service(const char *dir) {
/* Pull in systemd-remount-fs.service */
return generator_add_symlink(dir, SPECIAL_LOCAL_FS_TARGET, "wants",
SYSTEM_DATA_UNIT_PATH "/" SPECIAL_REMOUNT_FS_SERVICE);
SYSTEM_DATA_UNIT_DIR "/" SPECIAL_REMOUNT_FS_SERVICE);
}
int generator_write_blockdev_dependency(

View File

@ -247,7 +247,7 @@ static int path_is_vendor_or_generator(const LookupPaths *p, const char *path) {
if (path_is_generator(p, rpath))
return true;
return path_equal(rpath, SYSTEM_DATA_UNIT_PATH);
return path_equal(rpath, SYSTEM_DATA_UNIT_DIR);
}
static const char* config_path_from_flags(const LookupPaths *paths, UnitFileFlags flags) {

View File

@ -30,7 +30,7 @@ static int generate_symlink(void) {
}
p = strjoina(arg_dest, "/" SPECIAL_DEFAULT_TARGET);
if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0)
if (symlink(SYSTEM_DATA_UNIT_DIR "/system-update.target", p) < 0)
return log_error_errno(errno, "Failed to create symlink %s: %m", p);
return 1;