Blob Blame History Raw
%global upstreamver 4r4p12
%global gapdirname gap%(echo %upstreamver | cut -dp -f1)
%global gapdir %{_datadir}/gap
%global gaparchdir %{_prefix}/lib/gap
%global icondir %{_datadir}/icons/hicolor

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

Group:          Applications/Engineering
License:        GPLv2+
URL:            http://www.gap-system.org/
Source0:        ftp://ftp.gap-system.org/pub/gap/gap4/tar.bz2/%{name}%{upstreamver}.tar.bz2
Source1:        gap-README.fedora
Source2:        update-gap-workspace
Source3:        gap.xml
Source4:        gap.desktop
Source5:        gap.el
Source6:        gap.1.in
Source7:        gac.1.in
Source8:        update-gap-workspace.1
Source9:        gap.vim
# This patch from Debian rearranges some paths to match Linux conventions.
Patch0:         gap-paths.patch
# This patch from Debian makes GAP use termios controls instead of BSD ioctls
# to manage a raw terminal.
Patch1:         gap-raw.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.
Patch2:         gap-help.patch
# This patch will not be sent upstream.  It fixes some CRCs after converting
# the source files from ISO8859-1 to UTF-8 and applying the previous patches.
Patch3:         gap-crc.patch
# This patch will not be sent upstream.  It makes the main binary read the
# environment variables now read by gap.sh, so we can dispose of the shell
# script and run the actual binary directly.
Patch4:         gap-env.patch
# This patch was sent upstream 4 Aug 2011.  It fixes several places where the
# sources violate ANSI C alias analysis rules.
Patch5:         gap-alias.patch
# This patch was sent upstream 4 Aug 2011.  It fixes some cosmetic issues in
# the Emacs Lisp sources.
Patch6:         gap-emacs.patch

BuildRequires:  desktop-file-utils
BuildRequires:  netpbm-progs
BuildRequires:  emacs
BuildRequires:  xemacs

Requires:       %{name}-libs = %{version}-%{release}
Requires:       %{name}-core%{?_isa} = %{version}-%{release}
Requires:       %{name}-online-help = %{version}-%{release}
Requires:       %{name}-prim-groups = %{version}-%{release}
Requires:       %{name}-small-groups = %{version}-%{release}
Requires:       %{name}-trans-groups = %{version}-%{release}

%description
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

%description libs
This package contains the essential GAP libraries: lib and grp.

%package core
Summary:        GAP core components
Group:          Applications/Engineering
Requires:       %{name}-libs = %{version}-%{release}
# 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

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

%package prim-groups
Summary:        Database of primitive groups for GAP
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}
BuildArch:      noarch

%description prim-groups
This package contains a database of primitive groups for GAP.

%package small-groups
Summary:        Database of small groups for GAP
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}
BuildArch:      noarch

%description small-groups
This package contains a database of groups of small order for GAP.  The
database includes the group data and identification routines for groups
of order up to 2000.

%package trans-groups
Summary:        Database of transitive groups for GAP
Group:          Applications/Engineering
Requires:       %{name}-core = %{version}-%{release}
BuildArch:      noarch

%description trans-groups
This package contains a database of transitive groups for GAP.

%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.

%prep
%setup -q -n %{gapdirname}
%patch0
%patch1
%patch2
%patch3
%patch4
%patch5
%patch6

# Replace the CFLAGS
sed -i "s|gp_cv_cflags=\"-Wall -g -O2\"|gp_cv_cflags='$RPM_OPT_FLAGS -DSYS_DEFAULT_PATHS=\\\\\"%{gapdir}\\\\\"'|" \
    cnf/configure.out

# Fix file encodings
for f in description4r4p6 etc/gap*.vim etc/README.vim-utils lib/colorprompt.g \
         lib/grpffmat.gi lib/grpnames.gd lib/grpnames.gi lib/helpbase.* \
         lib/helpdef.* lib/helpview.* lib/memory.* lib/pager.* \
         lib/polyconw.gi lib/semirel.gi small/README; do
  iconv -f iso8859-1 -t utf-8 $f > $f.new
  touch -f $f $f.new
  mv -f $f.new $f
done

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

%build
%configure
make %{?_smp_mflags} compile

# 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}
%%_gap_arch_dir %{gaparchdir}
EOF

%install
# Get the value of the GAParch variable
source ./sysinfo.gap

