File _bin.spec of Package Meta

#
# spec file for package _bin
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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/
#


@@VERSION@@

%define __perl_requires		%{nil}
%define __os_install_post	/usr/lib/rpm/brp-compress \\\
  %(ls /usr/lib/rpm/brp-suse.d/* 2> /dev/null | grep -vE 'symlink|desktop') %{nil}

%if ! %{defined perl_version}
%global perl_version %(rpm -q --qf '%%{VERSION}' perl)
%endif
%global perl_versnum %(rpm -q --qf '%%{VERSION}' perl | sed 's/\\.//g')

#
# LuaJIT -- does not build nor support all architectures
#	    Current status is available at https://github.com/LuaJIT/LuaJIT
#                                          https://github.com/LuaJIT/LuaJIT/issues/42
#	    Compare with libs/luajit/LuaJIT-<version>/src/lj_arch.h
#
%ifnarch %power64 s390 s390x riscv64
%global         with_LuaJIT 1
%endif
%bcond_with	LuaJIT

# psutils -- is also available as the package psutils and therefore
#           not necessary required, enabling the resulting psutils
#           cause dependency on package collection-fontutils
%bcond_with	psutils

#
# buildbiber -- we build our own biber executable as with this all
#	    architectures can be supported (in theory) and the final
#	    perl dump binary is smaller
#
%bcond_without	buildbiber

#
# lcdf-typetools -- is also available as the package lcdf-typetools
#	    and therefore we may only require this external package
%bcond_without	lcdf_typetools

#
#
#
%bcond_without	luametatex

Name:           texlive
Version:        %{texlive_version}.%{texlive_release}
Release:        0
Summary:        The TeXLive Formatting System
License:        Apache-2.0 AND Artistic-1.0 AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-only AND LPPL-1.3c AND LPPL-1.0 AND MIT AND BSD-3-Clause AND SUSE-TeX AND SUSE-Public-Domain
Group:          Productivity/Publishing/TeX/Base
URL:            https://www.tug.org/texlive/
PreReq:         %{name}-filesystem >= %{texlive_version}
PreReq:         %{name}-kpathsea >= %{texlive_version}
PreReq:         %{name}-kpathsea-bin >= %{texlive_version}
PreReq:         %{name}-scripts >= %{texlive_version}
PreReq:         /usr/bin/clear
PreReq:         /usr/bin/dialog
PreReq:         /usr/bin/perl
PreReq:         coreutils
PreReq:         ed
PreReq:         findutils
PreReq:         grep
PreReq:         sed
#!BuildIgnore:  %{name}-kpathsea-bin
#!BuildIgnore:  %{name}-kpathsea
#!BuildIgnore:  %{name}-scripts-bin
#!BuildIgnore:  %{name}-scripts
Requires(pre):  user(mktex)
Requires(pre):  group(mktex)
Requires(post): coreutils
Requires(postun): coreutils
Requires(posttrans): coreutils
Requires(posttrans): ed
Requires(posttrans): findutils
Requires(posttrans): grep
Requires(posttrans): sed
Requires(posttrans): %{name}-filesystem >= %{texlive_version}
Requires(posttrans): %{name}-kpathsea-bin >= %{texlive_version}
Requires(posttrans): %{name}-kpathsea >= %{texlive_version}
Requires(posttrans): %{name}-scripts-bin >= %{texlive_version}
Requires(posttrans): %{name}-scripts >= %{texlive_version}
Recommends:     %{name}-scheme-medium
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  cairo
BuildRequires:  cairo-devel
BuildRequires:  dejavu
BuildRequires:  dialog
BuildRequires:  ed
BuildRequires:  expat
BuildRequires:  fdupes
BuildRequires:  fftw3-devel
BuildRequires:  flex
BuildRequires:  freeglut-devel
BuildRequires:  freetype2-devel
BuildRequires:  gc-devel
BuildRequires:  gcc-c++
%if 0%{?suse_version} <= 1500
BuildRequires:  Mesa-libglapi-devel
BuildRequires:  gcc13-c++
BuildRequires:  python311
BuildRequires:  python311-base
BuildRequires:  python311-packaging
%endif
BuildRequires:  gd-devel
BuildConflicts: ghostscript-mini
BuildRequires:  %{name}-filesystem
BuildRequires:  ghostscript-devel
BuildRequires:  ghostscript-library
BuildRequires:  glibc-devel
BuildRequires:  graphite2-devel
BuildRequires:  gsl-devel
%if 0%{?suse_version} > 1550
BuildRequires:  harfbuzz-devel >= 7.1
%endif
BuildRequires:  jpeg
%if 0%{?suse_version} > 1550
BuildRequires:  libicu-devel >= 72.1
%endif
BuildRequires:  Mesa-dri-devel
%if 0%{?suse_version} <= 1500
BuildRequires:  libboost_filesystem1_75_0-devel
BuildRequires:  libboost_program_options1_75_0-devel
BuildRequires:  libboost_system1_75_0-devel
BuildRequires:  libboost_thread1_75_0-devel
%else
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
%endif
BuildRequires:  libjpeg-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libpaper-devel
BuildRequires:  libpng-devel
BuildRequires:  libsigsegv-devel
BuildRequires:  libtool
BuildRequires:  libxml2-devel
BuildRequires:  libxslt-devel
BuildRequires:  makeinfo
BuildRequires:  mpfr-devel
BuildRequires:  ncurses-devel
BuildRequires:  netpbm
BuildRequires:  pango-devel
BuildRequires:  pango-tools
BuildRequires:  potrace-devel
BuildRequires:  pwdutils
BuildRequires:  readline-devel
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(libcurl)
%if 0%{?suse_version} < 1699
BuildRequires:  pkgconfig(osmesa)
%endif
#BuildRequires:  pkgconfig(glm)
BuildRequires:  glm-devel
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(libtirpc)
BuildConflicts: texinfo
BuildRequires:  unzip
BuildRequires:  xaw3d-devel
BuildRequires:  xz
BuildRequires:  zip
%if 0%{?suse_version} > 1550 && 0%{?is_opensuse}
BuildRequires:  zlib-ng-compat-devel
%else
BuildRequires:  zlib-devel
%endif
BuildRequires:  zziplib-devel
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xaw7)
BuildRequires:  pkgconfig(xi)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xpm)
BuildRequires:  pkgconfig(xt)
%if %{with buildbiber}
#BuildRequires:  perl-base >= 5.32.0
BuildRequires:  perl-base >= 5.26.1
BuildRequires:  perl(autovivification)
#BuildRequires: perl(Business::ISBN)
BuildRequires:  perl-Business-ISBN >= 3.005
BuildRequires:  perl-Business-ISBN-Data >= 20191107
BuildRequires:  perl(Business::ISMN)
BuildRequires:  perl(Business::ISSN)
BuildRequires:  perl(Class::Accessor)
BuildRequires:  perl(Class::Factory::Util)
BuildRequires:  perl(Config::AutoConf) >= 0.15
BuildRequires:  perl(Data::Compare)
BuildRequires:  perl(Data::Dump)
BuildRequires:  perl(Data::Uniqid)
BuildRequires:  perl(Date::Simple)
BuildRequires:  perl(DateTime)
BuildRequires:  perl(DateTime::Calendar::Julian)
BuildRequires:  perl(DateTime::Format::Builder)
BuildRequires:  perl(DateTime::Format::Strptime)
BuildRequires:  perl(Encode::EUCJPASCII)
BuildRequires:  perl(Encode::HanExtra)
BuildRequires:  perl(Encode::JIS2K)
BuildRequires:  perl(ExtUtils::LibBuilder) >= 0.02
BuildRequires:  perl(File::Slurp::Unicode)
BuildRequires:  perl(File::Slurper)
BuildRequires:  perl(File::Which)
BuildRequires:  perl(IO::String)
BuildRequires:  perl(IPC::Cmd)
BuildRequires:  perl(IPC::Run3)
BuildRequires:  perl(LWP::Protocol::https)
BuildRequires:  perl(LWP::Simple)
BuildRequires:  perl(LWP::UserAgent)
BuildRequires:  perl(Lingua::Translit) >= 0.28
BuildRequires:  perl(List::AllUtils)
BuildRequires:  perl(List::MoreUtils) >= 0.407
BuildRequires:  perl(List::MoreUtils::XS)
BuildRequires:  perl(Log::Log4perl)
BuildRequires:  perl(Module::Build) >= 0.38
BuildRequires:  perl(Package::DeprecationManager)
BuildRequires:  perl(Params::Util)
BuildRequires:  perl(Parse::RecDescent)
BuildRequires:  perl(PerlIO::utf8_strict)
BuildRequires:  perl(Readonly::XS)
BuildRequires:  perl(Regexp::Common)
BuildRequires:  perl(Sort::Key)
BuildRequires:  perl(Sub::Install)
BuildRequires:  perl(Test::Differences)
BuildRequires:  perl(Test::More)
BuildRequires:  perl(Test::Pod) >= 1.22
BuildRequires:  perl(Test::Pod::Coverage) >= 1.08
BuildRequires:  perl(Text::BibTeX) >= 0.88
BuildRequires:  perl(Text::CSV)
BuildRequires:  perl(Text::CSV_XS)
BuildRequires:  perl(Text::Roman)
BuildRequires:  perl(Unicode::Collate) >= 1.29
BuildRequires:  perl(Unicode::GCString)
BuildRequires:  perl(Unicode::LineBreak) >= 2019.001
BuildRequires:  perl(Unicode::Normalize) >= 1.26
BuildRequires:  perl(XML::LibXML) >= 1.70
BuildRequires:  perl(XML::LibXML::Simple)
BuildRequires:  perl(XML::LibXSLT)
BuildRequires:  perl(XML::Writer::String)
%endif
# Download at ftp://tug.org/texlive/historic/%{texlive_version}/
Source0:        %{texlive_source}.tar.xz
Source1:        https://github.com/plk/biber/archive/refs/tags/v%{biber_version}.tar.gz#/biber-%{biber_version}.tar.gz
Source2:        biblatex-biber-ms.tar.gz
%if %{with luametatex}
Source3:        luametatex-2.11.05.tar.gz
%endif
Source4:        cnf-to-paths.awk
Source30:       texlive-rpmlintrc
Source50:       public.c
Source51:       public.8
@@SOURCES@@
Patch0:         source.dif
Patch1:         source-configure.dif
Patch2:         source-xdvizilla.dif
Patch3:         source-arraysubs.dif
Patch4:         source-decNumber.dif
Patch5:         source-texdoc.dif
Patch6:         source-dviutils.dif
Patch7:         source-euptex.dif
Patch8:         source-psutils.dif
Patch9:         source-luacore.dif
Patch10:        source-LuaTeX.dif
Patch11:        source-lacheck.dif
Patch12:        source-warns.dif
Patch13:        source-x11r7.dif
Patch17:        source-64.dif
Patch18:        source-a2ping.dif
Patch19:        source-dvipng.dif
Patch21:        source-ppc64.dif
# fix missing include files to make gcc-15 happy
Patch22:        source-asymptote-liblsp.dif
# PATCH-FIX-SUSE Make biber work with our perl
Patch42:        biblatex-encoding.dif
Patch43:        biblatex-ms-encoding.dif
# PATCH-FIX-SUSE Old problem back: we do not use internal Certs!
Patch44:        biber-certs.dif
Patch45:        biblatex-ms-missing.dif
# PATCH-FIX-SUSE Make biber work with perl 5.18.2
Patch47:        biber-perl-5.18.2.dif
#
Patch50:        luametatex.dif
# PATCH-FIX-SUSE Let it build even without ls-R files around
Patch62:        source-psutils-kpathsea.dif
# fix build with boost 1.88
Patch70:        boost.dif
# Missed luajit fix for ppc/ppc64/ppc64le and riscv64
Prefix:         %{_bindir}

%define add_optflags(a:f:t:p:w:W:d:g:O:A:C:D:E:H:i:M:n:P:U:u:l:s:X:B:I:L:b:V:m:x:c:S:E:o:v:) \
%global optflags %{optflags} %{**}

%global options		~/.tmp.texlive-opts
%global _varlib		%{_localstatedir}/lib

%define libexec %(rpm --eval '%%{_libexecdir}' | sed 's-/usr--g')
%define libexecdir	${prefix}%{libexec}

%define _texmfdistdir	%{_datadir}/texmf
%if 0%{texlive_version} >= 2013
%define _texmfmaindir	%{_texmfdistdir}
%define _texmfdirs	%{_texmfdistdir}
%else
%define _texmfmaindir	%{_libexecdir}/texmf
%define _texmfdirs	\{%{_texmfdistdir},%{_texmfmaindir}\}
%endif

%define _texmfconfdir	%{_sysconfdir}/texmf
%define _texmfvardir	%{_varlib}/texmf
%define _texmfcache	%{_localstatedir}/cache/texmf
%define _fontcache	%{_texmfcache}/fonts
#
%define _x11bin		%{_prefix}/bin
%define _x11lib		%{_libdir}
%define _x11data	%{_datadir}/X11
%define _x11inc		%{_includedir}
%define _appdefdir	%{_x11data}/app-defaults
#
%define texgrp		mktex
%define texusr		mktex

#define texgid		505
#define texuid		505
#
%description
After installing texlive and the package texlive-latex, find a large
selection of documentation for TeX, LaTeX, and various layout styles in
/usr/share/texmf/doc.

TeX (pronounced tech) is an interpreter for text formatting and was
developed by Donald E. Knuth.  It works with control and macro commands
on a text file. Working with TeX is similar to typesetting methods.
LaTeX is a complex macro package that removes the cryptical TeX
interface and does most of the work for the user.

TeX uses special fonts produced by the MetaFont program. Various
printer drivers and an X11 viewer are also included in this package.
The teTeX package is based on the standard TeX package of Karl Berry,
which makes configuration much easier. It is also possible to use
PostScript fonts. A real PostScript printer is required, however. If
the ghostscript (gs) package is installed, all drivers for printing and
viewing can use these fonts. Note, however, that the fonts included in
the ghostscript package are not identical to Adobe's PostScript fonts.
The copyright prohibids us to include them on the CD.

Besides these features, the programs MakeIndex (for producing indexes)
and BibTeX (for literature data processing) exist.

The texlive package includes a full texmf tree, many programs like tex,
dvips, etc., shell script configuration, and a big collection of
documentations. This package is easily configured by the script
texconfig and has multilanguage options.

@@PACKAGES@@

%package -n libkpathsea6
Version:        @@KPSEVERSION@@
Release:        0
Summary:        Path searching library for TeX-related files
License:        LGPL-2.1-or-later
Group:          System/Libraries
URL:            https://www.tug.org/texlive/
Prefix:         %{_libdir}

%description -n libkpathsea6
Kpathsea is a library and utility programs which provide path
searching facilities for TeX file types, including the self-
locating feature required for movable installations, layered on
top of a general search mechanism. It is not distributed
separately, but rather is released and maintained as part of
the TeX-live sources.

%package -n %{name}-kpathsea-devel
Version:        @@KPSEVERSION@@
Release:        0
Summary:        Path searching library for TeX-related files
License:        LGPL-2.1-or-later
Group:          Development/Libraries/C and C++
URL:            https://www.tug.org/texlive/
Requires:       libkpathsea6 = @@KPSEVERSION@@

%description -n %{name}-kpathsea-devel
Kpathsea is a library and utility programs which provide path
searching facilities for TeX file types, including the self-
locating feature required for movable installations, layered on
top of a general search mechanism. It is not distributed
separately, but rather is released and maintained as part of
the TeX-live sources.

%package -n libptexenc1
Version:        @@PTEXENCVERSION@@
Release:        0
Summary:        Libraries of Kanji code convert library for pTeX
License:        BSD-3-Clause
Group:          System/Libraries
URL:            https://www.tug.org/texlive/
Prefix:         %{_libdir}

%description -n libptexenc1
The ptexenc is a useful library for Japanese pTeX
(which stands for publishing TeX, and is an extension of
TeX by ASCII Co.) and its surrounding tools.

%package -n %{name}-ptexenc-devel
Version:        @@PTEXENCVERSION@@
Release:        0
Summary:        Libraries of Kanji code convert library for pTeX
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
URL:            https://www.tug.org/texlive/
Requires:       libptexenc1 = @@PTEXENCVERSION@@

%description -n %{name}-ptexenc-devel
This package includes the ptexenc development files.
The ptexenc is a useful library for Japanese pTeX
(which stands for publishing TeX, and is an extension of
TeX by ASCII Co.) and its surrounding tools.

%package -n libsynctex2
Version:        @@SYNCTEXVERSION@@
Release:        0
Summary:        Libraries of The Synchronization TeXnology
License:        MIT
Group:          System/Libraries
URL:            https://www.tug.org/texlive/
Prefix:         %{_libdir}

%description -n libsynctex2
The Synchronization TeXnology by Jérôme Laurens is a new feature
of recent TeX engines.  It allows to synchronize between input
and output, which means to navigate from the source document to
the typeset material and vice versa.

%package -n %{name}-synctex-devel
Version:        @@SYNCTEXVERSION@@
Release:        0
Summary:        Libraries of The Synchronization TeXnology
License:        MIT
Group:          Development/Libraries/C and C++
URL:            https://www.tug.org/texlive/
Requires:       libsynctex2 = @@SYNCTEXVERSION@@

%description -n %{name}-synctex-devel
This package includes the synctex development files.
The Synchronization TeXnology by Jérôme Laurens is a new feature
of recent TeX engines.  It allows to synchronize between input
and output, which means to navigate from the source document to
the typeset material and vice versa.

%package -n libtexlua53-5
Version:        @@TEXLUAVERSION53@@
Release:        0
Summary:        Libraries of an extended version of pdfTeX using Lua
License:        MIT
Group:          System/Libraries
URL:            https://www.tug.org/texlive/
Prefix:         %{_libdir}

%description -n libtexlua53-5
LuaTeX is an extended version of pdfTeX using Lua as an
embedded scripting language

%package -n %{name}-texlua-devel
Version:        @@TEXLUAVERSION53@@
Release:        0
Summary:        Libraries of an extended version of pdfTeX using Lua
License:        MIT
Group:          Development/Libraries/C and C++
URL:            https://www.tug.org/texlive/
Requires:       libtexlua53-5 = @@TEXLUAVERSION53@@

%description -n %{name}-texlua-devel
This package includes the luatex development files.
LuaTeX is an extended version of pdfTeX using Lua as an
embedded scripting language

%if %{with LuaJIT}
%package -n libtexluajit2
Version:        @@TEXLUAJITVERSION@@
Release:        0
Summary:        Libraries of Just-In-Time compiler for Lua
License:        MIT
Group:          System/Libraries
URL:            https://www.tug.org/texlive/
Prefix:         %{_libdir}

%description -n libtexluajit2
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language

%package -n %{name}-texluajit-devel
Version:        @@TEXLUAJITVERSION@@
Release:        0
Summary:        Libraries of Just-In-Time compiler for Lua
License:        MIT
Group:          Development/Libraries/C and C++
URL:            https://www.tug.org/texlive/
Requires:       libtexlua53-5 = @@TEXLUAVERSION53@@
Requires:       libtexluajit2 = @@TEXLUAJITVERSION@@

%description -n %{name}-texluajit-devel
This package includes the LuaJIT development files.
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language
%endif

%package -n %{name}-bin-devel
Version:        %{texlive_version}.%{texlive_release}
Release:        0
Summary:        Basic development packages for TeXLive
License:        BSD-3-Clause AND LGPL-2.1-or-later AND SUSE-TeX
Group:          Development/Languages/Other
URL:            https://www.tug.org/texlive/
Requires:       libkpathsea6 = @@KPSEVERSION@@
Requires:       libptexenc1 = @@PTEXENCVERSION@@
Requires:       libsynctex2 = @@SYNCTEXVERSION@@
Requires:       libtexlua53-5 = @@TEXLUAVERSION53@@
%if %{with LuaJIT}
Requires:       libtexluajit2 = @@TEXLUAJITVERSION@@
%endif
Requires:       texlive-cweb-bin >= %{texlive_version}
Requires:       texlive-web-bin >= %{texlive_version}

%description -n %{name}-bin-devel
This package will cause the installation of several
development packages for TeXLive.

%if %{with buildbiber}
%package -n perl-biber
Version:        %{biber_version}
Release:        0
Summary:        Library files of Biber a BibTeX replacement
License:        LPPL-1.0
Group:          Productivity/Publishing/TeX/Utilities
URL:            https://biblatex-biber.sourceforge.net/
Recommends:     perl(Readonly::XS)
Requires:       perl-base = %{perl_version}
Requires:       perl(Business::ISBN) >= 3.005
Requires:       perl(Business::ISMN)
Requires:       perl(Business::ISSN)
Requires:       perl(Class::Accessor)
Requires:       perl(Data::Compare)
Requires:       perl(Data::Dump)
Requires:       perl(Data::Uniqid)
Requires:       perl(Date::Simple)
Requires:       perl(DateTime)
Requires:       perl(DateTime::Calendar::Julian)
Requires:       perl(DateTime::Format::Builder)
Requires:       perl(DateTime::TimeZone)
Requires:       perl(Encode::EUCJPASCII)
Requires:       perl(Encode::HanExtra)
Requires:       perl(Encode::JIS2K)
Requires:       perl(File::Slurp)
Requires:       perl(File::Slurp::Unicode)
Requires:       perl(File::Slurper)
Requires:       perl(IPC::Cmd)
Requires:       perl(IPC::Run3)
Requires:       perl(LWP::Protocol::https)
Requires:       perl(LWP::Simple)
Requires:       perl(List::AllUtils)
Requires:       perl(List::MoreUtils)
Requires:       perl(Log::Log4perl)
Requires:       perl(Regexp::Common)
Requires:       perl(Sort::Key)
Requires:       perl(Text::BibTeX) >= 0.88
Requires:       perl(Text::CSV)
Requires:       perl(Text::Roman)
Requires:       perl(URI)
Requires:       perl(Unicode::Collate) >= 1.29
Requires:       perl(Unicode::GCString)
Requires:       perl(XML::LibXML) >= 1.70
Requires:       perl(XML::LibXML::Simple)
Requires:       perl(XML::LibXSLT)
Requires:       perl(XML::Writer)
Requires:       perl(autovivification)
Prefix:         %{_bindir}
BuildArch:      noarch

%description -n perl-biber
Perl library files of Biber a BibTeX replacement for users of BibLaTeX.
This package is required by the package texlive-biber-bin.
%endif

%prep
%define _lto_cflags %{nil}
    OS=%{_target_os}
    CPU=%{_target_cpu}
%ifarch ia64
    RPM_OPT_FLAGS=$(echo "${RPM_OPT_FLAGS}"|sed -r 's/-O[0-9]?/-O1/g')
%endif
%ifarch %arm
    RPM_OPT_FLAGS=${RPM_OPT_FLAGS/-mthumb/-mthumb-interwork -marm}
%endif
%if 0%{?suse_version} <= 1500
    CC=gcc-13
    CXX=g++-13
    CPP=cpp-13
%else
    CC=gcc
    CXX=g++
    CPP=cpp
%endif
    export CC CXX CPP
    XCFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
    XCXXFLAGS="$XCFLAGS -include cstdint"
    cflags ()
    {
	local flag=$1; shift || return
	local cvar=$1; shift || return
	local xvar=$1; shift || true
	if test -z "${flag}" ; then
	    return
	fi
	case "$flag" in
	-Wl,*)
	    if test -z "${cvar}" ; then
		return
	    fi
	    case "${!cvar}" in
	    *${flag}*) return
	    esac
	    if echo 'int main () { return 0; }' | ${CC:-gcc} -Werror $flag -o /dev/null -xc - ; then
		eval $cvar=\${$cvar:+\$$cvar\ }$flag
	    fi
	    ;;
	*)
	    if test -z "${cvar}" ; then
		return
	    fi
	    case "${!cvar}" in
	    *${flag}*) ;;
	    *)	if ${CC:-gcc} -Werror $flag -S -o /dev/null -xc /dev/null ; then
		    eval $cvar=\${$cvar:+\$$cvar\ }$flag
		fi
	    esac
	    if test -z "${xvar}" ; then
		return
	    fi
	    case "${!xvar}" in
	    *${flag}*) ;;
	    *)	if ${CXX:-g++} -Werror $flag -S -o /dev/null -xc++ /dev/null ; then
		    eval $xvar=\${$xvar:+\$$xvar\ }$flag
		fi
	    esac
	esac > /dev/null 2>&1
    }
    cflags -std=gnu11			XCFLAGS
    cflags -std=gnu++14			XCXXFLAGS
    cflags -fno-const-strings		XCFLAGS XCXXFLAGS
    cflags -fno-strict-aliasing		XCFLAGS XCXXFLAGS
    cflags -fPIC			XCFLAGS XCXXFLAGS
    cflags -Wno-write-strings		XCFLAGS XCXXFLAGS
    cflags -Wno-char-subscripts		XCFLAGS XCXXFLAGS
    cflags -Wno-unused			XCFLAGS XCXXFLAGS
    cflags -Wno-uninitialized		XCFLAGS XCXXFLAGS
    cflags -Wno-return-type		XCFLAGS XCXXFLAGS
    cflags -Wno-parentheses		XCFLAGS XCXXFLAGS
    cflags -Wno-sign-compare		XCFLAGS XCXXFLAGS
    cflags -Wno-unprototyped-calls	XCFLAGS
    cflags -pipe			XCFLAGS XCXXFLAGS
    cflags -Wl,-O2			XLDFLAGS
    cflags -Wl,--as-needed		XLDFLAGS
    cflags -Wl,--hash-size=8599		XLDFLAGS
    cflags -Wl,-warn-common		XLDFLAGS
    cflags -Wl,-Bsymbolic-functions	XLDFLAGS
    #
    XCXXFLAGS="${XCXXFLAGS/-Wno-unprototyped-calls/}"
    HOST=%{_target_cpu}-suse-%{_host_os}
    BUILD=%{_target_cpu}-suse-%{_build_os}
    BINARY=${CPU}-${OS}
    VENDOR="%{vendor}"
    VENDOR="${VENDOR%%%%,*}"

    # Generate the Options file
    exec 6>&1
    exec 1>|%{options}

    # On error clear
    trap 'rm -vf %{options}' ERR

    # Disable MALLOC_PERTURB_
    # echo unset MALLOC_PERTURB_

    # System wide configuration
    echo CPU=\"$CPU\"
    echo BINARY=\"${BINARY%%-gnu*}\"
    echo XCFLAGS=\"$XCFLAGS\"
    echo XCXXFLAGS=\"$XCXXFLAGS\"
    echo XLDFLAGS=\"$XLDFLAGS\"
    echo HOST=\"${HOST%%-gnu*}\"
    echo BUILD=\"${BUILD%%-gnu*}\"

    echo export XCFLAGS XCXXFLAGS XLDFLAGS HOST BUILD BINARY

    # Do not include e.g. from manual build
    echo unset TEXINPUTS TEXMF
    echo export HOME=${PWD}/world

    # Use a well defined multi byte locale
    echo unset ${!LC_*}
    if test -d /usr/lib/locale/C.utf8
    then
        echo LANG=C.UTF-8
        echo LC_CTYPE=C.UTF-8
    else
        echo LANG=POSIX
        echo LC_CTYPE=en_US.UTF-8
    fi
    echo export LANG LC_CTYPE

    # Environment for configuration
    echo CONFIG_SHELL=/bin/bash
    echo CC=\"$CC\"
    echo CXX=\"$CXX\"
    echo CPP=\"$CPP\"
    echo CFLAGS=\"$XCFLAGS\"
    echo CXXFLAGS=\"$XCXXFLAGS\"
    echo LDFLAGS=\"-Wl,-warn-common $XLDFLAGS\"
    echo VENDOR=\"${VENDOR}\"
    echo ARCH_LIB=%{_lib}
    echo export CC CXX CPP CFLAGS CXXFLAGS LDFLAGS VENDOR PATH CONFIG_SHELL ARCH_LIB

    # Do not run TeX engine in fmtutil with batchmode
    echo batchmode=no
    echo export batchmode
%ifnarch hppa
    echo ulimit -s unlimited
%else
    # This is the maximum on hppa
    echo ulimit -s 81920
%endif
    exec 1>&6-

%setup -c -q -n texlive -T

    tar --strip-components=1 -xf %{SOURCE0}
%if %{with buildbiber}
    pushd ../
	tar xf %{SOURCE1}
    popd
    pushd ../
	tar xf %{SOURCE2}
    popd
%endif
%if %{with luametatex}
    pushd ../
       tar -xf %{SOURCE3}
    popd
%endif

%patch -P1  -p0 -b .configure
%patch -P2  -p0 -b .xdvizilla
%patch -P3  -p0 -b .arraysubs
%patch -P4  -p0 -b .unicode
%patch -P5  -p0 -b .texdoc
%patch -P6  -p0 -b .dviutils
%patch -P7  -p0 -b .crash
%patch -P8  -p0 -b .psutils
%patch -P9  -p0 -b .perms
%patch -P10 -p0 -b .r74603
%patch -P11 -p0 -b .lacheck
%patch -P12 -p0 -b .warns
%patch -P13 -p0 -b .x11r7
%patch -P17 -p0 -b .64
%patch -P18 -p0 -b .a2p
%patch -P19 -p0 -b .dvipng
%patch -P21 -p0 -b .ppcelf
%patch -P22 -p0 -b .asy
pushd libs/luajit/LuaJIT-src/
#Missed patch ppc and risc
popd
%patch -P0  -p0 -b .p0
%if %{with luametatex}
pushd ../luametatex*
%patch -P50 -p0 -b .unicode
popd
%endif
%if %{with buildbiber}
pushd ../biber-*/
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
%patch -P42 -p0 -b .en
%patch -P44 -p0 -b .noica
%if 0%{perl_versnum} < 5200
%patch -P47 -p0 -b .518
%endif
rm -vf bin/biber.noica
rm -vf t/*.fastsort
popd
pushd ../biblatex-biber-*/
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
%patch -P43 -p0 -b .en
%patch -P44 -p0 -b .noica
%patch -P45 -p0 -b .missing
%if 0%{perl_versnum} < 5200
%patch -P47 -p0 -b .518
%endif
rm -vf bin/biber.noica
rm -vf t/*.fastsort
popd
%endif
%patch -P70 -p0

%patch -P62 -p0 -b .kpserr

    # Correct FHS paths
    paths=$(find -name cnf-to-paths.awk)
    test -n "$paths" || exit 1
    cp -vf %{S:4} $paths

%build
    # Extend the options file
    echo "world=${PWD}/world" >> %{options}
    echo "prefix=${PWD}/prefix" >> %{options}
    echo "texmfcnf=${PWD}/texk/kpathsea" >> %{options}

    # Read the options file
    . %{options}

    if test -d /usr/include/unicode -a -d /usr/include/harfbuzz && \
        grep -qrs UBLOCK_LATIN_EXTENDED_F /usr/include/unicode
    then
	icu[0]='--with-system-icu'
	icu[1]='--with-system-harfbuzz'
    else
	icu[0]='--without-system-icu'
	icu[1]='--without-system-harfbuzz'
    fi
    if test -n "$(getconf LFS_CFLAGS)"
    then
	large='enable'
	if test -n "$(nm -D /lib/libzzip.so | grep zzip_init_io64)"
	then
	    zzip='--with-system-zziplib'
	else
	    zzip='--without-system-zziplib'
	fi
    else
	large='disable'
	zzip='--with-system-zziplib'
    fi
    # Wrong version string
    sed -ri '/m4_define.*tex_live_version/{s@[0-9]+/dev@%{texlive_version}@}' version.ac
    for rp in $(find -name configure) ; do
	sed -ri '/(Web2C|STRING|VERSION)/{s@[0-9]+/dev@%{texlive_version}@}' $rp
    done
    for rp in $(find -name configure.ac) ; do
	sed -ri 's/KPSE_WIN32_CALL/KPSE_COND_WIN32/' $rp
    done

    # Avoid -rpath as libtool is not configurable at this point
    for rp in $(find -name libtool.m4 -or -name configure) ; do
	sed -ri 's/(-rpath)/\1-link/g' $rp
    done
    LD_LIBRARY_PATH=${prefix}/%{_lib}:${world}/texk/kpathsea/.libs:${world}/texk/ptexenc/.libs
    export LD_LIBRARY_PATH

    # We have an other autoconf/automake version and some patch changing ac files
    ./reautoconf . libs/gd libs/icu/dummy texk/dvipdfm-x texk/dvipng texk/dvisvgm \
	texk/ttf2pk2 texk/web2c texk/web2c/web2c texk/xdvik

    if [[ $VENDOR =~ opensuse ]] ; then
	banner='for opensuse.org'
    else
	banner='for SUSE Linux'
    fi

    #
    # Avoid win32 Makefile
    #
    find -name configure | xargs sed -ri '/(CONFIG_FILES|ac_config_files)=/ { s@[[:blank:]]+(otps/|)win32/Makefile@@p; }'
    find -name config.status | xargs -r rm -vf

    #
    # The (up)mendex unsigned character sort does not work on non-Intel boxes
    #
    sed -ri '/^CFLAGS/{ s/$/ -fsigned-char/ }' texk/mendexk/Makefile.in
    sed -ri '/^CFLAGS/{ s/$/ -fsigned-char/ }' texk/upmendex/Makefile.in

    # Run configure now ... no reautoconf here as TeX Live uses modified m4 macros
    # longinteger and off_t declarations are still inconsistent, do not enable
    # largefile unless you are testing.
    # Default to building ICU without thread support, since xetex does not need it.
    cache=$PWD/config.cache
    mkdir -p ${world}
    pushd ${world}/
	STRIP=/bin/true				\
	STRIPPROG=/bin/true			\
	../configure				\
	    --host=${HOST}			\
	    --build=${BUILD}			\
	    --enable-fast-install=no		\
	    --disable-native-texlive-build	\
	    --disable-cxx-runtime-hack		\
	    --cache-file=$cache			\
	    --disable-multiplatform		\
	    --prefix=$prefix			\
	    --datadir=$prefix			\
	    --datarootdir=$prefix		\
	    --exec-prefix=$prefix		\
	    --bindir=$prefix/bin		\
	    --libdir=$prefix/%{_lib}		\
	    --infodir=$prefix/share/info	\
	    --mandir=$prefix/share/man		\
	    --sysconfdir=$prefix/etc		\
	    --localstatedir=$prefix/var/lib	\
	    --sharedstatedir=$prefix/var/lib	\
	    --includedir=$prefix/include	\
	    --x-libraries=%{_x11lib}		\
	    --x-includes=%{_x11inc}		\
	    --disable-cxx-runtime-hack		\
	    --disable-texinfo			\
	    --disable-texi2html			\
	    --disable-dialog			\
	    --disable-t1utils			\
	    --disable-dvi2tty			\
	    --disable-xindy			\
	    --disable-xindy-docs		\
	    --disable-xindy-rules		\
	    --disable-xz			\
	    --${large}-largefile		\
	    --enable-threads			\
	    --enable-year2038			\
	    --%{!?with_psutils:disable}%{?with_psutils:enable}-psutils \
	    --%{!?with_lcdf_typetools:disable}%{?with_lcdf_typetools:enable}-lcdf-typetools \
	    --enable-freetype			\
	    --enable-musixflx			\
	    --enable-lacheck			\
	    --enable-detex			\
	    --enable-seetexk			\
	    --enable-tex4htk			\
	    --enable-shared			\
%if %{with LuaJIT}
	    --enable-luajittex			\
	    --enable-luajithbtex		\
	    --enable-mfluajit			\
%else
	    --disable-luajittex			\
	    --disable-luajithbtex		\
	    --disable-mfluajit			\
%endif
	    --with-gnu-ld			\
	    --with-gnu-libc			\
	    --with-system-xz			\
	    --with-system-dialog		\
	    --with-system-t1utils		\
	    --with-system-ncurses		\
	    --with-system-zlib			\
	    --with-system-expat			\
	    --with-system-unzip			\
	    --with-system-libpng		\
	    --with-system-pnglib		\
	    --with-system-gd			\
	    ${zzip:+"${zzip}"}			\
	    --with-system-libgs			\
	    --with-system-freetype2		\
	    --with-freetype2-includes=%{_includedir}/freetype2 \
	    --with-system-cairo			\
	    --with-system-includes=%{_includedir}/cairo \
	    --with-system-mpfr			\
	    --with-system-graphite2		\
	    --with-system-potrace		\
	    --with-system-libpaper		\
	    --with-banner-add="/TeX Live $banner" \
	    ${icu[0]:+"${icu[@]}"}		\
	    --enable-epsfwin			\
	    --enable-mftalkwin			\
	    --enable-regiswin			\
	    --enable-tektronixwin		\
	    --enable-unitermwin			\
	    --with-ps=gs			\
	    --with-x				\
	    --with-mf-x-toolkit			\
	    --with-xdvi-x-toolkit=xaw3d		\
	    --with-editor='vi +%%d %%s'

	testsuite () {
	    test -s ${world}/texk/bibtex-x/test-suite.log || return
	    cat ${world}/texk/bibtex-x/test-suite.log
	    for log in ${world}/texk/bibtex-x/tests/*.log
	    do
		echo $log
		cat $log
	    done
	    rm -vf %{options}
	}
	trap "testsuite" ERR

	PATH=$prefix/bin:$PATH			\
	TEXMFLOCAL=%{_texmfmaindir}		\
	TEXMFCNF=$texmfcnf			\
	make %{?_smp_mflags} world STRIP=/bin/true STRIPPROG=/bin/true

	trap 'rm -vf %{options}' ERR

    popd

    pushd utils/asymptote
%if 0%{?suse_version} <= 1500
	mkdir bin
	ln -sf /usr/bin/python3.11 bin/python3
%endif
	version=$(autoreconf --version | head -n 1 | sed -r 's/.* ([0-9.]+)$/\1/')
	if test ${version%%.*} -ge 2 -a ${version#*.} -ge 71
	then
	    autoreconf
	fi
	if pkg-config --atleast-version 25 dri
	then
	    gallium=$(ls %{_libdir}/libgallium*.so)
	    gallium=-l${gallium##/*lib}
	    (cat>libOSMesa.so)<<-EOF
		/* GNU ld script */
		INPUT(%{_libdir}/libOSMesa.so AS_NEEDED(${gallium%%.so}))
		EOF
	else
	    (cat>libOSMesa.so)<<-'EOF'
		/* GNU ld script */
		INPUT(%{_libdir}/libOSMesa.so AS_NEEDED(-lglapi))
		EOF
	fi
	PATH=$prefix/bin:$PATH			\
	TEXMFLOCAL=%{_texmfmaindir}		\
	TEXMFCNF=$texmfcnf			\
	STRIP=/bin/true				\
	STRIPPROG=/bin/true			\
	LDFLAGS="$LDFLAGS -L$PWD"		\
	CFLAGS="${CFLAGS/-Wno-unprototyped-calls/}"	\
	CXXFLAGS="${CXXFLAGS/-Wno-unprototyped-calls/}"	\
	CFLAGS="${CFLAGS//-std=gnu11/}"		\
	CXXFLAGS="${CXXFLAGS//-std=gnu11/}"	\
	./configure				\
	    --host=${HOST}			\
	    --build=${BUILD}			\
	    --prefix=%{_prefix}			\
	    --bindir=%{_bindir}			\
	    --libdir=%{_libdir}			\
	    --datadir=%{_texmfmaindir}		\
	    --disable-texlive-build		\
	    --enable-offscreen			\
	    --enable-readline			\
	    --enable-gsl			\
	    --enable-fftw			\
	    --enable-gc=system			\
	    --enable-gl
%if 0%{?suse_version} <= 1500
	PATH=${PWD}/bin:$PATH \
%endif
	make asy
	mkdir -p ${prefix}/bin
	mkdir -p ${prefix}/texmf/asymptote/GUI
	install -m 0755 asy		${prefix}/bin/
	install -m 0755 GUI/xasy.py	${prefix}/texmf/asymptote/GUI
	ln -sf ../texmf/asymptote/GUI/xasy.py ${prefix}/bin/xasy
    popd

    # compile public
    mkdir -p %{libexecdir}/mktex
    $CC ${RPM_OPT_FLAGS} -D_GNU_SOURCE -DTEXGRP='"%{texgrp}"' -DTEXUSR='"%{texusr}"' -DMKTEX='"%{_libexecdir}/mktex"' -fPIE -pie -o %{libexecdir}/mktex/public %{S:50}

    # install our own scripts
    mkdir -p ${prefix}/bin
    install -m 0755 texk/seetexk/a4toa5 ${prefix}/bin/
    install -m 0755 texk/seetexk/mydvichk ${prefix}/bin/
    install -m 0755 texk/seetexk/odd2even ${prefix}/bin/

%if %{with LuaJIT}
    echo "Luaji is supported on this platform"
%else
    for broken in luajittex texluajit texluajitc luajithbtex luajittex texluajit texluajitc
    do
	test ! -x ${prefix}/bin/$broken || continue
	(cat>${prefix}/bin/$broken)<<-'EOF'
	#!/bin/sh
	echo "${0}: is not supported on $(uname -m)" 1>&2
	echo "${0}: Report at https://github.com/LuaJIT/LuaJIT/issues/42" 1>&2
	exit 1
	EOF
	chmod 0755 ${prefix}/bin/$broken
	unset broken
    done
%endif

    # install perl modules
    mkdir -p ${prefix}/share/texmf/tlpkg/TeXLive
    install -m 0644 texk/tests/TeXLive/TLConfig.pm ${prefix}/share/texmf/tlpkg/TeXLive/
    install -m 0644 texk/tests/TeXLive/TLUtils.pm  ${prefix}/share/texmf/tlpkg/TeXLive/

%if %{with luametatex}
    pushd ../luametatex*
	%cmake \
	-DVERBOSE=ON \
	-DCMAKE_C_COMPILER=${CC} \
	-DCMAKE_C_FLAGS="${CFLAGS}" \
	-DCMAKE_STRIP:FILEPATH=/bin/true \
	-DCMAKE_CXX_COMPILER=${CXX} \
	-DCMAKE_CXX_FLAGS="${CXXFLAGS}"
	cmake --build . --parallel %{?_smp_mflags}
    popd
%endif
%if %{with buildbiber}
    # dump a biber executable
    pushd ../biber-*/
	find -name '*.ca' | xargs -r rm -vf

	if test "$(getconf LONG_BIT)" -lt 64 ; then
	    sed -ri '/eq_or_diff.*(17000002|era[1234]|range[12])/{s@.*@eq_or_diff("dummy", "dummy", "skipped on 32bit");@}' t/dateformats.t
	fi

	LANG=en_US.UTF-8 %{__perl} ./Build.PL installdirs=vendor optimize="$RPM_OPT_FLAGS"
	LANG=en_US.UTF-8 ./Build build flags=%{?_smp_mflags}

	# There is no network here
	rm t/remote-files.t

	LANG=en_US.UTF-8 \
	BIBER_DEV_TESTS=1 \
	./Build test
    popd
    pushd ../biblatex-biber-*/
	find -name '*.ca' | xargs -r rm -vf

	if test "$(getconf LONG_BIT)" -lt 64 ; then
	    sed -ri '/eq_or_diff.*(17000002|era[1234]|range[12])/{s@.*@eq_or_diff("dummy", "dummy", "skipped on 32bit");@}' t/dateformats.t
	fi

	LANG=en_US.UTF-8 %{__perl} ./Build.PL installdirs=vendor optimize="$RPM_OPT_FLAGS"
	LANG=en_US.UTF-8 ./Build build flags=%{?_smp_mflags}

	# There is no network here
	rm t/remote-files.t

	LANG=en_US.UTF-8 \
	BIBER_DEV_TESTS=1 \
	./Build test
    popd
%endif

%install

    # Read the options file
    . %{options}
    rm -vf %{options}

    mkdir -p %{buildroot}%{_bindir}
    mkdir -p %{buildroot}%{_libdir}/pkgconfig
    mkdir -p %{buildroot}%{_includedir}
    mkdir -p %{buildroot}%{_infodir}
    mkdir -p %{buildroot}%{_libexecdir}/mktex
    mkdir -p %{buildroot}%{_mandir}
    mkdir -p %{buildroot}%{_mandir}/man1
    mkdir -p %{buildroot}%{_mandir}/man5
    mkdir -p %{buildroot}%{_mandir}/man8
    mkdir -p %{buildroot}%{_texmfmaindir}
    mkdir -p %{buildroot}%{_texmfdistdir}
    mkdir -p %{buildroot}%{_texmfconfdir}/dvipdfm/config
    mkdir -p %{buildroot}%{_texmfconfdir}/dvipdfmx
    mkdir -p %{buildroot}%{_texmfconfdir}/dvips/config
    mkdir -p %{buildroot}%{_texmfconfdir}/scripts/urlbst
    mkdir -p %{buildroot}%{_texmfconfdir}/scripts/match_parens
    mkdir -p %{buildroot}%{_texmfconfdir}/scripts/mf2pt1
    mkdir -p %{buildroot}%{_texmfconfdir}/tex/amstex/base
    mkdir -p %{buildroot}%{_texmfconfdir}/tex/generic/config
    mkdir -p %{buildroot}%{_texmfconfdir}/tex/lambda/config
    mkdir -p %{buildroot}%{_texmfconfdir}/tex/mex/base
    mkdir -p %{buildroot}%{_texmfconfdir}/tex/plain/cyrplain
    mkdir -p %{buildroot}%{_texmfconfdir}/web2c
    mkdir -p %{buildroot}%{_texmfconfdir}/xdvi
    mkdir -p %{buildroot}%{_texmfvardir}
    mkdir -p %{buildroot}%{_texmfvardir}/dist
    mkdir -p %{buildroot}%{_texmfvardir}/fonts
    mkdir -p %{buildroot}%{_texmfvardir}/fonts/dvipdfm
    mkdir -p %{buildroot}%{_texmfvardir}/fonts/dvips
    mkdir -p %{buildroot}%{_texmfvardir}/fonts/pdftex
    mkdir -p %{buildroot}%{_texmfvardir}/main
    mkdir -p %{buildroot}%{_texmfvardir}/md5
    mkdir -p %{buildroot}%{_texmfvardir}/web2c
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/aleph
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/eptex
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/luatex
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/metafont
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/pdftex
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/ptex
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/tex
    mkdir -p %{buildroot}%{_texmfvardir}/web2c/xetex
    mkdir -p %{buildroot}%{_texmfcache}
    mkdir -p %{buildroot}%{_fontcache}
    mkdir -p %{buildroot}%{_fontcache}/pk
    mkdir -p %{buildroot}%{_fontcache}/source
    mkdir -p %{buildroot}%{_fontcache}/tfm
    mkdir -p %{buildroot}%{_appdefdir}
    mkdir -p %{buildroot}/var/adm/update-scripts

    pushd ${prefix}/bin/
	tar -cpSf - . | tar -xvspSf - -C %{buildroot}%{_bindir}/
	rm -vf %{buildroot}%{_bindir}/tlmgr
	rm -vf %{buildroot}%{_bindir}/tlshell
	rm -vf %{buildroot}%{_bindir}/installfont-tl
	rm -vf %{buildroot}%{_bindir}/tlcockpit
    popd
    pushd ${prefix}/%{_lib}/
	tar -cpSf - *.so* | tar -xvspSf - -C %{buildroot}%{_libdir}/
    popd
    pushd %{libexecdir}/
	tar -cpSf - mktex | tar -xvspSf - -C %{buildroot}%{_libexecdir}/
    popd
    pushd ${prefix}/share/texmf
	tar -cpSf - tlpkg | tar -xvspSf - -C %{buildroot}%{_texmfdistdir}/
    popd
    pushd ${prefix}/include/
	tar -cpSf - . | tar -xvspSf - -C %{buildroot}%{_includedir}/
    popd
    pushd ${prefix}/share/man/
    popd
%if %{with luametatex}
    pushd ../luametatex*
        %cmake_install
        for exe in context mtxrun
        do
            ln -sf luametatex %{buildroot}%{_bindir}/${exe}
            ln -sf %{_texmfdistdir}/scripts/context/lua/${exe}.lua %{buildroot}%{_bindir}/${exe}.lua
        done
        ln -sf %{_texmfdistdir}/scripts/context/lua/mtx-context.lua %{buildroot}%{_bindir}/mtx-context.lua
        for exe in texexec texmfstart
        do
            ln -sf %{_texmfdistdir}/scripts/context/ruby/${exe}.rb %{buildroot}%{_bindir}/${exe}
        done
        for exe in contextjit luatools mtxrunjit
        do
            ln -sf %{_texmfdistdir}/scripts/context-texlive/stubs-mkiv/unix/${exe} %{buildroot}%{_bindir}/${exe}
        done
    popd
%endif
    #
    # Biber support
    #
%if %{with buildbiber}
    pushd ../biblatex-biber-*/
	./Build install destdir=%{buildroot}
	chmod    0755 %{buildroot}%{_bindir}/biber
	rm -vf        %{buildroot}%{_mandir}/man1/biber.1*
	chmod    0644 %{buildroot}%{perl_vendorlib}/Biber.pm
	chmod -R u+rw %{buildroot}%{perl_vendorlib}/Biber
	mkdir %{buildroot}%{perl_vendorlib}/biber-ms
	mv %{buildroot}%{perl_vendorlib}/Biber.pm %{buildroot}%{perl_vendorlib}/biber-ms/Biber.pm
	mv %{buildroot}%{perl_vendorlib}/Biber    %{buildroot}%{perl_vendorlib}/biber-ms/Biber
	mv %{buildroot}%{_bindir}/biber           %{buildroot}%{_bindir}/biber-ms
	if test -d %{buildroot}%{perl_vendorlib}/Unicode/Collate
	then
	    chmod -R u+rw %{buildroot}%{perl_vendorlib}/Unicode/Collate/*
	fi
	rm -vrf %{buildroot}%{perl_vendorarch}/auto
	rm -vrf %{buildroot}%{_mandir}/man3
	%perl_process_packlist
	%perl_gen_filelist
	pushd blib
	    install -m 0644 bindoc/biber.1 %{buildroot}%{_mandir}/man1/biber-ms.1
	    gzip -n9 %{buildroot}%{_mandir}/man1/biber-ms.1
	popd
	sed -ri "/^use warnings;/a\use lib %{perl_vendorlib}/biber-ms;" %{buildroot}%{_bindir}/biber-ms
	sed -ri '\@/usr/(share|bin)/.*@d' texlive.files
    popd
    mv ../biblatex-biber-*/texlive.files perl-biber-ms.files
    pushd ../biber-*/
	./Build install destdir=%{buildroot}
	chmod    0755 %{buildroot}%{_bindir}/biber
	rm -vf        %{buildroot}%{_mandir}/man1/biber.1*
	chmod    0644 %{buildroot}%{perl_vendorlib}/Biber.pm
	chmod -R u+rw %{buildroot}%{perl_vendorlib}/Biber
	if test -d %{buildroot}%{perl_vendorlib}/Unicode/Collate
	then
	    chmod -R u+rw %{buildroot}%{perl_vendorlib}/Unicode/Collate/*
	fi
	rm -vrf %{buildroot}%{perl_vendorarch}/auto
	rm -vrf %{buildroot}%{_mandir}/man3
	%perl_process_packlist
	%perl_gen_filelist
	pushd blib
	    install -m 0644 bindoc/biber.1 %{buildroot}%{_mandir}/man1/
	    gzip -n9 %{buildroot}%{_mandir}/man1/biber.1
	popd
	sed -ri '\@/usr/(share|bin)/.*@d' texlive.files
    popd
    mv ../biber-*/texlive.files perl-biber.files
%else
    (cat > %{buildroot}%{_bindir}/biber)<<-'EOF'
	#!/bin/sh
	echo No biber available due to old perl installation >&2
	exit 1
	EOF
    chmod	0755 %{buildroot}%{_bindir}/biber
%endif

    #
    # Those lines with exclamation mark have to done in the
    # specific spec files
    #
#!  pushd ${prefix}/share/info/
#!	tar -cpSf - *.info | tar -xvspSf - -C %{buildroot}%{_infodir}/
#!  popd
#!  pushd ${prefix}/share/man/
#!	tar -cpSf - . | tar -xvspSf - -C %{buildroot}%{_mandir}/
#!	rm -vf %{buildroot}%{_mandir}/man*/tlmgr*
#!	rm -vf %{buildroot}%{_mandir}/man*/installfont-tl*
#!  popd
    pushd ${prefix}/texmf/
	tar -cpSf - . | tar -xvspSf - -C %{buildroot}%{_texmfmaindir}/
	rm -vrf %{buildroot}%{_texmfmaindir}/texconfig/g
	rm -vrf %{buildroot}%{_texmfmaindir}/texconfig/v
	rm -vrf %{buildroot}%{_texmfmaindir}/texconfig/x
	rm -vrf %{buildroot}%{_texmfmaindir}/tlpkg/tlpobj
	rm -vf  %{buildroot}%{_texmfmaindir}/texconfig/generic
	rm -vf  %{buildroot}%{_texmfmaindir}/texconfig/README
#!	mv -vf  %{buildroot}%{_texmfmaindir}/dvipdfmx/dvipdfmx.cfg \
#!		%{buildroot}%{_texmfconfdir}/dvipdfmx/
#!	ln -sf		    %{_texmfconfdir}/dvipdfmx/dvipdfmx.cfg \
#!		%{buildroot}%{_texmfmaindir}/dvipdfmx/
	for cnf in %{buildroot}%{_texmfmaindir}/web2c/*.cnf ; do
	    test -e "$cnf" || break
	    mv -vf $cnf %{buildroot}%{_texmfconfdir}/web2c/
	    ln -sf %{_texmfconfdir}/web2c/${cnf##*/} $cnf
	done
