File groff.spec of Package groff-full.17893

#
# spec file for package groff
#
# Copyright (c) 2018 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 http://bugs.opensuse.org/
#


%global groff_base_only 1
Name:           groff
Version:        1.22.3
Release:        0
Summary:        GNU troff Document Formatting System
License:        GPL-3.0-or-later
Group:          Productivity/Publishing/Troff
Url:            http://www.gnu.org/software/groff/groff.html
Source0:        ftp://ftp.gnu.org/gnu/groff/groff-%{version}.tar.gz
Source1:        ftp://ftp.gnu.org/gnu/groff/groff-%{version}.tar.gz.sig
Source2:        groff-full.keyring
Source3:        zzz-groff.sh
Source4:        zzz-groff.csh
# rm -f foo
# for file in `cat series | grep -v '^#' | grep  '^[a-z]' `; do
#    cat $file >> foo
# done
##remove a part related to src/preproc/html/pre-html.cpp - see bnc#755533
# filterdiff -x 'src/preproc/html/pre-html.cpp' foo > groff_1.22.2-2.debian.diff
##remove Debian package string for openSUSE package string
##delete the papersize /etc settings patch
Patch0:         groff_1.22.3-1.debian.diff
Patch1:         groff-1.20.1-destbufferoverflow.patch
Patch2:         groff-1.20.1-nroff-empty-LANGUAGE.patch
Patch3:         groff-1.21-groffer-libexecdir.patch
Patch4:         groff-1.20.1-deunicode.patch
Patch5:         groff-1.21-CVE-2009-5044.patch
#PATCH-FIX-OPENSUSE: splitted patch6 and patch7 from
#http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/groff/groff-1.20.1-owl-tmp.diff?rev=1.2;content-type=text%2Fplain
Patch6:         groff-1.21-CVE-2009-5080.patch
Patch7:         groff-1.21-CVE-2009-5081.patch
#PATCH-FIX-OPENSUSE: FATE#312586
#sent upstream http://lists.gnu.org/archive/html/bug-groff/2011-09/msg00002.html
#so they would be available on next release of groff
Patch8:         0001-locale-support-in-papersize-definition.patch
Patch9:         0002-documentation-for-the-locale-keyword.patch
# change the papersize definition to force the locale usage
# it can be supressed by /etc/papersize if needed
Patch10:        groff-force-locale-usage.patch
# PATCH-FIX-UPSTREAM fix build with multiple threads ; taken from upstream
Patch11:        groff-multi-thread.patch
# PATCH-FIX-UPSTREAM make mdate.sh output not depend on mtime
Patch12:        0001-make-package-build-reproducible.patch
# PATCH-FIX-UPSTREAM normalize creation date
Patch13:        0002-Implement-SOURCE_DATE_EPOCH-for-reproducible-builds.patch
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1220
BuildRequires:  makeinfo
%endif
%if %{groff_base_only}
Recommends:     groff-full
%else
BuildRequires:  ghostscript-library
BuildRequires:  groff
BuildRequires:  netpbm
BuildRequires:  psutils
# for gxditview and X fontx
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xaw7)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xt)
# for pre-grohtml and pdfroff
Requires:       ghostscript-library
# requires the -base package
Requires:       groff = %{version}
Requires:       netpbm
Requires:       psutils
Requires(post): %{install_info_prereq}
Provides:       jgroff = %{version}-%{release}
Provides:       normal-groff = %{version}-%{release}
Obsoletes:      jgroff < %{version}
# X fonts were moved back
Provides:       groff-devx = %{version}-%{release}
Obsoletes:      groff-devx <= 1.21
%endif
%if %{groff_base_only}
%description
The groff package is a stripped-down package containing the necessary
components to read manual pages in ASCII, Latin-1, and UTF-8, plus the
PostScript device (groff's default). Users who want a full groff installation,
with the standard set of devices, fonts, macros, and documentation, should
install the groff-full package.

%else   #groff_base_only
%description
The groff-full package provides aditional tools excluded from base groff
package, like grohtml, X fonts et. all.

Groff is used to "compile" man pages stored in groff or nroff format
for different output devices, for example, displaying to a screen or in
PostScript(tm) format for printing on a PostScript(tm) printer. Most
programs store their man pages in either %{_mandir}/ or
%{_prefix}/X11R6/man/.

%package -n groff-doc
Summary:        HTML documentation and examples for groff
Group:          Productivity/Publishing/Troff
BuildArch:      noarch

%description -n groff-doc
The groff package provides compatible versions of troff, nroff, eqn,
tbl, and other Unix text formatting utilities.

Groff is used to "compile" man pages stored in groff or nroff format
for different output devices, for example, displaying to a screen or in
PostScript(tm) format for printing on a PostScript(tm) printer. Most
programs store their man pages in either %{_mandir}/ or
%{_prefix}/X11R6/man/.

%package -n gxditview
Summary:        Ditroff Output Displayer for Groff
Group:          Productivity/Publishing/Troff
Requires:       groff-full = %{version}
# bnc#668254
Supplements:    packageand(groff:xorg-x11-libX11)
Conflicts:      jgxdview
Provides:       gxdview = %{version}-%{release}
Obsoletes:      gxdview < %{version}

%description -n gxditview
This version of xditview is called gxditview and has some extensions
used by the groff command.  gxditview is used by groff if called with
the -X option.

%endif #groff_base_only

%prep
%setup -q -n groff-%{version}
%patch0 -p1 -b .debian
%patch1
%patch2 -p1 -b .bnc540600
%patch3 -p1 -b .groffer-libexecdir
%patch4 -p1 -b .deunicode
%patch5 -p1 -b .CVE-2009-5044
%patch6 -p1 -b .CVE-2009-5080
%patch7 -p1
%patch8 -p1 -b .locale
%patch9 -p1 -b .locale2
%patch10 -p1 -b .force-locale
%patch11 -b .multithread
%patch12 -p1
%patch13 -p1

%build
PATH=$PWD/src/roff/troff:$PWD/src/preproc/pic:$PWD/src/preproc/eqn:$PWD/src/preproc/tbl:$PWDsrc/preproc/refer:$PWD/src/preproc/soelim:$PATH
PATH=$PWD/src/roff/grog:$PWD/src/roff/groff:$PWD/src/devices/grops:$PWD/src/devices/grotty:$PWD/src/devices/grodvi:$PWD/src/devices/grohtml:$PATH
GROFF_COMMAND_PREFIX=
GROFF_FONT_PATH=$PWD
GROFF_TMAC_PATH=$PWD/tmac:$PWD/src/roff/troff
export PATH GROFF_COMMAND_PREFIX GROFF_FONT_PATH GROFF_TMAC_PATH
export CFLAGS="%{optflags} -fno-strict-aliasing -fPIE"
export CXXFLAGS="%{optflags} -fno-strict-aliasing -fPIE"
export LDFLAGS="-pie"
# Libdir override as we don't have any arch dependant code just pl scripts
%configure \
    --libdir=%{_libexecdir} \
    --with-appresdir=%{_datadir}/X11/app-defaults \
    --with-grofferdir=%{_libexecdir}/groff/groffer
make %{?_smp_mflags}

%install
%if %{groff_base_only}
    install -d -m 0755 %{buildroot}%{_bindir}
    install -d -m 0755 %{buildroot}%{_mandir}/man1
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/%{version}/
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/%{version}/font/
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/%{version}/tmac/
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mdoc/
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/site-tmac/
    install -d -m 0755 %{buildroot}%{_libexecdir}/groff/grog/
%else
    make DESTDIR=%{buildroot} install %{?_smp_mflags} docdir=%{_defaultdocdir}/groff
%endif

### see Debian's groff-base.install.in ###
for BIN in eqn groff grog grops grotty neqn nroff pic preconv soelim tbl troff; do

%if %{groff_base_only}
    # install binary
    install -m 0755 $(find . -type f -name ${BIN}) %{buildroot}/%{_bindir}/

    # install man
    MAN_SOURCE=$(find src -name "${BIN}.n")
    MAN_DEST="${MAN_SOURCE%.n}.1"       # replace suffix .n by .1
    MAN_DEST="${MAN_DEST##*/}"          # remove the path/before/
    install -m 0644 "${MAN_SOURCE}" "%{buildroot}%{_mandir}/man1/${MAN_DEST}"
%else
    # remove binary already in groff.rpm
    rm %{buildroot}/%{_bindir}/${BIN}
    # remove manual already in groff.rpm
    rm %{buildroot}/%{_mandir}/man1/${BIN}.*
%endif

done

%if %{groff_base_only}
    # datadir
    install -m 0644 src/utils/indxbib/eign %{buildroot}%{_datadir}/%{name}/%{version}/
%else
    rm %{buildroot}%{_datadir}/groff/%{version}/eign
%endif

%if %{groff_base_only}
    install -m 0644 src/roff/grog/subs.pl %{buildroot}%{_libexecdir}/groff/grog/subs.pl
%else
    rm %{buildroot}%{_libexecdir}/groff/grog/subs.pl
%endif

for FONT in devascii devlatin1 devps devutf8; do
%if %{groff_base_only}
    cp -pr "font/${FONT}" %{buildroot}%{_datadir}/%{name}/%{version}/font/
%else
    rm -r %{buildroot}%{_datadir}/groff/%{version}/font/${FONT}
%endif
done

for TMAC in a4.tmac an-ext.tmac an-old.tmac an.tmac andoc.tmac composite.tmac \
	    cp1047.tmac cs.tmac de.tmac den.tmac devtag.tmac doc.tmac \
	    doc-old.tmac e.tmac eqnrc europs.tmac fallbacks.tmac fr.tmac \
	    hyphen.cs hyphen.den hyphen.det hyphen.fr hyphen.sv hyphen.us \
	    hyphenex.cs hyphenex.det hyphenex.us ja.tmac latin1.tmac latin2.tmac \
	    latin5.tmac latin9.tmac man.tmac mandoc.tmac mdoc.tmac me.tmac \
	    ms.tmac papersize.tmac pic.tmac ps.tmac psatk.tmac psold.tmac \
	    pspic.tmac refer-me.tmac refer-ms.tmac refer.tmac s.tmac \
	    safer.tmac sv.tmac trace.tmac trans.tmac troffrc troffrc-end \
	    tty-char.tmac tty.tmac unicode.tmac www.tmac
do
%if %{groff_base_only}
    install -m 0644 tmac/${TMAC} %{buildroot}%{_datadir}/%{name}/%{version}/tmac/
%else
    rm %{buildroot}%{_datadir}/groff/%{version}/tmac/${TMAC}
%endif
done

%if %{groff_base_only}
    install -m 0644 tmac/{man,mdoc}.local %{buildroot}%{_datadir}/%{name}/site-tmac/
%else
    rm %{buildroot}%{_datadir}/groff/site-tmac/{man,mdoc}.local
%endif

pushd contrib/mm/
%if %{groff_base_only}
    install -d -m 0755 %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mm
    install -c -m 0755 mmroff %{buildroot}%{_bindir}/mmroff
    install -c -m 0644 mmroff.n %{buildroot}%{_mandir}/man1/mmroff.1
    for f in 0.MT 5.MT 4.MT ms.cov se_ms.cov ; do
	install -c -m 644 mm/$f %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mm/$f
    done
    for f in locale se_locale; do
	touch %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mm/$f
	chmod 0644 %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mm/$f
    done
    for f in *.tmac; do
	install -c -m 644 $f %{buildroot}%{_datadir}/%{name}/%{version}/tmac/$f
    done
%else
    rm %{buildroot}%{_bindir}/mmroff
    rm %{buildroot}%{_mandir}/man1/mmroff.1*
    rm -rf %{buildroot}%{_datadir}/groff/%{version}/tmac/mm/
    for f in *.tmac; do
	rm -f %{buildroot}%{_datadir}/groff/%{version}/tmac/$f
    done
%endif
popd

%if %{groff_base_only}
install -m 0644 tmac/doc-common tmac/doc-ditroff tmac/doc-nroff tmac/doc-syms \
                %{buildroot}%{_datadir}/%{name}/%{version}/tmac/mdoc/
%else
rm -rf %{buildroot}%{_datadir}/groff/%{version}/tmac/mdoc
%endif

%if %{groff_base_only}

ln -s -f current %{buildroot}%{_datadir}/%{name}/%{version}

# compat symlinks
ln -s -f eqn %{buildroot}%{_bindir}/geqn
ln -s -f tbl %{buildroot}%{_bindir}/gtbl

# install profiles to disable the use of ANSI colour sequences by default:
install -d -m 0755 %{buildroot}/%{_sysconfdir}/profile.d
install -m 644 %{SOURCE3} %{SOURCE4} %{buildroot}/%{_sysconfdir}/profile.d/

%endif  #groff_base_only

%fdupes -s %{buildroot}

%if ! %{groff_base_only}
%post
%install_info --info-dir=%{_infodir} %{_infodir}/groff.info.gz

%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/groff.info.gz
%endif

%if %{groff_base_only}
%files
%defattr(-,root,root)
%license COPYING FDL LICENSES
%doc BUG-REPORT ChangeLog* MANIFEST MORE.STUFF NEWS PROBLEMS PROJECTS README REVISION VERSION
%{_mandir}/man1/*
%{_bindir}/*
%config %{_sysconfdir}/profile.d/zzz-%{name}.*sh
%{_datadir}/%{name}
%dir %{_libexecdir}/groff
%dir %{_libexecdir}/groff/grog
%{_libexecdir}/groff/grog/subs.pl

%else #groff_base_only
%files
%defattr(-,root,root)
%dir %{_datadir}/groff/%{version}
%dir %{_libexecdir}/groff
%doc %{_docdir}/groff
%dir %{_libexecdir}/groff
%dir %{_libexecdir}/groff/glilypond
%{_libexecdir}/groff/glilypond/args.pl
%{_libexecdir}/groff/glilypond/oop_fh.pl
%{_libexecdir}/groff/glilypond/subs.pl
%dir %{_libexecdir}/groff/gpinyin
%{_libexecdir}/groff/gpinyin/subs.pl
%{_libexecdir}/groff/groff_opts_no_arg.txt
%{_libexecdir}/groff/groff_opts_with_arg.txt
%exclude %{_docdir}/groff/html
%exclude %{_docdir}/groff/examples
%{_infodir}/groff*
%{_mandir}/man*/*
%exclude %{_mandir}/man1/gxditview.1*
%{_bindir}/*
%exclude %{_bindir}/gxditview
%dir %{_datadir}/groff
%{_datadir}/groff/%{version}/font
%{_datadir}/groff/%{version}/oldfont
%{_datadir}/groff/%{version}/pic
%{_datadir}/groff/%{version}/tmac
%{_datadir}/groff/current
%{_datadir}/groff/site-tmac
%{_libexecdir}/groff/groffer

%files -n groff-doc
%defattr(-, root, root)
%dir %{_docdir}/groff
%doc %{_docdir}/groff/html
%doc %{_docdir}/groff/examples

%files -n gxditview
%defattr(-,root,root)
%dir %{_datadir}/X11/app-defaults
%doc src/devices/xditview/ChangeLog
%doc src/devices/xditview/README
%doc src/devices/xditview/TODO
%{_bindir}/gxditview
%{_mandir}/man1/gxditview.1*
%{_datadir}/X11/app-defaults/GXditview
%{_datadir}/X11/app-defaults/GXditview-color

%endif #groff_base_only

%changelog
openSUSE Build Service is sponsored by