574c352
%global upstreamver 4r4p12
574c352
%global gapdirname gap%(echo %upstreamver | cut -dp -f1)
574c352
%global gapdir %{_datadir}/gap
574c352
%global gaparchdir %{_prefix}/lib/gap
574c352
%global icondir %{_datadir}/icons/hicolor
574c352
574c352
Name:           gap
574c352
Version:        %(echo %upstreamver | sed -r "s/r|p/./g")
652a298
Release:        4%{?dist}
574c352
Summary:        Computational discrete algebra
574c352
574c352
Group:          Applications/Engineering
574c352
License:        GPLv2+
574c352
URL:            http://www.gap-system.org/
574c352
Source0:        ftp://ftp.gap-system.org/pub/gap/gap4/tar.bz2/%{name}%{upstreamver}.tar.bz2
574c352
Source1:        gap-README.fedora
574c352
Source2:        update-gap-workspace
574c352
Source3:        gap.xml
574c352
Source4:        gap.desktop
574c352
Source5:        gap.el
574c352
Source6:        gap.1.in
574c352
Source7:        gac.1.in
574c352
Source8:        update-gap-workspace.1
574c352
Source9:        gap.vim
574c352
# This patch from Debian rearranges some paths to match Linux conventions.
574c352
Patch0:         gap-paths.patch
574c352
# This patch from Debian makes GAP use termios controls instead of BSD ioctls
574c352
# to manage a raw terminal.
574c352
Patch1:         gap-raw.patch
574c352
# This patch applies a change from Debian to allow help files to be in gzip
574c352
# compressed DVI files, and also adds support for viewing with xdg-open.
574c352
Patch2:         gap-help.patch
574c352
# This patch will not be sent upstream.  It fixes some CRCs after converting
574c352
# the source files from ISO8859-1 to UTF-8 and applying the previous patches.
574c352
Patch3:         gap-crc.patch
574c352
# This patch will not be sent upstream.  It makes the main binary read the
574c352
# environment variables now read by gap.sh, so we can dispose of the shell
574c352
# script and run the actual binary directly.
574c352
Patch4:         gap-env.patch
574c352
# This patch was sent upstream 4 Aug 2011.  It fixes several places where the
574c352
# sources violate ANSI C alias analysis rules.
574c352
Patch5:         gap-alias.patch
574c352
# This patch was sent upstream 4 Aug 2011.  It fixes some cosmetic issues in
574c352
# the Emacs Lisp sources.
574c352
Patch6:         gap-emacs.patch
574c352
574c352
BuildRequires:  desktop-file-utils
574c352
BuildRequires:  netpbm-progs
574c352
BuildRequires:  emacs
574c352
BuildRequires:  xemacs
574c352
574c352
Requires:       %{name}-libs = %{version}-%{release}
574c352
Requires:       %{name}-core%{?_isa} = %{version}-%{release}
574c352
Requires:       %{name}-online-help = %{version}-%{release}
574c352
Requires:       %{name}-prim-groups = %{version}-%{release}
574c352
Requires:       %{name}-small-groups = %{version}-%{release}
574c352
Requires:       %{name}-trans-groups = %{version}-%{release}
574c352
574c352
%description
574c352
GAP is a system for computational discrete algebra, with particular
574c352
emphasis on Computational Group Theory.  GAP provides a programming
574c352
language, a library of thousands of functions implementing algebraic
574c352
algorithms written in the GAP language as well as large data libraries
574c352
of algebraic objects.  GAP is used in research and teaching for studying
574c352
groups and their representations, rings, vector spaces, algebras,
574c352
combinatorial structures, and more.
574c352
574c352
This is a metapackage that requires the standard GAP components.
574c352
574c352
%package libs
574c352
Summary:        Essential GAP libraries
574c352
Group:          Applications/Engineering
574c352
BuildArch:      noarch
574c352
574c352
%description libs
574c352
This package contains the essential GAP libraries: lib and grp.
574c352
574c352
%package core
574c352
Summary:        GAP core components
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-libs = %{version}-%{release}
574c352
# The gap binary executes gunzip
574c352
Requires:       gzip
574c352
Requires:       hicolor-icon-theme
574c352
574c352
%description core
574c352
This package contains the core GAP system.
574c352
574c352
%package online-help
574c352
Summary:        Online help for GAP
574c352
Group:          Documentation
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description online-help
574c352
This package contains the documentation in TeX format needed for GAP's
574c352
online help system.
574c352
574c352
%package devel
574c352
Summary:        GAP compiler and development files
574c352
Group:          Development/Languages
574c352
Requires:       %{name}-core%{?isa} = %{version}-%{release}
574c352
Requires:       gcc
574c352
574c352
%description devel
574c352
This package contains the GAP compiler (gac) and the header files necessary
574c352
for developing GAP programs.
574c352
574c352
%package prim-groups
574c352
Summary:        Database of primitive groups for GAP
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description prim-groups
574c352
This package contains a database of primitive groups for GAP.
574c352
574c352
%package small-groups
574c352
Summary:        Database of small groups for GAP
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description small-groups
574c352
This package contains a database of groups of small order for GAP.  The
574c352
database includes the group data and identification routines for groups
574c352
of order up to 2000.
574c352
574c352
%package trans-groups
574c352
Summary:        Database of transitive groups for GAP
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description trans-groups
574c352
This package contains a database of transitive groups for GAP.
574c352
574c352
%package vim
574c352
Summary:        Edit GAP files with VIM
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}, vim-filesystem
574c352
BuildArch:      noarch
574c352
574c352
%description vim
574c352
This package provides VIM add-on files to support editing GAP sources.
574c352
Both syntax highlighting and indentation are supported.
574c352
574c352
%package emacs
574c352
Summary:        Edit GAP files with Emacs
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
Requires:       emacs(bin) >= %{_emacs_version}
574c352
BuildArch:      noarch
574c352
574c352
%description emacs
574c352
This package provides Emacs add-on files to support editing GAP sources
574c352
and running GAP from within Emacs.
574c352
574c352
%package emacs-el
574c352
Summary:        Emacs Lisp source files for GAP
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-emacs = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description emacs-el
574c352
Emacs Lisp source files for GAP.  This package is not needed to use the
574c352
GAP Emacs support.
574c352
574c352
%package xemacs
574c352
Summary:        Edit GAP files with XEmacs
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-core = %{version}-%{release}
574c352
Requires:       xemacs(bin) >= %{_xemacs_version}, xemacs-packages-base
574c352
BuildArch:      noarch
574c352
574c352
%description xemacs
574c352
This package provides XEmacs add-on files to support editing GAP sources
574c352
and running GAP from within XEmacs.
574c352
574c352
%package xemacs-el
574c352
Summary:        XEmacs Lisp source files for GAP
574c352
Group:          Applications/Engineering
574c352
Requires:       %{name}-xemacs = %{version}-%{release}
574c352
BuildArch:      noarch
574c352
574c352
%description xemacs-el
574c352
XEmacs Lisp source files for GAP.  This package is not needed to use the
574c352
GAP XEmacs support.
574c352
574c352
%prep
574c352
%setup -q -n %{gapdirname}
574c352
%patch0
574c352
%patch1
574c352
%patch2
574c352
%patch3
574c352
%patch4
574c352
%patch5
574c352
%patch6
574c352
574c352
# Replace the CFLAGS
574c352
sed -i "s|gp_cv_cflags=\"-Wall -g -O2\"|gp_cv_cflags='$RPM_OPT_FLAGS -DSYS_DEFAULT_PATHS=\\\\\"%{gapdir}\\\\\"'|" \
574c352
    cnf/configure.out
