File gnulib.spec of Package gnulib

#
# spec file for package gnulib
#
# Copyright (c) 2024 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/
#

%global module1 git-merge-changelog

Name:           gnulib
Version:        git.20240213.c99c8d4918
Release:        0
Summary:        GNU Portability Library
License:        GPL-2.0-or-later AND SUSE-Public-Domain AND GPL-3.0-only AND GPL-3.0-or-later AND LGPL-2.0-only AND LGPL-2.1-or-later AND LGPL-3.0-or-later
Group:          Development/Languages/C and C++
URL:            http://www.gnu.org/software/gnulib
Source:         %{name}-%{version}.tar.xz
Source1:        http://erislabs.net/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f=debian/manpages/check-module.1
Source2:        http://erislabs.net/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f=debian/manpages/gnulib-tool.1
BuildRequires:  bison
# For building Modules, all gnulib requires must be found, Modules BRs:
BuildRequires:  gettext-devel
BuildRequires:  gperf
BuildRequires:  help2man
BuildRequires:  java-devel
BuildRequires:  libtool
BuildRequires:  texinfo

%description
The GNU portability library is a macro system and C declarations and
definitions for commonly-used API elements and abstracted system behaviors.
It can be used to improve portability and other functionality in your programs.

%package devel
Summary:        Devel files of %{name}
License:        GPL-2.0-or-later AND SUSE-Public-Domain AND GPL-3.0-only AND GPL-3.0-or-later AND LGPL-2.0-only AND LGPL-2.1-or-later AND LGPL-3.0-or-later
Group:          Development/Languages/C and C++
Requires:       bison
Requires:       coreutils
Requires:       diffutils
Requires:       gettext-devel
Requires:       gperf
Requires:       libtool
Requires:       make
Requires:       patch
Requires:       texinfo
Provides:       gnulib
BuildArch:      noarch

%description devel
The GNU portability library is a macro system and C declarations and
definitions for commonly-used API elements and abstracted system behaviors.
It can be used to improve portability and other functionality in your programs.

This package contains devel files of %{name}.

%package docs
Summary:        Documentation for %{name} modules
License:        GFDL-1.3-only
Group:          Development/Languages/C and C++
Requires:       %{name}-devel = %{version}-%{release}
Requires(post): info
Requires(preun):info
BuildArch:      noarch

%description docs
The GNU portability library is a macro system and C declarations and
definitions for commonly-used API elements and abstracted system behaviors.
It can be used to improve portability and other functionality in your programs.

This package contains documentation for %{name}.

%package -n git-merge-changelog
Summary:        Git merge driver for ChangeLog files
License:        GPL-2.0-or-later
Group:          Development/Languages/C and C++

%description -n git-merge-changelog
Git Merge Changelog is a git merge driver for changelogs that combines
parallel additions to the changelog without generating merge conflicts.
It can be enabled for specific files by setting appropriate git attributes.

%prep
%setup -q

#modules not to be tested by direct import
toRemove="lib-symbol-visibility havelib .*-obsolete localcharset gettext-h gettext alloca-opt alloca "

list="$(./gnulib-tool --list)"
for item in $toRemove
do
   list="$(echo $list| sed "s:\b$item\b::g")"
done
#is necessary to avoid some modules to test prep pass
./gnulib-tool --create-testdir --with-tests --with-obsolete --avoid=alloca --avoid=lib-symbol-visibility --avoid=havelib --dir=build-tests $list

rm lib/javaversion.class
# MODULE #1 - git-merge-changelog
./gnulib-tool --create-testdir --dir=build-git-merge-changelog git-merge-changelog

