Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] dev/mgorny:master commit in: sys-apps/systemd/, sys-apps/systemd/files/
Date: Fri, 06 Jan 2012 10:18:07
Message-Id: 339601a030c05fb9e8e2f873b05c11cc73c0d9bb.mgorny@gentoo
1 commit: 339601a030c05fb9e8e2f873b05c11cc73c0d9bb
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 6 09:49:49 2012 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 6 09:49:49 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/mgorny.git;a=commit;h=339601a0
7
8 sys-apps/systemd: Migrate to /usr.
9
10 (Portage version: 2.2.0_alpha84/git/Linux x86_64, unsigned Manifest commit)
11
12 ---
13 .../systemd/files/update-etc-systemd-symlinks.path | 5 +++
14 .../files/update-etc-systemd-symlinks.service | 6 ++++
15 .../systemd/files/update-etc-systemd-symlinks.sh | 19 +++++++++++++
16 sys-apps/systemd/systemd-9999.ebuild | 28 ++++++++++++++++++-
17 4 files changed, 56 insertions(+), 2 deletions(-)
18
19 diff --git a/sys-apps/systemd/files/update-etc-systemd-symlinks.path b/sys-apps/systemd/files/update-etc-systemd-symlinks.path
20 new file mode 100644
21 index 0000000..33a9576
22 --- /dev/null
23 +++ b/sys-apps/systemd/files/update-etc-systemd-symlinks.path
24 @@ -0,0 +1,5 @@
25 +[Unit]
26 +Description=Update /etc/systemd/system symlinks for units moved to /usr
27 +
28 +[Path]
29 +PathChanged=/lib/systemd/system
30
31 diff --git a/sys-apps/systemd/files/update-etc-systemd-symlinks.service b/sys-apps/systemd/files/update-etc-systemd-symlinks.service
32 new file mode 100644
33 index 0000000..c05a194
34 --- /dev/null
35 +++ b/sys-apps/systemd/files/update-etc-systemd-symlinks.service
36 @@ -0,0 +1,6 @@
37 +[Unit]
38 +Description=Update /etc/systemd/system symlinks for units moved to /usr
39 +
40 +[Service]
41 +Type=oneshot
42 +ExecStart=/usr/libexec/systemd/update-etc-systemd-symlinks.sh
43
44 diff --git a/sys-apps/systemd/files/update-etc-systemd-symlinks.sh b/sys-apps/systemd/files/update-etc-systemd-symlinks.sh
45 new file mode 100755
46 index 0000000..ce81bba
47 --- /dev/null
48 +++ b/sys-apps/systemd/files/update-etc-systemd-symlinks.sh
49 @@ -0,0 +1,19 @@
50 +#!/bin/sh
51 +# Update symlinks to systemd units moved into /usr/systemd.
52 +# (c) 2012 Michał Górny
53 +# Released under the terms of the 2-clause BSD license
54 +
55 +IFS_SAVE=${IFS}
56 +IFS='
57 +'
58 +# follow + symlink type will match broken symlinks only
59 +set -- $(find -L /etc/systemd/system -type l -print)
60 +IFS=${IFS_SAVE}
61 +
62 +for f; do
63 + old_path=$(readlink "${f}")
64 + new_path=/usr/lib${old_path#/lib}
65 + if [ -f "${new_path}" ]; then
66 + ln -v -s -f "${new_path}" "${f}"
67 + fi
68 +done
69
70 diff --git a/sys-apps/systemd/systemd-9999.ebuild b/sys-apps/systemd/systemd-9999.ebuild
71 index da2e400..c13decc 100644
72 --- a/sys-apps/systemd/systemd-9999.ebuild
73 +++ b/sys-apps/systemd/systemd-9999.ebuild
74 @@ -77,14 +77,18 @@ pkg_setup() {
75 src_prepare() {
76 # Force the rebuild of .vala sources
77 touch src/*.vala || die
78 +
79 + # Fix hardcoded path in .vala.
80 + sed -i -e 's:/lib/systemd:/usr/lib/systemd:g' src/*.vala || die
81 +
82 autotools-utils_src_prepare
83 }
84
85 src_configure() {
86 local myeconfargs=(
87 --with-distro=gentoo
88 - --with-rootprefix=
89 - --with-rootlibdir=/$(get_libdir)
90 + --with-rootprefix=/usr
91 + --with-rootlibdir=/usr/$(get_libdir)
92 --localstatedir=/var
93 --docdir=/tmp/docs
94 $(use_enable acl)
95 @@ -108,6 +112,9 @@ src_install() {
96 autotools-utils_src_install \
97 bashcompletiondir=/tmp
98
99 + # compat for init= use
100 + dosym ../usr/bin/systemd /bin/systemd
101 +
102 # move files as necessary
103 newbashcomp "${D}"/tmp/systemd-bash-completion.sh ${PN}
104 dodoc "${D}"/tmp/docs/*
105 @@ -122,6 +129,12 @@ src_install() {
106 # Create /run/lock as required by new baselay/OpenRC compat.
107 insinto /usr/lib/tmpfiles.d
108 doins "${FILESDIR}"/gentoo-run.conf
109 +
110 + # Migration helpers.
111 + exeinto /usr/libexec/systemd
112 + doexe "${FILESDIR}"/update-etc-systemd-symlinks.sh
113 + systemd_dounit "${FILESDIR}"/update-etc-systemd-symlinks.{service,path}
114 + systemd_enable_service sysinit.target update-etc-systemd-symlinks.path
115 }
116
117 pkg_preinst() {
118 @@ -160,4 +173,15 @@ pkg_postinst() {
119 ewarn "responsibility. Please remember than you can pass:"
120 ewarn " init=/sbin/init"
121 ewarn "to your kernel to boot using sysvinit / OpenRC."
122 +
123 + # Don't run it if we're outta /
124 + if [[ ! ${ROOT%/} ]]; then
125 + # Update symlinks to moved units.
126 + sh "${FILESDIR}"/update-etc-systemd-symlinks.sh
127 +
128 + # Try to start migration unit.
129 + ebegin "Trying to start migration helper path monitoring."
130 + systemctl --system start update-etc-systemd-symlinks.path 2>/dev/null
131 + eend ${?}
132 + fi
133 }