File cde.spec of Package cde

#
# spec file for package cde
#
# Copyright (c) 2023 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define dt_hierarchy 1
%if 0%{dt_hierarchy}
%define cmd sed '/--program-prefix=/d;/--prefix=/d;/--exec-prefix=/d;/--bindir=/d;/--sbindir=/d;/--sysconfdir=/d;/--datadir=/d;/--includedir=/d;/--libdir=/d;/--libexecdir=/d;/--localstatedir=/d;/--sharedstatedir=/d;/--mandir=/d;/--infodir=/d'
%else
%define cmd cat
%endif
Name:           cde
Version:        2.5.2
Release:        0
Summary:        Common Desktop Environment
License:        LGPL-2.1-or-later
Group:          System/GUI/Other
URL:            https://cdesktopenv.sourceforge.net/
Source0:        %{name}-%{version}.tar.gz
Source1:        dtlogin
Source2:        %{name}.permissions
Source3:        %{name}.conf
Source4:        %{name}.sh
Source5:        %{name}.csh
Source6:        README.SUSE
Source7:        README
Source8:        %{name}.rpmlintrc
Patch0:         no_suid_install.patch
Patch1:         fix_gcc12_errors.patch
Patch2:         restore_getty.patch
Patch3:         fix_dterror.patch

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bdftopcf
BuildRequires:  bison
BuildRequires:  chrpath
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gcc-c++
%if 0%{?suse_version} > 1500
#for tumbleweed
BuildRequires:  glibc-locale
%endif
BuildRequires:  ksh
BuildRequires:  libXScrnSaver-devel
BuildRequires:  libXaw-devel
BuildRequires:  libXdmcp-devel
BuildRequires:  libXinerama-devel
BuildRequires:  libjpeg8-devel
BuildRequires:  libtirpc-devel
BuildRequires:  libtool
BuildRequires:  mkfontdir
BuildRequires:  motif
BuildRequires:  motif-devel
BuildRequires:  ncompress
BuildRequires:  ncurses-devel
BuildRequires:  opensp
BuildRequires:  pam-devel
BuildRequires:  rpcbind
BuildRequires:  rpcgen
BuildRequires:  sessreg
BuildRequires:  tcl-devel
BuildRequires:  utempter-devel
BuildRequires:  xinetd
BuildRequires:  xrdb

Requires:       motif
Requires:       rpcbind
Requires:       xdm
#xdm pulls busybox-sysvinit-tools which does not have startproc
#pull sysvinit-tools which does have it
Requires:       sysvinit-tools
Requires:       xf86-input-libinput
Requires:       xinetd
Requires:       xorg-x11-server
Requires:       xset
Requires(post): update-alternatives
Requires(pre):  permissions
Recommends:     xorg-x11-fonts
#Desktop_Tools
Recommends:     aspell-spell
Recommends:     bitmap
Recommends:     make
Recommends:     ncompress
Recommends:     xclipboard
Recommends:     xclock
Recommends:     xdpyinfo
Recommends:     xfd
Recommends:     xload
Recommends:     xlsfonts
Recommends:     xprop
Recommends:     xrefresh
Recommends:     xwd
Recommends:     xwud
Recommends:     xwininfo

%{expand:%%global configure %(rpm --eval %%configure | %{cmd} | tr -d '\012' | tr -d \\\\)}

%description
CDE is the Common Desktop Environment from The Open Group.

%package devel
Summary:        CDE Include Files and Libraries Mandatory for Development
Group:          Development/Libraries/X11
Requires:       %{name} = %{version}

%description devel
This package provides the include files and libraries necessary for developing
CDE applications.

%package extra
Summary:        Extra programs that can be started using the application manager
Group:          System/GUI/Other
BuildArch:      noarch
#Education
Recommends:     gcompris-qt
Recommends:     geogebra-classic
Recommends:     stellarium
Recommends:     tuxpaint
#Games
Recommends:     dreamchess
Recommends:     eboard
Recommends:     gcompris-qt
Recommends:     ktuberling
Recommends:     lbreakout2
Recommends:     powermanga
#Recommends:     pychess
Recommends:     supertux
Recommends:     xboard
#Graphics
Recommends:     fontforge
Recommends:     gimp
Recommends:     inkscape
Recommends:     okular
Recommends:     xv
#Internet
Recommends:     chromium
Recommends:     MozillaFirefox
#Recommends:     nomachine
Recommends:     skypeforlinux
Recommends:     MozillaThunderbird
#Office
#Recommends:     acroread
Recommends:     libreoffice
Recommends:     nedit
Recommends:     xournal
Recommends:     xpdf
#Sound_and_Video
Recommends:     amarok
Recommends:     brasero
Recommends:     k3b
#Recommends:     k9copy
Recommends:     pavucontrol
Recommends:     rhythmbox
Recommends:     rosegarden
Recommends:     sound-juicer
Recommends:     vlc
Recommends:     xine-ui
#System
Recommends:     caja
Recommends:     engrampa
Recommends:     file-roller
#Recommends:     firestarter
Recommends:     pgadmin4
Recommends:     gsynaptics
Recommends:     virtualbox
#Recommends:     wicd
#Tex
#Recommends:     acroread
Recommends:     emacs
Recommends:     gv
Recommends:     kile
#Recommends:     mgv
Recommends:     tex
Recommends:     texlive-xdvi-bin
Recommends:     xournal
Recommends:     xpdf

