1 local/bin/sh 000755 001752 001752 00000000000 11226071440 017141 2/usr/local/bin/bash ustar 00peter peter 000000 000000 local/bin/make 000755 001752 001752 00000000000 11226071440 017613 2/usr/local/bin/gmake ustar 00peter peter 000000 000000 local/bin/gfortran 000755 001752 001752 00000000000 11236642376 021442 2/usr/local/bin/gfortran43 ustar 00peter peter 000000 000000 local/bin/gcc 000755 001752 001752 00000000000 11226071440 017251 2/usr/local/bin/gcc43 ustar 00peter peter 000000 000000 local/bin/g++ 000755 001752 001752 00000000000 11226071440 016711 2/usr/local/bin/g++43 ustar 00peter peter 000000 000000 spkg/base/sage-spkg 000755 001752 001752 00000024071 11226076675 015067 0 ustar 00peter peter 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 # The following sets environment variables for building
41 # packages. (Using dot suggested by W. Cheung.)
42
43 . "$SAGE_ROOT/local/bin/sage-env"
44
45 cd "$SAGE_PACKAGES"
46
47 if [ $# -eq 0 ]; then
48 echo "Currently installed packages:"
49 /bin/ls -1 "$SAGE_PACKAGES/installed/"
50 exit 0
51 fi
52
53
54 cd "$SAGE_PACKAGES"
55 mymkdir "$BUILD"
56 mymkdir installed
57 cd "$BUILD"
58 mymkdir old
59
60 # the following two options are mutually exclusive -- i.e., you
61 # can give only one.
62
63 INFO=0
64 if [ $1 = '-info' ]; then
65 INFO=1
66 shift
67 fi
68
69 FORCE=0
70 if [ $1 = '-f' ]; then
71 FORCE=1
72 shift
73 fi
74 export FORCE
75
76 DELETE_TMP=1
77 if [ $1 = '-s' -o $1 = '-m' ]; then
78 DELETE_TMP=0
79 shift
80 fi
81
82 INSTALLED="$SAGE_PACKAGES/installed/"
83 PKG_NAME=`echo "$1" | sed -e "s/\.spkg$//"`
84 PKG_NAME=`basename "$PKG_NAME"`
85 PKG_SRC="$1"
86 PKG_BASE=`echo "$PKG_NAME" | sed -e "s/-.*//"`
87 # check if noclobber is set and warn about it
88 if [ $PKG_SRC == "noclobber" ]; then
89 echo "***********************************************************"
90 echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
91 echo "* *"
92 echo "* noclobber is set in .bashrc and/or .bash_profile - you *"
93 echo "* should consider disabling it. The Sage install should *"
94 echo "* continue to work, so don't worry about it too much. *"
95 echo "* *"
96 echo "* WARNING WARNING WARNING WARNING WARNING WARNING WARNING *"
97 echo "***********************************************************"
98 exit 0
99 fi
100
101 if [ ! -f "$PKG_SRC" ]; then
102 if [ -f "$SAGE_PACKAGES/standard/$PKG_NAME.spkg" ]; then
103 PKG_SRC="$SAGE_PACKAGES/standard/$PKG_NAME.spkg"
104 else
105 if [ -f "$SAGE_PACKAGES/optional/$PKG_NAME.spkg" ]; then
106 PKG_SRC="$SAGE_PACKAGES/optional/$PKG_NAME.spkg"
107 fi
108 fi
109 fi
110
111 if [ $INFO -ne 0 ]; then
112 if [ ! -f "$PKG_SRC" ]; then
113 echo "Package $PKG_NAME not found"
114 fi
115 bunzip2 -c "$PKG_SRC" 2>/dev/null | tar Ofx - $PKG_NAME/SAGE.txt 2>/dev/null
116 if [ $? -ne 0 ]; then
117 tar Ofx "$PKG_SRC" "$PKG_NAME/SAGE.txt" 2>/dev/null
118 fi
119 echo ""
120 if [ $? -ne 0 ]; then
121 echo "No file SAGE.txt in $PKG_NAME"
122 exit 1
123 fi
124 exit 0
125 fi
126
127 echo "$PKG_NAME"
128
129 echo "Machine:"
130 uname -a
131
132 if [ -f "$INSTALLED/$PKG_NAME" -a $FORCE -eq 0 ]; then
133 echo "sage: $1 is already installed"
134 touch "$INSTALLED/$PKG_NAME"
135 exit 0
136 fi
137
138 cd "$SAGE_PACKAGES/build"
139
140 if [ $DELETE_TMP -eq 1 ]; then
141 echo "Deleting directories from past builds of previous/current versions of $PKG_NAME"
142 # Make triply sure that we are in the build directory before doing
143 # a scary "rm -rf".
144 cd "$SAGE_PACKAGES/build"
145 if [ $? -ne 0 ]; then
146 echo "Unable to find build directory."
147 else
148 rm -rf "$PKG_BASE-"*
149 fi
150 else
151 echo "Moving directories from past builds of previous/current versions of $PKG_NAME to build/old"
152 mv -f "$PKG_BASE-"* old/ 2>/dev/null
153 fi
154
155 if [ ! -f "$PKG_SRC" ]; then
156
157 echo "$0: file $PKG_NAME does not exist"
158 echo "Attempting to download it."
159 CUR=`pwd`
160 cd "$SAGE_PACKAGES"
161 if [ ! -d optional ]; then
162 $MKDIR optional
163 fi
164 cd optional
165 sage-download_package "$1"
166 if [ ! -f "$PKG_NAME.spkg" ]; then
167 echo "sage: Failed to download package $PKG_NAME from $SAGE_SERVER"
168 exit 1
169 fi
170 PKG_SRC="`pwd`/$PKG_NAME.spkg"
171 cd "$CUR"
172 fi
173
174 # * The -i option below to ignore checksum errors, since
175 # I've had problems with this on Solaris.
176 # * The m option avoids clock skew problems.
177
178 echo "Extracting package $PKG_SRC ..."
179 ls -l "$PKG_SRC"
180
181 if [ -d "$PKG_NAME" ]; then
182 echo "Removing previous version."
183 rm -rf "$PKG_NAME"
184 fi
185
186 bunzip2 -c "$PKG_SRC" 2>/dev/null | tar fxv - 2>/dev/null
187 if [ ! -d "$PKG_NAME" ]; then
188 tar fxv "$PKG_SRC"
189 fi
190 echo "Finished extraction"
191
192 if [ ! -d "$PKG_NAME" ]; then
193 echo "sage: After decompressing the directory $PKG_NAME does not exist"
194 echo "This means that the corresponding .spkg needs to be downloaded"
195 echo "again."
196 sage-download_package "$PKG_NAME"
197 echo `pwd`
198 bunzip2 -c "$PKG_NAME.spkg" | tar fxv -
199 if [ ! -d "$PKG_NAME.spkg" ]; then
200 tar fxv "$PKG_NAME.spkg"
201 fi
202 if [ ! -d "$PKG_NAME" ]; then
203 echo "Second download resulted in a corrupted package."
204 exit 1
205 fi
206 fi
207
208 if [ -f "$SAGE_PACKAGES/patches/$PKG_NAME.patch" ]; then
209 echo "Applying local patches for $PKG_NAME"
210 if ! patch -p0 < "$SAGE_PACKAGES/patches/$PKG_NAME.patch"; then
211 echo "Patching failed"
212 exit 1
213 fi
214 fi
215
216 cd "$PKG_NAME"
217 if [ ! -f spkg-install ]; then
218 echo "#!/usr/bin/env bash" > spkg-install
219 echo "" >> spkg-install
220 if [ -f setup.py ]; then
221 echo "python setup.py install" >> spkg-install
222 else
223 if [ -f configure ]; then
224 echo "./configure --prefix=\$SAGE_ROOT/local/" >> spkg-install
225 echo "make" >> spkg-install
226 echo "make install" >> spkg-install
227 else
228 echo "There is no spkg-install script, no setup.py, and no configure script,"
229 echo "so I do not know how to install $PKG_SRC."
230 exit 1
231 fi
232 fi
233 fi
234
235 chmod +x spkg-install
236
237 # this is just wrong... (so don't do it)
238 #echo "TOUCHING"
239 #touch * */* */*/* */*/*/* 1>/dev/null 2>/dev/null
240
241 echo "****************************************************"
242 echo "Host system"
243 echo "uname -a:"
244 uname -a
245 if [ $? -ne 0 ]; then
246 echo "Unable to determine host system information."
247 fi
248 echo "****************************************************"
249
250 echo "****************************************************"
251 echo "GCC Version"
252 echo "gcc -v"
253 gcc -v
254 if [ $? -ne 0 ]; then
255 echo "Unable to determine gcc version."
256 fi
257 echo "****************************************************"
258
259 BASEDIR=`pwd`
260 if [ -n "$DEBIAN_RELEASE" ]; then
261 SAGE_CHECK=''
262 if [ -e ./spkg-debian ]; then
263 time ./spkg-debian
264 else
265 time sage-build-debian $BASEDIR
266 fi
267 else
268 time ./spkg-install
269 fi
270
271 if [ $? -eq 0 ]; then
272 cd $INSTALLED
273 # TURNED OFF: Remove all old packages with the same name up to the first "-":
274 # rm -f $PKG_BASE-*
275
276 # Mark that the new package has been installed.
277 # This file will eventually be a certificate like in OS X.
278 echo "PACKAGE NAME: $PKG_NAME" > "$PKG_NAME"
279 echo "INSTALL DATE: `date`" >> "$PKG_NAME"
280 echo "UNAME: `uname -a`" >> "$PKG_NAME"
281 echo "Sage VERSION: `grep Sage $SAGE_LOCAL/bin/sage-banner`" >> "$PKG_NAME"
282 echo "Successfully installed $PKG_NAME"
283
284 cd $BASEDIR
285 if [ "$SAGE_CHECK" != "" -a -f spkg-check ]; then
286 echo "Running the test suite."
287 chmod +x spkg-check
288 ./spkg-check
289 if [ $? -ne 0 ]; then
290 echo "*************************************"
291 echo "Error testing package ** $PKG_NAME **"
292 echo "*************************************"
293 rm -f $SAGE_ROOT/spkg/installed/$PKG_NAME
294 echo "sage: An error occurred while testing $PKG_NAME"
295 echo "Please email sage-devel http://groups.google.com/group/sage-devel"
296 echo "explaining the problem and send the relevant part of"
297 echo "of $SAGE_ROOT/install.log. Describe your computer, operating system, etc."
298 echo "If you want to try to fix the problem, yourself *don't* just cd to"
299 echo "`pwd` and type 'make check' or whatever is appropriate."
300 echo "Instead type \"$SAGE_ROOT/sage -sh\""
301 echo "in order to set all environment variables correctly, then cd to"
302 echo "`pwd`"
303 echo "(When you are done debugging, you can type \"exit\" to leave the"
304 echo "subshell.)"
305 exit 1
306 else
307 echo "TEST SUITE: passed" >> "$PKG_NAME"
308 fi
309 fi
310
311
312 # Delete the temporary build directory if required.
313 if [ $DELETE_TMP -eq 1 ]; then
314 echo "Now cleaning up tmp files."
315 if [ -d "$SAGE_PACKAGES/build/$PKG_NAME" ]; then
316 # the if is there only to avoid the possibility of a weird bug.
317 rm -rf "$SAGE_PACKAGES/build/$PKG_NAME"
318 fi
319 else
320 echo "You can safely delete the temporary build directory"
321 echo "$SAGE_PACKAGES/build/$PKG_NAME"
322 fi
323
324 else
325
326 echo "sage: An error occurred while installing $PKG_NAME"
327 echo "Please email sage-devel http://groups.google.com/group/sage-devel"
328 echo "explaining the problem and send the relevant part of"
329 echo "of $SAGE_ROOT/install.log. Describe your computer, operating system, etc."
330 echo "If you want to try to fix the problem, yourself *don't* just cd to"
331 echo "`pwd` and type 'make'."
332 echo "Instead type \"$SAGE_ROOT/sage -sh\""
333 echo "in order to set all environment variables correctly, then cd to"
334 echo "`pwd`"
335 echo "(When you are done debugging, you can type \"exit\" to leave the"
336 echo "subshell.)"
337 exit 1
338 fi
339
340
341 echo "Making Sage/Python scripts relocatable..."
342
343 cd "$SAGE_LOCAL"/bin
344 ./sage-make_relative
345
346 echo "Finished installing $PKG_NAME.spkg"
347
348 # It's OK if they above fails -- in fact it will until Python
349 # itself gets installed. That's fine.
350 exit 0
351