Christian Cornelssen on Wed, 22 Aug 2001 16:48:43 +0200 (CEST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Pari-2.1.1 patches and RPM spec file


Dear Pari maintainers and users,

I have downloaded and built Pari-2.1.1 on the following platform
(this surely sets no record, but gives yet another MACHINES entry):

Arch / proc:         OS:             Configure:     sta:    dyn:   GP version:
==============================================================================
486DX (Cyrix) 66MHz  Linux 2.2.18    gcc none dl2   59078   60600  2.1.1

Note: X11 support should work as well, but I do not use X11 on that
platform and have no X11 headers installed, so I could not test that.
The build process used GCC version 2.95.2.

I have accomplished fitting Pari to the following filesystem hierarchy:

=============================================================================
PARI FILES	DESTINATION DIR (RPM syntax)	EXAMPLE (my setup)
-----------------------------------------------------------------------------
gp executable	%{_bindir}			/usr/bin
Pari library	%{_libdir}			/usr/lib
Pari headers	%{_includedir}/%{name}		/usr/include/pari
man pages	%{_mandir}/man*			/usr/share/man/man1
Galois data	%{_datadir}/%{name}/galdata	/usr/share/pari/galdata
online docs	%{_datadir}/%{name}/doc		/usr/share/pari/doc
emacs files	%{_datadir}/%{name}/emacs	/usr/share/pari/emacs
examples	%{_datadir}/%{name}/examples	/usr/share/pari/examples
gpalias etc.	%{_datadir}/%{name}/misc	/usr/share/pari/misc
README etc.	%{_docdir}/%{name}		/usr/share/doc/packages/pari
=============================================================================

In particular, I did not want auxiliary files or files referenced by
programs at run-time to reside in the %{_docdir} tree which is not meant
for "automatic" usage.  Instead, placing symlinks to the doc, emacs,
examples and misc directories in %{_docdir}/%{name} completed the
documentation without dislocating machine-evaluated data.

I have composed a corresponding spec file for use with the RedHat Package
Manager (RPM).  As demonstrated above, the spec file has been designed to
automatically adapt the package to the target's filesystem structure, as
reflected in RPM's macro setup.  It also makes RPM create the mentioned
symlinks in %{_docdir}/%{name} and sets up an initial /etc/gprc (with
paths to gpalias, gphelp etc. adjusted).

I needed to do some patching in order to achieve the desired level of
flexibility, and to properly reflect the resulting pathnames in the
documentation.  By the way, I have fixed some typesetting bugs and tuned
the modes of the installed files.  See the %changelog in the attached
spec file for an overview, or look at the attached patch file directly.

Though there are already some RPM packages for Pari around, I recommend
building them on your own, using the attached spec file, plus the
pristine sources (pari-*.tgz and galdata.tgz) and applicable patches,
if any (like those attached here).  Thus, you can smoothly integrate
the binaries, documentation, and auxiliary files into the filesystem
structure that your RPM has been configured for.  Here is a quick guide:

1.  Move the source *.tgz files and the patch file(s) to RPM's
    SOURCES directory (which typically has /tmp-like permissions,
    so you need not be root in order to do that).

2.  Move the spec file to RPM's SPECS directory.  When changing version
    or release number, create a copy with a corresponding name, and
    update its entries accordingly.  Do not forget to disable old patches.

3.  Set the CFLAGS environment variable to your preferred compiler flags.
    For X11 support, add the environment variable settings `graphic=X11'
    and `Xincroot=/usr/X11R6/include' (or whatever).
    Note: CFLAGS and Xincroot are respected by Pari's Configure script.
    The `graphic' variable is inspected by the specfile scriptlets in
    order to pass the desired --graphic option to the Configure script.

4.  Run "rpm -bb <specfile>" (replace <specfile> by the spec file name)
    and relax while RPM builds the binary package.

5.  Get root permissions, change to the RPMS/<arch> directory where RPM
    has produced the binary package, and install the package using
    something like "rpm -Uvh <packagefile>".

To my regret, I did not dare rewriting the Configure script to make it
accept more pathname options.  (Actually, providing some options to
individually preset the existing pathname variables would be sufficient.)
Instead, I made the spec file scriptlets patch the Configure script
dynamically, setting the path defaults to the values of the respective RPM
macros. Clearly, this approach may fail with future versions of the
Configure script, so that's backward.  After all, it has given a quick
solution, and needs to change only when `Configure' gets even better than
it is now. (The straightforward creation of the dynamic Pari lib was quite
impressive.)


Have fun,

Christian Cornelssen <ccorn@cs.tu-berlin.de>
*** pari-2.1.1/config/DOC_Make.SH.orig	Mon Jan 15 20:21:55 2001
--- pari-2.1.1/config/DOC_Make.SH	Tue Aug 21 17:44:26 2001
***************
*** 16,24 ****
  
  paricfg.tex: paricfg.tex.in
  	sed -e 's/@version@/$version.$patch/'\\
! 	    -e 's!@includedir@!/usr/local/include/pari!'\\
! 	    -e 's!@libdir@!/usr/local/lib!'\\
! 	    -e 's!@miscdir@!/usr/local/lib/pari!' paricfg.tex.in > \$@
  
  tutorial.pdf: tutorial.tex paricfg.tex
  	-touch $pdf
--- 16,24 ----
  
  paricfg.tex: paricfg.tex.in
  	sed -e 's/@version@/$version.$patch/'\\
! 	    -e 's!@includedir@!$includedir!'\\
! 	    -e 's!@libdir@!$libdir!'\\
! 	    -e 's!@miscdir@!$miscdir!' paricfg.tex.in > \$@
  
  tutorial.pdf: tutorial.tex paricfg.tex
  	-touch $pdf
*** pari-2.1.1/config/Makefile.SH.orig	Wed Apr 18 13:40:57 2001
--- pari-2.1.1/config/Makefile.SH	Wed Aug 22 03:08:26 2001
***************
*** 169,174 ****
--- 169,175 ----
  DATADIR= \$(DESTDIR)$datadir
  MANDIR = \$(DESTDIR)$mandir
  ALLDIR = \$(DESTDIR)$miscdir
+ READMEDIR = \$(ALLDIR)
  DOCDIR  = \$(ALLDIR)/doc
  EMACSDIR= \$(ALLDIR)/emacs
  EXDIR   = \$(ALLDIR)/examples
***************
*** 306,332 ****
  	\$(INSTALL_DATA) $misc/README    \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/color.dft \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/gpalias   \$(MISCDIR)
! 	\$(INSTALL_DATA) $misc/gpflog    \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/gprc.dft  \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/new.dic   \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/pari.xpm  \$(MISCDIR)
! 	\$(INSTALL_DATA) $misc/xgp       \$(MISCDIR)
  
  install-top::
! 	-mkdir -p \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/AUTHORS      \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/Announce.2.1 \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/CHANGES      \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/COMPAT       \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/COPYING      \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/CVS.txt      \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/MACHINES     \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/NEW          \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/README       \$(ALLDIR)
! 	\$(INSTALL_DATA) $TOP/TODO         \$(ALLDIR)
  
  install-doc::
! 	-mkdir -p \$(ALLDIR) \$(BINDIR) \$(DOCDIR)
  	-cd $doc; \$(MAKE) all
  	-\$(INSTALL_PROGRAM) $doc/gphelp    \$(BINDIR)
  	-\$(INSTALL_DATA) $doc/Makefile     \$(DOCDIR)
--- 307,333 ----
  	\$(INSTALL_DATA) $misc/README    \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/color.dft \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/gpalias   \$(MISCDIR)
! 	\$(INSTALL_PROGRAM) $misc/gpflog \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/gprc.dft  \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/new.dic   \$(MISCDIR)
  	\$(INSTALL_DATA) $misc/pari.xpm  \$(MISCDIR)
! 	\$(INSTALL_PROGRAM) $misc/xgp    \$(MISCDIR)
  
  install-top::
! 	-mkdir -p \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/AUTHORS      \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/Announce.2.1 \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/CHANGES      \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/COMPAT       \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/COPYING      \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/CVS.txt      \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/MACHINES     \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/NEW          \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/README       \$(READMEDIR)
! 	\$(INSTALL_DATA) $TOP/TODO         \$(READMEDIR)
  
  install-doc::
! 	-mkdir -p \$(BINDIR) \$(DOCDIR)
  	-cd $doc; \$(MAKE) all
  	-\$(INSTALL_PROGRAM) $doc/gphelp    \$(BINDIR)
  	-\$(INSTALL_DATA) $doc/Makefile     \$(DOCDIR)
***************
*** 345,350 ****
--- 346,352 ----
  	-\$(INSTALL_DATA) $doc/usersch3.tex \$(DOCDIR)
  	-\$(INSTALL_DATA) $doc/usersch4.tex \$(DOCDIR)
  	-\$(INSTALL_DATA) $doc/usersch5.tex \$(DOCDIR)
+ 	-\$(INSTALL_DATA) $doc/paricfg.tex  \$(DOCDIR)
  	-\$(INSTALL_DATA) $doc/users.dvi    \$(DOCDIR)
  	-\$(INSTALL_DATA) $doc/tutorial.dvi \$(DOCDIR)
  	-\$(INSTALL_DATA) $doc/refcard.dvi  \$(DOCDIR)
***************
*** 378,384 ****
  install-lib-dyn: \$(LIBPARI_DYN)
  	-mkdir -p \$(LIBDIR)
  	-\$(RM) \$(LIBDIR)/\$(LIBPARI_DYN)
! 	\$(INSTALL_DATA) \$(LIBPARI_DYN) \$(LIBDIR)/\$(LIBPARI_DYN)
  EOT
  if test "$soname" != "$sodest"; then
    cat >> $file << EOT
--- 380,386 ----
  install-lib-dyn: \$(LIBPARI_DYN)
  	-mkdir -p \$(LIBDIR)
  	-\$(RM) \$(LIBDIR)/\$(LIBPARI_DYN)
! 	\$(INSTALL_PROGRAM) \$(LIBPARI_DYN) \$(LIBDIR)/\$(LIBPARI_DYN)
  EOT
  if test "$soname" != "$sodest"; then
    cat >> $file << EOT
*** pari-2.1.1/doc/refcard.tex.orig	Mon Jan 15 20:21:55 2001
--- pari-2.1.1/doc/refcard.tex	Tue Aug 21 11:46:40 2001
***************
*** 17,23 ****
--- 17,29 ----
  %% which I modified from his GNU emacs reference card
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \def\TITLE{Pari-GP reference card}
+ % ignore parimacro.tex's \magnification setting
+ \let\oldmagnification\magnification
+ \catcode`@=11
+ \def\magnification{\afterassignment\relax\count@}%
+ \catcode`@=12
  \input parimacro.tex
+ \let\magnification\oldmagnification
  \ifPDF
    \input pdfmacs.tex
    \pdfpagewidth=11.69in
*** pari-2.1.1/doc/users.tex.orig	Mon Jan 15 20:21:55 2001
--- pari-2.1.1/doc/users.tex	Mon Aug 20 01:14:22 2001
***************
*** 63,69 ****
    \ifPDF \writesecnumbers \fi
    \expandafter\end % stop here the first time (don't process index)
  \fi
- \newpage
  
  \ifPDF
  % Add a bookmark entry for the index.   CHB
--- 63,68 ----
*** pari-2.1.1/doc/usersch2.tex.orig	Mon Jan 15 20:21:55 2001
--- pari-2.1.1/doc/usersch2.tex	Wed Aug 22 02:48:58 2001
***************
*** 1896,1905 ****
  GNU Emacs to be installed on your machine!). To use this, you should
  include in your \kbd{.emacs} file the following lines:
  \bprog
! (autoload 'gp-mode "@miscdir/pari" nil t)
! (autoload 'gp-script-mode "@miscdir/pari" nil t)
! (autoload 'gp "@miscdir/pari" nil t)
! (autoload 'gpman "@miscdir/pari" nil t)
  (setq auto-mode-alist
    (cons '("\\.gp$" . gp-script-mode) auto-mode-alist))
  @eprog
--- 1896,1905 ----
  GNU Emacs to be installed on your machine!). To use this, you should
  include in your \kbd{.emacs} file the following lines:
  \bprog
! (autoload 'gp-mode "@miscdir/emacs/pari" nil t)
! (autoload 'gp-script-mode "@miscdir/emacs/pari" nil t)
! (autoload 'gp "@miscdir/emacs/pari" nil t)
! (autoload 'gpman "@miscdir/emacs/pari" nil t)
  (setq auto-mode-alist
    (cons '("\\.gp$" . gp-script-mode) auto-mode-alist))
  @eprog
# RPM spec file for Pari
# Before building, set the following environment variables:
# CFLAGS=<Compiler flags>
# graphic=X11 Xincroot=<X11 include dir>	for --graphic=X11
# Check the make targets in the %build section for the tests you want to run.

Summary: PARI/GP - Number Theory-oriented Computer Algebra System
Name: pari
Version: 2.1.1
Release: 1
Copyright: GPL
Group: Applications/Math
Source0: ftp://megrez.math.u-bordeaux.fr/pub/pari/unix/%{name}-%{version}.tgz
Source1: ftp://megrez.math.u-bordeaux.fr/pub/pari/galdata.tgz
Patch: %{name}-%{version}-%{release}.patch
URL: http://www.parigp-home.de/
BuildRoot: /var/tmp/%{name}-install
#Requires:
#Provides:

%description
PARI / GP  is a package which is aimed at efficient computations in number
theory, but also contains a large number of other useful functions.  It is
somewhat related to a Computer Algebra System, but is not really one since
it treats symbolic expressions as mathematical entities such as  matrices,
polynomials, series, etc..., and not as expressions per se.  However it is
often much faster than other CAS,  and contains a large number of specific
functions not found elsewhere, essentially for use in number theory.

This package can be used in an interactive shell (GP) or as a C/C++ library
(PARI). It is free software, in the sense of freedom AND 'free of charge'.

%prep
%setup -T -b0 -a1
mkdir data && mv COS* RES* data
%patch -p1 -b .orig

%build
%define _pkgdocdir	%{_docdir}/%{name}
%define _pkgincludedir	%{_includedir}/%{name}
%define _pkgdatadir	%{_datadir}/%{name}

# The delivered Configure script's path defaults are not flexible enough.
# Preset these directly.
sed -e '
  /dflt=.*; bindir=\$ans/	s|=[^;]*|='%{_bindir}'|
  /dflt=.*; libdir=\$ans/	s|=[^;]*|='%{_libdir}'|
  /dflt=.*; includedir=\$ans/	s|=[^;]*|='%{_pkgincludedir}'|
  /dflt=.*; mandir=\$ans/	s|=[^;]*|='%{_mandir}/man1'|
  /dflt=.*; miscdir=\$ans/	s|=[^;]*|='%{_pkgdatadir}'|
  /dflt=.*; datadir=\$ans/	s|=[^;]*|='%{_pkgdatadir}/galdata'|
' Configure >MyConfigure

# Build
CFLAGS="${CFLAGS:-$RPM_OPT_FLAGS}" sh MyConfigure	\
	--host=%{_arch}-%{_os}				\
	--prefix=%{_prefix}				\
	--share-prefix=%{_datadir}			\
	${graphic:+--graphic="$graphic"}
make gp doc bench test-compat #test-graphic

# Setup configuration file
sed	-e 's,/usr/local/,'%{_prefix}/',g'\
	-e 's,"[^"	 ]*/share/,"'%{_datadir}/',g'\
	-e 's,"[^"	 ]*/bin/,"'%{_bindir}/',g'\
	-e 's,"[^"	 ]*/gpalias","'%{_pkgdatadir}/misc/gpalias'",g'\
	-e 's,"[^"	 ]*/galdata","'%{_pkgdatadir}/galdata'",g'\
	-e '/^\\\\[	 ]*\(read "\|compatible =\|secure =\)/ s/^\\\\[	 ]*//'\
	misc/gprc.dft >gprc

%install
rm -rf "$RPM_BUILD_ROOT"

# Move the README files to the standard documentation folder
# while leaving the others where the binaries expect them.
make	DESTDIR="$RPM_BUILD_ROOT"\
	READMEDIR='$(DESTDIR)'%{_pkgdocdir}\
	install #install-lib-sta install-bin-sta

# Create links to the interesting directories in the standard doc folder
# unless _pkgdocdir and _pkgdatadir are identical
for i in doc emacs examples misc; do
  if test ! -d "$RPM_BUILD_ROOT"%{_pkgdocdir}/"$i"; then
    ln -s %{_pkgdatadir}/"$i" "$RPM_BUILD_ROOT"%{_pkgdocdir}/"$i"
  fi
done

# Install global configuration file.
# /etc is hardcoded into gp, so do NOT use the _sysconfdir macro.
mkdir "$RPM_BUILD_ROOT"/etc
cp gprc "$RPM_BUILD_ROOT"/etc

%clean
rm -rf "$RPM_BUILD_ROOT"

%post
%define ___ldconfig	%{?__ldconfig:%{__ldconfig}}%{!?__ldconfig:/sbin/ldconfig}
if test -x %{___ldconfig}; then %{___ldconfig} -n %{_libdir}; fi

%postun
if test -x %{___ldconfig}; then %{___ldconfig} -n %{_libdir}; fi

%files
%defattr(-,root,root)
%doc %{_mandir}/man*/*.*
%doc %{_pkgdocdir}
%{_libdir}/*
%{_includedir}/*
%{_bindir}/*
%{_pkgdatadir}
%config /etc/*

%changelog
* Tue Aug 21 2001 Christian Cornelssen <ccorn@cs.tu-berlin.de>
- config/DOC_Make.SH: now writes config results to paricfg.tex
- config/Makefile.SH: installs doc/paricfg.tex to enable `tex' without `make'
- config/Makefile.SH: installs misc/gpflog, misc/xgp with exec permission
- config/Makefile.SH: installs ${LIBPARI_DYN} with exec permission (for ldd)
- config/Makefile.SH: independent variable for the destination of README files
- doc/refcard.tex: avoids \mag change by parimacro.tex
- doc/users.tex: removed excessive \newpage that caused wrong index toc entry
- doc/usersch2.tex: updated the specification of where to find the .el* files