]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Extract more objects instead of compiling multiple times
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 15 May 2025 12:16:57 +0000 (14:16 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 20 May 2025 08:29:58 +0000 (10:29 +0200)
Also, let's deflatten the lists of sources in preparation for the
next commit at the same time.

In systemctl, we split out systemctl-main.c to make sure the definition
of main() is in a separate object which allows us to extract the systemctl.c
object and link it in the fuzzer target without getting a multiple definition
error when linking.

31 files changed:
src/analyze/meson.build
src/busctl/meson.build
src/coredump/meson.build
src/hibernate-resume/meson.build
src/home/meson.build
src/import/meson.build
src/integritysetup/meson.build
src/journal-remote/meson.build
src/journal/meson.build
src/libsystemd-network/meson.build
src/locale/meson.build
src/login/meson.build
src/machine/meson.build
src/network/meson.build
src/nspawn/meson.build
src/nsresourced/meson.build
src/oom/meson.build
src/resolve/meson.build
src/shutdown/meson.build
src/sleep/meson.build
src/systemctl/meson.build
src/systemctl/systemctl-main.c [new file with mode: 0644]
src/systemctl/systemctl.c
src/systemctl/systemctl.h
src/sysupdate/meson.build
src/test/meson.build
src/timesync/meson.build
src/tmpfiles/meson.build
src/udev/meson.build
src/vmspawn/meson.build
src/xdg-autostart-generator/meson.build

index b84d064d332be567d747a5ea10c65615a0d1b54a..7d437953d9b601d8aa7a54c2f4e6a9a2c4b9d172 100644 (file)
@@ -44,7 +44,7 @@ executables += [
         executable_template + {
                 'name' : 'systemd-analyze',
                 'public' : conf.get('ENABLE_ANALYZE') == 1,
-                'sources' : [systemd_analyze_sources, systemd_analyze_extract_sources],
+                'sources' : systemd_analyze_sources + systemd_analyze_extract_sources,
                 'extract' : systemd_analyze_extract_sources,
                 'include_directories' : core_includes,
                 'link_with' : [
index 8c8e110360d4aa88364efd63342461311b3f94a7..e47531cf028f5d7007f5ec3b5993f062832d70d7 100644 (file)
@@ -11,7 +11,7 @@ executables += [
         executable_template + {
                 'name' : 'busctl',
                 'public' : true,
-                'sources' : [busctl_sources, busctl_extract_sources],
+                'sources' : busctl_sources + busctl_extract_sources,
                 'extract' : busctl_extract_sources,
         },
         test_template + {
index e1667e19a9bb54f4a64ba2bbd2dfd8d01ae69cf7..1896d22c25862bff6435f969557bf77df38dd47e 100644 (file)
@@ -21,7 +21,7 @@ common_dependencies = [
 executables += [
         libexec_template + {
                 'name' : 'systemd-coredump',
-                'sources' : [systemd_coredump_sources, systemd_coredump_extract_sources],
+                'sources' : systemd_coredump_sources + systemd_coredump_extract_sources,
                 'extract' : systemd_coredump_extract_sources,
                 'link_with' : [libshared],
                 'dependencies' : common_dependencies + [libacl],
index ce3430d2c3c579d64954e13af84fc49bfd454444..0aa085a8062318be37c5d3b354a7812c93970228 100644 (file)
@@ -5,18 +5,17 @@ if conf.get('ENABLE_HIBERNATE') != 1
 endif
 
 executables += [
-        generator_template + {
-                'name' : 'systemd-hibernate-resume-generator',
-                'sources' : files(
-                        'hibernate-resume-generator.c',
-                        'hibernate-resume-config.c',
-                ),
-        },
         libexec_template + {
                 'name' : 'systemd-hibernate-resume',
                 'sources' : files(
                         'hibernate-resume.c',
                         'hibernate-resume-config.c',
                 ),
+                'extract' : files('hibernate-resume-config.c'),
+        },
+        generator_template + {
+                'name' : 'systemd-hibernate-resume-generator',
+                'sources' : files('hibernate-resume-generator.c'),
+                'objects' : ['systemd-hibernate-resume'],
         },
 ]
index acbefef054defe30c8e510e14ab8b1437c9d005a..10e794bd707f7eeba5a38d61beec0d95cb7092f6 100644 (file)
@@ -67,7 +67,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-homed',
                 'dbus' : true,
-                'sources' : [systemd_homed_sources, systemd_homed_extract_sources],
+                'sources' : systemd_homed_sources + systemd_homed_extract_sources,
                 'include_directories' : includes +
                                         include_directories('.'),
                 'extract' : systemd_homed_extract_sources,
index 65e1ff2e1209e57e79bd0e75ea1abb23f71d9259..a2bb54992b4f4066fb12eedf6d5540f7f24759be 100644 (file)
@@ -50,7 +50,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-importd',
                 'dbus' : true,
-                'sources' : [systemd_importd_sources, systemd_importd_extract_sources],
+                'sources' : systemd_importd_sources + systemd_importd_extract_sources,
                 'extract' : systemd_importd_extract_sources,
                 'dependencies' : [common_deps, threads],
         },
index d72474a2a22fe224131f1f8b75b73997534baf2e..a81c17e8459ae6fe25171db5b6ddfcb97993d78a 100644 (file)
@@ -11,13 +11,12 @@ executables += [
                         'integrity-util.c',
                         'integritysetup.c',
                 ),
+                'extract' : files('integrity-util.c'),
                 'dependencies' : libcryptsetup,
         },
         generator_template + {
                 'name' : 'systemd-integritysetup-generator',
-                'sources' : files(
-                        'integrity-util.c',
-                        'integritysetup-generator.c',
-                ),
+                'sources' : files('integritysetup-generator.c'),
+                'objects' : ['systemd-integritysetup'],
         },
 ]
index 64cccd23554b7bf56428f84f2873ba93fec64c97..04b0f6e88128c30fe1e45f1aa3298a4eb6d88c56 100644 (file)
@@ -4,13 +4,11 @@ if conf.get('ENABLE_REMOTE') != 1
         subdir_done()
 endif
 
-systemd_journal_upload_sources = files(
-        'journal-compression-util.c',
-        'journal-upload-journal.c',
-        'journal-upload.c',
+systemd_journal_gatewayd_sources = files(
+        'journal-gatewayd.c',
 )
-systemd_journal_upload_extract_sources = files(
-        'journal-header-util.c',
+systemd_journal_gatewayd_extract_sources = files(
+        'microhttpd-util.c',
 )
 
 systemd_journal_remote_sources = files('journal-remote-main.c')
@@ -21,15 +19,12 @@ systemd_journal_remote_extract_sources = files(
         'journal-remote.c',
 )
 
-if conf.get('HAVE_MICROHTTPD') == 1
-        systemd_journal_remote_extract_sources += files(
-                'microhttpd-util.c',
-        )
-endif
-
-systemd_journal_gatewayd_sources = files(
-        'journal-gatewayd.c',
-        'microhttpd-util.c',
+systemd_journal_upload_sources = files(
+        'journal-upload-journal.c',
+        'journal-upload.c',
+)
+systemd_journal_upload_extract_sources = files(
+        'journal-header-util.c',
 )
 
 common_deps = [
@@ -42,26 +37,29 @@ common_deps = [
 
 executables += [
         libexec_template + {
-                'name' : 'systemd-journal-upload',
+                'name' : 'systemd-journal-gatewayd',
                 'public' : true,
-                'conditions' : ['HAVE_LIBCURL'],
-                'sources' : [systemd_journal_upload_sources, systemd_journal_upload_extract_sources],
-                'extract' : systemd_journal_upload_extract_sources,
-                'dependencies' : common_deps + [libcurl],
+                'conditions' : ['HAVE_MICROHTTPD'],
+                'sources' : systemd_journal_gatewayd_sources + systemd_journal_gatewayd_extract_sources,
+                'extract' : systemd_journal_gatewayd_extract_sources,
+                'dependencies' : common_deps + [libmicrohttpd],
         },
         libexec_template + {
                 'name' : 'systemd-journal-remote',
                 'public' : true,
-                'sources' : [systemd_journal_remote_sources, systemd_journal_remote_extract_sources],
+                'sources' : systemd_journal_remote_sources + systemd_journal_remote_extract_sources,
+                'objects' : conf.get('HAVE_MICROHTTPD') == 1 ? ['systemd-journal-gatewayd'] : [],
                 'extract' : systemd_journal_remote_extract_sources,
                 'dependencies' : common_deps + [libmicrohttpd],
         },
         libexec_template + {
-                'name' : 'systemd-journal-gatewayd',
+                'name' : 'systemd-journal-upload',
                 'public' : true,
-                'conditions' : ['HAVE_MICROHTTPD'],
-                'sources' : systemd_journal_gatewayd_sources,
-                'dependencies' : common_deps + [libmicrohttpd],
+                'conditions' : ['HAVE_LIBCURL'],
+                'sources' : systemd_journal_upload_sources + systemd_journal_upload_extract_sources,
+                'objects' : ['systemd-journal-remote'],
+                'extract' : systemd_journal_upload_extract_sources,
+                'dependencies' : common_deps + [libcurl],
         },
         test_template + {
                 'sources' : files('test-journal-header-util.c'),
index d0122c849582eff736d3df82aded55eaa8bf8f1b..cbce43fc546b715d449712c59cae6735b9f9ee3a 100644 (file)
@@ -64,7 +64,7 @@ journal_fuzz_template = fuzz_template + {
 executables += [
         libexec_template + {
                 'name' : 'systemd-journald',
-                'sources' : [systemd_journald_sources, systemd_journald_extract_sources],
+                'sources' : systemd_journald_sources + systemd_journald_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : systemd_journald_extract_sources,
                 'dependencies' : [
index 333b3e0541f21e32065c4469828a817c4314d240..a6de329627b7e624b5a79c56a323b0ec82d2d694 100644 (file)
@@ -95,12 +95,11 @@ executables += [
                         'test-ndisc-ra.c',
                         'icmp6-test-util.c',
                 ),
+                'extract' : files('icmp6-test-util.c'),
         },
         network_test_template + {
-                'sources' : files(
-                        'test-ndisc-rs.c',
-                        'icmp6-test-util.c',
-                ),
+                'sources' : files('test-ndisc-rs.c'),
+                'objects' : ['test-ndisc-ra'],
         },
         network_test_template + {
                 'sources' : files('test-ndisc-send.c'),
@@ -125,9 +124,7 @@ executables += [
                 'sources' : files('fuzz-lldp-rx.c'),
         },
         network_fuzz_template + {
-                'sources' : files(
-                        'fuzz-ndisc-rs.c',
-                        'icmp6-test-util.c',
-                ),
+                'sources' : files('fuzz-ndisc-rs.c'),
+                'objects' : ['test-ndisc-ra'],
         },
 ]
index e9c61f49b32981850905ef3b0bc49594ea52d856..c41759168014f6576f578a7da0acb95950e57d5f 100644 (file)
@@ -29,7 +29,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-localed',
                 'dbus' : true,
-                'sources' : [systemd_localed_sources, systemd_localed_extract_sources],
+                'sources' : systemd_localed_sources + systemd_localed_extract_sources,
                 'extract' : systemd_localed_extract_sources,
                 'dependencies' : libxkbcommon_deps,
         },
index 99096c4c292e6e11b4d5f448647125d093f42d5a..8e3212a0f6cb6bdc7c1700f0917ba16705c12c14 100644 (file)
@@ -46,7 +46,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-logind',
                 'dbus' : true,
-                'sources' : [systemd_logind_sources, systemd_logind_extract_sources],
+                'sources' : systemd_logind_sources + systemd_logind_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : systemd_logind_extract_sources,
                 'dependencies' : [
index 19ab1fa8f7e22022a2685b6237dabc50461fca7e..9370077fdccc1965ad0646f7c66a6a3cb848eb3c 100644 (file)
@@ -24,7 +24,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-machined',
                 'dbus' : true,
-                'sources' : [systemd_machined_sources, systemd_machined_extract_sources],
+                'sources' : systemd_machined_sources + systemd_machined_extract_sources,
                 'extract' : systemd_machined_extract_sources,
         },
         executable_template + {
index 990dac22839ac6d7422270bbeb360cfa8e19cca0..97191fb171f42ebe3c10e9c9efcf346980657bcf 100644 (file)
@@ -200,7 +200,7 @@ executables += [
                 'name' : 'systemd-networkd',
                 'dbus' : true,
                 'conditions' : ['ENABLE_NETWORKD'],
-                'sources' : [systemd_networkd_sources, systemd_networkd_extract_sources],
+                'sources' : systemd_networkd_sources + systemd_networkd_extract_sources,
                 'extract' : systemd_networkd_extract_sources,
                 'include_directories' : network_includes,
                 'link_with' : [
index b59017c15ecdfadb0c500d3c347de505f6f350ac..29fec248dfeea889741992d531af2f618373cbf3 100644 (file)
@@ -8,7 +8,6 @@ nspawn_sources = files(
         'nspawn.c',
         'nspawn-bind-user.c',
         'nspawn-cgroup.c',
-        'nspawn-network.c',
         'nspawn-register.c',
         'nspawn-seccomp.c',
         'nspawn-setuid.c',
@@ -42,7 +41,7 @@ executables += [
         executable_template + {
                 'name' : 'systemd-nspawn',
                 'public' : true,
-                'sources' : [nspawn_sources, nspawn_extract_sources],
+                'sources' : nspawn_sources + nspawn_extract_sources,
                 'include_directories' : [
                         executable_template['include_directories'],
                         include_directories('.')
index 85ebf6a0217c78ea3b62bb77bae6c8e0ebc8dc4a..805a4788d023d7ecf86143ce5def0b0d85b2ba04 100644 (file)
@@ -30,7 +30,7 @@ endif
 executables += [
         libexec_template + {
                 'name' : 'systemd-nsresourced',
-                'sources' : [systemd_nsresourced_sources, systemd_nsresourced_extract_sources],
+                'sources' : systemd_nsresourced_sources + systemd_nsresourced_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : systemd_nsresourced_extract_sources,
                 'dependencies' : threads,
index 1d0880e3f28ee7ea487561af97913d9dd80dfa43..f462169e711f3fab9a1b878c79dc765c8a1238b8 100644 (file)
@@ -18,7 +18,7 @@ executables += [
         libexec_template + {
                 'name' : 'systemd-oomd',
                 'dbus' : true,
-                'sources' : [systemd_oomd_sources, systemd_oomd_extract_sources],
+                'sources' : systemd_oomd_sources + systemd_oomd_extract_sources,
                 'extract' : systemd_oomd_extract_sources,
                 'dependencies' : libatomic,
         },
index 57edb6508f868618a6c133cd7766d1033dfafb2a..2c20a8299d0a3b5ef3ade3de291df856ebdfa0ac 100644 (file)
@@ -114,7 +114,7 @@ executables += [
         libexec_template + resolve_common_template + {
                 'name' : 'systemd-resolved',
                 'dbus' : true,
-                'sources' : [systemd_resolved_sources, systemd_resolved_extract_sources],
+                'sources' : systemd_resolved_sources + systemd_resolved_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : systemd_resolved_extract_sources,
         },
index 5fc896c000530e052eb46371889b1fffdcbadb28..c91253ca8e0f84e3b548b7242a4c3df238fce4e5 100644 (file)
@@ -14,13 +14,13 @@ systemd_shutdown_extract_sources = files(
 executables += [
         libexec_template + {
                 'name' : 'systemd-shutdown',
-                'sources' : [systemd_shutdown_sources, systemd_shutdown_extract_sources],
+                'sources' : systemd_shutdown_sources + systemd_shutdown_extract_sources,
                 'extract' : systemd_shutdown_extract_sources,
                 'dependencies' : libmount,
         },
         libexec_template + {
                 'name' : 'systemd-shutdown.standalone',
-                'sources' : [systemd_shutdown_sources, systemd_shutdown_extract_sources],
+                'sources' : systemd_shutdown_sources + systemd_shutdown_extract_sources,
                 'c_args' : '-DSTANDALONE',
                 'link_with' : [
                         libbasic_static,
index 03fc9f1ab5029cd39da9eace91fc99e492bb8e47..f17c778fe2c2988a61dc71001ebbc6cac172e684 100644 (file)
@@ -10,7 +10,7 @@ sleep_extract_sources = files(
 executables += [
         libexec_template + {
                 'name' : 'systemd-sleep',
-                'sources' : [sleep_sources, sleep_extract_sources],
+                'sources' : sleep_sources + sleep_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : sleep_extract_sources,
         },
index bdeda919fdfc5f8bf66fdfe28fbe527c0eabd7b7..4cff1f31de7a7735e7615f5938ddc0e1acbcf905 100644 (file)
@@ -4,11 +4,6 @@ systemctl_sources = files(
         'systemctl-add-dependency.c',
         'systemctl-cancel-job.c',
         'systemctl-clean-or-freeze.c',
-        'systemctl-compat-halt.c',
-        'systemctl-compat-runlevel.c',
-        'systemctl-compat-shutdown.c',
-        'systemctl-compat-telinit.c',
-        'systemctl-daemon-reload.c',
         'systemctl-edit.c',
         'systemctl-enable.c',
         'systemctl-is-active.c',
@@ -21,7 +16,7 @@ systemctl_sources = files(
         'systemctl-list-unit-files.c',
         'systemctl-list-units.c',
         'systemctl-log-setting.c',
-        'systemctl-logind.c',
+        'systemctl-main.c',
         'systemctl-mount.c',
         'systemctl-preset-all.c',
         'systemctl-reset-failed.c',
@@ -31,12 +26,20 @@ systemctl_sources = files(
         'systemctl-set-property.c',
         'systemctl-show.c',
         'systemctl-start-special.c',
-        'systemctl-start-unit.c',
         'systemctl-switch-root.c',
-        'systemctl-sysv-compat.c',
         'systemctl-trivial-method.c',
-        'systemctl-util.c',
         'systemctl-whoami.c',
+)
+systemctl_extract_sources = files(
+        'systemctl-compat-halt.c',
+        'systemctl-compat-runlevel.c',
+        'systemctl-compat-shutdown.c',
+        'systemctl-compat-telinit.c',
+        'systemctl-daemon-reload.c',
+        'systemctl-logind.c',
+        'systemctl-start-unit.c',
+        'systemctl-sysv-compat.c',
+        'systemctl-util.c',
         'systemctl.c',
 )
 
@@ -51,7 +54,8 @@ executables += [
         executable_template + {
                 'name' : 'systemctl',
                 'public' : true,
-                'sources' : systemctl_sources,
+                'sources' : systemctl_sources + systemctl_extract_sources,
+                'extract' : systemctl_extract_sources,
                 'link_with' : systemctl_link_with,
                 'dependencies' : [
                         libcap,
@@ -64,12 +68,9 @@ executables += [
                 'install_tag' : 'systemctl',
         },
         fuzz_template + {
-                'sources' : [
-                        files('fuzz-systemctl-parse-argv.c'),
-                        systemctl_sources,
-                ],
+                'sources' : files('fuzz-systemctl-parse-argv.c'),
+                'objects' : ['systemctl'],
                 'link_with' : systemctl_link_with,
-                'c_args' : ['-DFUZZ_SYSTEMCTL_PARSE_ARGV'],
         },
 ]
 
diff --git a/src/systemctl/systemctl-main.c b/src/systemctl/systemctl-main.c
new file mode 100644 (file)
index 0000000..48c083e
--- /dev/null
@@ -0,0 +1,267 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <getopt.h>
+#include <locale.h>
+#include <unistd.h>
+
+#include "dissect-image.h"
+#include "glyph-util.h"
+#include "log.h"
+#include "logs-show.h"
+#include "loop-util.h"
+#include "main-func.h"
+#include "mount-util.h"
+#include "stat-util.h"
+#include "systemctl.h"
+#include "systemctl-add-dependency.h"
+#include "systemctl-cancel-job.h"
+#include "systemctl-clean-or-freeze.h"
+#include "systemctl-compat-halt.h"
+#include "systemctl-compat-runlevel.h"
+#include "systemctl-compat-telinit.h"
+#include "systemctl-daemon-reload.h"
+#include "systemctl-edit.h"
+#include "systemctl-enable.h"
+#include "systemctl-is-active.h"
+#include "systemctl-is-enabled.h"
+#include "systemctl-is-system-running.h"
+#include "systemctl-kill.h"
+#include "systemctl-list-dependencies.h"
+#include "systemctl-list-jobs.h"
+#include "systemctl-list-machines.h"
+#include "systemctl-list-unit-files.h"
+#include "systemctl-list-units.h"
+#include "systemctl-log-setting.h"
+#include "systemctl-logind.h"
+#include "systemctl-mount.h"
+#include "systemctl-preset-all.h"
+#include "systemctl-reset-failed.h"
+#include "systemctl-service-watchdogs.h"
+#include "systemctl-set-default.h"
+#include "systemctl-set-environment.h"
+#include "systemctl-set-property.h"
+#include "systemctl-show.h"
+#include "systemctl-start-special.h"
+#include "systemctl-start-unit.h"
+#include "systemctl-switch-root.h"
+#include "systemctl-trivial-method.h"
+#include "systemctl-util.h"
+#include "systemctl-whoami.h"
+#include "verbs.h"
+#include "virt.h"
+
+static int systemctl_main(int argc, char *argv[]) {
+        static const Verb verbs[] = {
+                { "list-units",            VERB_ANY, VERB_ANY, VERB_DEFAULT|VERB_ONLINE_ONLY, verb_list_units },
+                { "list-unit-files",       VERB_ANY, VERB_ANY, 0,                verb_list_unit_files         },
+                { "list-automounts",       VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_automounts         },
+                { "list-paths",            VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_paths              },
+                { "list-sockets",          VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_sockets            },
+                { "list-timers",           VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_timers             },
+                { "list-jobs",             VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_jobs               },
+                { "list-machines",         VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_machines           },
+                { "clear-jobs",            VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_trivial_method          },
+                { "cancel",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_cancel                  },
+                { "start",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "stop",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "condstop",              2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with ALTLinux */
+                { "reload",                2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "restart",               2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "try-restart",           2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "reload-or-restart",     VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "reload-or-try-restart", 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with old systemctl <= 228 */
+                { "try-reload-or-restart", 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
+                { "force-reload",          2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with SysV */
+                { "condreload",            2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with ALTLinux */
+                { "condrestart",           2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with RH */
+                { "isolate",               2,        2,        VERB_ONLINE_ONLY, verb_start                   },
+                { "kill",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_kill                    },
+                { "clean",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
+                { "freeze",                2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
+                { "thaw",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
+                { "is-active",             2,        VERB_ANY, VERB_ONLINE_ONLY, verb_is_active               },
+                { "check",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_is_active               }, /* deprecated alias of is-active */
+                { "is-failed",             VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_is_failed               },
+                { "show",                  VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
+                { "cat",                   2,        VERB_ANY, VERB_ONLINE_ONLY, verb_cat                     },
+                { "status",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
+                { "help",                  VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
+                { "daemon-reload",         1,        1,        VERB_ONLINE_ONLY, verb_daemon_reload           },
+                { "daemon-reexec",         1,        1,        VERB_ONLINE_ONLY, verb_daemon_reload           },
+                { "log-level",             VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_log_setting             },
+                { "log-target",            VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_log_setting             },
+                { "service-log-level",     2,        3,        VERB_ONLINE_ONLY, verb_service_log_setting     },
+                { "service-log-target",    2,        3,        VERB_ONLINE_ONLY, verb_service_log_setting     },
+                { "service-watchdogs",     VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_service_watchdogs       },
+                { "show-environment",      VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_show_environment        },
+                { "set-environment",       2,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_environment         },
+                { "unset-environment",     2,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_environment         },
+                { "import-environment",    VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_import_environment      },
+                { "halt",                  VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "poweroff",              VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "reboot",                VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "kexec",                 VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "soft-reboot",           VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "sleep",                 VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "suspend",               VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "hibernate",             VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "hybrid-sleep",          VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "suspend-then-hibernate",VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "default",               VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_special           },
+                { "rescue",                VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "emergency",             VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
+                { "exit",                  VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_start_special           },
+                { "reset-failed",          VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_reset_failed            },
+                { "enable",                2,        VERB_ANY, 0,                verb_enable                  },
+                { "disable",               2,        VERB_ANY, 0,                verb_enable                  },
+                { "is-enabled",            2,        VERB_ANY, 0,                verb_is_enabled              },
+                { "reenable",              2,        VERB_ANY, 0,                verb_enable                  },
+                { "preset",                2,        VERB_ANY, 0,                verb_enable                  },
+                { "preset-all",            VERB_ANY, 1,        0,                verb_preset_all              },
+                { "mask",                  2,        VERB_ANY, 0,                verb_enable                  },
+                { "unmask",                2,        VERB_ANY, 0,                verb_enable                  },
+                { "link",                  2,        VERB_ANY, 0,                verb_enable                  },
+                { "revert",                2,        VERB_ANY, 0,                verb_enable                  },
+                { "switch-root",           VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_switch_root             },
+                { "list-dependencies",     VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_dependencies       },
+                { "set-default",           2,        2,        0,                verb_set_default             },
+                { "get-default",           VERB_ANY, 1,        0,                verb_get_default             },
+                { "set-property",          3,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_property            },
+                { "is-system-running",     VERB_ANY, 1,        0,                verb_is_system_running       },
+                { "add-wants",             3,        VERB_ANY, 0,                verb_add_dependency          },
+                { "add-requires",          3,        VERB_ANY, 0,                verb_add_dependency          },
+                { "edit",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_edit                    },
+                { "bind",                  3,        4,        VERB_ONLINE_ONLY, verb_bind                    },
+                { "mount-image",           4,        5,        VERB_ONLINE_ONLY, verb_mount_image             },
+                { "whoami",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_whoami                  },
+                {}
+        };
+
+        const Verb *verb = verbs_find_verb(argv[optind], verbs);
+        if (verb && (verb->flags & VERB_ONLINE_ONLY) && arg_root)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                       "Verb '%s' cannot be used with --root= or --image=.",
+                                       argv[optind] ?: verb->verb);
+
+        return dispatch_verb(argc, argv, verbs, NULL);
+}
+
+static int run(int argc, char *argv[]) {
+        _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
+        _cleanup_(umount_and_freep) char *mounted_dir = NULL;
+        int r;
+
+        setlocale(LC_ALL, "");
+        log_setup();
+
+        r = systemctl_dispatch_parse_argv(argc, argv);
+        if (r <= 0)
+                goto finish;
+
+        journal_browse_prepare();
+
+        if (proc_mounted() == 0)
+                log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING,
+                         "%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n"
+                         "your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway.\n"
+                         "Your mileage may vary.",
+                         optional_glyph(GLYPH_WARNING_SIGN),
+                         optional_glyph(GLYPH_SPACE));
+
+        if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
+                if (!arg_quiet)
+                        log_info("Running in chroot, ignoring request.");
+                r = 0;
+                goto finish;
+        }
+
+        /* systemctl_main() will print an error message for the bus connection, but only if it needs to */
+
+        if (arg_image) {
+                assert(!arg_root);
+
+                r = mount_image_privately_interactively(
+                                arg_image,
+                                arg_image_policy,
+                                DISSECT_IMAGE_GENERIC_ROOT |
+                                DISSECT_IMAGE_REQUIRE_ROOT |
+                                DISSECT_IMAGE_RELAX_VAR_CHECK |
+                                DISSECT_IMAGE_VALIDATE_OS |
+                                DISSECT_IMAGE_ALLOW_USERSPACE_VERITY,
+                                &mounted_dir,
+                                /* ret_dir_fd= */ NULL,
+                                &loop_device);
+                if (r < 0)
+                        return r;
+
+                arg_root = strdup(mounted_dir);
+                if (!arg_root)
+                        return log_oom();
+        }
+
+        switch (arg_action) {
+
+        case ACTION_SYSTEMCTL:
+                r = systemctl_main(argc, argv);
+                break;
+
+        /* Legacy command aliases set arg_action. They provide some fallbacks, e.g. to tell sysvinit to
+         * reboot after you have installed systemd binaries. */
+
+        case ACTION_HALT:
+        case ACTION_POWEROFF:
+        case ACTION_REBOOT:
+        case ACTION_KEXEC:
+                r = halt_main();
+                break;
+
+        case ACTION_RUNLEVEL2:
+        case ACTION_RUNLEVEL3:
+        case ACTION_RUNLEVEL4:
+        case ACTION_RUNLEVEL5:
+        case ACTION_RESCUE:
+                r = start_with_fallback();
+                break;
+
+        case ACTION_RELOAD:
+        case ACTION_REEXEC:
+                r = reload_with_fallback();
+                break;
+
+        case ACTION_CANCEL_SHUTDOWN:
+                r = logind_cancel_shutdown();
+                break;
+
+        case ACTION_SHOW_SHUTDOWN:
+        case ACTION_SYSTEMCTL_SHOW_SHUTDOWN:
+                r = logind_show_shutdown();
+                break;
+
+        case ACTION_RUNLEVEL:
+                r = runlevel_main();
+                break;
+
+        case ACTION_EXIT:
+        case ACTION_SLEEP:
+        case ACTION_SUSPEND:
+        case ACTION_HIBERNATE:
+        case ACTION_HYBRID_SLEEP:
+        case ACTION_SUSPEND_THEN_HIBERNATE:
+        case ACTION_EMERGENCY:
+        case ACTION_DEFAULT:
+                /* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
+                 * arg_action. Fall through. */
+
+        case _ACTION_INVALID:
+        default:
+                assert_not_reached();
+        }
+
+finish:
+        release_busses();
+
+        /* Note that we return r here, not 0, so that we can implement the LSB-like return codes */
+        return r;
+}
+
+DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
index d1e33407377702264c91b7a8b7bd3e2dc6991a6d..cffaae5c393921ab33365f8a3f88458419ec7df8 100644 (file)
 #include "stat-util.h"
 #include "string-table.h"
 #include "systemctl.h"
-#include "systemctl-add-dependency.h"
-#include "systemctl-cancel-job.h"
-#include "systemctl-clean-or-freeze.h"
 #include "systemctl-compat-halt.h"
 #include "systemctl-compat-runlevel.h"
 #include "systemctl-compat-shutdown.h"
 #include "systemctl-compat-telinit.h"
-#include "systemctl-daemon-reload.h"
-#include "systemctl-edit.h"
-#include "systemctl-enable.h"
-#include "systemctl-is-active.h"
-#include "systemctl-is-enabled.h"
-#include "systemctl-is-system-running.h"
-#include "systemctl-kill.h"
-#include "systemctl-list-dependencies.h"
-#include "systemctl-list-jobs.h"
-#include "systemctl-list-machines.h"
-#include "systemctl-list-unit-files.h"
-#include "systemctl-list-units.h"
-#include "systemctl-log-setting.h"
 #include "systemctl-logind.h"
 #include "systemctl-mount.h"
 #include "systemctl-preset-all.h"
@@ -1167,221 +1151,3 @@ int systemctl_dispatch_parse_argv(int argc, char *argv[]) {
         arg_action = ACTION_SYSTEMCTL;
         return systemctl_parse_argv(argc, argv);
 }
-
-#ifndef FUZZ_SYSTEMCTL_PARSE_ARGV
-static int systemctl_main(int argc, char *argv[]) {
-        static const Verb verbs[] = {
-                { "list-units",            VERB_ANY, VERB_ANY, VERB_DEFAULT|VERB_ONLINE_ONLY, verb_list_units },
-                { "list-unit-files",       VERB_ANY, VERB_ANY, 0,                verb_list_unit_files         },
-                { "list-automounts",       VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_automounts         },
-                { "list-paths",            VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_paths              },
-                { "list-sockets",          VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_sockets            },
-                { "list-timers",           VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_timers             },
-                { "list-jobs",             VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_jobs               },
-                { "list-machines",         VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_machines           },
-                { "clear-jobs",            VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_trivial_method          },
-                { "cancel",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_cancel                  },
-                { "start",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "stop",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "condstop",              2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with ALTLinux */
-                { "reload",                2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "restart",               2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "try-restart",           2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "reload-or-restart",     VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "reload-or-try-restart", 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with old systemctl <= 228 */
-                { "try-reload-or-restart", 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   },
-                { "force-reload",          2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with SysV */
-                { "condreload",            2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with ALTLinux */
-                { "condrestart",           2,        VERB_ANY, VERB_ONLINE_ONLY, verb_start                   }, /* For compatibility with RH */
-                { "isolate",               2,        2,        VERB_ONLINE_ONLY, verb_start                   },
-                { "kill",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_kill                    },
-                { "clean",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
-                { "freeze",                2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
-                { "thaw",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_clean_or_freeze         },
-                { "is-active",             2,        VERB_ANY, VERB_ONLINE_ONLY, verb_is_active               },
-                { "check",                 2,        VERB_ANY, VERB_ONLINE_ONLY, verb_is_active               }, /* deprecated alias of is-active */
-                { "is-failed",             VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_is_failed               },
-                { "show",                  VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
-                { "cat",                   2,        VERB_ANY, VERB_ONLINE_ONLY, verb_cat                     },
-                { "status",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
-                { "help",                  VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_show                    },
-                { "daemon-reload",         1,        1,        VERB_ONLINE_ONLY, verb_daemon_reload           },
-                { "daemon-reexec",         1,        1,        VERB_ONLINE_ONLY, verb_daemon_reload           },
-                { "log-level",             VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_log_setting             },
-                { "log-target",            VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_log_setting             },
-                { "service-log-level",     2,        3,        VERB_ONLINE_ONLY, verb_service_log_setting     },
-                { "service-log-target",    2,        3,        VERB_ONLINE_ONLY, verb_service_log_setting     },
-                { "service-watchdogs",     VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_service_watchdogs       },
-                { "show-environment",      VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_show_environment        },
-                { "set-environment",       2,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_environment         },
-                { "unset-environment",     2,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_environment         },
-                { "import-environment",    VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_import_environment      },
-                { "halt",                  VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "poweroff",              VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "reboot",                VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "kexec",                 VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "soft-reboot",           VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "sleep",                 VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "suspend",               VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "hibernate",             VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "hybrid-sleep",          VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "suspend-then-hibernate",VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "default",               VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_special           },
-                { "rescue",                VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "emergency",             VERB_ANY, 1,        VERB_ONLINE_ONLY, verb_start_system_special    },
-                { "exit",                  VERB_ANY, 2,        VERB_ONLINE_ONLY, verb_start_special           },
-                { "reset-failed",          VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_reset_failed            },
-                { "enable",                2,        VERB_ANY, 0,                verb_enable                  },
-                { "disable",               2,        VERB_ANY, 0,                verb_enable                  },
-                { "is-enabled",            2,        VERB_ANY, 0,                verb_is_enabled              },
-                { "reenable",              2,        VERB_ANY, 0,                verb_enable                  },
-                { "preset",                2,        VERB_ANY, 0,                verb_enable                  },
-                { "preset-all",            VERB_ANY, 1,        0,                verb_preset_all              },
-                { "mask",                  2,        VERB_ANY, 0,                verb_enable                  },
-                { "unmask",                2,        VERB_ANY, 0,                verb_enable                  },
-                { "link",                  2,        VERB_ANY, 0,                verb_enable                  },
-                { "revert",                2,        VERB_ANY, 0,                verb_enable                  },
-                { "switch-root",           VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_switch_root             },
-                { "list-dependencies",     VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_list_dependencies       },
-                { "set-default",           2,        2,        0,                verb_set_default             },
-                { "get-default",           VERB_ANY, 1,        0,                verb_get_default             },
-                { "set-property",          3,        VERB_ANY, VERB_ONLINE_ONLY, verb_set_property            },
-                { "is-system-running",     VERB_ANY, 1,        0,                verb_is_system_running       },
-                { "add-wants",             3,        VERB_ANY, 0,                verb_add_dependency          },
-                { "add-requires",          3,        VERB_ANY, 0,                verb_add_dependency          },
-                { "edit",                  2,        VERB_ANY, VERB_ONLINE_ONLY, verb_edit                    },
-                { "bind",                  3,        4,        VERB_ONLINE_ONLY, verb_bind                    },
-                { "mount-image",           4,        5,        VERB_ONLINE_ONLY, verb_mount_image             },
-                { "whoami",                VERB_ANY, VERB_ANY, VERB_ONLINE_ONLY, verb_whoami                  },
-                {}
-        };
-
-        const Verb *verb = verbs_find_verb(argv[optind], verbs);
-        if (verb && (verb->flags & VERB_ONLINE_ONLY) && arg_root)
-                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                       "Verb '%s' cannot be used with --root= or --image=.",
-                                       argv[optind] ?: verb->verb);
-
-        return dispatch_verb(argc, argv, verbs, NULL);
-}
-
-static int run(int argc, char *argv[]) {
-        _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
-        _cleanup_(umount_and_freep) char *mounted_dir = NULL;
-        int r;
-
-        setlocale(LC_ALL, "");
-        log_setup();
-
-        r = systemctl_dispatch_parse_argv(argc, argv);
-        if (r <= 0)
-                goto finish;
-
-        journal_browse_prepare();
-
-        if (proc_mounted() == 0)
-                log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING,
-                         "%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n"
-                         "your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway.\n"
-                         "Your mileage may vary.",
-                         optional_glyph(GLYPH_WARNING_SIGN),
-                         optional_glyph(GLYPH_SPACE));
-
-        if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
-                if (!arg_quiet)
-                        log_info("Running in chroot, ignoring request.");
-                r = 0;
-                goto finish;
-        }
-
-        /* systemctl_main() will print an error message for the bus connection, but only if it needs to */
-
-        if (arg_image) {
-                assert(!arg_root);
-
-                r = mount_image_privately_interactively(
-                                arg_image,
-                                arg_image_policy,
-                                DISSECT_IMAGE_GENERIC_ROOT |
-                                DISSECT_IMAGE_REQUIRE_ROOT |
-                                DISSECT_IMAGE_RELAX_VAR_CHECK |
-                                DISSECT_IMAGE_VALIDATE_OS |
-                                DISSECT_IMAGE_ALLOW_USERSPACE_VERITY,
-                                &mounted_dir,
-                                /* ret_dir_fd= */ NULL,
-                                &loop_device);
-                if (r < 0)
-                        return r;
-
-                arg_root = strdup(mounted_dir);
-                if (!arg_root)
-                        return log_oom();
-        }
-
-        switch (arg_action) {
-
-        case ACTION_SYSTEMCTL:
-                r = systemctl_main(argc, argv);
-                break;
-
-        /* Legacy command aliases set arg_action. They provide some fallbacks, e.g. to tell sysvinit to
-         * reboot after you have installed systemd binaries. */
-
-        case ACTION_HALT:
-        case ACTION_POWEROFF:
-        case ACTION_REBOOT:
-        case ACTION_KEXEC:
-                r = halt_main();
-                break;
-
-        case ACTION_RUNLEVEL2:
-        case ACTION_RUNLEVEL3:
-        case ACTION_RUNLEVEL4:
-        case ACTION_RUNLEVEL5:
-        case ACTION_RESCUE:
-                r = start_with_fallback();
-                break;
-
-        case ACTION_RELOAD:
-        case ACTION_REEXEC:
-                r = reload_with_fallback();
-                break;
-
-        case ACTION_CANCEL_SHUTDOWN:
-                r = logind_cancel_shutdown();
-                break;
-
-        case ACTION_SHOW_SHUTDOWN:
-        case ACTION_SYSTEMCTL_SHOW_SHUTDOWN:
-                r = logind_show_shutdown();
-                break;
-
-        case ACTION_RUNLEVEL:
-                r = runlevel_main();
-                break;
-
-        case ACTION_EXIT:
-        case ACTION_SLEEP:
-        case ACTION_SUSPEND:
-        case ACTION_HIBERNATE:
-        case ACTION_HYBRID_SLEEP:
-        case ACTION_SUSPEND_THEN_HIBERNATE:
-        case ACTION_EMERGENCY:
-        case ACTION_DEFAULT:
-                /* systemctl verbs with no equivalent in the legacy commands. These cannot appear in
-                 * arg_action. Fall through. */
-
-        case _ACTION_INVALID:
-        default:
-                assert_not_reached();
-        }
-
-finish:
-        release_busses();
-
-        /* Note that we return r here, not 0, so that we can implement the LSB-like return codes */
-        return r;
-}
-
-DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
-#endif
index e28238032393cc9dbdece1eeb87cf13a004bd6d9..7bdca74bedbdc2e74d3c6547c1bf6eafd2098675 100644 (file)
@@ -84,6 +84,7 @@ extern int arg_signal;
 extern int arg_kill_value;
 extern bool arg_kill_value_set;
 extern char *arg_root;
+extern char *arg_image;
 extern usec_t arg_when;
 extern bool arg_stdin;
 extern const char *arg_reboot_argument;
index baf3e93a8d330ff65115f84e91ca27bc03c44c3b..3f733c7933287b092d82e767edcad6d2e2d87610 100644 (file)
@@ -9,14 +9,14 @@ systemd_sysupdate_sources = files(
         'sysupdate-resource.c',
         'sysupdate-transfer.c',
         'sysupdate-update-set.c',
+        'sysupdate.c',
+)
+systemd_sysupdate_extract_sources = files(
         'sysupdate-update-set-flags.c',
         'sysupdate-util.c',
-        'sysupdate.c',
 )
 
 systemd_updatectl_sources = files(
-        'sysupdate-update-set-flags.c',
-        'sysupdate-util.c',
         'updatectl.c',
 )
 
@@ -25,7 +25,8 @@ executables += [
                 'name' : 'systemd-sysupdate',
                 'public' : true,
                 'conditions' : ['ENABLE_SYSUPDATE'],
-                'sources' : systemd_sysupdate_sources,
+                'sources' : systemd_sysupdate_sources + systemd_sysupdate_extract_sources,
+                'extract' : systemd_sysupdate_extract_sources,
                 'link_with' : [
                         libshared,
                         libshared_fdisk,
@@ -48,6 +49,7 @@ executables += [
                 'name' : 'updatectl',
                 'public' : true,
                 'sources' : systemd_updatectl_sources,
+                'objects' : ['systemd-sysupdate'],
                 'conditions' : ['ENABLE_SYSUPDATED'],
         },
 ]
index 24d0dca2eebe92548b63e3750c54d9ce32beab61..0ccc9332cdf235d3446b6454d40e0f3e38bb120f 100644 (file)
@@ -364,15 +364,14 @@ executables += [
                         'test-nss-hosts.c',
                         'nss-test-util.c',
                 ),
+                'extract' : files('nss-test-util.c'),
                 'dependencies' : libdl,
                 'conditions' : ['ENABLE_NSS'],
                 'timeout' : 120,
         },
         test_template + {
-                'sources' : files(
-                        'test-nss-users.c',
-                        'nss-test-util.c',
-                ),
+                'sources' : files('test-nss-users.c'),
+                'objects' : ['test-nss-hosts'],
                 'dependencies' : libdl,
                 'conditions' : ['ENABLE_NSS'],
         },
index d32e32dcbc3a35e21fbabaa4111fdad1159363ff..608589e4b846601354c2e3823c0d46f439eac9bd 100644 (file)
@@ -33,7 +33,7 @@ endif
 executables += [
         libexec_template + {
                 'name' : 'systemd-timesyncd',
-                'sources' : [timesyncd_sources, timesyncd_extract_sources],
+                'sources' : timesyncd_sources + timesyncd_extract_sources,
                 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
                 'extract' : timesyncd_extract_sources,
                 'link_with' : timesyncd_link_with,
index e035d5f03d1c4525d0458addf44e5f1ed2769721..1016573969a262fee45c02a32c9fde3232820884 100644 (file)
@@ -15,14 +15,14 @@ executables += [
         executable_template + {
                 'name' : 'systemd-tmpfiles',
                 'public' : true,
-                'sources' : [systemd_tmpfiles_sources, systemd_tmpfiles_extract_sources],
+                'sources' : systemd_tmpfiles_sources + systemd_tmpfiles_extract_sources,
                 'extract' : systemd_tmpfiles_extract_sources,
                 'dependencies' : libacl,
         },
         executable_template + {
                 'name' : 'systemd-tmpfiles.standalone',
                 'public' : have_standalone_binaries,
-                'sources' : [systemd_tmpfiles_sources, systemd_tmpfiles_extract_sources],
+                'sources' : systemd_tmpfiles_sources + systemd_tmpfiles_extract_sources,
                 'c_args' : '-DSTANDALONE',
                 'link_with' : [
                         libbasic_static,
index ba0a6b14ff056e349bd8b15eeb92087083158fbc..ccf630919f5cb84ca55ded5338e6cd96f855202a 100644 (file)
@@ -149,11 +149,9 @@ udev_binaries_dict = [
         executable_template + {
                 'name' : 'udevadm',
                 'public' : true,
-                'sources' : [
-                        udevadm_sources,
-                        udevadm_extract_sources,
-                        keyboard_keys_from_name_h,
-                ],
+                'sources' : udevadm_sources +
+                            udevadm_extract_sources +
+                            keyboard_keys_from_name_h,
                 'include_directories' : [
                         libexec_template['include_directories'],
                         include_directories('.', 'net'),
index eefe81c8709c560abddf9ec35a829cd5be44c950..4ba56b71f1ecd899bc0533607c09919ff18401db 100644 (file)
@@ -19,7 +19,7 @@ executables += [
         executable_template + {
                 'name' : 'systemd-vmspawn',
                 'public' : true,
-                'sources' : [vmspawn_sources, vmspawn_extract_sources],
+                'sources' : vmspawn_sources + vmspawn_extract_sources,
                 'extract' : vmspawn_extract_sources,
                 'dependencies' : [libblkid]
         },
index 58620b5dcd54b14d9bbbcf64a3bb85507b894a07..8f51bdcc7d0a07c02839b9bee28313a2da32df38 100644 (file)
@@ -14,10 +14,8 @@ systemd_xdg_autostart_generator_extract_sources = files(
 executables += [
         executable_template + {
                 'name' : 'systemd-xdg-autostart-generator',
-                'sources' : [
-                        systemd_xdg_autostart_generator_sources,
-                        systemd_xdg_autostart_generator_extract_sources,
-                ],
+                'sources' : systemd_xdg_autostart_generator_sources +
+                            systemd_xdg_autostart_generator_extract_sources,
                 'extract' : systemd_xdg_autostart_generator_extract_sources,
                 'install_dir' : usergeneratordir,
         },