c93f5b1
#!/usr/bin/sh
c93f5b1
#
c93f5b1
# Script to prepare a GIAC spkg for Fedora.  This script is only for the
c93f5b1
# package maintainer.
c93f5b1
#
c93f5b1
2273a23
VERSION="1.2.3"
3f113bc
VERSIONREV="13"
c93f5b1
c93f5b1
# The upstream tarball name is: giac"$SOURCEORIG".tar.gz
c93f5b1
SOURCEORIG=_"$VERSION"-"$VERSIONREV"
c93f5b1
c93f5b1
# The name of the output file without tar.gz or tar.bz2 extension
c93f5b1
OUTPUTFILEBASENAME=giac-"$VERSION"."$VERSIONREV"
c93f5b1
c93f5b1
echo >&2 "Testing if the output file already exist in one of gz or bz2 format"
c93f5b1
if [ -f "$OUTPUTFILEBASENAME".tar.gz -o -f "$OUTPUTFILEBASENAME".tar.bz2 ] ; then
c93f5b1
    echo >&2 "there is already a giac archive of this version"
c93f5b1
    exit 1
c93f5b1
fi
c93f5b1
c93f5b1
echo >&2 "Build a temporary working dir"
c93f5b1
TARGET=$(mkdir -p "giac-src")
c93f5b1
ORIGDIR=`pwd`
c93f5b1
cd "$TARGET"
c93f5b1
c93f5b1
echo >&2 "Downloading upstream source ..."
c93f5b1
wget "http://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac$SOURCEORIG.tar.gz"
c93f5b1
c93f5b1
c93f5b1
echo >&2 "Untar upstream source ..."
c93f5b1
tar -xzf giac"$SOURCEORIG".tar.gz
c93f5b1
c93f5b1
c93f5b1
echo >&2 "Removing javagiac ..."
c93f5b1
rm -rf giac-"$VERSION"/src/javagiac*
c93f5b1
c93f5b1
echo >&2 "Removing french html doc, but keep keywords, and working makefiles.
c93f5b1
 NB: the french html doc is huge and not GPL.
c93f5b1
 It is freely redistibuable only for non commercial purposes ..."
c93f5b1
cd giac-"$VERSION"/doc/fr
c93f5b1
rm -rf [^Mkx]*
c93f5b1
rm -rf *.pdf *.eps *.pdf *.png *.cxx *.cas *.jpg *.tex *.stamp *html* cas* *.fig fig*
c93f5b1
c93f5b1
echo >&2 "Repair the build procedure with a minimal Makefile.am ..."
c93f5b1
echo -e "EXTRA_DIST = xcasmenu xcasex keywords\n\nlocaldocdir = \$(docdir)/fr \n\n\
c93f5b1
dist_localdoc_DATA = xcasmenu xcasex keywords html_mall html_mtt html_vall">Makefile.am
c93f5b1
c93f5b1
echo >&2 "Copy and adjust a minimal Makefile.in ..."
c93f5b1
cp ../local/Makefile.in ./
c93f5b1
sed -ie 's|localdocdir = $(docdir)/local|localdocdir = $(docdir)/fr|' Makefile.in
c93f5b1
sed -ie 's|doc/local|subdir = doc/fr|g' Makefile.in
c93f5b1
#
c93f5b1
touch html_mall
c93f5b1
touch html_mtt
c93f5b1
touch html_vall
c93f5b1
#
c93f5b1
c93f5b1
c93f5b1
echo >&2 "Building giac source tarball ..."
c93f5b1
cd ../../../
c93f5b1
tar -cz giac-"$VERSION" -f "$OUTPUTFILEBASENAME".tar.gz
c93f5b1
c93f5b1
c93f5b1
echo >&2 "Cleaning extracted dir ..."
c93f5b1
rm -rf giac-src
c93f5b1
rm -f "giac$SOURCEORIG.tar.gz"
c93f5b1
rm -rf giac-"$VERSION"
c93f5b1
c93f5b1
echo >&2 "Finished."