Blob Blame Raw
%global upstreamver 4r6p2
%global pkgdate 2013_02_02-01_00
%global gapdirname gap%(echo %upstreamver | cut -dp -f1)
%global gapdir %{_prefix}/lib/gap
%global icondir %{_datadir}/icons/hicolor

Name:           gap
Version:        %(echo %upstreamver | sed -r "s/r|p/./g")
Release:        1%{?dist}
Summary:        Computational discrete algebra

Group:          Applications/Engineering
License:        GPLv2+
Source1:        gap-README.fedora
Source2:        update-gap-workspace
Source3:        gap.xml
Source4:        gap.desktop
Source5:        gap.el
Source8:        update-gap-workspace.1
Source9:        gap.vim
# This patch from Debian rearranges some paths to match Linux conventions.
Patch0:         %{name}-paths.patch
# This patch applies a change from Debian to allow help files to be in gzip
# compressed DVI files, and also adds support for viewing with xdg-open.
Patch1:         %{name}-help.patch
# This patch will not be sent upstream.  It makes the main binary read the
# environment variables now read by, so we can dispose of the shell
# script and run the actual binary directly.
Patch2:         %{name}-env.patch
# This patch was sent upstream 4 Aug 2011.  It fixes some cosmetic issues in
# the Emacs Lisp sources.
Patch3:         %{name}-emacs.patch
# This patch will not be sent upstream.  Force use of the 64-bit stat()
# routines to avoid overflow of the inode and size fields.
Patch4:         %{name}-stat.patch

BuildRequires:  desktop-file-utils
BuildRequires:  gmp-devel
BuildRequires:  netpbm-progs
BuildRequires:  readline-devel
BuildRequires:  emacs
BuildRequires:  xemacs

Requires:       %{name}-libs = %{version}-%{release}
Requires:       %{name}-core%{?_isa} = %{version}-%{release}
Requires:       %{name}-online-help = %{version}-%{release}
Requires:       meataxe

GAP is a system for computational discrete algebra, with particular
emphasis on Computational Group Theory.  GAP provides a programming
language, a library of thousands of functions implementing algebraic
algorithms written in the GAP language as well as large data libraries
of algebraic objects.  GAP is used in research and teaching for studying
groups and their representations, rings, vector spaces, algebras,
combinatorial structures, and more.

This is a metapackage that requires the standard GAP components.

%package libs
Summary:        Essential GAP libraries
Group:          Applications/Engineering
BuildArch:      noarch

# These obsoletes and provides can be removed once Fedora 18 is EOL.
Obsoletes:      %{name}-prim-groups < 4.5.6-3
Provides:       %{name}-prim-groups = %{version}-%{release}
Obsoletes:      %{name}-small-groups < 4.5.6-3
Provides:       %{name}-small-groups = %{version}-%{release}
Obsoletes:      %{name}-trans-groups < 4.5.6-3
Provides:       %{name}-trans-groups = %{version}-%{release}

%description libs
This package contains the essential GAP libraries: lib and grp, as well as
the primitive, small, and transitive group databases.

%package core
Summary:        GAP core components
Group:          Applications/Engineering
Requires:       %{name}-libs = %{version}-%{release}
Requires:       GAPDoc
# The gap binary executes gunzip
Requires:       gzip
Requires:       hicolor-icon-theme

%description core
This package contains the core GAP system.

%package online-help
Summary:        Online help for GAP
Group:          Documentation
Requires:       %{name}-core = %{version}-%{release}
BuildArch:      noarch

%description online-help
This package contains the documentation in TeX format needed for GAP's
online help system.

%package devel
Summary:        GAP compiler and development files
Group:          Development/Languages
Requires:       %{name}-core%{?isa} = %{version}-%{release}
Requires:       gcc
Requires:       gmp-devel%{?_isa}

%description devel
This package contains the GAP compiler (gac) and the header files necessary
for developing GAP programs.

%package vim
Summary:        Edit GAP files with VIM
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}, vim-filesystem
BuildArch:      noarch

%description vim
This package provides VIM add-on files to support editing GAP sources.
Both syntax highlighting and indentation are supported.

%package emacs
Summary:        Edit GAP files with Emacs
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}
Requires:       emacs(bin) >= %{_emacs_version}
BuildArch:      noarch

%description emacs
This package provides Emacs add-on files to support editing GAP sources
and running GAP from within Emacs.

%package emacs-el
Summary:        Emacs Lisp source files for GAP
Group:          Applications/Engineering
Requires:       %{name}-emacs = %{version}-%{release}
BuildArch:      noarch

%description emacs-el
Emacs Lisp source files for GAP.  This package is not needed to use the
GAP Emacs support.

%package xemacs
Summary:        Edit GAP files with XEmacs
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}
Requires:       xemacs(bin) >= %{_xemacs_version}, xemacs-packages-base
BuildArch:      noarch

%description xemacs
This package provides XEmacs add-on files to support editing GAP sources
and running GAP from within XEmacs.