%description extra
Install the programs that have predefined actions for the
application manager 

%prep
%setup -q

%patch -P0 -p1
%if 0%{?suse_version} > 1500
%patch -P1 -p1
%endif
%patch -P2 -p1
%patch -P3 -p1

%build
cp %{SOURCE6} %{SOURCE7} .

#output a new-line instead of \n
sed -i 's@\([[:blank:]]\)\(sh -c\)@\1k\2@' programs/types/*.{dt,src}
#geogebra -> geogebra-classic
sed -i '/EXEC_STRING/s@geogebra@&-classic@' programs/types/geogebra.dt
#nxclient -> nxplayer
sed -i '/EXEC_STRING/s@nxclient@/usr/NX/bin/nxplayer@' programs/types/nxclient.dt
#skype -> skypeforlinux
sed -i '/EXEC_STRING/s@skype@&forlinux@' programs/types/skype.dt
#gcompris -> gcompris-qt
sed -i '/EXEC_STRING/s@gcompris@&-qt@' programs/types/gcompris.dt
#pgadmin -> pgAdmin4
sed -i '/EXEC_STRING/s@pgadmin@pgAdmin4@' programs/types/pgadmin.dt
#synaptic -> gsynaptics
sed -i '/EXEC_STRING/s@synaptic@g&s@' programs/types/synaptic.dt
#virtualbox -> VirtualBox
sed -i '/EXEC_STRING/s@virtualbox@VirtualBox@' programs/types/virtualbox.dt
#do not show actions for programs not available on modern linux
for a in pychess acroread k9copy firestarter wicd mgv ; do
    sed -i "s@[^ ]*/$a@@" programs/localized/templates/appmgr.am
done

%if ! 0%{dt_hierarchy}
#nothing provides /usr/dt/bin/dtksh
sed -i 's@/usr/dt/bin@%{_bindir}@' programs/dthelp/dthelpgen/dthelpgen.dtsh
#hardcoded /usr/dt/...
sed -i '/^Prog/s@/usr/dt/bin@%{_bindir}@' programs/dthelp/dthelpprint/dthelpprint.sh
sed -i 's@/usr/dt/lib/dtks@%{_libdir}/dtks@' programs/dthelp/dthelpgen/dthelpgen.dtsh
sed -i 's@/usr/dt/lib/dtks@%{_libdir}/dtks@' programs/dtprintegrate/dtlp.src
%endif

./autogen.sh

%configure --disable-static --enable-spanish --enable-italian --enable-french --enable-german

if ((1)); then
env -u MALLOC_PERTURB_ %make_build
else
%make_build
fi

%install
%make_install
%if 0%{dt_hierarchy}
# Remove the rpath setting from ELF objects.
find %{buildroot}/usr/dt/bin -type f | \
    grep -v -E "(Xsession|dsdm|dtappintegrate|dtdocbook2man|dtdocbook2sdl|dtdspmsg|dterror\.ds|dtfile_error|dthelpgen\.dtsh|dthelpprint\.sh|dthelptag|dtlp|dtlpsetup|dtopen|dtopen_image|dtopen_pdf|dtopen_ps|dtopen_video|dtprintegrate|dtsession_res)" | \
    xargs chrpath -d
