Ticket #9433: install.2

File install.2, 10.4 KB (added by vbraun, 9 years ago)

Updated spkg/install

Line 
1#!/usr/bin/env bash
2
3###############################################################################
4# Check if pipestatus already exists, otherwise
5# create it to allow upgrade from Sage <4.5.  This is a temporary fix.
6# See trac 9528: http://trac.sagemath.org/sage_trac/ticket/9528
7# Go about 56 lines down from here for the actual "install" script.
8###############################################################################
9if [ ! -f pipestatus ]; then
10  echo "Creating pipestatus."
11  cat >pipestatus <<'EOF'
12#!/usr/bin/env bash
13#
14# spkg/pipestatus: run two commands in a pipeline CMD1 | CMD2 and exit
15# with the status of the last command to exit with a non-zero status, or
16# zero if no command exited with a non-zero status.
17#
18# This is useful, for example, in a Makefile, where we tee the output
19# of a build command to a log file.  Using pipestatus, make will stop if
20# tee succeeds but a preceding command in the pipeline fails.
21#
22# Syntactically, the command executed is "CMD1 | CMD2" where CMD1 and
23# CMD2 are *not* treated as atoms.  If CMD1 is "A && B" and CMD2 is "C",
24# then pipestatus CMD1 CMD2 will act as A && (B | C).  This also implies
25# that CMD1 and CMD2 *MUST NOT* contain pipes, or this script will break.
26#
27# IMPORTANT: if you edit this file, be sure to also edit spkg/install
28#            where this file is created for upgrading.
29#
30#
31# AUTHORS:
32#
33# - Jeroen Demeyer (2010-12-19): complete rewrite (#10339)
34#
35#*****************************************************************************
36#       Copyright (C) 2010 Jeroen Demeyer <jdemeyer@cage.ugent.be>
37#
38#  Distributed under the terms of the GNU General Public License (GPL)
39#  as published by the Free Software Foundation; either version 2 of
40#  the License, or (at your option) any later version.
41#                  http://www.gnu.org/licenses/
42#*****************************************************************************
43
44
45if [ $# -ne 2 ] || [ -z "$1" -o -z "$2" ]; then
46    echo >&2 "Usage: $0 CMD1 CMD2"
47    echo >&2 "Run two commands in a pipeline 'CMD1 | CMD2' and exit with the status"
48    echo >&2 "of the last command to exit with a non-zero status, or zero if no"
49    echo >&2 "command exited with a non-zero status."
50    exit 2
51fi
52
53eval "$1 | $2; pipestatus=(\${PIPESTATUS[*]})"
54
55if [ ${pipestatus[1]} -ne 0 ]; then
56    exit ${pipestatus[1]}
57else
58    exit ${pipestatus[0]}
59fi
60EOF
61  chmod +x pipestatus
62fi
63
64###############################################################################
65
66
67CUR=`pwd`
68cd ..
69SAGE_ROOT=`pwd`
70# Storing the start time of the build process. The time is stored in
71# seconds since 1970-01-01 in a hidden file called
72# "SAGE_ROOT/.BUILDSTART". See ticket #6744.
73echo `date -u "+%s"` > .BUILDSTART
74cd "$CUR"
75SAGE_LOCAL="$SAGE_ROOT/local"
76SAGE_LOGS="$SAGE_ROOT/spkg/logs"
77PATH="$SAGE_ROOT:$SAGE_LOCAL/bin:$PATH"
78PYTHONPATH="$SAGE_LOCAL"
79PKGDIR=standard
80export PATH SAGE_ROOT SAGE_LOCAL SAGE_LOGS PYTHONPATH
81
82if [ ! -f "$SAGE_LOCAL/bin/sage-spkg" ]; then
83    if [ ! -d "$SAGE_LOCAL" ]; then
84        mkdir "$SAGE_LOCAL"
85    fi
86    if [ ! -d "$SAGE_LOCAL/bin" ]; then
87        mkdir "$SAGE_LOCAL/bin"
88    fi
89    cp base/sage-* base/testcc.sh base/testcxx.sh "$SAGE_LOCAL/bin/"
90fi
91
92if [ ! -d "$SAGE_LOGS" ]; then
93    mkdir -p "$SAGE_LOGS"
94fi
95
96###############################################################################
97# Make upgrading work: If this script is called from sage-upgrade,
98# either sage-upgrade has set SAGE_UPGRADING to "yes",
99# or we have an old version of sage-upgrade that doesn't contain
100# the string "SAGE_UPGRADING".
101# If SAGE_UPGRADING is not set to "yes", or sage-upgrade does not (yet)
102# exist, do the usual build (without setting SAGE_SPKG_OPTS).
103###############################################################################
104if [ "$SAGE_UPGRADING" = yes ] \
105    || ([ -f "$SAGE_LOCAL/bin/sage-upgrade" ] && \
106        ! grep SAGE_UPGRADING "$SAGE_LOCAL/bin/sage-upgrade" >/dev/null);
107then
108    # We're doing an upgrade.
109    # Let the Makefile (spkg/standard/deps) call sage-spkg with "-f"
110    # to force rebuilding dependent packages, too:
111    export SAGE_SPKG_OPTS="-f"
112fi
113
114###############################################################################
115# Setup environment variables pointing to the newest versions
116# of the base packages:
117###############################################################################
118newest="$PKGDIR/newest_version -base "
119
120SAGE_BZIP2=`$newest bzip2`
121export SAGE_BZIP2
122
123DIR=`$newest dir`
124export DIR
125
126PREREQ=`$newest prereq`
127export PREREQ
128
129###############################################################################
130# Setup environment variables pointing to the newest versions
131# of the standard packages:
132###############################################################################
133newest="$PKGDIR/newest_version"
134
135ATLAS=`$newest atlas`
136export ATLAS
137
138BLAS=`$newest blas`
139export BLAS
140
141BOEHM_GC=`$newest boehm_gc`
142export BOEHM_GC
143
144BOOST_CROPPED=`$newest boost-cropped`
145export BOOST_CROPPED
146
147CEPHES=`$newest cephes`
148export CEPHES
149
150CLIQUER=`$newest cliquer`
151export CLIQUER
152
153CDDLIB=`$newest cddlib`
154export CDDLIB
155
156ECL=`$newest ecl`
157export ECL
158
159CONWAY=`$newest conway_polynomials`
160if [ $? -ne 0 ]; then
161    echo "Error determining package name using spkg/standard/newest_version script."
162    exit 1
163fi
164export CONWAY
165
166ECLIB=`$newest eclib`
167export ECLIB
168
169ELLIPTIC_CURVES=`$newest elliptic_curves`
170export ELLIPTIC_CURVES
171
172CVXOPT=`$newest cvxopt`
173export CVXOPT
174
175DOCUTILS=`$newest docutils`
176export DOCUTILS
177
178ECM=`$newest ecm`
179export ECM
180
181EXAMPLES=`$newest examples`
182export EXAMPLES
183
184EXTCODE=`$newest extcode`
185export EXTCODE
186
187F2C=`$newest f2c`
188export F2C
189
190GLPK=`$newest glpk`
191export GLPK
192
193ICONV=`$newest iconv`
194export ICONV
195
196#############
197# This is all for GNUtls crypto
198LIBGCRYPT=`$newest libgcrypt`
199export LIBGCRYPT
200
201OPENCDK=`$newest opencdk`
202export OPENCDK
203
204GNUTLS=`$newest gnutls`
205export GNUTLS
206
207LIBGPG_ERROR=`$newest libgpg_error`
208export LIBGPG_ERROR
209
210PYGMENTS=`$newest pygments`
211export PYGMENTS
212
213PYTHON_GNUTLS=`$newest python_gnutls`
214export PYTHON_GNUTLS
215############# end gnutls crypto
216
217PIL=`$newest pil`
218export PIL
219
220PATCH=`$newest patch`
221export PATCH
222
223LIBM4RI=`$newest libm4ri`
224export LIBM4RI
225
226FORTRAN=`$newest fortran`
227export FORTRAN
228
229FPLLL=`$newest libfplll`
230export FPLLL
231
232FREETYPE=`$newest freetype`
233export FREETYPE
234
235GAP=`$newest gap`
236export GAP
237
238G2RED=`$newest genus2reduction`
239export G2RED
240
241GD=`$newest gd`
242export GD
243
244GDMODULE=`$newest gdmodule`
245export GDMODULE
246
247GFAN=`$newest gfan`
248export GFAN
249
250GIVARO=`$newest givaro`
251export GIVARO
252
253MPIR=`$newest mpir`
254export MPIR
255
256GRAPHS=`$newest graphs`
257export GRAPHS
258
259GSL=`$newest gsl`
260export GSL
261
262IPYTHON=`$newest ipython`
263export IPYTHON
264
265LAPACK=`$newest lapack`
266export LAPACK
267
268LCALC=`$newest lcalc`
269export LCALC
270
271LIBPNG=`$newest libpng`
272export LIBPNG
273
274LINBOX=`$newest linbox`
275export LINBOX
276
277IML=`$newest iml`
278export IML
279
280JINJA2=`$newest jinja2` 
281export JINJA2
282
283MATPLOTLIB=`$newest matplotlib`
284export MATPLOTLIB
285
286MAXIMA=`$newest maxima`
287export MAXIMA
288
289MERCURIAL=`$newest mercurial`
290export MERCURIAL
291
292MPFI=`$newest mpfi`
293export MPFI
294
295MOIN=`$newest moin`
296export MOIN
297
298MPFR=`$newest mpfr`
299export MPFR
300
301MPMATH=`$newest mpmath`
302export MPMATH
303
304NETWORKX=`$newest networkx`
305export NETWORKX
306
307NUMPY=`$newest numpy`
308export NUMPY
309
310NTL=`$newest ntl`
311export NTL
312
313#OPENSSL=`$newest openssl`
314#export OPENSSL
315
316#PYOPENSSL=`$newest pyopenssl`
317#export PYOPENSSL
318
319PALP=`$newest palp`
320export PALP
321
322PARI=`$newest pari`
323export PARI
324
325PEXPECT=`$newest pexpect`
326export PEXPECT
327
328POLYBORI=`$newest polybori`
329export POLYBORI
330
331PYNAC=`$newest pynac`
332export PYNAC
333
334CYTHON=`$newest cython`
335export CYTHON
336
337RATPOINTS=`$newest ratpoints`
338export RATPOINTS
339
340SAGENB=`$newest sagenb`
341export SAGENB
342
343SAGETEX=`$newest sagetex`
344export SAGETEX
345
346SPHINX=`$newest sphinx`
347export SPHINX
348
349SQLALCHEMY=`$newest sqlalchemy`
350export SQLALCHEMY
351
352SQLITE=`$newest sqlite`
353export SQLITE
354
355FLINTQS=`$newest flintqs`
356export FLINTQS
357
358FLINT=`$newest flint`
359export FLINT
360
361POLYTOPES_DB=`$newest polytopes_db`
362export POLYTOPES_DB
363
364PYCRYPTO=`$newest pycrypto`
365export PYCRYPTO
366
367PYTHON=`$newest python`
368export PYTHON
369
370R=`$newest r`
371export R
372
373# Needed when #9906 gets merged:
374# RPY=`$newest rpy2`
375# export RPY
376
377READLINE=`$newest readline`
378export READLINE
379
380RUBIKS=`$newest rubiks`
381export RUBIKS
382
383SAGE=`$newest sage`
384export SAGE
385
386SAGE_ROOT_REPO=`$newest sage_root` 
387export SAGE_ROOT_REPO
388
389SAGE_SCRIPTS=`$newest sage_scripts`
390export SAGE_SCRIPTS
391
392SCIPY=`$newest scipy`
393export SCIPY
394
395SCIPY_SANDBOX=`$newest scipy_sandbox`
396export SCIPY_SANDBOX
397
398TACHYON=`$newest tachyon`
399export TACHYON
400
401TWISTED=`$newest twisted`
402export TWISTED
403
404SCONS=`$newest scons`
405export SCONS
406
407SETUPTOOLS=`$newest setuptools`
408export SETUPTOOLS
409
410SINGULAR=`$newest singular`
411export SINGULAR
412
413SYMPOW=`$newest sympow`
414export SYMPOW
415
416SYMPY=`$newest sympy`
417export SYMPY
418
419SYMMETRICA=`$newest symmetrica`
420export SYMMETRICA
421
422TERMCAP=`$newest termcap`
423export TERMCAP
424
425WEAVE=`$newest weave`
426export WEAVE
427
428ZLIB=`$newest zlib`
429export ZLIB
430
431ZODB=`$newest zodb3`
432export ZODB
433
434ZNPOLY=`$newest zn_poly`
435export ZNPOLY
436
437
438# Skip the rest if nothing to do (i.e., to [re]build):
439# Note that we should use $MAKE here, but we currently don't use
440# it further below either unless SAGE_PARALLEL_SPKG_BUILD=yes, which
441# I consider a "bug". -- Leif Leonhardy
442# If "make" doesn't understand the -q option, it should exit with a
443# non-zero status which is not a problem.
444if make -q -f standard/deps $1; then
445    echo "Nothing to (re)build / all up-to-date."
446    exit 0
447fi
448
449
450# Dump environment for debugging purposes:
451echo "*** ALL ENVIRONMENT VARIABLES BEFORE BUILD: ***"
452env
453echo "***********************************************"
454
455
456###############################################################################
457# NOW do the actual build:
458###############################################################################
459if [ "$SAGE_PARALLEL_SPKG_BUILD" = "yes" ] && [ -n "$MAKE" ]; then
460    time $MAKE -f standard/deps $1
461else
462    time make -f standard/deps $1
463fi
464
465# added by Burcin Erocal, see trac #6295.
466if [ $? -ne 0 ]; then
467    echo "Error building Sage."
468    exit 1
469fi
470
471cd "$SAGE_ROOT"
472
473# Rename makefile to Makefile (see #10156)
474if [ -f makefile ]; then
475    mv makefile Makefile
476    if [ $? -ne 0 ]; then
477        echo "Error renaming 'makefile' to 'Makefile'."
478        exit 1
479    fi
480fi
481
482# build succeeded
483if [ "$1" = "all" ]; then
484    echo "To install gap, gp, singular, etc., scripts"
485    echo "in a standard bin directory, start sage and"
486    echo "type something like"
487    echo "   sage: install_scripts('/usr/local/bin')"
488    echo "at the Sage command prompt."
489    echo ""
490    echo "To build the documentation, run"
491    echo "   make doc"
492    echo ""
493fi
494
495echo "Sage build/upgrade complete!"
496