%package xemacs-el
Summary:        XEmacs Lisp source files for GAP
Group:          Applications/Engineering
Requires:       %{name}-xemacs = %{version}-%{release}
BuildArch:      noarch

%description xemacs-el
XEmacs Lisp source files for GAP.  This package is not needed to use the
GAP XEmacs support.

%setup -q -n %{gapdirname}

# Replace the CFLAGS, find the math functions and sigsetjmp
sed -re "s|(gp_cv_prog_cc_cdynoptions=)\"-fpic -Wall -O2|\1\"\$RPM_OPT_FLAGS -fPIC -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_DEFAULT_PATHS='\"%{gapdir}\"'|" \
    -e "s|(gp_cv_prog_cc_cdynlinking=)\"-shared -g|\1\"\$RPM_LD_FLAGS -shared|" \
    -e '/log2 log10/iLIBS="-lm $LIBS"' \
    -e "/sigsetjmp/,\$s|(ac_fn_c_check_func.*)ac_func(.*)|\1{ac_func/sigsetjmp/__sigsetjmp}\2|" \
    -i cnf/configure.out

# The -m32 and -m64 flags are not available on all platforms, and we provide
# them in optflags when they are needed.
sed -e 's/GMP_CFLAGS="-m${ABI}"/GMP_CFLAGS=""/' \
    -e 's/ABI_CFLAGS="-m[[:digit:]]*"/ABI_CFLAGS=""/' \
    -i configure

# Get the README
cp -p %{SOURCE1} README.fedora

# Fix a missing executable bit
chmod a+x makepkgs

%configure --with-gmp=system \
# FIXME: GAP 4.5 broke %%{?_smp_mflags}

# Get the value of the GAParch variable
source ./

# The packages must be built for the check script to succeed
sed -e "s|@gaparch@|$GAParch|" \
    -e "s| -DSYS_DEFAULT_PATHS=\\\"/usr/share/gap\\\"||" \
    -i bin/$GAParch/gac
mkdir -p bin/$GAParch/extern/gmp/include
ln -s %{_includedir}/gmp.h bin/$GAParch/extern/gmp/include
sed -i "s|-D_GNU_SOURCE|-I$PWD|" Makefile-default*
sed -i "s|-o|-p -I -p $PWD -p -I -p $PWD/bin/$GAParch &|" \
    pkg/edim/ pkg/Browse/
make packages

# Compress help files
find doc -name \*.dvi -o -name \*.toc | xargs gzip --best