chrpath -d %{buildroot}/usr/dt/infolib/etc/dtinfo_start
chrpath -d %{buildroot}/usr/dt/libexec/cde/dtdocbook/infolib/{MixedGen,NCFGen,NodeParser,StyleUpdate,dbdrv,valBase,validator}
chrpath -d %{buildroot}/usr/dt/libexec/cde/dtdocbook/instant/instant
gzip -9 %{buildroot}/usr/dt/share/man/man*/*
%else
sed -i '/^PATH=/d' %{SOURCE4}
sed -i '/^setenv PATH/d' %{SOURCE5}
sed -i 's@/usr/dt/etc@%{_sysconfdir}@;s@/usr/dt/share@%{_datadir}@' %{SOURCE4} %{SOURCE5}
sed -i '/^Exec=/s@/usr/dt/bin@%{_bindir}@' contrib/desktopentry/cde.desktop
sed -i 's@/usr/dt/bin@%{_bindir}@' %{SOURCE2} %{SOURCE1}
%endif

#cde.sh/csh
install -Dm 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
install -m 644 %{SOURCE5} %{buildroot}%{_sysconfdir}/profile.d
#xsessions
install -Dm 644 contrib/desktopentry/%{name}.desktop %{buildroot}%{_datadir}/xsessions/%{name}.desktop
#xinetd services
install -Dm 644 contrib/xinetd/cmsd %{buildroot}%{_sysconfdir}/xinetd.d/cmsd
install -m 644 contrib/xinetd/ttdbserver %{buildroot}%{_sysconfdir}/xinetd.d
#permissions
install -Dm 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/permissions.d/%{name}
#ld.so.conf
%if 0%{dt_hierarchy}
install -Dm 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}.conf
%endif
#dtlogin
install -Dm 644 %{SOURCE1} %{buildroot}%{_libexecdir}/X11/displaymanagers/dtlogin
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/default-displaymanager
ln -s %{_sysconfdir}/alternatives/default-displaymanager %{buildroot}%{_libexecdir}/X11/displaymanagers/default-displaymanager
#Xstartup/Xreset
#https://sourceforge.net/p/cdesktopenv/wiki/Sound-Video%20and%20dtlogin/
echo 'setfacl -m "u:$USER:rw-" /dev/video* || :' >>%{buildroot}/usr/dt/config/Xstartup
echo 'setfacl -m "u:$USER:rw-" /dev/snd/* || :' >>%{buildroot}/usr/dt/config/Xstartup
echo 'setfacl -m "u:$USER" /dev/video* || :' >>%{buildroot}/usr/dt/config/Xreset
echo 'setfacl -x "u:$USER" /dev/snd/* || :' >>%{buildroot}/usr/dt/config/Xreset

%fdupes %{buildroot}/usr/dt
%if 0%{dt_hierarchy}
find %{buildroot}/usr/dt/lib -type f -name "*.la" -delete -print
%else
find %{buildroot}%{_libdir} -type f -name "*.la" -delete -print
%fdupes %{buildroot}%{_mandir}
%fdupes %{buildroot}%{_bindir}
%endif

%post
/sbin/ldconfig
%if 0%{dt_hierarchy}
%set_permissions /usr/dt/bin/dtappgather
%else
%set_permissions %{_bindir}/dtappgather
%endif
%{_sbindir}/update-alternatives --install %{_libexecdir}/X11/displaymanagers/default-displaymanager \
  default-displaymanager %{_libexecdir}/X11/displaymanagers/dtlogin 12
mkdir -p %{_localstatedir}/adm/update-messages
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}
cat > %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release} << EOF
INFO: Please ensure that the rpcbind services is enabled and started:
INFO: systemctl enable --now rpcbind.service
EOF

%preun
%{_sbindir}/update-alternatives --remove default-displaymanager \
  %{_libexecdir}/X11/displaymanagers/dtlogin

%postun
/sbin/ldconfig
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}

%verifyscript
%if 0%{dt_hierarchy}
%verify_permissions -e /usr/dt/bin/dtappgather
%else
%verify_permissions -e %{_bindir}/dtappgather
%endif

%files
%license COPYING
%doc CONTRIBUTORS README.md README.SUSE copyright
/usr/dt
%if 0%{dt_hierarchy}
%exclude /usr/dt/include
%exclude /usr/dt/lib/*.so
%exclude /usr/dt/share/man/man3/*
%exclude /usr/dt/share/man/man5/*
%config %{_sysconfdir}/ld.so.conf.d/%{name}.conf
%verify(not mode) %attr(4755,root,root) /usr/dt/bin/dtappgather
%else
%{_bindir}/*
%{_libdir}/*.so.*
%{_libdir}/%{name}
%{_libdir}/dtksh
%{_libexecdir}/%{name}
%{_datadir}/%{name}
%exclude %{_includedir}
%exclude %{_libdir}/*.so
%config %{_sysconfdir}/%{name}
%{_mandir}/man1/*
%{_mandir}/man1m
%{_mandir}/man4/*
%{_mandir}/man6/*
%exclude %{_mandir}/man3/*
%exclude %{_mandir}/man5/*
%verify(not mode) %attr(4755,root,root) %{_bindir}/dtappgather
%endif
%{_datadir}/xsessions/%{name}.desktop
%if 0%{?suse_version} > 1500
%dir %{_libexecdir}/X11
%endif
%dir %{_libexecdir}/X11/displaymanagers
%{_libexecdir}/X11/displaymanagers/dtlogin
%ghost %{_sysconfdir}/alternatives/default-displaymanager
%ghost %{_libexecdir}/X11/displaymanagers/default-displaymanager
%{_localstatedir}/spool/calendar
%config %{_sysconfdir}/pam.d/dtlogin
%config %{_sysconfdir}/pam.d/dtsession
%config %{_sysconfdir}/permissions.d/%{name}
%config %{_sysconfdir}/profile.d/%{name}.sh
%config %{_sysconfdir}/profile.d/%{name}.csh
%config(noreplace) %{_sysconfdir}/xinetd.d/cmsd
%config(noreplace) %{_sysconfdir}/xinetd.d/ttdbserver

%files devel
%if 0%{dt_hierarchy}
/usr/dt/include
/usr/dt/lib/*.so
/usr/dt/share/man/man3/*
/usr/dt/share/man/man5/*
%else
%{_includedir}/*
%{_libdir}/*.so
%{_mandir}/man3/*
%{_mandir}/man5/*
%endif

%files extra
%doc README

%changelog

openSUSE Build Service is sponsored by