%build
# MODULE #1 - git-merge-changelog
pushd build-git-merge-changelog
%configure --prefix=%{_prefix}
make %{?_smp_mflags}
popd
#tests build
cp -p lib/timevar.def build-tests/gllib #Fix timevar.def not found
pushd build-tests
%configure --prefix=%{_prefix}
make %{?_smp_mflags}
popd
# Rebuild removed java class
javac -d lib -source 1.8 -target 1.8 lib/javaversion.java
# This part is done with the original path
make %{?_smp_mflags} MODULES.html
sed -i -r 's#HREF="(lib|m4|modules)#HREF="%{_datadir}/%{name}/\1#g' MODULES.html
sed -i "/^[ ]*gnulib_dir=/s#\`[^\`]*\`#%{_datadir}/%{name}#" gnulib-tool
# This part is done with the target path
make %{?_smp_mflags} info html
# Removing unused files
rm -f */.cvsignore
rm -f */.gitignore
rm -f */.gitattributes
rm -f lib/.cppi-disable
rm -f lib/uniname/gen-uninames.lisp

%check
pushd build-tests
make %{?_smp_mflags} check
popd

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/%{name}
mkdir -p %{buildroot}%{_datadir}/info
mkdir -p %{buildroot}%{_datadir}/%{name}/doc
mkdir -p %{buildroot}%{_docdir}/%{name}
mkdir -p %{buildroot}%{_mandir}/man1

# install helper binaries
cp -p check-module %{buildroot}%{_bindir}/
cp -p gnulib-tool %{buildroot}%{_bindir}/
# install git-merge-changelog binary built in its build dir
if [ -f build-git-merge-changelog/git-merge-changelog ]; then
  cp -p build-git-merge-changelog/git-merge-changelog %{buildroot}%{_bindir}/
fi

# install main data for devel package
cp -rp build-aux lib m4 modules config tests %{buildroot}%{_datadir}/%{name}/
# relocatable.texi is needed during compilation of PSPP. See rh#1474792 and
# https://src.fedoraproject.org/rpms/gnulib/c/cea2f6f12fe24479e282900341575352689d7cfe?branch=master
if [ -f doc/relocatable.texi ]; then
  mkdir -p %{buildroot}%{_datadir}/%{name}/doc
  cp -p doc/relocatable.texi %{buildroot}%{_datadir}/%{name}/doc/
fi

# install MODULES.html
if [ -f MODULES.html ]; then
  cp -p MODULES.html %{buildroot}%{_datadir}/%{name}/
fi

# install info and html docs if present
if [ -d info ]; then
  cp -rp info/* %{buildroot}%{_datadir}/info/ || true
fi
if [ -d html ]; then
  mkdir -p %{buildroot}%{_datadir}/%{name}/doc/html
  cp -rp html/* %{buildroot}%{_datadir}/%{name}/doc/html/ || true
fi
# install additional docs
if [ -d doc ]; then
  cp -rp doc/* %{buildroot}%{_datadir}/%{name}/doc/ || true
fi

# install manpages shipped in debian dir from Source1/Source2 if present
if [ -f debian/manpages/check-module.1 ]; then
  cp -p debian/manpages/check-module.1 %{buildroot}%{_mandir}/man1/
fi
if [ -f debian/manpages/gnulib-tool.1 ]; then
  cp -p debian/manpages/gnulib-tool.1 %{buildroot}%{_mandir}/man1/
fi

# clean up files not needed in packages
rm -f %{buildroot}%{_datadir}/%{name}/lib/javaversion.class || true

%files
%doc %{_datadir}/%{name}/doc
%{_bindir}/gnulib-tool
%{_bindir}/check-module
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/MODULES.html
%{_mandir}/man1/check-module.1*
%{_mandir}/man1/gnulib-tool.1*

%files -n %{name}-devel
%defattr(-,root,root,-)
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/lib
%{_datadir}/%{name}/m4
%{_datadir}/%{name}/modules
%{_datadir}/%{name}/config
%{_datadir}/%{name}/tests
%{_datadir}/%{name}/build-aux
%{_datadir}/%{name}/doc

%files -n %{name}-docs
%defattr(-,root,root,-)
%doc %{_datadir}/%{name}/doc
%{_datadir}/info/*
%{_docdir}/%{name}/*

%files -n git-merge-changelog
%{_bindir}/git-merge-changelog

%changelog
* Thu Jan 25 2024 SUSE Package Maintainer <suse@example.com> - git.20240213.c99c8d4918-0
- Initial packaging/import of gnulib git snapshot
openSUSE Build Service is sponsored by