# Compress large group files
find -O3 small -mindepth 2 -type f | xargs gzip --best -f
gzip --best prim/grps/*.g trans/*.grp

# Create an RPM macro file for GAP packages
cat > macros.%{name} << EOF
%%_gap_version %{version}
%%_gap_upstream_version %{upstreamver}
%%_gap_dir %{gapdir}

# Get the value of the GAParch variable
source ./

# Install the binaries
mkdir -p $RPM_BUILD_ROOT%{_bindir}
cp -p bin/$GAParch/{gac,gap} $RPM_BUILD_ROOT%{_bindir}
cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}

# Install the data
mkdir -p $RPM_BUILD_ROOT%{gapdir}/etc
cp -a grp lib prim small trans tst $RPM_BUILD_ROOT%{gapdir}
cp -p etc/debug* $RPM_BUILD_ROOT%{gapdir}/etc

# Install the arch-specific files
cp -a* $RPM_BUILD_ROOT%{gapdir}

# Create the system workspace, initially empty
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/workspace

# Install the header and object files where the GAP compiler can find them
mkdir -p $RPM_BUILD_ROOT%{gapdir}/src
cp -p src/*.h $RPM_BUILD_ROOT%{gapdir}/src
mkdir -p $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch
cp -p bin/$GAParch/config.h $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch
cp -p bin/$GAParch/*.o $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch
rm -f bin/$GAParch/extern/Makefile
cp -a bin/$GAParch/extern $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch
ln -s %{_bindir}/gac $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch/gac
ln -s %{_bindir}/gap $RPM_BUILD_ROOT%{gapdir}/bin/$GAParch/gap

# Make an empty directory to hold the GAP packages
mkdir -p $RPM_BUILD_ROOT%{gapdir}/pkg

# Intall the documentation
cp -a doc $RPM_BUILD_ROOT%{gapdir}
rm -f $RPM_BUILD_ROOT%{gapdir}/doc/manualindex
rm -fr $RPM_BUILD_ROOT%{gapdir}/doc/test

# Install the icon
mkdir -p $RPM_BUILD_ROOT%{icondir}/32x32
bmptopnm bin/gapicon.bmp | pnmtopng -compression=9 \
         > $RPM_BUILD_ROOT%{icondir}/32x32/gap.png

# Install the MIME type
mkdir -p $RPM_BUILD_ROOT%{_datadir}/mime/packages
cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/mime/packages

# Install the desktop file
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
desktop-file-install --mode=644 --dir=$RPM_BUILD_ROOT%{_datadir}/applications \

# Install the RPM macro file
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
cp -p macros.%{name} $RPM_BUILD_ROOT%{_sysconfdir}/rpm

# Install the VIM support
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/indent
cp -p etc/gap_indent.vim $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/indent
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/syntax
cp -p etc/gap.vim $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/syntax
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/ftdetect
cp -p %{SOURCE9}  $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/ftdetect

# Install the Emacs support
mkdir -p $RPM_BUILD_ROOT%{_emacs_sitelispdir}
cp -p etc/emacs/gap*.el $RPM_BUILD_ROOT%{_emacs_sitelispdir}
pushd $RPM_BUILD_ROOT%{_emacs_sitelispdir}
%{_emacs_bytecompile} gap*.el
mkdir -p $RPM_BUILD_ROOT%{_emacs_sitestartdir}
cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_emacs_sitestartdir}

# Install the XEmacs support
mkdir -p $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
cp -p etc/emacs/gap*.el $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
pushd $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
%{_xemacs_bytecompile} gap*.el
mkdir -p $RPM_BUILD_ROOT%{_xemacs_sitestartdir}
cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_xemacs_sitestartdir}

# Install the man pages
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
sed "s|@VERSION@|%{version}|" %{SOURCE6} > $RPM_BUILD_ROOT%{_mandir}/man1/gap.1
sed "s|@VERSION@|%{version}|" %{SOURCE7} > $RPM_BUILD_ROOT%{_mandir}/man1/gac.1
cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_mandir}/man1

%post core
update-desktop-database %{_datadir}/applications &>/dev/null ||:
update-mime-database %{_datadir}/mime &>/dev/null ||:
touch --no-create %{icondir} >&/dev/null ||:

%{_bindir}/gtk-update-icon-cache %{icondir} >&/dev/null ||:
%{_bindir}/update-gap-workspace ||:

%postun core
update-desktop-database %{_datadir}/applications &>/dev/null ||:
update-mime-database %{_datadir}/mime &>/dev/null ||:
if [ $1 -eq 0 ] ; then
  touch --no-create %{icondir} >&/dev/null ||:
  %{_bindir}/gtk-update-icon-cache %{icondir} >&/dev/null ||:

sed -e "s|^GAP_DIR=.*|GAP_DIR=$PWD|" \
    -e "s|\$GAP_DIR/bin/\$GAP_PRG|$PWD/bin/\$GAP_PRG|" \
    -i bin/ bin/gap-default*.sh
sed -i "s|80 -r|& -l $PWD|" Makefile-default*
make testinstall

# No files in the metapackage

%files libs
%doc etc/GPL small/README
%dir %{gapdir}

%files core
%doc README.fedora
%dir %{_localstatedir}/lib/%{name}/
%verify(user group mode) %{_localstatedir}/lib/%{name}/workspace

%files online-help

%files devel
%config(noreplace) %{_sysconfdir}/rpm/macros.%{name}

%files vim

%files emacs
%doc etc/emacs/gap-mode.doc

%files emacs-el

%files xemacs
%doc etc/emacs/gap-mode.doc

%files xemacs-el

* Wed Feb 20 2013 Jerry James <> - 4.6.2-1
- New upstream release
- Move update-gap-workspace call to posttrans (bz 912067)
- Add -stat patch and -D_FILE_OFFSET_BITS=64 to CPPFLAGS to use 64-bit
  stat interface on 32-bit systems

* Wed Feb 13 2013 Fedora Release Engineering <> - 4.5.7-3
- Rebuilt for

* Fri Dec 21 2012 Rex Dieter <> 4.5.7-2
- optimize/update icon scriptlets

* Mon Dec 17 2012 Jerry James <> - 4.5.7-1
- New upstream release

* Mon Oct 22 2012 Jerry James <> - 4.5.6-3
- Further fixes for the -m32/-m64 issue
- Many packages need the primitive, small, or transitive groups; collapse them
  all into the -libs subpackage so they are always available
- Provide sysinfo-default[32|64], as required by some packages
- Provide symbolic links to gac and gap from the bin directory, as required by
  some packages

* Sat Oct 20 2012 Peter Robinson <>	4.5.6-2
- -m32/-m64 should come from RPM_OPT_FLAGS. Fix build issues on non x86 arches

* Mon Sep 24 2012 Jerry James <> - 4.5.6-1
- New upstream release
- Remove unused patches from git

* Thu Sep 13 2012 Jerry James <> - 4.5.5-1
- New upstream release
- Drop upstreamed patches
- Sources are now UTF-8; no conversion necessary

* Thu Jul 19 2012 Fedora Release Engineering <> - 4.4.12-5
- Rebuilt for

* Tue Jan 31 2012 Jerry James <> - 4.4.12-4
- Add an RPM macro file for GAP packages
- Fix the location of config.h

* Wed Jan 11 2012 Jerry James <> - 4.4.12-3
- Fix problems found on review

* Tue Jan  3 2012 Jerry James <> - 4.4.12-2
- Mimic Debian's subpackage structure

* Wed Oct 12 2011 Jerry James <> - 4.4.12-1
- Initial RPM