File xdm.spec of Package xdm

# spec file for package xdm
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%if 0%{?suse_version} > 1230
%define with_systemd 1
%define with_systemd 0

%define _dminitdir %{_libexecdir}/X11/displaymanagers

%if 0%{?suse_version} < 01210
%define dm_fallbacks 1
%define dm_fallbacks 0

Name:           xdm
Version:        1.1.11
Release:        0
Summary:        X Display Manager
License:        MIT
Group:          System/X11/Utilities
Source1:        xdm.tar.bz2
Source2:        HOWTO.xdm
Source3:        xdm-fallbacks.tar.bz2
Source4:        display-manager.service
%if !%with_systemd
Patch0:         xdm-consolekit.diff
Patch1:         xdm-tolerant-hostname-changes.diff
%if 0%{?suse_version} >= 01140 && 0%{?suse_version} < 1320
# Needed to create the man page symlink to init.d
BuildRequires:  aaa_base-extras
# needed for patch0, patch2, patch3, patch4
BuildRequires:  libtool
BuildRequires:  pam-devel
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xau)
BuildRequires:  pkgconfig(xaw7)
BuildRequires:  pkgconfig(xdmcp)
BuildRequires:  pkgconfig(xext)
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xinerama)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xorg-macros) >= 1.4
BuildRequires:  pkgconfig(xpm)
BuildRequires:  pkgconfig(xt)
BuildRequires:  pkgconfig(xtrans)
%if !%with_systemd
BuildRequires:  ConsoleKit-devel
Requires:       ConsoleKit
BuildRequires:  systemd-rpm-macros
Requires:       /sbin/pidof
Requires:       logrotate
Requires:       sessreg
Requires:       xconsole
Requires:       xli
Requires:       xmessage
Requires:       xrdb
Requires:       xset
Requires:       xsetroot
%if 0%{?suse_version} > 1320
Requires:       xterm-bin
Requires:       xterm
Recommends:     dbus-1-x11
# This was part of the xorg-x11 package up to version 7.6
Conflicts:      xorg-x11 <= 7.6
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if !%with_systemd
%define _unitdir /usr/lib/systemd/system

Xdm manages a collection of X displays, which may be on the local host
or remote servers.

%setup -q
cp %{SOURCE2} .
%if !%with_systemd
%patch0 -p1
pushd xdm
%patch1 -p1

# needed for patch0
autoreconf -fi
%configure \
        --disable-static \
        --with-pam \
        --with-xdmconfigdir=%{_sysconfdir}/X11/xdm \
make %{?_smp_mflags}

# Not used anymore by SuSE
rm %{buildroot}%{_sysconfdir}/X11/xdm/{GiveConsole,TakeConsole,Xsetup_0}

pushd %{buildroot}
# SuSE default XDM configuration
tar xf %{SOURCE1}
%if %dm_fallbacks
tar xf %{SOURCE3}
%ifarch s390 s390x

# Correct location (FHS-2.1)
ln -s %{_localstatedir}/lib/xdm/authdir %{buildroot}%{_sysconfdir}/X11/xdm/authdir
# bnc#223734
rm %{buildroot}%{_libdir}/X11/xdm/
# for FHS compliance (bnc#21857)
mv %{buildroot}%{_libdir}/X11/xdm/chooser %{buildroot}%{_bindir}
# fdo#35868 (closed INVALID, but because of above fix, we want it)
ln -s xdm.1%{?ext_man} %{buildroot}%{_mandir}/man1/chooser.1%{?ext_man}
%if 0%{?suse_version} < 1315
# missing manual page
mkdir -p %{buildroot}%{_mandir}/man8
ln -s ../man7/init.d.7%{?ext_man} %{buildroot}%{_mandir}/man8/rcxdm.8%{?ext_man}
ln -sf %{_sysconfdir}/init.d/xdm %{buildroot}%{_sbindir}/rcxdm
rm -f %{buildroot}%{_sbindir}/rcxdm
%__install -D %{S:4} -m 0444 %{buildroot}%{_unitdir}/display-manager.service
ln -sf service %{buildroot}%{_sbindir}/rcdisplay-manager
cat > %{buildroot}%{_sbindir}/rcxdm <<-'EOF'
	exec -a rcdisplay-manager %{_sbindir}/rcdisplay-manager ${1+"$@"}
chmod 0755 %{buildroot}%{_sbindir}/rcxdm

%if 0%{?suse_version} < 1315
%{fillup_and_insserv -Y xdm}
%service_add_post display-manager.service
%{fillup_only -n displaymanager}

%if !0%{?suse_version} < 1315
  %service_add_pre display-manager.service

%if 0%{?suse_version} < 1315

%if !0%{?suse_version} < 1315
  %service_del_preun display-manager.service

%doc HOWTO.xdm
%dir %{_dminitdir}
%if %dm_fallbacks
%config %{_sysconfdir}/X11/xdm/
%config(noreplace) %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/xdmcp
%if 0%{?suse_version} < 1315
%exclude %{_libexecdir}/X11/display-manager
%exclude %{_sysconfdir}/init.d/xdm
%config %{_sysconfdir}/logrotate.d/xdm
%config %{_sysconfdir}/pam.d/xdm
%config %{_sysconfdir}/pam.d/xdm-np
%dir %{_localstatedir}/lib/xdm/
%ghost %{_localstatedir}/log/xdm.errors
%if 0%{?suse_version} >= 1315
%dir %{_datadir}/X11/app-defaults
%if 0%{?suse_version} < 1315
%ifnarch %ix86
%dir %{_libdir}/X11