# Install the binaries
mkdir -p $RPM_BUILD_ROOT%{_bindir}
cp -p bin/$GAParch/gap $RPM_BUILD_ROOT%{_bindir}
cp -p %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}
sed -e "s|@gaparch@|$GAParch|" \
    -e "s| -DSYS_DEFAULT_PATHS=\\\"/usr/share/gap\\\"||" \
    bin/$GAParch/gac > $RPM_BUILD_ROOT%{_bindir}/gac
chmod a+x $RPM_BUILD_ROOT%{_bindir}/ga*

# 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
mkdir -p $RPM_BUILD_ROOT%{gaparchdir}
cp -p sysinfo.gap $RPM_BUILD_ROOT%{gaparchdir}

# 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%{gaparchdir}/src
cp -p src/*.h $RPM_BUILD_ROOT%{gaparchdir}/src
mkdir -p $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch
cp -p bin/$GAParch/config.h $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch
cp -p bin/$GAParch/*.o $RPM_BUILD_ROOT%{gaparchdir}/bin/$GAParch

# 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 \
  %{SOURCE4}

# 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
popd
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
popd
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-mime-database %{_datadir}/mime &>/dev/null ||:
touch --no-create %{icondir} >&/dev/null ||:
update-desktop-database %{_datadir}/applications &>/dev/null ||:
%{_bindir}/update-gap-workspace

%postun core
update-mime-database %{_datadir}/mime &>/dev/null ||:
touch --no-create %{icondir} >&/dev/null ||:
%{_bindir}/gtk-update-icon-cache %{icondir} >&/dev/null ||:
update-desktop-database %{_datadir}/applications &>/dev/null ||:

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

%posttrans prim-groups -p %{_bindir}/update-gap-workspace

%postun prim-groups -p %{_bindir}/update-gap-workspace

%posttrans small-groups -p %{_bindir}/update-gap-workspace

%postun small-groups -p %{_bindir}/update-gap-workspace

%posttrans trans-groups -p %{_bindir}/update-gap-workspace

%postun trans-groups -p %{_bindir}/update-gap-workspace

%check
sed -e "s|^GAP_DIR=.*|GAP_DIR=$RPM_BUILD_ROOT%{gapdir}|" \
    -e "s|\$GAP_DIR/bin/\$GAP_PRG|$RPM_BUILD_ROOT%{_bindir}/gap|" \
    -i bin/gap.sh
make testinstall

%files
# No files in the metapackage

%files libs
%doc etc/GPL
%dir %{gapdir}
%{gapdir}/grp/
%{gapdir}/lib/

%files core
%doc README README.fedora description*
%{_bindir}/gap
%{_bindir}/update-gap-workspace
%dir %{gaparchdir}
%{gaparchdir}/sysinfo.gap
%{gapdir}/pkg/
%{_mandir}/man1/gap.1*
%{_mandir}/man1/update-gap-workspace.1*
%{_datadir}/applications/gap.desktop
%{_datadir}/mime/packages/gap.xml
%{icondir}/32x32/gap.png
%dir %{_localstatedir}/lib/%{name}/
%verify(user group mode) %{_localstatedir}/lib/%{name}/workspace

%files online-help
%{gapdir}/doc/

%files devel
%{_bindir}/gac
%{gaparchdir}/bin/
%{gaparchdir}/src/
%{gapdir}/tst/
%{_mandir}/man1/gac.1*
%config(noreplace) %{_sysconfdir}/rpm/macros.%{name}

%files prim-groups
%{gapdir}/prim/

%files small-groups
%doc small/README
%{gapdir}/small/

%files trans-groups
%{gapdir}/trans/

%files vim
%{gapdir}/etc/
%{_datadir}/vim/vimfiles/ftdetect/gap.vim
%{_datadir}/vim/vimfiles/indent/gap_indent.vim
%{_datadir}/vim/vimfiles/syntax/gap.vim

%files emacs
%doc etc/emacs/gap-mode.doc
%{_emacs_sitelispdir}/gap*.elc
%{_emacs_sitestartdir}/gap.el

%files emacs-el
%{_emacs_sitelispdir}/gap*.el

%files xemacs
%doc etc/emacs/gap-mode.doc
%{_xemacs_sitelispdir}/gap*.elc
%{_xemacs_sitestartdir}/gap.el

%files xemacs-el
%{_xemacs_sitelispdir}/gap*.el

%changelog
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.4.12-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

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

* Wed Jan 11 2012 Jerry James <loganjerry@gmail.com> - 4.4.12-3
- Fix problems found on review

* Tue Jan  3 2012 Jerry James <loganjerry@gmail.com> - 4.4.12-2
- Mimic Debian's subpackage structure

* Wed Oct 12 2011 Jerry James <loganjerry@gmail.com> - 4.4.12-1
- Initial RPM