1 local/bin/make 000755 000314 000000 00000000000 11320004222 017537 2/usr/local/bin/gmake ustar 00peter wheel 000000 000000 local/bin/gfortran 000755 000314 000000 00000000000 11423202337 021366 2/usr/local/bin/gfortran45 ustar 00peter wheel 000000 000000 local/bin/gcc 000755 000314 000000 00000000000 11413615755 017225 2/usr/local/bin/gcc45 ustar 00peter wheel 000000 000000 local/bin/g++ 000755 000314 000000 00000000000 11413615761 016662 2/usr/local/bin/g++45 ustar 00peter wheel 000000 000000 spkg/base/sage-spkg 000755 000314 000000 00000033564 11471023065 015020 0 ustar 00peter wheel 000000 000000 #!/usr/bin/env bash
2
3 # William Stein, 2005-12-20 -- removed "m" option from tar,
4 # which was seriously confusing the build process on some
5 # (too fast?) machines, especially for mpfr.
6
7 #######################################################
8 # Install a Sage package. This script is
9 # typically invoked by giving the command
10 # sage -i <package name>
11 #
12 # A package may assume that the following environment
13 # variables are defined:
14 #
15 # SAGE_ROOT -- root directory of sage install
16 # SAGE_LOCAL -- $SAGE_ROOT/local
17 # SAGE_DATA -- $SAGE_ROOT/data
18 # LIBRARY_PATH, PYTHONPATH, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH
19 # CC, CXX, CFLAGS, CXXFLAGS, LDFLAGS, MAKE
20 #
21 # Your package script should try to build using the giving CC, CXX,
22 # CFLAGS, MAKE, etc, via a file spkg-install in your script.
23 #
24 # This script does the following:
25 #
26 # 1. Set environment variables (by calling sage-env)
27 # 2. Decompress package into a build directory
28 # 3. Run the script in the package called spkg-install
29 # 4. Return error 1 if anything goes wrong.
30 #
31 #######################################################
32
33 mymkdir()
34 {
35 if [ ! -d $1 ]; then
36 mkdir $1
37 fi
38 }
39
40 no_version()
41 {
42 if [ -z "`echo "$1" | grep -`" ]; then
43 echo "no version"
44 fi
45 }
46 # The following sets environment variables for building
47 # packages. (Using dot suggested by W. Cheung.)
48
49 . "$SAGE_ROOT/local/bin/sage-env"
50
51 cd "$SAGE_PACKAGES"
52
53 if [ $# -eq 0 ]; then
54 echo "Currently installed packages:"
55 /bin/ls -1 "$SAGE_PACKAGES/installed/"
56 exit 0
57 fi
58
59
60 cd "$SAGE_PACKAGES"
61 mymkdir "$BUILD"
62 mymkdir installed
63 cd "$BUILD"
64 mymkdir old
65
66 # the following two options are mutually exclusive -- i.e., you
67 # can give only one.
68
69 INFO=0
70 if [ $1 = '-info' ]; then
71 INFO=1
72 shift
73 fi
74
75 FORCE=0
76 if [ $1 = '-f' ]; then
77 FORCE=1
78 shift
79 fi
80 export FORCE
81
82 DELETE_TMP=0
83 if [ $1 = '-s' -o $1 = '-m' ]; then
84 DELETE_TMP=0
85 shift
86 fi
87
88 INSTALLED="$SAGE_PACKAGES/installed/"
89 PKG_NAME=`echo "$1" | sed -e "s/\.spkg$//"`
90 PKG_NAME=`basename "$PKG_NAME"`
91 PKG_SRC="$1"
92 PKG_BASE=`echo "$PKG_NAME" | sed -e "s/-.*//"`
93
94 # check if noclobber is set and warn about it
95 if [ $PKG_SRC == "noclobber" ]; then
96 echo "***********************************************************"
97 echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
98 echo "* *"
99 echo "* noclobber is set in .bashrc and/or .bash_profile - you *"
100 echo "* should consider disabling it. The Sage install should *"
101 echo "* continue to work, so don't worry about it too much. *"
102 echo "* *"
103 echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
104 echo "***********************************************************"
105 exit 0
106 fi
107
108 if [ ! -f "$PKG_SRC" ]; then
109 if [ -f "$SAGE_PACKAGES/standard/$PKG_NAME.spkg" ]; then
110 PKG_SRC="$SAGE_PACKAGES/standard/$PKG_NAME.spkg"
111 else
112 if [ -f "$SAGE_PACKAGES/optional/$PKG_NAME.spkg" ]; then
113 PKG_SRC="$SAGE_PACKAGES/optional/$PKG_NAME.spkg"
114 else
115 CUR=`pwd`
116 cd "$SAGE_PACKAGES"
117 PKG_NEWEST_VER=`./standard/newest_version "$PKG_NAME" 2> /dev/null`
118 if [ -n "$PKG_NEWEST_VER" ]; then
119 PKG_SRC="$SAGE_PACKAGES/standard/$PKG_NEWEST_VER.spkg"
120 else
121 PKG_NEWEST_VER=`./standard/newest_version -base "$PKG_NAME" 2> /dev/null`
122 if [ -n "$PKG_NEWEST_VER" ]; then
123 PKG_SRC="$SAGE_PACKAGES/standard/$PKG_NEWEST_VER.spkg"
124 fi
125 fi
126 fi
127 fi
128 fi
129
130 # Don't verbosely extract files from spkgs by default (#10040):
131
132 if [ "$SAGE_SPKG_LIST_FILES" = "yes" ]; then
133 UNTAR_VERBOSE=v
134 else
135 unset UNTAR_VERBOSE
136 fi
137
138 if [ $INFO -ne 0 ]; then
139 if [ ! -f "$PKG_SRC" ]; then
140 echo "Package $PKG_NAME not found"
141 fi
142 bunzip2 -c "$PKG_SRC" 2>/dev/null | tar Ofx${UNTAR_VERBOSE} - $PKG_NAME/SAGE.txt 2>/dev/null
143 if [ $? -ne 0 ]; then
144 tar Ofx${UNTAR_VERBOSE} "$PKG_SRC" "$PKG_NAME/SAGE.txt" 2>/dev/null
145 fi
146 echo ""
147 if [ $? -ne 0 ]; then
148 echo "No file SAGE.txt in $PKG_NAME"
149 exit 1
150 fi
151 exit 0
152 fi
153
154 echo "$PKG_NAME"
155
156 echo "Machine:"
157 uname -a
158
159 if [ -f "$INSTALLED/$PKG_NAME" -a $FORCE -eq 0 ]; then
160 echo "sage: $1 is already installed"
161 touch "$INSTALLED/$PKG_NAME"
162 exit 0
163 fi
164
165 cd "$SAGE_PACKAGES/build"
166
167 if [ $DELETE_TMP -eq 1 ]; then
168 echo "Deleting directories from past builds of previous/current versions of $PKG_NAME"
169 # Make triply sure that we are in the build directory before doing
170 # a scary "rm -rf".
171 cd "$SAGE_PACKAGES/build"
172 if [ $? -ne 0 ]; then
173 echo "Unable to find build directory."
174 else
175 rm -rf "$PKG_BASE-"*
176 fi
177 else
178 echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
179 mv -f "$PKG_BASE-"* old/ 2>/dev/null
180 fi
181
182 if [ ! -f "$PKG_SRC" ]; then
183
184 echo "$0: file $PKG_NAME does not exist"
185 echo "Attempting to download it."
186 CUR=`pwd`
187 cd "$SAGE_PACKAGES"
188 if [ ! -d optional ]; then
189 mkdir optional
190 fi
191 cd optional
192
193 FOUND_VERSION=''
194 if [ -n "`no_version "$PKG_NAME"`" ]; then
195 echo "Searching for latest version of $PKG_NAME"
196 PKG_NAME=`sage-latest-online-package "$PKG_NAME"`
197 if [ $? -eq 0 ]; then
198 echo "Found package $PKG_NAME"
199 FOUND_VERSION='1'
200 else
201 echo "$PKG_NAME"
202 exit 1
203 fi
204 fi
205
206 # See trac ticket #7544. One should be able to install a package using
207 # sage -i <package-name> where <package-name> can be any of the
208 # following values:
209 #
210 # 1. <package>-x.y.z, i.e. the name of the package plus the package's
211 # version numbers.
212 # 2. the full name <package>-x.y.z.spkg, i.e. the name of the package in
213 # addition to the version numbers and the ".spkg" extension.
214 # 3. <URL>/<package>-x.y.z.spkg, i.e. the full URL where the package is
215 # hosted. This can be a URL on the Sage website or somewhere else.
216 # 4. /path/to/<package>-x.y.z.spkg, i.e. the package is found somewhere
217 # in your file system and you're giving an absolute or relative path
218 # to the package.
219 #
220 # See trac ticket #8043. If no version was specified but a version
221 # was found above, then $PKG_NAME now contains the version number.
222 # Download this, since it's a known Sage package. Otherwise,
223 # download the package specified by $1, since it either already
224 # contains the version number or is a URL.
225 if [ "x$FOUND_VERSION" = "x" ]; then
226 sage-download_package "$1"
227 else
228 sage-download_package "$PKG_NAME"
229 fi
230 if [ ! -f "$PKG_NAME.spkg" ]; then
231 echo "sage: Failed to download package $PKG_NAME from $SAGE_SERVER"
232 exit 1
233 fi
234 PKG_SRC="`pwd`/$PKG_NAME.spkg"
235 cd "$CUR"
236 fi
237
238 # * The -i option below to ignore checksum errors, since
239 # I've had problems with this on Solaris.
240 # * The m option avoids clock skew problems.
241
242 echo "Extracting package $PKG_SRC ..."
243 ls -l "$PKG_SRC"
244
245 if [ -d "$PKG_NAME" ]; then
246 echo "Removing previous version."
247 rm -rf "$PKG_NAME"
248 fi
249
250 bunzip2 -c "$PKG_SRC" 2>/dev/null | tar fx${UNTAR_VERBOSE} - 2>/dev/null
251 if [ ! -d "$PKG_NAME" ]; then
252 tar fx${UNTAR_VERBOSE} "$PKG_SRC"
253 fi
254 echo "Finished extraction"
255
256 if [ ! -d "$PKG_NAME" ]; then
257 echo "sage: After decompressing the directory $PKG_NAME does not exist"
258 echo "This means that the corresponding .spkg needs to be downloaded"
259 echo "again."
260 if [ -n "`no_version "$PKG_NAME"`" ]; then
261 echo "Searching for latest version of $PKG_NAME"
262 PKG_NAME=`sage-latest-online-package "$PKG_NAME"`
263 if [ $? -eq 0 ]; then
264 echo "Found package $PKG_NAME"
265 else
266 echo "$PKG_NAME"
267 exit 1
268 fi
269 fi
270 sage-download_package "$PKG_NAME"
271 echo `pwd`
272 bunzip2 -c "$PKG_NAME.spkg" | tar fx${UNTAR_VERBOSE} -
273 if [ ! -d "$PKG_NAME.spkg" ]; then
274 tar fx${UNTAR_VERBOSE} "$PKG_NAME.spkg"
275 fi
276 if [ ! -d "$PKG_NAME" ]; then
277 echo "Second download resulted in a corrupted package."
278 exit 1
279 fi
280 fi
281
282 if [ -f "$SAGE_PACKAGES/patches/$PKG_NAME.patch" ]; then
283 echo "Applying local patches for $PKG_NAME"
284 if ! patch -p0 < "$SAGE_PACKAGES/patches/$PKG_NAME.patch"; then
285 echo "Patching failed"
286 exit 1
287 fi
288 fi
289
290 cd "$PKG_NAME"
291 if [ ! -f spkg-install ]; then
292 echo "#!/usr/bin/env bash" > spkg-install
293 echo "" >> spkg-install
294 if [ -f setup.py ]; then
295 echo "python setup.py install" >> spkg-install
296 else
297 if [ -f configure ]; then
298 echo "./configure --prefix=\$SAGE_ROOT/local/" >> spkg-install
299 echo "make" >> spkg-install
300 echo "make install" >> spkg-install
301 else
302 echo "There is no spkg-install script, no setup.py, and no configure script,"
303 echo "so I do not know how to install $PKG_SRC."
304 exit 1
305 fi
306 fi
307 fi
308
309 chmod +x spkg-install
310
311 # this is just wrong... (so don't do it)
312 #echo "TOUCHING"
313 #touch * */* */*/* */*/*/* 1>/dev/null 2>/dev/null
314
315 echo "****************************************************"
316 echo "Host system"
317 echo "uname -a:"
318 uname -a
319 if [ $? -ne 0 ]; then
320 echo "Unable to determine host system information."
321 fi
322 echo "****************************************************"
323
324 echo "****************************************************"
325 echo "CC Version"
326 echo "$CC -v"
327 $CC -v
328 if [ $? -ne 0 ]; then
329 echo "Unable to determine C compiler version."
330 fi
331 echo "****************************************************"
332
333
334 ##################################################################
335 # If spkg-install is a Python script, verify that the Sage Python
336 # has already been installed.
337 ##################################################################
338 # Check the first line of the file for the string "python".
339 head -1 spkg-install | grep python > /dev/null
340 if [ $? -eq 0 ]; then # if it is found, then the exit code will be 0
341 if [ ! -f "$SAGE_LOCAL"/bin/python ]; then # now check if the python program is in local/bin/
342 # if so, exit with an error.
343 echo "The spkg-install script depends on the Sage Python package,"
344 echo "but the Sage Python package is not yet installed. This may be"
345 echo "a bug in the Sage build system dependency file. Please"
346 echo "update the $SAGE_ROOT/spkg/standard/deps makefile."
347 exit 1
348 fi
349 fi
350
351 BASEDIR=`pwd`
352 if [ -n "$DEBIAN_RELEASE" ]; then
353 SAGE_CHECK=''
354 if [ -e ./spkg-debian ]; then
355 time ./spkg-debian
356 else
357 time sage-build-debian $BASEDIR
358 fi
359 else
360 time ./spkg-install
361 fi
362
363 if [ $? -eq 0 ]; then
364 cd $INSTALLED
365 # TURNED OFF: Remove all old packages with the same name up to the first "-":
366 # rm -f $PKG_BASE-*
367
368 # Mark that the new package has been installed.
369 # This file will eventually be a certificate like in OS X.
370 echo "PACKAGE NAME: $PKG_NAME" > "$PKG_NAME"
371 echo "INSTALL DATE: `date`" >> "$PKG_NAME"
372 echo "UNAME: `uname -a`" >> "$PKG_NAME"
373 echo "Sage VERSION: `grep Sage $SAGE_LOCAL/bin/sage-banner`" >> "$PKG_NAME"
374 echo "Successfully installed $PKG_NAME"
375
376 cd $BASEDIR
377 if [ "$SAGE_CHECK" != "" -a -f spkg-check ]; then
378 echo "Running the test suite."
379 chmod +x spkg-check
380 ./spkg-check
381 if [ $? -ne 0 ]; then
382 echo "*************************************"
383 echo "Error testing package ** $PKG_NAME **"
384 echo "*************************************"
385 rm -f $SAGE_ROOT/spkg/installed/$PKG_NAME
386 echo "sage: An error occurred while testing $PKG_NAME"
387 echo "Please email sage-devel http://groups.google.com/group/sage-devel"
388 echo "explaining the problem and send the relevant part of"
389 echo "of $SAGE_ROOT/install.log. Describe your computer, operating system, etc."
390 echo "If you want to try to fix the problem yourself, *don't* just cd to"
391 echo "`pwd` and type 'make check' or whatever is appropriate."
392 echo "Instead, the following commands setup all environment variables"
393 echo "correctly and load a subshell for you to debug the error:"
394 echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)"
395 echo "When you are done debugging, you can type \"exit\" to leave the"
396 echo "subshell."
397 exit 1
398 else
399 echo "TEST SUITE: passed" >> "$PKG_NAME"
400 fi
401 fi
402
403
404 # Delete the temporary build directory if required.
405 if [ $DELETE_TMP -eq 1 ]; then
406 echo "Now cleaning up tmp files."
407 if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
408 # the if is there only to avoid the possibility of a weird bug.
409 cd "$SAGE_PACKAGES/build/"
410 rm -rf "$SAGE_PACKAGES/build/$PKG_NAME"
411 fi
412 else
413 echo "You can safely delete the temporary build directory"
414 echo "$SAGE_PACKAGES/build/$PKG_NAME"
415 fi
416
417 else
418 echo "sage: An error occurred while installing $PKG_NAME"
419 echo "Please email sage-devel http://groups.google.com/group/sage-devel"
420 echo "explaining the problem and send the relevant part of"
421 echo "of $SAGE_ROOT/install.log. Describe your computer, operating system, etc."
422 echo "If you want to try to fix the problem yourself, *don't* just cd to"
423 echo "`pwd` and type 'make check' or whatever is appropriate."
424 echo "Instead, the following commands setup all environment variables"
425 echo "correctly and load a subshell for you to debug the error:"
426 echo "(cd '`pwd`' && '$SAGE_ROOT/sage' -sh)"
427 echo "When you are done debugging, you can type \"exit\" to leave the"
428 echo "subshell."
429 exit 1
430 fi
431
432
433 echo "Making Sage/Python scripts relocatable..."
434
435 cd "$SAGE_LOCAL"/bin
436 ./sage-make_relative
437
438 echo "Finished installing $PKG_NAME.spkg"
439
440 # It's OK if the above fails -- in fact it will until Python
441 # itself gets installed. That's fine.
442 exit 0
443