gnome-base/gdm: workaround file perm and bluetooth sound issues
[gentoo.git] / gnome-base / gdm / gdm-3.30.3-r3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 GNOME2_LA_PUNT="yes"
6 GNOME2_EAUTORECONF="yes"
7
8 inherit eutils gnome2 pam readme.gentoo-r1 systemd udev user
9
10 DESCRIPTION="GNOME Display Manager for managing graphical display servers and user logins"
11 HOMEPAGE="https://wiki.gnome.org/Projects/GDM"
12
13 SRC_URI="${SRC_URI}
14         branding? ( https://www.mail-archive.com/tango-artists@lists.freedesktop.org/msg00043/tango-gentoo-v1.1.tar.gz )
15 "
16
17 LICENSE="
18         GPL-2+
19         branding? ( CC-BY-SA-4.0 )
20 "
21
22 SLOT="0"
23
24 IUSE="accessibility audit bluetooth-sound branding elogind fprint +introspection ipv6 plymouth selinux smartcard systemd tcpd test wayland xinerama"
25 REQUIRED_USE="^^ ( elogind systemd )"
26
27 KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~sh ~x86"
28
29 # NOTE: x11-base/xorg-server dep is for X_SERVER_PATH etc, bug #295686
30 # nspr used by smartcard extension
31 # dconf, dbus and g-s-d are needed at install time for dconf update
32 # We need either systemd or >=openrc-0.12 to restart gdm properly, bug #463784
33 COMMON_DEPEND="
34         app-text/iso-codes
35         >=dev-libs/glib-2.44:2
36         dev-libs/libgudev
37         >=x11-libs/gtk+-2.91.1:3
38         >=gnome-base/dconf-0.20
39         >=gnome-base/gnome-settings-daemon-3.1.4
40         gnome-base/gsettings-desktop-schemas
41         >=media-libs/fontconfig-2.5.0:1.0
42         >=media-libs/libcanberra-0.4[gtk3]
43         sys-apps/dbus
44         >=sys-apps/accountsservice-0.6.35
45
46         x11-base/xorg-server
47         x11-libs/libXau
48         x11-libs/libX11
49         x11-libs/libXdmcp
50         x11-libs/libXext
51         x11-libs/libxcb
52         >=x11-misc/xdg-utils-1.0.2-r3
53
54         virtual/pam
55         elogind? ( >=sys-auth/elogind-239.3[pam] )
56         systemd? ( >=sys-apps/systemd-186:0=[pam] )
57
58         sys-auth/pambase[elogind?,systemd?]
59
60         audit? ( sys-process/audit )
61         introspection? ( >=dev-libs/gobject-introspection-0.9.12:= )
62         plymouth? ( sys-boot/plymouth )
63         selinux? ( sys-libs/libselinux )
64         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
65         xinerama? ( x11-libs/libXinerama )
66 "
67 # XXX: These deps are from session and desktop files in data/ directory
68 # fprintd is used via dbus by gdm-fingerprint-extension
69 # gnome-session-3.6 needed to avoid freezing with orca
70 RDEPEND="${COMMON_DEPEND}
71         >=gnome-base/gnome-session-3.6
72         >=gnome-base/gnome-shell-3.1.90
73         x11-apps/xhost
74
75         accessibility? (
76                 >=app-accessibility/orca-3.10
77                 gnome-extra/mousetweaks )
78         fprint? (
79                 sys-auth/fprintd
80                 sys-auth/pam_fprint )
81
82         !gnome-extra/fast-user-switch-applet
83 "
84 DEPEND="${COMMON_DEPEND}
85         app-text/docbook-xml-dtd:4.1.2
86         dev-util/gdbus-codegen
87         dev-util/glib-utils
88         dev-util/itstool
89         >=sys-devel/gettext-0.19.8
90         virtual/pkgconfig
91         x11-base/xorg-proto
92         test? ( >=dev-libs/check-0.9.4 )
93         app-text/yelp-tools
94 " # yelp-tools needed for eautoreconf to not lose help docs (m4_ifdeffed YELP_HELP_INIT call and setup)
95
96 DOC_CONTENTS="
97         To make GDM start at boot with systemd, run:\n
98         # systemctl enable gdm.service\n
99         \n
100         To make GDM start at boot with OpenRC, edit /etc/conf.d to have
101         DISPLAYMANAGER=\"gdm\" and enable the xdm service:\n
102         # rc-update add xdm
103         \n
104         For passwordless login to unlock your keyring, you need to install
105         sys-auth/pambase with USE=gnome-keyring and set an empty password
106         on your keyring. Use app-crypt/seahorse for that.\n
107         \n
108         You may need to install app-crypt/coolkey and sys-auth/pam_pkcs11
109         for smartcard support
110 "
111
112 pkg_setup() {
113         enewgroup gdm
114         enewgroup video # Just in case it hasn't been created yet
115         enewuser gdm -1 -1 /var/lib/gdm gdm,video
116
117         # For compatibility with certain versions of nvidia-drivers, etc., need to
118         # ensure that gdm user is in the video group
119         if ! egetent group video | grep -q gdm; then
120                 # FIXME XXX: is this at all portable, ldap-safe, etc.?
121                 # XXX: egetent does not have a 1-argument form, so we can't use it to
122                 # get the list of gdm's groups
123                 local g=$(groups gdm)
124                 elog "Adding user gdm to video group"
125                 usermod -G video,${g// /,} gdm || die "Adding user gdm to video group failed"
126         fi
127 }
128
129 src_prepare() {
130         # ssh-agent handling must be done at xinitrc.d, bug #220603
131         eapply "${FILESDIR}/${PN}-2.32.0-xinitrc-ssh-agent.patch"
132
133         # Gentoo does not have a fingerprint-auth pam stack
134         eapply "${FILESDIR}/${PN}-3.8.4-fingerprint-auth.patch"
135
136         # Drop legacy argument to pam_systemd.so, included in 3.32
137         eapply "${FILESDIR}/${PV}-pam-drop-legacy-arg.patch"
138         # Support pam_elogind.so in gdm-launch-environment.pam
139         eapply "${FILESDIR}/pam-elogind.patch"
140
141         # Wait 10 seconds for a DRM master with systemd. Workaround for gdm not waiting for CanGraphical=yes property on the seat. Bug #613222
142         eapply "${FILESDIR}/gdm-CanGraphical-wait.patch" # needs eautoreconf
143
144         # Show logo when branding is enabled
145         use branding && eapply "${FILESDIR}/${PN}-3.30.3-logo.patch"
146
147         gnome2_src_prepare
148 }
149
150 src_configure() {
151         # PAM is the only auth scheme supported
152         # even though configure lists shadow and crypt
153         # they don't have any corresponding code.
154         # --with-at-spi-registryd-directory= needs to be passed explicitly because
155         # of https://bugzilla.gnome.org/show_bug.cgi?id=607643#c4
156         # Xevie is obsolete, bug #482304
157
158         # --with-initial-vt=7 conflicts with plymouth, bug #453392
159         # gdm-3.30 now reaps (stops) the login screen when the login VT isn't active, which
160         # saves on memory. However this means if we don't start on VT1, gdm doesn't start up
161         # before user manually goes to VT7. Thus as-is we can not keep gdm away from VT1,
162         # so lets try always having it in VT1 and see if that is an issue for people before
163         # hacking up workarounds for the initial start case.
164         # ! use plymouth && myconf="${myconf} --with-initial-vt=7"
165         local myconf=(
166                 --enable-gdm-xsession
167                 --enable-user-display-server
168                 --with-run-dir=/run/gdm
169                 --localstatedir="${EPREFIX}"/var
170                 --disable-static
171                 --with-xdmcp=yes
172                 --enable-authentication-scheme=pam
173                 --with-default-pam-config=exherbo
174                 --with-pam-mod-dir=$(getpam_mod_dir)
175                 --with-udevdir=$(get_udevdir)
176                 --with-at-spi-registryd-directory="${EPREFIX}"/usr/libexec
177                 --without-xevie
178                 $(use_enable systemd systemd-journal)
179                 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
180                 $(use_with audit libaudit)
181                 $(use_enable ipv6)
182                 $(use_with plymouth)
183                 $(use_with selinux)
184                 $(use_with tcpd tcp-wrappers)
185                 $(use_enable wayland wayland-support)
186                 $(use_with xinerama)
187         )
188
189         if use elogind; then
190                 myconf+=(
191                         --with-initial-vt=7 # TODO: Revisit together with startDM.sh and other xinit talks; also ignores plymouth possibility
192                         SYSTEMD_CFLAGS=`pkg-config --cflags "libelogind" 2>/dev/null`
193                         SYSTEMD_LIBS=`pkg-config --libs "libelogind" 2>/dev/null`
194                 )
195         fi
196
197         gnome2_src_configure "${myconf[@]}"
198 }
199
200 src_install() {
201         gnome2_src_install
202
203         if ! use accessibility ; then
204                 rm "${ED}"/usr/share/gdm/greeter/autostart/orca-autostart.desktop || die
205         fi
206
207         exeinto /etc/X11/xinit/xinitrc.d
208         newexe "${FILESDIR}/49-keychain-r1" 49-keychain
209         newexe "${FILESDIR}/50-ssh-agent-r1" 50-ssh-agent
210
211         # gdm user's home directory
212         keepdir /var/lib/gdm
213         fowners gdm:gdm /var/lib/gdm
214
215         if ! use bluetooth-sound ; then
216                 # Workaround https://gitlab.freedesktop.org/pulseaudio/pulseaudio/merge_requests/10
217                 # bug #679526
218                 insinto /var/lib/gdm/.config/pulse
219                 doins "${FILESDIR}"/default.pa
220         fi
221
222         # install XDG_DATA_DIRS gdm changes
223         echo 'XDG_DATA_DIRS="/usr/share/gdm"' > 99xdg-gdm
224         doenvd 99xdg-gdm
225
226         use branding && newicon "${WORKDIR}/tango-gentoo-v1.1/scalable/gentoo.svg" gentoo-gdm.svg
227
228         readme.gentoo_create_doc
229 }
230
231 pkg_postinst() {
232         gnome2_pkg_postinst
233         local d ret
234
235         # bug #669146; gdm may crash if /var/lib/gdm subdirs are not owned by gdm:gdm
236         ret=0
237         ebegin "Fixing "${EROOT}"var/lib/gdm ownership"
238         chown --no-dereference gdm:gdm "${EROOT}var/lib/gdm" || ret=1
239         for d in "${EROOT}var/lib/gdm/"{.cache,.color,.config,.dbus,.local}; do
240                 [[ ! -e "${d}" ]] || chown --no-dereference -R gdm:gdm "${d}" || ret=1
241         done
242         eend ${ret}
243
244         systemd_reenable gdm.service
245         readme.gentoo_print_elog
246 }