#!	mv -vf  %{buildroot}%{_texmfmaindir}/xdvi/xdvi.cfg \
#!		%{buildroot}%{_texmfconfdir}/xdvi/
#!	ln -sf		    %{_texmfconfdir}/xdvi/xdvi.cfg \
#!		%{buildroot}%{_texmfmaindir}/xdvi/
#!	mv -vf  %{buildroot}%{_texmfmaindir}/xdvi/XDvi \
#!		%{buildroot}%{_texmfconfdir}/xdvi/
#!	ln -sf		    %{_texmfconfdir}/xdvi/XDvi \
#!		%{buildroot}%{_appdefdir}/
    popd
    pushd ${prefix}/texmf-dist/
	tar -cpSf - . | tar -xvspSf - -C %{buildroot}%{_texmfdistdir}/
	rm -vrf %{buildroot}%{_texmfdistdir}/texconfig/g
	rm -vrf %{buildroot}%{_texmfdistdir}/texconfig/v
	rm -vrf %{buildroot}%{_texmfdistdir}/texconfig/x
	rm -vrf %{buildroot}%{_texmfdistdir}/tlpkg/tlpobj
	rm -vf  %{buildroot}%{_texmfdistdir}/texconfig/generic
	rm -vf  %{buildroot}%{_texmfdistdir}/texconfig/README
	for cnf in %{buildroot}%{_texmfdistdir}/web2c/*.cnf ; do
	    test -e "$cnf" || break
	    mv -vf $cnf %{buildroot}%{_texmfconfdir}/web2c/
	    ln -sf %{_texmfconfdir}/web2c/${cnf##*/} $cnf
	done
    popd
    pushd %{buildroot}%{_bindir}/
	# ppower4 (currently) not part of TEX Live
	rm -f pdfthumb
	rm -f ppower4
	# repair/relocate the script links
	find -type l -printf '%f\a%l\n' | \
	    while IFS=$'\a' read dst src; do
		case "$src" in
                /*)             ;;
%if 0%{texlive_version} >= 2013
		*/texmf/*)	ln -vsf ../share/texmf/${src#../texmf/}	    $dst ;;
%else
		*/texmf/*)	ln -vsf ../lib/texmf/${src#../texmf/}	    $dst ;;
%endif
		*/texmf-dist/*)	ln -vsf ../share/texmf/${src#../texmf-dist/} $dst ;;
		esac
	    done
	# set xasy script link
%if 0%{texlive_version} >= 2013
	ln -vsf ../share/texmf/asymptote/GUI/xasy.py xasy
%else
	ln -vsf ../lib/texmf/asymptote/GUI/xasy.py xasy
%endif
	# some scripts not included in main source tar ball
	test -e match_parens || ln -vsf ../share/texmf/scripts/match_parens/match_parens match_parens
	test -e mf2pt1       || ln -vsf ../share/texmf/scripts/mf2pt1/mf2pt1.pl mf2pt1
	test -e urlbst       || ln -vsf ../share/texmf/scripts/urlbst/urlbst urlbst
	# set some may missed symbolic links
	test -e mfplain  || ln -vsf mpost    mfplain
	test -e texlua   || ln -vsf luatex   texlua
	test -e texluac  || ln -vsf luatex   texluac
	test -e texhash  || ln -vsf mktexlsr texhash
	test -e rpdfcrop || ln -vsf pdfcrop  rpdfcrop
	test -e latexdef || ln -vsf texdef   latexdef
	# stolen from texlink script, also added musixtex case
	sed -r '\@^[[:blank:]]*(#|$)@d;s@\*@@' < $prefix/texmf-dist/web2c/fmtutil.cnf | \
	awk '{print $1, $2 }' | while read fmt engine ; do
	    test -f "$engine" || continue
	    case "$fmt" in
	    mf) test "$engine" = mf-nowin -a -f mfw && engine=mfw
	    esac
	    case "$fmt" in
	    cont-??|mptopdf|*musixtex) continue ;;
	    *)  test "$fmt" = "$(ls -ld "$fmt" 2> /dev/null | awk '{print $NF}')" || rm -rf "$fmt"
		test ! -f "$fmt" || continue
		test "$fmt" = "pdfcsplain" && engine=pdftex
		ln -vsf "$engine" "$fmt"
	    esac
	done
	# our pdfmusixtex extension of the musixtex lua script
	test -e pdfmusixtex  || ln -sf musixtex pdfmusixtex
	if test ! -e rlxtools ; then
	    printf '#!/bin/sh\nmtxrun --script rlxtools "$@"\n' > rlxtools
	    chmod 755 rlxtools
	fi
%if 0%{texlive_version} >= 2017
	# new dviinfox perl script
	ln -vsf ../share/texmf/scripts/dviinfox/dviinfox.pl dviinfox
%endif
%if 0%{texlive_version} >= 2018
	# new ketcindy wrapper script
	ln -vsf ../share/texmf/scripts/ketcindy/ketcindy.sh ketcindy
%endif
%if 0%{texlive_version} >= 2020
	# new git-latexdiff wrapper script
	ln -vsf ../share/texmf/scripts/git-latexdiff/git-latexdiff git-latexdiff
	# ... and add rungs texlua script as dvipdfmx/dvipdfm require this
%if 0%{texlive_version} >= 2023
	ln -vsf ../share/texmf/scripts/texlive/rungs.lua rungs
	rm -vf %{buildroot}%{_texmfdistdir}/scripts/texlive/rungs.lua
%else
	ln -vsf ../share/texmf/scripts/texlive/rungs.tlu rungs
	rm -vf %{buildroot}%{_texmfdistdir}/scripts/texlive/rungs.tlu
%endif
%endif
    popd

    # clear out all file below texmf tree as this will delivered by texlive tar balls
    find %{buildroot}%{_texmfdirs} -type f | xargs -r rm -vf

    # but work around missing MusixTeX files ...
%if 0%{texlive_version} < 2013
    pushd ${prefix}/texmf-dist/
	install -m 0755 scripts/m-tx/m-tx.lua %{buildroot}%{_texmfdistdir}/scripts/m-tx/
	install -m 0755 scripts/pmx/pmx2pdf.lua %{buildroot}%{_texmfdistdir}/scripts/pmx/
    popd
%endif
    # install manual page of public
    install -m 0644 %{S:51} %{buildroot}%{_mandir}/man8/public.8
    gzip -n9 %{buildroot}%{_mandir}/man8/public.8

    # is part of texlive-kpathsea
    rm -vf %{buildroot}%{_texmfconfdir}/web2c/fmtutil.cnf
    rm -vf %{buildroot}%{_texmfconfdir}/web2c/texmf.cnf
    rm -vf %{buildroot}%{_texmfmaindir}/web2c/fmtutil.cnf
    rm -vf %{buildroot}%{_texmfmaindir}/web2c/texmf.cnf
    rm -vf %{buildroot}%{_texmfdistdir}/web2c/fmtutil.cnf
    rm -vf %{buildroot}%{_texmfdistdir}/web2c/texmf.cnf

    # relink texlive helpers to public binary
    for mktex in texhash mktexlsr mktexmf mktexpk mktextfm
    do
        # mktexlsr and co are now perl/shell script out of package texlive-scripts
	rm -f %{buildroot}%{_bindir}/$mktex
	case "$mktex" in
	mktexlsr*)
	   ln -sf ../../share/texmf/scripts/texlive/${mktex}.pl %{buildroot}%{_libexecdir}/mktex/$mktex
	   ;;
	texhash*)
	   ln -sf ../../share/texmf/scripts/texlive/mktexlsr.pl %{buildroot}%{_libexecdir}/mktex/$mktex
	   ;;
	*)
	   ln -sf ../../share/texmf/scripts/texlive/${mktex}    %{buildroot}%{_libexecdir}/mktex/$mktex
	   ;;
	esac
	ln -sf %{_libexecdir}/mktex/public %{buildroot}%{_bindir}/$mktex
    done
%if %{with zypper_posttrans}
    ln -sf %{_texmfdistdir}/texconfig/zypper.py \
	%{buildroot}/var/adm/update-scripts/%{name}-%{version}-%{release}-zypper
%endif

    pushd ${prefix}/%{_lib}/pkgconfig/
    for pc in kpathsea ptexenc texlua texlua53 texluajit synctex
    do
	test -e "$pc.pc" || continue
	sed -ri "s@([^=]+=)${prefix}@\1/usr@" $pc.pc
	install -m 0644 $pc.pc %{buildroot}%{_libdir}/pkgconfig/
    done
    popd

    pushd ${world}/texk/kpathsea/
	install -m 0644 c-auto.h %{buildroot}%{_includedir}/kpathsea/
    popd

%if %{with buildbiber}
    for scr in %{_bindir}/biber \
	%{_bindir}/biber-ms \
%else
    for scr in \
%endif
	%{_texmfdistdir}/scripts/texlive/rungs.tlu \
	%{_texmfdistdir}/scripts/texlive/rungs.lua
    do
	test -e %{buildroot}/$scr || continue
	ed %{buildroot}/${scr} <<-'EOF'
		1
		s@/env[[:blank:]]\+@/@
		.
		w
		q
	EOF
    done

    # Currently disabled due python2 requirement
    rm -vf %{buildroot}%{_bindir}/ebong

    # Rename memoize script
    pushd %{buildroot}%{_bindir}
	for m in memoize-clean memoize-extract
	do
	    rm -vf ${m}.p*
	    ln -sf ../share/texmf/scripts/memoize/${m}.pl $m
	done
    popd

%if %{defined verify_permissions}
%verifyscript kpathsea-bin
%verify_permissions -e %{_libexecdir}/mktex/public
%endif

%post kpathsea-bin
%if %{defined set_permissions}
%set_permissions %{_libexecdir}/mktex/public
%endif

%post
mkdir -p /var/run/texlive
> /var/run/texlive/run-mktexlsr
> /var/run/texlive/run-update

%postun
if test $1 = 1; then
    mkdir -p /var/run/texlive
    > /var/run/texlive/run-mktexlsr
    > /var/run/texlive/run-update
fi

%posttrans
%if %{with zypper_posttrans}
test -z "$ZYPP_IS_RUNNING" || exit 0
%endif
test -d /var/run/texlive || exit 0
VERBOSE=false %{_texmfdistdir}/texconfig/update || :

%post   -n libkpathsea6 -p /sbin/ldconfig
%postun -n libkpathsea6 -p /sbin/ldconfig

%post   -n libptexenc1 -p /sbin/ldconfig
%postun -n libptexenc1 -p /sbin/ldconfig

%post   -n libsynctex2 -p /sbin/ldconfig
%postun -n libsynctex2 -p /sbin/ldconfig

%post   -n libtexlua53-5 -p /sbin/ldconfig
%postun -n libtexlua53-5 -p /sbin/ldconfig

%if %{with LuaJIT}
%post   -n libtexluajit2 -p /sbin/ldconfig
%postun -n libtexluajit2 -p /sbin/ldconfig
%endif

%if %{with luametatex}
%post context-bin
mkdir -p /var/run/texlive
> /var/run/texlive/run-fmtutil.context

%postun context-bin
if test $1 = 1; then
    mkdir -p /var/run/texlive
    > /var/run/texlive/run-fmtutil.context
fi
%endif

%files
# is part of texlive-texlive.infra
#%{_texmfdistdir}/tlpkg/TeXLive/TLConfig.pm
#%{_texmfdistdir}/tlpkg/TeXLive/TLUtils.pm
# is part of texlive-kpathsea
#%config(noreplace) %verify(not md5 size mtime) %{_texmfconfdir}/web2c/fmtutil.cnf
#%config(noreplace) %verify(not md5 size mtime) %{_texmfconfdir}/web2c/texmf.cnf
#%verify(link) %{_texmfmaindir}/web2c/fmtutil.cnf
#%verify(link) %{_texmfmaindir}/web2c/texmf.cnf
# is part of texlive-luatex
#%config(noreplace) %verify(not md5 size mtime) %{_texmfconfdir}/web2c/texmfcnf.lua
#%verify(link) %{_texmfmaindir}/web2c/texmfcnf.lua
%{_mandir}/man8/public.8%{?ext_man}
%if %{with zypper_posttrans}
%verify(link) /var/adm/update-scripts/%{name}-%{version}-%{release}-zypper
%endif

@@FILES@@

%files -n libkpathsea6
%{_libdir}/libkpathsea*.so.*

%files -n %{name}-kpathsea-devel
%dir %{_includedir}/kpathsea
%{_includedir}/kpathsea/*
%{_libdir}/libkpathsea.so
%{_libdir}/pkgconfig/kpathsea.pc

%files -n libptexenc1
%{_libdir}/libptexenc*.so.*

%files -n %{name}-ptexenc-devel
%dir %{_includedir}/ptexenc
%{_includedir}/ptexenc/*
%{_libdir}/libptexenc.so
%{_libdir}/pkgconfig/ptexenc.pc

%files -n libsynctex2
%{_libdir}/libsynctex.so.*

%files -n %{name}-synctex-devel
%dir %{_includedir}/synctex/
%{_includedir}/synctex/*.h
%{_libdir}/libsynctex.so
%{_libdir}/pkgconfig/synctex.pc

%files -n libtexlua53-5
%{_libdir}/libtexlua53*so.*

%files -n %{name}-texlua-devel
%dir %{_includedir}/texlua[0-9]*/
%{_includedir}/texlua[0-9]*/*.h*
%{_libdir}/libtexlua[0-9]*so
%{_libdir}/pkgconfig/texlua[0-9]*.pc

%if %{with LuaJIT}
%files -n libtexluajit2
%{_libdir}/libtexluajit.so.*

%files -n %{name}-texluajit-devel
%dir %{_includedir}/texluajit/
%{_includedir}/texluajit/*.h*
%{_libdir}/libtexluajit.so
%{_libdir}/pkgconfig/texluajit.pc
%endif

%files -n %{name}-bin-devel

%if %{with buildbiber}
%files -n perl-biber -f perl-biber.files
%endif

%changelog
openSUSE Build Service is sponsored by