574c352
574c352
# Fix file encodings
574c352
for f in description4r4p6 etc/gap*.vim etc/README.vim-utils lib/colorprompt.g \
574c352
         lib/grpffmat.gi lib/grpnames.gd lib/grpnames.gi lib/helpbase.* \
574c352
         lib/helpdef.* lib/helpview.* lib/memory.* lib/pager.* \
574c352
         lib/polyconw.gi lib/semirel.gi small/README; do
574c352
  iconv -f iso8859-1 -t utf-8 $f > $f.new
574c352
  touch -f $f $f.new
574c352
  mv -f $f.new $f
574c352
done
574c352
574c352
# Get the README
574c352
cp -p %{SOURCE1} README.fedora
574c352
574c352
%build
574c352
%configure
574c352
make %{?_smp_mflags} compile
574c352
574c352
# Compress help files
574c352
find doc -name \*.dvi -o -name \*.toc | xargs gzip --best
574c352
574c352
# Compress large group files
574c352
find -O3 small -mindepth 2 -type f | xargs gzip --best -f
574c352
gzip --best prim/grps/*.g trans/*.grp
574c352
652a298
# Create an RPM macro file for GAP packages
652a298
cat > macros.%{name} << EOF
652a298
%%_gap_version %{version}
652a298
%%_gap_upstream_version %{upstreamver}
652a298
%%_gap_dir %{gapdir}
652a298
%%_gap_arch_dir %{gaparchdir}
652a298
EOF
652a298
574c352
%install
574c352
# Get the value of the GAParch variable
574c352
source ./sysinfo.gap
574c352
574c352
# Install the binaries
574c352
mkdir -p $RPM_BUILD_ROOT%{_bindir}
574c352
cp -p bin/$GAParch/gap $RPM_BUILD_ROOT%{_bindir}
574c352
cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}
574c352
sed -e "s|@gaparch@|$GAParch|" \
574c352
    -e "s| -DSYS_DEFAULT_PATHS=\\\"/usr/share/gap\\\"||" \
574c352
    bin/$GAParch/gac > $RPM_BUILD_ROOT%{_bindir}/gac
574c352
chmod a+x $RPM_BUILD_ROOT%{_bindir}/ga*
574c352
574c352
# Install the data
574c352
mkdir -p $RPM_BUILD_ROOT%{gapdir}/etc
574c352
cp -a grp lib prim small trans tst $RPM_BUILD_ROOT%{gapdir}
574c352
cp -p etc/debug* $RPM_BUILD_ROOT%{gapdir}/etc
574c352
574c352
# Install the arch-specific files
574c352
mkdir -p $RPM_BUILD_ROOT%{gaparchdir}
574c352
cp -p sysinfo.gap $RPM_BUILD_ROOT%{gaparchdir}
574c352
574c352
# Create the system workspace, initially empty
574c352
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}
574c352
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/%{name}/workspace
574c352
574c352
# Install the header and object files where the GAP compiler can find them
574c352
mkdir -p $RPM_BUILD_ROOT%{gaparchdir}/src
652a298
cp -p src/*.h $RPM_BUILD_ROOT%{gaparchdir}/src
574c352
mkdir -p $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch
652a298
cp -p bin/$GAParch/config.h $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch
574c352
cp -p bin/$GAParch/*.o $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch
574c352
574c352
# Make an empty directory to hold the GAP packages
574c352
mkdir -p $RPM_BUILD_ROOT%{gapdir}/pkg
574c352
574c352
# Intall the documentation
574c352
cp -a doc $RPM_BUILD_ROOT%{gapdir}
574c352
rm -f $RPM_BUILD_ROOT%{gapdir}/doc/manualindex
574c352
rm -fr $RPM_BUILD_ROOT%{gapdir}/doc/test
574c352
574c352
# Install the icon
574c352
mkdir -p $RPM_BUILD_ROOT%{icondir}/32x32
574c352
bmptopnm bin/gapicon.bmp | pnmtopng -compression=9 \
574c352
         > $RPM_BUILD_ROOT%{icondir}/32x32/gap.png
574c352
574c352
# Install the MIME type
574c352
mkdir -p $RPM_BUILD_ROOT%{_datadir}/mime/packages
574c352
cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/mime/packages
574c352
574c352
# Install the desktop file
574c352
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
574c352
desktop-file-install --mode=644 --dir=$RPM_BUILD_ROOT%{_datadir}/applications \
574c352
  %{SOURCE4}
574c352
652a298
# Install the RPM macro file
652a298
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rpm
652a298
cp -p macros.%{name} $RPM_BUILD_ROOT%{_sysconfdir}/rpm
652a298
574c352
# Install the VIM support
574c352
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/indent
574c352
cp -p etc/gap_indent.vim $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/indent
574c352
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/syntax
574c352
cp -p etc/gap.vim $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/syntax
574c352
mkdir -p $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/ftdetect
574c352
cp -p %{SOURCE9}  $RPM_BUILD_ROOT%{_datadir}/vim/vimfiles/ftdetect
574c352
574c352
# Install the Emacs support
574c352
mkdir -p $RPM_BUILD_ROOT%{_emacs_sitelispdir}
574c352
cp -p etc/emacs/gap*.el $RPM_BUILD_ROOT%{_emacs_sitelispdir}
574c352
pushd $RPM_BUILD_ROOT%{_emacs_sitelispdir}
574c352
%{_emacs_bytecompile} gap*.el
574c352
popd
574c352
mkdir -p $RPM_BUILD_ROOT%{_emacs_sitestartdir}
574c352
cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_emacs_sitestartdir}
574c352
574c352
# Install the XEmacs support
574c352
mkdir -p $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
574c352
cp -p etc/emacs/gap*.el $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
574c352
pushd $RPM_BUILD_ROOT%{_xemacs_sitelispdir}
574c352
%{_xemacs_bytecompile} gap*.el
574c352
popd
574c352
mkdir -p $RPM_BUILD_ROOT%{_xemacs_sitestartdir}
574c352
cp -p %{SOURCE5} $RPM_BUILD_ROOT%{_xemacs_sitestartdir}
574c352
574c352
# Install the man pages
574c352
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man1
574c352
sed "s|@VERSION@|%{version}|" %{SOURCE6} > $RPM_BUILD_ROOT%{_mandir}/man1/gap.1
574c352
sed "s|@VERSION@|%{version}|" %{SOURCE7} > $RPM_BUILD_ROOT%{_mandir}/man1/gac.1
574c352
cp -p %{SOURCE8} $RPM_BUILD_ROOT%{_mandir}/man1
574c352
574c352
%post core
574c352
update-mime-database %{_datadir}/mime &>/dev/null ||:
574c352
touch --no-create %{icondir} >&/dev/null ||:
574c352
update-desktop-database %{_datadir}/applications &>/dev/null ||:
574c352
%{_bindir}/update-gap-workspace
574c352
574c352
%postun core
574c352
update-mime-database %{_datadir}/mime &>/dev/null ||:
574c352
touch --no-create %{icondir} >&/dev/null ||:
574c352
%{_bindir}/gtk-update-icon-cache %{icondir} >&/dev/null ||:
574c352
update-desktop-database %{_datadir}/applications &>/dev/null ||:
574c352
574c352
%posttrans
574c352
%{_bindir}/gtk-update-icon-cache %{icondir} >&/dev/null ||:
574c352
574c352
%posttrans prim-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%postun prim-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%posttrans small-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%postun small-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%posttrans trans-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%postun trans-groups -p %{_bindir}/update-gap-workspace
574c352
574c352
%check
574c352
sed -e "s|^GAP_DIR=.*|GAP_DIR=$RPM_BUILD_ROOT%{gapdir}|" \
574c352
    -e "s|\$GAP_DIR/bin/\$GAP_PRG|$RPM_BUILD_ROOT%{_bindir}/gap|" \
574c352
    -i bin/gap.sh
574c352
make testinstall
574c352
574c352
%files
574c352
# No files in the metapackage
574c352
574c352
%files libs
574c352
%doc etc/GPL
574c352
%dir %{gapdir}
574c352
%{gapdir}/grp/
574c352
%{gapdir}/lib/
574c352
574c352
%files core
574c352
%doc README README.fedora description*
574c352
%{_bindir}/gap
574c352
%{_bindir}/update-gap-workspace
574c352
%dir %{gaparchdir}
574c352
%{gaparchdir}/sysinfo.gap
574c352
%{gapdir}/pkg/
574c352
%{_mandir}/man1/gap.1*
574c352
%{_mandir}/man1/update-gap-workspace.1*
574c352
%{_datadir}/applications/gap.desktop
574c352
%{_datadir}/mime/packages/gap.xml
574c352
%{icondir}/32x32/gap.png
574c352
%dir %{_localstatedir}/lib/%{name}/
574c352
%verify(user group mode) %{_localstatedir}/lib/%{name}/workspace
574c352
574c352
%files online-help
574c352
%{gapdir}/doc/
574c352
574c352
%files devel
574c352
%{_bindir}/gac
574c352
%{gaparchdir}/bin/
574c352
%{gaparchdir}/src/
574c352
%{gapdir}/tst/
574c352
%{_mandir}/man1/gac.1*
652a298
%config(noreplace) %{_sysconfdir}/rpm/macros.%{name}
574c352
574c352
%files prim-groups
574c352
%{gapdir}/prim/
574c352
574c352
%files small-groups
574c352
%doc small/README
574c352
%{gapdir}/small/
574c352
574c352
%files trans-groups
574c352
%{gapdir}/trans/
574c352
574c352
%files vim
574c352
%{gapdir}/etc/
574c352
%{_datadir}/vim/vimfiles/ftdetect/gap.vim
574c352
%{_datadir}/vim/vimfiles/indent/gap_indent.vim
574c352
%{_datadir}/vim/vimfiles/syntax/gap.vim
574c352
574c352
%files emacs
574c352
%doc etc/emacs/gap-mode.doc
574c352
%{_emacs_sitelispdir}/gap*.elc
574c352
%{_emacs_sitestartdir}/gap.el
574c352
574c352
%files emacs-el
574c352
%{_emacs_sitelispdir}/gap*.el
574c352
574c352
%files xemacs
574c352
%doc etc/emacs/gap-mode.doc
574c352
%{_xemacs_sitelispdir}/gap*.elc
574c352
%{_xemacs_sitestartdir}/gap.el
574c352
574c352
%files xemacs-el
574c352
%{_xemacs_sitelispdir}/gap*.el
574c352
574c352
%changelog
652a298
* Tue Jan 31 2012 Jerry James <loganjerry@gmail.com> - 4.4.12-4
652a298
- Add an RPM macro file for GAP packages
652a298
- Fix the location of config.h
652a298
574c352
* Wed Jan 11 2012 Jerry James <loganjerry@gmail.com> - 4.4.12-3
574c352
- Fix problems found on review
574c352
574c352
* Tue Jan  3 2012 Jerry James <loganjerry@gmail.com> - 4.4.12-2
574c352
- Mimic Debian's subpackage structure
574c352
574c352
* Wed Oct 12 2011 Jerry James <loganjerry@gmail.com> - 4.4.12-1
574c352
- Initial RPM