# Ticket #9433: install.2

File install.2, 10.4 KB (added by , 10 years ago) |
---|

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 | ############################################################################### |

9 | if [ ! -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 | |

45 | if [ $# -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 |

51 | fi |

52 | |

53 | eval "$1 | $2; pipestatus=(\${PIPESTATUS[*]})" |

54 | |

55 | if [ ${pipestatus[1]} -ne 0 ]; then |

56 | exit ${pipestatus[1]} |

57 | else |

58 | exit ${pipestatus[0]} |

59 | fi |

60 | EOF |

61 | chmod +x pipestatus |

62 | fi |

63 | |

64 | ############################################################################### |

65 | |

66 | |

67 | CUR=`pwd` |

68 | cd .. |

69 | SAGE_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. |

73 | echo `date -u "+%s"` > .BUILDSTART |

74 | cd "$CUR" |

75 | SAGE_LOCAL="$SAGE_ROOT/local" |

76 | SAGE_LOGS="$SAGE_ROOT/spkg/logs" |

77 | PATH="$SAGE_ROOT:$SAGE_LOCAL/bin:$PATH" |

78 | PYTHONPATH="$SAGE_LOCAL" |

79 | PKGDIR=standard |

80 | export PATH SAGE_ROOT SAGE_LOCAL SAGE_LOGS PYTHONPATH |

81 | |

82 | if [ ! -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/" |

90 | fi |

91 | |

92 | if [ ! -d "$SAGE_LOGS" ]; then |

93 | mkdir -p "$SAGE_LOGS" |

94 | fi |

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 | ############################################################################### |

104 | if [ "$SAGE_UPGRADING" = yes ] \ |

105 | || ([ -f "$SAGE_LOCAL/bin/sage-upgrade" ] && \ |

106 | ! grep SAGE_UPGRADING "$SAGE_LOCAL/bin/sage-upgrade" >/dev/null); |

107 | then |

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" |

112 | fi |

113 | |

114 | ############################################################################### |

115 | # Setup environment variables pointing to the newest versions |

116 | # of the base packages: |

117 | ############################################################################### |

118 | newest="$PKGDIR/newest_version -base " |

119 | |

120 | SAGE_BZIP2=`$newest bzip2` |

121 | export SAGE_BZIP2 |

122 | |

123 | DIR=`$newest dir` |

124 | export DIR |

125 | |

126 | PREREQ=`$newest prereq` |

127 | export PREREQ |

128 | |

129 | ############################################################################### |

130 | # Setup environment variables pointing to the newest versions |

131 | # of the standard packages: |

132 | ############################################################################### |

133 | newest="$PKGDIR/newest_version" |

134 | |

135 | ATLAS=`$newest atlas` |

136 | export ATLAS |

137 | |

138 | BLAS=`$newest blas` |

139 | export BLAS |

140 | |

141 | BOEHM_GC=`$newest boehm_gc` |

142 | export BOEHM_GC |

143 | |

144 | BOOST_CROPPED=`$newest boost-cropped` |

145 | export BOOST_CROPPED |

146 | |

147 | CEPHES=`$newest cephes` |

148 | export CEPHES |

149 | |

150 | CLIQUER=`$newest cliquer` |

151 | export CLIQUER |

152 | |

153 | CDDLIB=`$newest cddlib` |

154 | export CDDLIB |

155 | |

156 | ECL=`$newest ecl` |

157 | export ECL |

158 | |

159 | CONWAY=`$newest conway_polynomials` |

160 | if [ $? -ne 0 ]; then |

161 | echo "Error determining package name using spkg/standard/newest_version script." |

162 | exit 1 |

163 | fi |

164 | export CONWAY |

165 | |

166 | ECLIB=`$newest eclib` |

167 | export ECLIB |

168 | |

169 | ELLIPTIC_CURVES=`$newest elliptic_curves` |

170 | export ELLIPTIC_CURVES |

171 | |

172 | CVXOPT=`$newest cvxopt` |

173 | export CVXOPT |

174 | |

175 | DOCUTILS=`$newest docutils` |

176 | export DOCUTILS |

177 | |

178 | ECM=`$newest ecm` |

179 | export ECM |

180 | |

181 | EXAMPLES=`$newest examples` |

182 | export EXAMPLES |

183 | |

184 | EXTCODE=`$newest extcode` |

185 | export EXTCODE |

186 | |

187 | F2C=`$newest f2c` |

188 | export F2C |

189 | |

190 | GLPK=`$newest glpk` |

191 | export GLPK |

192 | |

193 | ICONV=`$newest iconv` |

194 | export ICONV |

195 | |

196 | ############# |

197 | # This is all for GNUtls crypto |

198 | LIBGCRYPT=`$newest libgcrypt` |

199 | export LIBGCRYPT |

200 | |

201 | OPENCDK=`$newest opencdk` |

202 | export OPENCDK |

203 | |

204 | GNUTLS=`$newest gnutls` |

205 | export GNUTLS |

206 | |

207 | LIBGPG_ERROR=`$newest libgpg_error` |

208 | export LIBGPG_ERROR |

209 | |

210 | PYGMENTS=`$newest pygments` |

211 | export PYGMENTS |

212 | |

213 | PYTHON_GNUTLS=`$newest python_gnutls` |

214 | export PYTHON_GNUTLS |

215 | ############# end gnutls crypto |

216 | |

217 | PIL=`$newest pil` |

218 | export PIL |

219 | |

220 | PATCH=`$newest patch` |

221 | export PATCH |

222 | |

223 | LIBM4RI=`$newest libm4ri` |

224 | export LIBM4RI |

225 | |

226 | FORTRAN=`$newest fortran` |

227 | export FORTRAN |

228 | |

229 | FPLLL=`$newest libfplll` |

230 | export FPLLL |

231 | |

232 | FREETYPE=`$newest freetype` |

233 | export FREETYPE |

234 | |

235 | GAP=`$newest gap` |

236 | export GAP |

237 | |

238 | G2RED=`$newest genus2reduction` |

239 | export G2RED |

240 | |

241 | GD=`$newest gd` |

242 | export GD |

243 | |

244 | GDMODULE=`$newest gdmodule` |

245 | export GDMODULE |

246 | |

247 | GFAN=`$newest gfan` |

248 | export GFAN |

249 | |

250 | GIVARO=`$newest givaro` |

251 | export GIVARO |

252 | |

253 | MPIR=`$newest mpir` |

254 | export MPIR |

255 | |

256 | GRAPHS=`$newest graphs` |

257 | export GRAPHS |

258 | |

259 | GSL=`$newest gsl` |

260 | export GSL |

261 | |

262 | IPYTHON=`$newest ipython` |

263 | export IPYTHON |

264 | |

265 | LAPACK=`$newest lapack` |

266 | export LAPACK |

267 | |

268 | LCALC=`$newest lcalc` |

269 | export LCALC |

270 | |

271 | LIBPNG=`$newest libpng` |

272 | export LIBPNG |

273 | |

274 | LINBOX=`$newest linbox` |

275 | export LINBOX |

276 | |

277 | IML=`$newest iml` |

278 | export IML |

279 | |

280 | JINJA2=`$newest jinja2` |

281 | export JINJA2 |

282 | |

283 | MATPLOTLIB=`$newest matplotlib` |

284 | export MATPLOTLIB |

285 | |

286 | MAXIMA=`$newest maxima` |

287 | export MAXIMA |

288 | |

289 | MERCURIAL=`$newest mercurial` |

290 | export MERCURIAL |

291 | |

292 | MPFI=`$newest mpfi` |

293 | export MPFI |

294 | |

295 | MOIN=`$newest moin` |

296 | export MOIN |

297 | |

298 | MPFR=`$newest mpfr` |

299 | export MPFR |

300 | |

301 | MPMATH=`$newest mpmath` |

302 | export MPMATH |

303 | |

304 | NETWORKX=`$newest networkx` |

305 | export NETWORKX |

306 | |

307 | NUMPY=`$newest numpy` |

308 | export NUMPY |

309 | |

310 | NTL=`$newest ntl` |

311 | export NTL |

312 | |

313 | #OPENSSL=`$newest openssl` |

314 | #export OPENSSL |

315 | |

316 | #PYOPENSSL=`$newest pyopenssl` |

317 | #export PYOPENSSL |

318 | |

319 | PALP=`$newest palp` |

320 | export PALP |

321 | |

322 | PARI=`$newest pari` |

323 | export PARI |

324 | |

325 | PEXPECT=`$newest pexpect` |

326 | export PEXPECT |

327 | |

328 | POLYBORI=`$newest polybori` |

329 | export POLYBORI |

330 | |

331 | PYNAC=`$newest pynac` |

332 | export PYNAC |

333 | |

334 | CYTHON=`$newest cython` |

335 | export CYTHON |

336 | |

337 | RATPOINTS=`$newest ratpoints` |

338 | export RATPOINTS |

339 | |

340 | SAGENB=`$newest sagenb` |

341 | export SAGENB |

342 | |

343 | SAGETEX=`$newest sagetex` |

344 | export SAGETEX |

345 | |

346 | SPHINX=`$newest sphinx` |

347 | export SPHINX |

348 | |

349 | SQLALCHEMY=`$newest sqlalchemy` |

350 | export SQLALCHEMY |

351 | |

352 | SQLITE=`$newest sqlite` |

353 | export SQLITE |

354 | |

355 | FLINTQS=`$newest flintqs` |

356 | export FLINTQS |

357 | |

358 | FLINT=`$newest flint` |

359 | export FLINT |

360 | |

361 | POLYTOPES_DB=`$newest polytopes_db` |

362 | export POLYTOPES_DB |

363 | |

364 | PYCRYPTO=`$newest pycrypto` |

365 | export PYCRYPTO |

366 | |

367 | PYTHON=`$newest python` |

368 | export PYTHON |

369 | |

370 | R=`$newest r` |

371 | export R |

372 | |

373 | # Needed when #9906 gets merged: |

374 | # RPY=`$newest rpy2` |

375 | # export RPY |

376 | |

377 | READLINE=`$newest readline` |

378 | export READLINE |

379 | |

380 | RUBIKS=`$newest rubiks` |

381 | export RUBIKS |

382 | |

383 | SAGE=`$newest sage` |

384 | export SAGE |

385 | |

386 | SAGE_ROOT_REPO=`$newest sage_root` |

387 | export SAGE_ROOT_REPO |

388 | |

389 | SAGE_SCRIPTS=`$newest sage_scripts` |

390 | export SAGE_SCRIPTS |

391 | |

392 | SCIPY=`$newest scipy` |

393 | export SCIPY |

394 | |

395 | SCIPY_SANDBOX=`$newest scipy_sandbox` |

396 | export SCIPY_SANDBOX |

397 | |

398 | TACHYON=`$newest tachyon` |

399 | export TACHYON |

400 | |

401 | TWISTED=`$newest twisted` |

402 | export TWISTED |

403 | |

404 | SCONS=`$newest scons` |

405 | export SCONS |

406 | |

407 | SETUPTOOLS=`$newest setuptools` |

408 | export SETUPTOOLS |

409 | |

410 | SINGULAR=`$newest singular` |

411 | export SINGULAR |

412 | |

413 | SYMPOW=`$newest sympow` |

414 | export SYMPOW |

415 | |

416 | SYMPY=`$newest sympy` |

417 | export SYMPY |

418 | |

419 | SYMMETRICA=`$newest symmetrica` |

420 | export SYMMETRICA |

421 | |

422 | TERMCAP=`$newest termcap` |

423 | export TERMCAP |

424 | |

425 | WEAVE=`$newest weave` |

426 | export WEAVE |

427 | |

428 | ZLIB=`$newest zlib` |

429 | export ZLIB |

430 | |

431 | ZODB=`$newest zodb3` |

432 | export ZODB |

433 | |

434 | ZNPOLY=`$newest zn_poly` |

435 | export 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. |

444 | if make -q -f standard/deps $1; then |

445 | echo "Nothing to (re)build / all up-to-date." |

446 | exit 0 |

447 | fi |

448 | |

449 | |

450 | # Dump environment for debugging purposes: |

451 | echo "*** ALL ENVIRONMENT VARIABLES BEFORE BUILD: ***" |

452 | env |

453 | echo "***********************************************" |

454 | |

455 | |

456 | ############################################################################### |

457 | # NOW do the actual build: |

458 | ############################################################################### |

459 | if [ "$SAGE_PARALLEL_SPKG_BUILD" = "yes" ] && [ -n "$MAKE" ]; then |

460 | time $MAKE -f standard/deps $1 |

461 | else |

462 | time make -f standard/deps $1 |

463 | fi |

464 | |

465 | # added by Burcin Erocal, see trac #6295. |

466 | if [ $? -ne 0 ]; then |

467 | echo "Error building Sage." |

468 | exit 1 |

469 | fi |

470 | |

471 | cd "$SAGE_ROOT" |

472 | |

473 | # Rename makefile to Makefile (see #10156) |

474 | if [ -f makefile ]; then |

475 | mv makefile Makefile |

476 | if [ $? -ne 0 ]; then |

477 | echo "Error renaming 'makefile' to 'Makefile'." |

478 | exit 1 |

479 | fi |

480 | fi |

481 | |

482 | # build succeeded |

483 | if [ "$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 "" |

493 | fi |

494 | |

495 | echo "Sage build/upgrade complete!" |

496 |