From b1c4ca25bf58e1925012d1dcdd83d61cecbf87fb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 4 Jan 2013 21:48:47 +0100 Subject: [PATCH] build-sys: make rc-local support part of SYSV compat This also drops automatic selection of the rc local scripts based on the local distro. Distributions now should specify the paths of the rc-local and halt-local scripts on the configure command line. --- Makefile.am | 41 ++++--------------- configure.ac | 21 ++++++++++ src/rc-local-generator/rc-local-generator.c | 14 +++---- units/.gitignore | 2 + units/fedora/Makefile | 1 - ...lt-local.service => halt-local.service.in} | 6 +-- .../rc-local.service => rc-local.service.in} | 7 ++-- units/suse/halt-local.service | 20 --------- units/suse/rc-local.service | 19 --------- 9 files changed, 46 insertions(+), 85 deletions(-) delete mode 120000 units/fedora/Makefile rename units/{fedora/halt-local.service => halt-local.service.in} (75%) rename units/{fedora/rc-local.service => rc-local.service.in} (66%) delete mode 100644 units/suse/halt-local.service delete mode 100644 units/suse/rc-local.service diff --git a/Makefile.am b/Makefile.am index 94ae549b8..9132ccdfc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -406,34 +406,15 @@ EXTRA_DIST += \ units/systemd-modules-load.service.in endif -if TARGET_FEDORA -dist_systemunit_DATA += \ - units/fedora/rc-local.service \ - units/fedora/halt-local.service -systemgenerator_PROGRAMS += \ - systemd-rc-local-generator -endif - -if TARGET_MANDRIVA -dist_systemunit_DATA += \ - units/fedora/rc-local.service \ - units/fedora/halt-local.service -systemgenerator_PROGRAMS += \ - systemd-rc-local-generator -endif +if HAVE_SYSV_COMPAT +nodist_systemunit_DATA += \ + units/rc-local.service \ + units/halt-local.service -if TARGET_SUSE -dist_systemunit_DATA += \ - units/suse/rc-local.service \ - units/suse/halt-local.service -systemgenerator_PROGRAMS += \ - systemd-rc-local-generator -endif +EXTRA_DIST += \ + units/rc-local.service.in \ + units/halt-local.service.in -if TARGET_MAGEIA -dist_systemunit_DATA += \ - units/fedora/rc-local.service \ - units/fedora/halt-local.service systemgenerator_PROGRAMS += \ systemd-rc-local-generator endif @@ -3856,6 +3837,8 @@ SED_PROCESS = \ -e 's,@QUOTACHECK\@,$(QUOTACHECK),g' \ -e 's,@SYSTEM_SYSVINIT_PATH\@,$(sysvinitdir),g' \ -e 's,@VARLOGDIR\@,$(varlogdir),g' \ + -e 's,@RC_LOCAL_SCRIPT_PATH_START\@,$(RC_LOCAL_SCRIPT_PATH_START),g' \ + -e 's,@RC_LOCAL_SCRIPT_PATH_STOP\@,$(RC_LOCAL_SCRIPT_PATH_STOP),g' \ < $< > $@ units/%: units/%.in Makefile @@ -4133,12 +4116,6 @@ if TARGET_MANDRIVA $(LN_S) rescue.service single.service ) endif -if TARGET_SUSE - ( cd $(DESTDIR)$(systemunitdir) && \ - rm -f local.service && \ - $(LN_S) rc-local.service local.service ) -endif - if TARGET_MAGEIA ( cd $(DESTDIR)$(systemunitdir) && \ rm -f display-manager.service ) diff --git a/configure.ac b/configure.ac index d0003bb5b..92dbdf5a3 100644 --- a/configure.ac +++ b/configure.ac @@ -588,6 +588,25 @@ if test "x$enable_coredump" != "xno"; then fi AM_CONDITIONAL(ENABLE_COREDUMP, [test "$have_coredump" = "yes"]) +# ------------------------------------------------------------------------------ +AC_ARG_WITH(rc-local-script-path-start, + AS_HELP_STRING([--with-rc-local-script-path-start=PATH], + [Path to /etc/rc.local]), + [RC_LOCAL_SCRIPT_PATH_START="$withval"], + [RC_LOCAL_SCRIPT_PATH_START="/etc/rc.local"]) + +AC_ARG_WITH(rc-local-script-path-stop, + AS_HELP_STRING([--with-rc-local-script-path-stop=PATH], + [Path to /sbin/halt.local]), + [RC_LOCAL_SCRIPT_PATH_STOP="$withval"], + [RC_LOCAL_SCRIPT_PATH_STOP="/sbin/halt.local"]) + +AC_DEFINE_UNQUOTED(RC_LOCAL_SCRIPT_PATH_START, ["$RC_LOCAL_SCRIPT_PATH_START"], [Path of /etc/rc.local script]) +AC_DEFINE_UNQUOTED(RC_LOCAL_SCRIPT_PATH_STOP, ["$RC_LOCAL_SCRIPT_PATH_STOP"], [Path of /sbin/halt.local script]) + +AC_SUBST(RC_LOCAL_SCRIPT_PATH_START) +AC_SUBST(RC_LOCAL_SCRIPT_PATH_STOP) + # ------------------------------------------------------------------------------ AC_ARG_WITH(firmware-path, AS_HELP_STRING([--with-firmware-path=DIR[[[:DIR[...]]]]], @@ -889,6 +908,8 @@ AC_MSG_RESULT([ Split /usr: ${enable_split_usr} man pages: ${have_manpages} gtk-doc: ${enable_gtk_doc} + Extra start script: ${RC_LOCAL_SCRIPT_PATH_START} + Extra stop script: ${RC_LOCAL_SCRIPT_PATH_STOP} CFLAGS: ${OUR_CFLAGS} ${CFLAGS} CPPLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index c219e7704..448980ba2 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -28,13 +28,13 @@ #include "util.h" #include "mkdir.h" -#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA) -#define SCRIPT_PATH_START "/etc/rc.d/rc.local" -#elif defined(TARGET_SUSE) -#define SCRIPT_PATH_START "/etc/init.d/boot.local" +#ifndef RC_LOCAL_SCRIPT_PATH_START +#define RC_LOCAL_SCRIPT_PATH_START "/etc/rc.d/rc.local" #endif -#define SCRIPT_PATH_STOP "/sbin/halt.local" +#ifndef RC_LOCAL_SCRIPT_PATH_STOP +#define RC_LOCAL_SCRIPT_PATH_STOP "/sbin/halt.local" +#endif const char *arg_dest = "/tmp"; @@ -97,14 +97,14 @@ int main(int argc, char *argv[]) { umask(0022); - if (file_is_executable(SCRIPT_PATH_START)) { + if (file_is_executable(RC_LOCAL_SCRIPT_PATH_START)) { log_debug("Automatically adding rc-local.service."); if (add_symlink("rc-local.service", "multi-user.target") < 0) r = EXIT_FAILURE; } - if (file_is_executable(SCRIPT_PATH_STOP)) { + if (file_is_executable(RC_LOCAL_SCRIPT_PATH_STOP)) { log_debug("Automatically adding halt-local.service."); if (add_symlink("halt-local.service", "final.target") < 0) diff --git a/units/.gitignore b/units/.gitignore index 63c7ba06b..5e86d3011 100644 --- a/units/.gitignore +++ b/units/.gitignore @@ -1,3 +1,5 @@ +/halt-local.service +/rc-local.service /systemd-hybrid-sleep.service /systemd-journal-gatewayd.service /systemd-journal-flush.service diff --git a/units/fedora/Makefile b/units/fedora/Makefile deleted file mode 120000 index 50be21181..000000000 --- a/units/fedora/Makefile +++ /dev/null @@ -1 +0,0 @@ -../../src/Makefile \ No newline at end of file diff --git a/units/fedora/halt-local.service b/units/halt-local.service.in similarity index 75% rename from units/fedora/halt-local.service rename to units/halt-local.service.in index a0a3a292e..c8be8965a 100644 --- a/units/fedora/halt-local.service +++ b/units/halt-local.service.in @@ -6,15 +6,15 @@ # (at your option) any later version. [Unit] -Description=/sbin/halt.local Compatibility -ConditionFileIsExecutable=/sbin/halt.local +Description=@RC_LOCAL_SCRIPT_PATH_STOP@ Compatibility +ConditionFileIsExecutable=@RC_LOCAL_SCRIPT_PATH_STOP@ DefaultDependencies=no After=shutdown.target Before=final.target [Service] Type=oneshot -ExecStart=/sbin/halt.local +ExecStart=@RC_LOCAL_SCRIPT_PATH_STOP@ TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes diff --git a/units/fedora/rc-local.service b/units/rc-local.service.in similarity index 66% rename from units/fedora/rc-local.service rename to units/rc-local.service.in index 3b3bda9f6..97d44a7a2 100644 --- a/units/fedora/rc-local.service +++ b/units/rc-local.service.in @@ -6,14 +6,15 @@ # (at your option) any later version. # This unit gets pulled automatically into multi-user.target by -# systemd-rc-local-generator if /etc/rc.d/rc.local is executable. +# systemd-rc-local-generator if @RC_LOCAL_SCRIPT_PATH_START@ is executable. [Unit] -Description=/etc/rc.d/rc.local Compatibility +Description=@RC_LOCAL_SCRIPT_PATH_START@ Compatibility +ConditionFileIsExecutable=@RC_LOCAL_SCRIPT_PATH_START@ After=network.target [Service] Type=forking -ExecStart=/etc/rc.d/rc.local start +ExecStart=@RC_LOCAL_SCRIPT_PATH_START@ start TimeoutSec=0 RemainAfterExit=yes SysVStartPriority=99 diff --git a/units/suse/halt-local.service b/units/suse/halt-local.service deleted file mode 100644 index 3a3a7930e..000000000 --- a/units/suse/halt-local.service +++ /dev/null @@ -1,20 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -[Unit] -Description=/etc/init.d/halt.local Compatibility -ConditionFileIsExecutable=/etc/init.d/halt.local -DefaultDependencies=no -After=shutdown.target -Before=final.target - -[Service] -Type=oneshot -ExecStart=/etc/init.d/halt.local -TimeoutSec=0 -StandardOutput=tty -RemainAfterExit=yes diff --git a/units/suse/rc-local.service b/units/suse/rc-local.service deleted file mode 100644 index 0fd70e0fc..000000000 --- a/units/suse/rc-local.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or -# (at your option) any later version. - -# This unit gets pulled automatically into multi-user.target by -# systemd-rc-local-generator if /etc/init.d/boot.local is executable. -[Unit] -Description=/etc/init.d/boot.local Compatibility -After=network.target - -[Service] -Type=oneshot -ExecStart=/etc/init.d/boot.local -TimeoutSec=0 -RemainAfterExit=yes -SysVStartPriority=99 -- 2.30.2