Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/systemd/files/, sys-apps/systemd/
Date: Wed, 31 Jul 2019 14:06:56
Message-Id: 1564582008.bcd58187d0fe53114f2968d7f345bd48f50b89df.floppym@gentoo
1 commit: bcd58187d0fe53114f2968d7f345bd48f50b89df
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 31 14:06:37 2019 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 31 14:06:48 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bcd58187
7
8 sys-apps/systemd: bump to 243-rc1
9
10 Package-Manager: Portage-2.3.69_p8_p111567, Repoman-2.3.16_p17_p111567
11 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
12
13 sys-apps/systemd/Manifest | 1 +
14 sys-apps/systemd/files/243-rc1-analyze.patch | 125 +++++++
15 sys-apps/systemd/systemd-243_rc1.ebuild | 472 +++++++++++++++++++++++++++
16 3 files changed, 598 insertions(+)
17
18 diff --git a/sys-apps/systemd/Manifest b/sys-apps/systemd/Manifest
19 index 88ceb157a23..da67bf86c71 100644
20 --- a/sys-apps/systemd/Manifest
21 +++ b/sys-apps/systemd/Manifest
22 @@ -1 +1,2 @@
23 DIST systemd-242.tar.gz 7831435 BLAKE2B 288e65d0a8e133ef5885689eb16118a83d93c730e342da63115cea0892fc999104c3a4856c83f3e7ef909ba2f3311146730b05ee02d84cc0400851ccbdcd54cd SHA512 578f68a3c8f2d454198fc04ff8d943abcfb390531d57f9603d185857f7afa7f4dc641dafecf49ce50fe22f5837b252b181400891e8efd4459fd4f69bb4283cb4
24 +DIST systemd-243-rc1.tar.gz 8209533 BLAKE2B 6f28d839563104b488bfe030483bf1b24c3d01cedb59ffa655f03a37d7c636c2daef34ca9d13b9fbe848b131d21920138583c63a049c1747f7e569c68384c0bf SHA512 6626d7fd5781578d01a30c0d2647a293668d0819f2f85ce78a6aaf62ae1aa4b2c687cf237ca833c5befbc00321a344ff5ca56747cedc6ce00cd0f51c71dd25ff
25
26 diff --git a/sys-apps/systemd/files/243-rc1-analyze.patch b/sys-apps/systemd/files/243-rc1-analyze.patch
27 new file mode 100644
28 index 00000000000..e38b51eb121
29 --- /dev/null
30 +++ b/sys-apps/systemd/files/243-rc1-analyze.patch
31 @@ -0,0 +1,125 @@
32 +From 417b82e1c341946d277383471f2972b7227061ff Mon Sep 17 00:00:00 2001
33 +From: Mike Gilbert <floppym@g.o>
34 +Date: Tue, 30 Jul 2019 14:51:38 -0400
35 +Subject: [PATCH] analyze: declare dump_exit_status outside of HAVE_SECCOMP
36 + block
37 +
38 +Fixes: 76ed04d936f757763c32db5dbaaebd8b13785d7b
39 +Closes: https://github.com/systemd/systemd/issues/13230
40 +---
41 + src/analyze/analyze.c | 92 +++++++++++++++++++++----------------------
42 + 1 file changed, 46 insertions(+), 46 deletions(-)
43 +
44 +diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
45 +index f62879371d..4d81026084 100644
46 +--- a/src/analyze/analyze.c
47 ++++ b/src/analyze/analyze.c
48 +@@ -1608,6 +1608,52 @@ static int dump_unit_paths(int argc, char *argv[], void *userdata) {
49 + return 0;
50 + }
51 +
52 ++static int dump_exit_status(int argc, char *argv[], void *userdata) {
53 ++ _cleanup_(table_unrefp) Table *table = NULL;
54 ++ int r;
55 ++
56 ++ table = table_new("name", "status", "class");
57 ++ if (!table)
58 ++ return log_oom();
59 ++
60 ++ r = table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
61 ++ if (r < 0)
62 ++ return log_error_errno(r, "Failed to right-align status: %m");
63 ++
64 ++ if (strv_isempty(strv_skip(argv, 1)))
65 ++ for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) {
66 ++ if (!exit_status_mappings[i].name)
67 ++ continue;
68 ++
69 ++ r = table_add_many(table,
70 ++ TABLE_STRING, exit_status_mappings[i].name,
71 ++ TABLE_INT, (int) i,
72 ++ TABLE_STRING, exit_status_class(i));
73 ++ if (r < 0)
74 ++ return r;
75 ++ }
76 ++ else
77 ++ for (int i = 1; i < argc; i++) {
78 ++ int status;
79 ++
80 ++ status = exit_status_from_string(argv[i]);
81 ++ if (status < 0)
82 ++ return log_error_errno(r, "Invalid exit status \"%s\": %m", argv[i]);
83 ++
84 ++ assert(status >= 0 && (size_t) status < ELEMENTSOF(exit_status_mappings));
85 ++ r = table_add_many(table,
86 ++ TABLE_STRING, exit_status_mappings[status].name ?: "-",
87 ++ TABLE_INT, status,
88 ++ TABLE_STRING, exit_status_class(status) ?: "-");
89 ++ if (r < 0)
90 ++ return r;
91 ++ }
92 ++
93 ++ (void) pager_open(arg_pager_flags);
94 ++
95 ++ return table_print(table, NULL);
96 ++}
97 ++
98 + #if HAVE_SECCOMP
99 +
100 + static int load_kernel_syscalls(Set **ret) {
101 +@@ -1685,52 +1731,6 @@ static void dump_syscall_filter(const SyscallFilterSet *set) {
102 + printf(" %s%s%s\n", syscall[0] == '@' ? ansi_underline() : "", syscall, ansi_normal());
103 + }
104 +
105 +-static int dump_exit_status(int argc, char *argv[], void *userdata) {
106 +- _cleanup_(table_unrefp) Table *table = NULL;
107 +- int r;
108 +-
109 +- table = table_new("name", "status", "class");
110 +- if (!table)
111 +- return log_oom();
112 +-
113 +- r = table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
114 +- if (r < 0)
115 +- return log_error_errno(r, "Failed to right-align status: %m");
116 +-
117 +- if (strv_isempty(strv_skip(argv, 1)))
118 +- for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) {
119 +- if (!exit_status_mappings[i].name)
120 +- continue;
121 +-
122 +- r = table_add_many(table,
123 +- TABLE_STRING, exit_status_mappings[i].name,
124 +- TABLE_INT, (int) i,
125 +- TABLE_STRING, exit_status_class(i));
126 +- if (r < 0)
127 +- return r;
128 +- }
129 +- else
130 +- for (int i = 1; i < argc; i++) {
131 +- int status;
132 +-
133 +- status = exit_status_from_string(argv[i]);
134 +- if (status < 0)
135 +- return log_error_errno(r, "Invalid exit status \"%s\": %m", argv[i]);
136 +-
137 +- assert(status >= 0 && (size_t) status < ELEMENTSOF(exit_status_mappings));
138 +- r = table_add_many(table,
139 +- TABLE_STRING, exit_status_mappings[status].name ?: "-",
140 +- TABLE_INT, status,
141 +- TABLE_STRING, exit_status_class(status) ?: "-");
142 +- if (r < 0)
143 +- return r;
144 +- }
145 +-
146 +- (void) pager_open(arg_pager_flags);
147 +-
148 +- return table_print(table, NULL);
149 +-}
150 +-
151 + static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
152 + bool first = true;
153 +
154 +--
155 +2.22.0
156 +
157
158 diff --git a/sys-apps/systemd/systemd-243_rc1.ebuild b/sys-apps/systemd/systemd-243_rc1.ebuild
159 new file mode 100644
160 index 00000000000..529c0bffc49
161 --- /dev/null
162 +++ b/sys-apps/systemd/systemd-243_rc1.ebuild
163 @@ -0,0 +1,472 @@
164 +# Copyright 2011-2019 Gentoo Authors
165 +# Distributed under the terms of the GNU General Public License v2
166 +
167 +EAPI=7
168 +
169 +if [[ ${PV} == 9999 ]]; then
170 + EGIT_REPO_URI="https://github.com/systemd/systemd.git"
171 + inherit git-r3
172 +else
173 + MY_PV=${PV/_/-}
174 + MY_P=${PN}-${MY_PV}
175 + S=${WORKDIR}/${MY_P}
176 + SRC_URI="https://github.com/systemd/systemd/archive/v${MY_PV}/${MY_P}.tar.gz"
177 + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
178 +fi
179 +
180 +PYTHON_COMPAT=( python{3_5,3_6,3_7} )
181 +
182 +inherit bash-completion-r1 linux-info meson multilib-minimal ninja-utils pam python-any-r1 systemd toolchain-funcs udev
183 +
184 +DESCRIPTION="System and service manager for Linux"
185 +HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
186 +
187 +LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
188 +SLOT="0/2"
189 +IUSE="acl apparmor audit build cryptsetup curl dns-over-tls elfutils +gcrypt gnuefi http idn importd +kmod +lz4 lzma nat pam pcre policykit qrcode +resolvconf +seccomp selinux split-usr +sysv-utils test vanilla xkb"
190 +
191 +REQUIRED_USE="importd? ( curl gcrypt lzma )"
192 +RESTRICT="!test? ( test )"
193 +
194 +MINKV="3.11"
195 +
196 +COMMON_DEPEND=">=sys-apps/util-linux-2.30:0=[${MULTILIB_USEDEP}]
197 + sys-libs/libcap:0=[${MULTILIB_USEDEP}]
198 + !<sys-libs/glibc-2.16
199 + acl? ( sys-apps/acl:0= )
200 + apparmor? ( sys-libs/libapparmor:0= )
201 + audit? ( >=sys-process/audit-2:0= )
202 + cryptsetup? ( >=sys-fs/cryptsetup-1.6:0= )
203 + curl? ( net-misc/curl:0= )
204 + dns-over-tls? ( >=net-libs/gnutls-3.5.3:0= )
205 + elfutils? ( >=dev-libs/elfutils-0.158:0= )
206 + gcrypt? ( >=dev-libs/libgcrypt-1.4.5:0=[${MULTILIB_USEDEP}] )
207 + http? (
208 + >=net-libs/libmicrohttpd-0.9.33:0=[epoll(+)]
209 + >=net-libs/gnutls-3.1.4:0=
210 + )
211 + idn? ( net-dns/libidn2:= )
212 + importd? (
213 + app-arch/bzip2:0=
214 + sys-libs/zlib:0=
215 + )
216 + kmod? ( >=sys-apps/kmod-15:0= )
217 + lz4? ( >=app-arch/lz4-0_p131:0=[${MULTILIB_USEDEP}] )
218 + lzma? ( >=app-arch/xz-utils-5.0.5-r1:0=[${MULTILIB_USEDEP}] )
219 + nat? ( net-firewall/iptables:0= )
220 + pam? ( virtual/pam:=[${MULTILIB_USEDEP}] )
221 + pcre? ( dev-libs/libpcre2 )
222 + qrcode? ( media-gfx/qrencode:0= )
223 + seccomp? ( >=sys-libs/libseccomp-2.3.3:0= )
224 + selinux? ( sys-libs/libselinux:0= )
225 + xkb? ( >=x11-libs/libxkbcommon-0.4.1:0= )"
226 +
227 +# Newer linux-headers needed by ia64, bug #480218
228 +DEPEND="${COMMON_DEPEND}
229 + >=sys-kernel/linux-headers-${MINKV}
230 + gnuefi? ( >=sys-boot/gnu-efi-3.0.2 )
231 +"
232 +
233 +# baselayout-2.2 has /run
234 +RDEPEND="${COMMON_DEPEND}
235 + acct-group/adm
236 + acct-group/wheel
237 + acct-group/kmem
238 + acct-group/tty
239 + acct-group/utmp
240 + acct-group/audio
241 + acct-group/cdrom
242 + acct-group/dialout
243 + acct-group/disk
244 + acct-group/input
245 + acct-group/kvm
246 + acct-group/render
247 + acct-group/tape
248 + acct-group/video
249 + acct-group/systemd-journal
250 + acct-user/systemd-journal-remote
251 + acct-user/systemd-coredump
252 + acct-user/systemd-network
253 + acct-user/systemd-resolve
254 + acct-user/systemd-timesync
255 + >=sys-apps/baselayout-2.2
256 + selinux? ( sec-policy/selinux-base-policy[systemd] )
257 + sysv-utils? ( !sys-apps/sysvinit )
258 + !sysv-utils? ( sys-apps/sysvinit )
259 + resolvconf? ( !net-dns/openresolv )
260 + !build? ( || (
261 + sys-apps/util-linux[kill(-)]
262 + sys-process/procps[kill(+)]
263 + sys-apps/coreutils[kill(-)]
264 + ) )
265 + !sys-auth/nss-myhostname
266 + !<sys-kernel/dracut-044
267 + !sys-fs/eudev
268 + !sys-fs/udev
269 +"
270 +
271 +# sys-apps/dbus: the daemon only (+ build-time lib dep for tests)
272 +PDEPEND=">=sys-apps/dbus-1.9.8[systemd]
273 + >=sys-apps/hwids-20150417[udev]
274 + >=sys-fs/udev-init-scripts-25
275 + policykit? ( sys-auth/polkit )
276 + !vanilla? ( sys-apps/gentoo-systemd-integration )"
277 +
278 +BDEPEND="
279 + app-arch/xz-utils:0
280 + dev-util/gperf
281 + >=dev-util/meson-0.46
282 + >=dev-util/intltool-0.50
283 + >=sys-apps/coreutils-8.16
284 + sys-devel/m4
285 + virtual/pkgconfig[${MULTILIB_USEDEP}]
286 + test? ( sys-apps/dbus )
287 + app-text/docbook-xml-dtd:4.2
288 + app-text/docbook-xml-dtd:4.5
289 + app-text/docbook-xsl-stylesheets
290 + dev-libs/libxslt:0
291 + $(python_gen_any_dep 'dev-python/lxml[${PYTHON_USEDEP}]')
292 +"
293 +
294 +pkg_pretend() {
295 + if [[ ${MERGE_TYPE} != buildonly ]]; then
296 + if use test && has pid-sandbox ${FEATURES}; then
297 + ewarn "Tests are known to fail with PID sandboxing enabled."
298 + ewarn "See https://bugs.gentoo.org/674458."
299 + fi
300 +
301 + local CONFIG_CHECK="~AUTOFS4_FS ~BLK_DEV_BSG ~CGROUPS
302 + ~CHECKPOINT_RESTORE ~DEVTMPFS ~EPOLL ~FANOTIFY ~FHANDLE
303 + ~INOTIFY_USER ~IPV6 ~NET ~NET_NS ~PROC_FS ~SIGNALFD ~SYSFS
304 + ~TIMERFD ~TMPFS_XATTR ~UNIX
305 + ~CRYPTO_HMAC ~CRYPTO_SHA256 ~CRYPTO_USER_API_HASH
306 + ~!FW_LOADER_USER_HELPER_FALLBACK ~!GRKERNSEC_PROC ~!IDE ~!SYSFS_DEPRECATED
307 + ~!SYSFS_DEPRECATED_V2"
308 +
309 + use acl && CONFIG_CHECK+=" ~TMPFS_POSIX_ACL"
310 + use seccomp && CONFIG_CHECK+=" ~SECCOMP ~SECCOMP_FILTER"
311 + kernel_is -lt 3 7 && CONFIG_CHECK+=" ~HOTPLUG"
312 + kernel_is -lt 4 7 && CONFIG_CHECK+=" ~DEVPTS_MULTIPLE_INSTANCES"
313 + kernel_is -ge 4 10 && CONFIG_CHECK+=" ~CGROUP_BPF"
314 +
315 + if linux_config_exists; then
316 + local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
317 + if [[ -n ${uevent_helper_path} ]] && [[ ${uevent_helper_path} != '""' ]]; then
318 + ewarn "It's recommended to set an empty value to the following kernel config option:"
319 + ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
320 + fi
321 + if linux_chkconfig_present X86; then
322 + CONFIG_CHECK+=" ~DMIID"
323 + fi
324 + fi
325 +
326 + if kernel_is -lt ${MINKV//./ }; then
327 + ewarn "Kernel version at least ${MINKV} required"
328 + fi
329 +
330 + check_extra_config
331 + fi
332 +}
333 +
334 +pkg_setup() {
335 + :
336 +}
337 +
338 +src_unpack() {
339 + default
340 + [[ ${PV} != 9999 ]] || git-r3_src_unpack
341 +}
342 +
343 +src_prepare() {
344 + # Do NOT add patches here
345 + local PATCHES=()
346 +
347 + [[ -d "${WORKDIR}"/patches ]] && PATCHES+=( "${WORKDIR}"/patches )
348 +
349 + # Add local patches here
350 + PATCHES+=(
351 + "${FILESDIR}"/243-rc1-analyze.patch
352 + )
353 +
354 + if ! use vanilla; then
355 + PATCHES+=(
356 + "${FILESDIR}/gentoo-Dont-enable-audit-by-default.patch"
357 + "${FILESDIR}/gentoo-systemd-user-pam.patch"
358 + "${FILESDIR}/gentoo-generator-path-r1.patch"
359 + )
360 + fi
361 +
362 + default
363 +}
364 +
365 +src_configure() {
366 + # Prevent conflicts with i686 cross toolchain, bug 559726
367 + tc-export AR CC NM OBJCOPY RANLIB
368 +
369 + python_setup
370 +
371 + multilib-minimal_src_configure
372 +}
373 +
374 +meson_use() {
375 + usex "$1" true false
376 +}
377 +
378 +meson_multilib() {
379 + if multilib_is_native_abi; then
380 + echo true
381 + else
382 + echo false
383 + fi
384 +}
385 +
386 +meson_multilib_native_use() {
387 + if multilib_is_native_abi && use "$1"; then
388 + echo true
389 + else
390 + echo false
391 + fi
392 +}
393 +
394 +multilib_src_configure() {
395 + local myconf=(
396 + --localstatedir="${EPREFIX}/var"
397 + -Dsupport-url="https://gentoo.org/support/"
398 + -Dpamlibdir="$(getpam_mod_dir)"
399 + # avoid bash-completion dep
400 + -Dbashcompletiondir="$(get_bashcompdir)"
401 + # make sure we get /bin:/sbin in PATH
402 + -Dsplit-usr=$(usex split-usr true false)
403 + -Drootprefix="$(usex split-usr "${EPREFIX:-/}" "${EPREFIX}/usr")"
404 + -Dsysvinit-path=
405 + -Dsysvrcnd-path=
406 + # Avoid infinite exec recursion, bug 642724
407 + -Dtelinit-path="${EPREFIX}/lib/sysvinit/telinit"
408 + # no deps
409 + -Defi=$(meson_multilib)
410 + -Dima=true
411 + # Optional components/dependencies
412 + -Dacl=$(meson_multilib_native_use acl)
413 + -Dapparmor=$(meson_multilib_native_use apparmor)
414 + -Daudit=$(meson_multilib_native_use audit)
415 + -Dlibcryptsetup=$(meson_multilib_native_use cryptsetup)
416 + -Dlibcurl=$(meson_multilib_native_use curl)
417 + -Ddns-over-tls=$(meson_multilib_native_use dns-over-tls)
418 + -Delfutils=$(meson_multilib_native_use elfutils)
419 + -Dgcrypt=$(meson_use gcrypt)
420 + -Dgnu-efi=$(meson_multilib_native_use gnuefi)
421 + -Defi-libdir="${ESYSROOT}/usr/$(get_libdir)"
422 + -Dmicrohttpd=$(meson_multilib_native_use http)
423 + -Didn=$(meson_multilib_native_use idn)
424 + -Dimportd=$(meson_multilib_native_use importd)
425 + -Dbzip2=$(meson_multilib_native_use importd)
426 + -Dzlib=$(meson_multilib_native_use importd)
427 + -Dkmod=$(meson_multilib_native_use kmod)
428 + -Dlz4=$(meson_use lz4)
429 + -Dxz=$(meson_use lzma)
430 + -Dlibiptc=$(meson_multilib_native_use nat)
431 + -Dpam=$(meson_use pam)
432 + -Dpcre2=$(meson_multilib_native_use pcre)
433 + -Dpolkit=$(meson_multilib_native_use policykit)
434 + -Dqrencode=$(meson_multilib_native_use qrcode)
435 + -Dseccomp=$(meson_multilib_native_use seccomp)
436 + -Dselinux=$(meson_multilib_native_use selinux)
437 + -Ddbus=$(meson_multilib_native_use test)
438 + -Dxkbcommon=$(meson_multilib_native_use xkb)
439 + # hardcode a few paths to spare some deps
440 + -Dkill-path=/bin/kill
441 + -Dntp-servers="0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"
442 + # Breaks screen, tmux, etc.
443 + -Ddefault-kill-user-processes=false
444 +
445 + # multilib options
446 + -Dbacklight=$(meson_multilib)
447 + -Dbinfmt=$(meson_multilib)
448 + -Dcoredump=$(meson_multilib)
449 + -Denvironment-d=$(meson_multilib)
450 + -Dfirstboot=$(meson_multilib)
451 + -Dhibernate=$(meson_multilib)
452 + -Dhostnamed=$(meson_multilib)
453 + -Dhwdb=$(meson_multilib)
454 + -Dldconfig=$(meson_multilib)
455 + -Dlocaled=$(meson_multilib)
456 + -Dman=$(meson_multilib)
457 + -Dnetworkd=$(meson_multilib)
458 + -Dquotacheck=$(meson_multilib)
459 + -Drandomseed=$(meson_multilib)
460 + -Drfkill=$(meson_multilib)
461 + -Dsysusers=$(meson_multilib)
462 + -Dtimedated=$(meson_multilib)
463 + -Dtimesyncd=$(meson_multilib)
464 + -Dtmpfiles=$(meson_multilib)
465 + -Dvconsole=$(meson_multilib)
466 + )
467 +
468 + meson_src_configure "${myconf[@]}"
469 +}
470 +
471 +multilib_src_compile() {
472 + eninja
473 +}
474 +
475 +multilib_src_test() {
476 + unset DBUS_SESSION_BUS_ADDRESS XDG_RUNTIME_DIR
477 + eninja test
478 +}
479 +
480 +multilib_src_install() {
481 + DESTDIR="${D}" eninja install
482 +}
483 +
484 +multilib_src_install_all() {
485 + local rootprefix=$(usex split-usr '' /usr)
486 +
487 + # meson doesn't know about docdir
488 + mv "${ED}"/usr/share/doc/{systemd,${PF}} || die
489 +
490 + einstalldocs
491 + dodoc "${FILESDIR}"/nsswitch.conf
492 +
493 + if ! use resolvconf; then
494 + rm -f "${ED}${rootprefix}"/sbin/resolvconf || die
495 + fi
496 +
497 + if ! use sysv-utils; then
498 + rm "${ED}${rootprefix}"/sbin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit} || die
499 + rm "${ED}"/usr/share/man/man1/init.1 || die
500 + rm "${ED}"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 || die
501 + fi
502 +
503 + if ! use resolvconf && ! use sysv-utils; then
504 + rmdir "${ED}${rootprefix}"/sbin || die
505 + fi
506 +
507 + # Preserve empty dirs in /etc & /var, bug #437008
508 + keepdir /etc/{binfmt.d,modules-load.d,tmpfiles.d}
509 + keepdir /etc/kernel/install.d
510 + keepdir /etc/systemd/{network,user}
511 + keepdir /etc/udev/{hwdb.d,rules.d}
512 + keepdir "${rootprefix}"/lib/systemd/{system-sleep,system-shutdown}
513 + keepdir /usr/lib/{binfmt.d,modules-load.d}
514 + keepdir /usr/lib/systemd/user-generators
515 + keepdir /var/lib/systemd
516 + rm -rf "${ED}"/var/log || die
517 +
518 + # Symlink /etc/sysctl.conf for easy migration.
519 + dosym ../sysctl.conf /etc/sysctl.d/99-sysctl.conf
520 +
521 + local udevdir=/lib/udev
522 + use split-usr || udevdir=/usr/lib/udev
523 +
524 + rm -r "${ED}${udevdir}/hwdb.d" || die
525 +
526 + if use split-usr; then
527 + # Avoid breaking boot/reboot
528 + dosym ../../../lib/systemd/systemd /usr/lib/systemd/systemd
529 + dosym ../../../lib/systemd/systemd-shutdown /usr/lib/systemd/systemd-shutdown
530 + fi
531 +}
532 +
533 +migrate_locale() {
534 + local envd_locale_def="${EROOT}/etc/env.d/02locale"
535 + local envd_locale=( "${EROOT}"/etc/env.d/??locale )
536 + local locale_conf="${EROOT}/etc/locale.conf"
537 +
538 + if [[ ! -L ${locale_conf} && ! -e ${locale_conf} ]]; then
539 + # If locale.conf does not exist...
540 + if [[ -e ${envd_locale} ]]; then
541 + # ...either copy env.d/??locale if there's one
542 + ebegin "Moving ${envd_locale} to ${locale_conf}"
543 + mv "${envd_locale}" "${locale_conf}"
544 + eend ${?} || FAIL=1
545 + else
546 + # ...or create a dummy default
547 + ebegin "Creating ${locale_conf}"
548 + cat > "${locale_conf}" <<-EOF
549 + # This file has been created by the sys-apps/systemd ebuild.
550 + # See locale.conf(5) and localectl(1).
551 +
552 + # LANG=${LANG}
553 + EOF
554 + eend ${?} || FAIL=1
555 + fi
556 + fi
557 +
558 + if [[ ! -L ${envd_locale} ]]; then
559 + # now, if env.d/??locale is not a symlink (to locale.conf)...
560 + if [[ -e ${envd_locale} ]]; then
561 + # ...warn the user that he has duplicate locale settings
562 + ewarn
563 + ewarn "To ensure consistent behavior, you should replace ${envd_locale}"
564 + ewarn "with a symlink to ${locale_conf}. Please migrate your settings"
565 + ewarn "and create the symlink with the following command:"
566 + ewarn "ln -s -n -f ../locale.conf ${envd_locale}"
567 + ewarn
568 + else
569 + # ...or just create the symlink if there's nothing here
570 + ebegin "Creating ${envd_locale_def} -> ../locale.conf symlink"
571 + ln -n -s ../locale.conf "${envd_locale_def}"
572 + eend ${?} || FAIL=1
573 + fi
574 + fi
575 +}
576 +
577 +save_enabled_units() {
578 + ENABLED_UNITS=()
579 + type systemctl &>/dev/null || return
580 + for x; do
581 + if systemctl --quiet --root="${ROOT:-/}" is-enabled "${x}"; then
582 + ENABLED_UNITS+=( "${x}" )
583 + fi
584 + done
585 +}
586 +
587 +pkg_preinst() {
588 + save_enabled_units {machines,remote-{cryptsetup,fs}}.target getty@××××.service
589 +}
590 +
591 +pkg_postinst() {
592 + systemd_update_catalog
593 +
594 + # Keep this here in case the database format changes so it gets updated
595 + # when required. Despite that this file is owned by sys-apps/hwids.
596 + if has_version "sys-apps/hwids[udev]"; then
597 + udevadm hwdb --update --root="${EROOT}"
598 + fi
599 +
600 + udev_reload || FAIL=1
601 +
602 + # Bug 465468, make sure locales are respect, and ensure consistency
603 + # between OpenRC & systemd
604 + migrate_locale
605 +
606 + systemd_reenable systemd-networkd.service systemd-resolved.service
607 +
608 + if [[ ${ENABLED_UNITS[@]} ]]; then
609 + systemctl --root="${ROOT:-/}" enable "${ENABLED_UNITS[@]}"
610 + fi
611 +
612 + if [[ -L ${EROOT}/var/lib/systemd/timesync ]]; then
613 + rm "${EROOT}/var/lib/systemd/timesync"
614 + fi
615 +
616 + if [[ -z ${ROOT} && -d /run/systemd/system ]]; then
617 + ebegin "Reexecuting system manager"
618 + systemctl daemon-reexec
619 + eend $?
620 + fi
621 +
622 + if [[ ${FAIL} ]]; then
623 + eerror "One of the postinst commands failed. Please check the postinst output"
624 + eerror "for errors. You may need to clean up your system and/or try installing"
625 + eerror "systemd again."
626 + eerror
627 + fi
628 +}
629 +
630 +pkg_prerm() {
631 + # If removing systemd completely, remove the catalog database.
632 + if [[ ! ${REPLACED_BY_VERSION} ]]; then
633 + rm -f -v "${EROOT}"/var/lib/systemd/catalog/database
634 + fi
635 +}