Gentoo Archives: gentoo-commits

From: Piotr Karbowski <slashbeast@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: gui-libs/display-manager-init/files/, gui-libs/display-manager-init/
Date: Sat, 30 Jan 2021 19:21:19
Message-Id: 1612034262.c78bee32adb057ac965b7f60f46980951cfa44bc.slashbeast@gentoo
1 commit: c78bee32adb057ac965b7f60f46980951cfa44bc
2 Author: Aisha Tammy <gentoo <AT> aisha <DOT> cc>
3 AuthorDate: Thu Sep 10 01:30:09 2020 +0000
4 Commit: Piotr Karbowski <slashbeast <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 30 19:17:42 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c78bee32
7
8 gui-libs/display-manager-init: refactor init files out of xorg-server
9
10 Closes: https://bugs.gentoo.org/730644
11 Package-Manager: Portage-3.0.5, Repoman-3.0.1
12 Signed-off-by: Aisha Tammy <gentoo <AT> aisha.cc>
13 Signed-off-by: Piotr Karbowski <slashbeast <AT> gentoo.org>
14
15 .../display-manager-init-1.0.ebuild | 37 ++++
16 .../files/display-manager-setup.initd | 13 ++
17 .../files/display-manager.confd | 13 ++
18 .../files/display-manager.initd | 234 +++++++++++++++++++++
19 gui-libs/display-manager-init/files/startDM | 29 +++
20 gui-libs/display-manager-init/files/xdm.initd | 13 ++
21 gui-libs/display-manager-init/metadata.xml | 8 +
22 7 files changed, 347 insertions(+)
23
24 diff --git a/gui-libs/display-manager-init/display-manager-init-1.0.ebuild b/gui-libs/display-manager-init/display-manager-init-1.0.ebuild
25 new file mode 100644
26 index 00000000000..576a0a7c887
27 --- /dev/null
28 +++ b/gui-libs/display-manager-init/display-manager-init-1.0.ebuild
29 @@ -0,0 +1,37 @@
30 +# Copyright 1999-2020 Gentoo Authors
31 +# Distributed under the terms of the GNU General Public License v2
32 +
33 +EAPI=7
34 +
35 +DESCRIPTION="RC init files for starting display and login managers"
36 +HOMEPAGE="https://wiki.gentoo.org/wiki/Project:X11"
37 +
38 +LICENSE="GPL-2"
39 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
40 +SLOT="0"
41 +
42 +S="${FILESDIR}"
43 +
44 +RDEPEND="
45 + sys-apps/gentoo-functions
46 + !<=sys-apps/sysvinit-2.98
47 + !<=x11-apps/xinit-1.4.1
48 + !<=x11-base/xorg-server-1.20.10
49 +"
50 +
51 +src_install() {
52 + newinitd "${FILESDIR}"/display-manager-setup.initd display-manager-setup
53 + newinitd "${FILESDIR}"/display-manager.initd display-manager
54 + newinitd "${FILESDIR}"/xdm.initd xdm
55 + newconfd "${FILESDIR}"/display-manager.confd display-manager
56 + exeinto /usr/bin
57 + doexe "${FILESDIR}"/startDM
58 + # backwards compatibility
59 + dosym "${ESYSROOT}"/usr/bin/startDM /etc/X11/startDM.sh
60 +}
61 +
62 +pkg_preinst() {
63 + if [[ ${REPLACING_VERSIONS} == "" && -f "${EROOT}"/etc/conf.d/xdm && ! -f "${EROOT}"/etc/conf.d/display-manager ]]; then
64 + mv "${EROOT}"/etc/conf.d/{xdm,display-manager} || die
65 + fi
66 +}
67
68 diff --git a/gui-libs/display-manager-init/files/display-manager-setup.initd b/gui-libs/display-manager-init/files/display-manager-setup.initd
69 new file mode 100644
70 index 00000000000..05feeee84ae
71 --- /dev/null
72 +++ b/gui-libs/display-manager-init/files/display-manager-setup.initd
73 @@ -0,0 +1,13 @@
74 +#!/sbin/openrc-run
75 +# Copyright 1999-2020 Gentoo Authors
76 +# Distributed under the terms of the GNU General Public License v2
77 +
78 +depend() {
79 + need localmount
80 +}
81 +
82 +start() {
83 + if get_bootparam "nogui" ; then
84 + touch /run/.nogui
85 + fi
86 +}
87
88 diff --git a/gui-libs/display-manager-init/files/display-manager.confd b/gui-libs/display-manager-init/files/display-manager.confd
89 new file mode 100644
90 index 00000000000..25d57e923c4
91 --- /dev/null
92 +++ b/gui-libs/display-manager-init/files/display-manager.confd
93 @@ -0,0 +1,13 @@
94 +# We always try and start the DM on a static VT. The various DMs normally
95 +# default to using VT7. If you wish to use the display-manager init
96 +# script, then you should ensure that the VT checked is the same VT your
97 +# DM wants to use.
98 +# We do this check to ensure that you haven't accidentally configured
99 +# something to run on the VT in your /etc/inittab file so that
100 +# you don't get a dead keyboard.
101 +CHECKVT=7
102 +
103 +# What display manager do you use ?
104 +# [ xdm | greetd | gdm | sddm | gpe | lightdm | entrance ]
105 +# NOTE: If this is set in /etc/rc.conf, that setting will override this one.
106 +DISPLAYMANAGER="xdm"
107
108 diff --git a/gui-libs/display-manager-init/files/display-manager.initd b/gui-libs/display-manager-init/files/display-manager.initd
109 new file mode 100644
110 index 00000000000..e650df9600e
111 --- /dev/null
112 +++ b/gui-libs/display-manager-init/files/display-manager.initd
113 @@ -0,0 +1,234 @@
114 +#!/sbin/openrc-run
115 +# Copyright 1999-2020 Gentoo Authors
116 +# Distributed under the terms of the GNU General Public License, v2
117 +
118 +# This is here to serve as a note to myself, and future developers.
119 +#
120 +# Any Display manager (gdm,kdm,xdm) has the following problem: if
121 +# it is started before any getty, and no vt is specified, it will
122 +# usually run on vt2. When the getty on vt2 then starts, and the
123 +# DM is already started, the getty will take control of the keyboard,
124 +# leaving us with a "dead" keyboard.
125 +#
126 +# Resolution: add the following line to /etc/inittab
127 +#
128 +# x:a:once:/usr/bin/startDM
129 +#
130 +# and have /usr/bin/startDM start the DM in daemon mode if
131 +# a lock is present (with the info of what DM should be started),
132 +# else just fall through.
133 +#
134 +# How this basically works, is the "a" runlevel is a additional
135 +# runlevel that you can use to fork processes with init, but the
136 +# runlevel never gets changed to this runlevel. Along with the "a"
137 +# runlevel, the "once" key word means that startDM will only be
138 +# run when we specify it to run, thus eliminating respawning
139 +# startDM when "display-manager" is not added to the default
140 +# runlevel, as was done previously.
141 +#
142 +# This script then just calls "telinit a", and init will run
143 +# /usr/bin/startDM after the current runlevel completes (this
144 +# script should only be added to the actual runlevel the user is
145 +# using).
146 +#
147 +# Martin Schlemmer
148 +# aka Azarah
149 +# 04 March 2002
150 +
151 +depend() {
152 + need localmount display-manager-setup
153 +
154 + # this should start as early as possible
155 + # we can't do 'before *' as that breaks it
156 + # (#139824) Start after ypbind and autofs for network authentication
157 + # (#145219 #180163) Could use lirc mouse as input device
158 + # (#70689 comment #92) Start after consolefont to avoid display corruption
159 + # (#291269) Start after quota, since some dm need readable home
160 + # (#390609) gdm-3 will fail when dbus is not running
161 + # (#366753) starting keymaps after X causes problems
162 + after bootmisc consolefont modules netmount
163 + after readahead-list ypbind autofs openvpn gpm lircmd
164 + after quota keymaps
165 + before alsasound
166 +
167 + # Start before GUI
168 + use dbus xfs
169 +}
170 +
171 +setup_dm() {
172 + local MY_XDM
173 +
174 + MY_XDM=$(echo "${DISPLAYMANAGER}" | tr '[:upper:]' '[:lower:]')
175 +
176 + NAME=
177 + case "${MY_XDM}" in
178 + kdm|kde)
179 + # Load our root path from profile.env
180 + # Needed for kdm
181 + PATH=${PATH}:$(. /etc/profile.env; echo "${ROOTPATH}")
182 + EXE=/usr/bin/kdm
183 + PIDFILE=/run/kdm.pid
184 + ;;
185 + entrance*)
186 + EXE=/usr/sbin/entrance
187 + PIDFILE=/run/entrance.pid
188 + ;;
189 + gdm|gnome)
190 + # gdm-3 and above has different paths
191 + if [ -f /usr/sbin/gdm ]; then
192 + EXE=/usr/sbin/gdm
193 + PIDFILE=/run/gdm/gdm.pid
194 + START_STOP_ARGS="--background"
195 + AUTOCLEAN_CGROUP="yes"
196 + else
197 + EXE=/usr/bin/gdm
198 + PIDFILE=/run/gdm.pid
199 + fi
200 + [ "${RC_UNAME}" != "Linux" ] && NAME=gdm-binary
201 + ;;
202 + greetd)
203 + EXE=/usr/bin/greetd
204 + PIDFILE=/run/greetd.pid
205 + START_STOP_ARGS="-m --background"
206 + ;;
207 + wdm)
208 + EXE=/usr/bin/wdm
209 + PIDFILE=
210 + ;;
211 + gpe)
212 + EXE=/usr/bin/gpe-dm
213 + PIDFILE=/run/gpe-dm.pid
214 + ;;
215 + lxdm)
216 + EXE=/usr/sbin/lxdm-binary
217 + PIDFILE=/run/lxdm.pid
218 + START_STOP_ARGS="--background"
219 + ;;
220 + lightdm)
221 + EXE=/usr/sbin/lightdm
222 + PIDFILE=/run/lightdm.pid
223 + START_STOP_ARGS="--background"
224 + ;;
225 + sddm)
226 + EXE="/usr/bin/sddm"
227 + START_STOP_ARGS="-m --background"
228 + PIDFILE=/run/sddm.pid
229 + ;;
230 + *)
231 + # first find out if there is such executable
232 + EXE="$(command -v ${MY_XDM} 2>/dev/null)"
233 + PIDFILE="/run/${MY_XDM}.pid"
234 +
235 + # warn user that they are doing sick things if the exe was not found
236 + if [ -z "${EXE}" ]; then
237 + echo "ERROR: Your XDM value is invalid."
238 + echo " No ${MY_XDM} executable could be found on your system."
239 + fi
240 + ;;
241 + esac
242 +
243 + if ! [ -x "${EXE}" ]; then
244 + EXE=/usr/bin/xdm
245 + PIDFILE=/run/xdm.pid
246 + if ! [ -x "/usr/bin/xdm" ]; then
247 + echo "ERROR: Please set your DISPLAYMANAGER variable in /etc/conf.d/xdm,"
248 + echo " or install x11-apps/xdm package"
249 + eend 255
250 + fi
251 + fi
252 +}
253 +
254 +# Check to see if something is defined on our VT
255 +vtstatic() {
256 + if [ -e /etc/inittab ] ; then
257 + grep -Eq "^[^#]+.*\<tty$1\>" /etc/inittab
258 + elif [ -e /etc/ttys ] ; then
259 + grep -q "^ttyv$(($1 - 1))" /etc/ttys
260 + else
261 + return 1
262 + fi
263 +}
264 +
265 +start() {
266 + local EXE NAME PIDFILE AUTOCLEAN_CGROUP
267 + setup_dm
268 +
269 + if [ -f /run/.nogui ]; then
270 + einfo "Skipping ${EXE##*/}, /run/.nogui found or 'nogui' bootparam passed."
271 + rm /run/.nogui
272 + return 0
273 + fi
274 +
275 + ebegin "Setting up ${EXE##*/}"
276 +
277 + # save the prefered DM
278 + save_options "service" "${EXE}"
279 + save_options "name" "${NAME}"
280 + save_options "pidfile" "${PIDFILE}"
281 + save_options "start_stop_args" "${START_STOP_ARGS}"
282 + save_options "autoclean_cgroup" "${AUTOCLEAN_CGROUP:-no}"
283 +
284 + if [ -n "${CHECKVT-y}" ] ; then
285 + if vtstatic "${CHECKVT:-7}" ; then
286 + if [ -x /sbin/telinit ] && [ "${SOFTLEVEL}" != "BOOT" ] && [ "${RC_SOFTLEVEL}" != "BOOT" ]; then
287 + ewarn "Something is already defined on VT ${CHECKVT:-7}, will start X later"
288 + telinit a >/dev/null 2>&1
289 + return 0
290 + else
291 + eerror "Something is already defined on VT ${CHECKVT:-7}, not starting"
292 + return 1
293 + fi
294 + fi
295 + fi
296 +
297 + /usr/bin/startDM
298 + eend 0
299 +}
300 +
301 +stop() {
302 + local curvt retval
303 +
304 + retval=0
305 + if [ -t 0 ]; then
306 + if type fgconsole >/dev/null 2>&1; then
307 + curvt=$(fgconsole 2>/dev/null)
308 + else
309 + curvt=$(tty)
310 + case "${curvt}" in
311 + /dev/ttyv[0-9]*) curvt=${curvt#/dev/ttyv} ;;
312 + *) curvt= ;;
313 + esac
314 + fi
315 + fi
316 + local myexe myname mypidfile myservice
317 + myexe=$(get_options "service")
318 + myname=$(get_options "name")
319 + mypidfile=$(get_options "pidfile")
320 + myservice=${myexe##*/}
321 + yesno "${rc_cgroup_cleanup:-no}" || rc_cgroup_cleanup=$(get_options "autoclean_cgroup")
322 +
323 + [ -z "${myexe}" ] && return 0
324 +
325 + ebegin "Stopping ${myservice}"
326 +
327 + if start-stop-daemon --quiet --test --stop --exec "${myexe}" 2>/dev/null; then
328 + start-stop-daemon --stop --exec "${myexe}" --retry TERM/5/TERM/5 \
329 + "${mypidfile:+--pidfile}" "${mypidfile}" \
330 + "${myname:+--name}" "${myname}"
331 + retval=${?}
332 + fi
333 +
334 + # switch back to original vt
335 + if [ -n "${curvt}" ]; then
336 + if type chvt >/dev/null 2>&1; then
337 + chvt "${curvt}"
338 + else
339 + vidcontrol -s "$((curvt + 1))"
340 + fi
341 + fi
342 +
343 + eend ${retval} "Error stopping ${myservice}"
344 + return ${retval}
345 +}
346 +
347 +# vim: set ts=4 :
348
349 diff --git a/gui-libs/display-manager-init/files/startDM b/gui-libs/display-manager-init/files/startDM
350 new file mode 100644
351 index 00000000000..976d1dd2d56
352 --- /dev/null
353 +++ b/gui-libs/display-manager-init/files/startDM
354 @@ -0,0 +1,29 @@
355 +#!/bin/sh
356 +# Copyright 1999-2020 Gentoo Authors
357 +# Distributed under the terms of the GNU General Public License, v2
358 +
359 +# We need to source /etc/profile.env for stuff like $LANG to work
360 +# bug #10190.
361 +. /etc/profile.env
362 +
363 +# need eerror
364 +. /lib/gentoo/functions.sh
365 +
366 +# Bail out early if on a non-OpenRC system:
367 +if [ ! -d /run/openrc ]; then
368 + eerror "$0 should only be used on OpenRC systems"
369 +fi
370 +
371 +. /lib/rc/sh/functions.sh
372 +
373 +export RC_SVCNAME=display-manager
374 +EXEC="$(get_options service)"
375 +NAME="$(get_options name)"
376 +PIDFILE="$(get_options pidfile)"
377 +START_STOP_ARGS="$(get_options start_stop_args)"
378 +
379 +start-stop-daemon --start --exec "${EXEC}" \
380 +"${NAME:+--name}" "${NAME}" "${PIDFILE:+--pidfile}" "${PIDFILE}" ${START_STOP_ARGS} || \
381 +eerror "ERROR: could not start the Display Manager"
382 +
383 +# vim:ts=4
384
385 diff --git a/gui-libs/display-manager-init/files/xdm.initd b/gui-libs/display-manager-init/files/xdm.initd
386 new file mode 100644
387 index 00000000000..2fce43b0f47
388 --- /dev/null
389 +++ b/gui-libs/display-manager-init/files/xdm.initd
390 @@ -0,0 +1,13 @@
391 +#!/sbin/openrc-run
392 +# Copyright 1999-2020 Gentoo Authors
393 +# Distributed under the terms of the GNU General Public License, v2
394 +
395 +depend() {
396 + need display-manager
397 +}
398 +
399 +start() {
400 + return
401 +}
402 +
403 +# vim: set ts=4 :
404
405 diff --git a/gui-libs/display-manager-init/metadata.xml b/gui-libs/display-manager-init/metadata.xml
406 new file mode 100644
407 index 00000000000..7a7bbf81054
408 --- /dev/null
409 +++ b/gui-libs/display-manager-init/metadata.xml
410 @@ -0,0 +1,8 @@
411 +<?xml version="1.0" encoding="UTF-8"?>
412 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
413 +<pkgmetadata>
414 + <maintainer type="project">
415 + <email>x11@g.o</email>
416 + <name>X11</name>
417 + </maintainer>
418 +</pkgmetadata>