@@ -212,6 +212,7 @@ BOOL_OPTIONS=""
212
212
VAL_OPTIONS=" "
213
213
214
214
flag uninstall " only uninstall from the installation prefix"
215
+ opt verify 1 " verify that the installed binaries run correctly"
215
216
valopt prefix " /usr/local" " set installation prefix"
216
217
# NB This isn't quite the same definition as in `configure`.
217
218
# just using 'lib' instead of CFG_LIBDIR_RELATIVE
@@ -230,19 +231,36 @@ validate_opt
230
231
231
232
# OK, let's get installing ...
232
233
234
+ # Sanity check: can we run the binaries?
235
+ if [ -z " ${CFG_DISABLE_VERIFY} " ]
236
+ then
237
+ # Don't do this if uninstalling. Failure here won't help in any way.
238
+ if [ -z " ${CFG_UNINSTALL} " ]
239
+ then
240
+ msg " verifying platform can run binaries"
241
+ " ${CFG_SRC_DIR} /bin/rustc" --version > /dev/null
242
+ if [ $? -ne 0 ]
243
+ then
244
+ err " can't execute rustc binary on this platform"
245
+ fi
246
+ fi
247
+ fi
248
+
233
249
# Sanity check: can we can write to the destination?
250
+ msg " verifying destination is writable"
234
251
umask 022 && mkdir -p " ${CFG_LIBDIR} "
235
- need_ok " can't write to destination. consider ' sudo' ."
236
- touch " ${CFG_LIBDIR} /rust-install-probe" 2 > /dev/null
252
+ need_ok " can't write to destination. consider \` sudo\` ."
253
+ touch " ${CFG_LIBDIR} /rust-install-probe" > /dev/null
237
254
if [ $? -ne 0 ]
238
255
then
239
- err " can't write to destination. consider ' sudo' ."
256
+ err " can't write to destination. consider \` sudo\` ."
240
257
fi
241
258
rm " ${CFG_LIBDIR} /rust-install-probe"
242
259
need_ok " failed to remove install probe"
243
260
244
261
# Sanity check: don't install to the directory containing the installer.
245
262
# That would surely cause chaos.
263
+ msg " verifying destination is not the same as source"
246
264
INSTALLER_DIR=" $( cd $( dirname $0 ) && pwd) "
247
265
PREFIX_DIR=" $( cd ${CFG_PREFIX} && pwd) "
248
266
if [ " ${INSTALLER_DIR} " = " ${PREFIX_DIR} " ]
@@ -273,6 +291,10 @@ then
273
291
fi
274
292
done < " ${INSTALLED_MANIFEST} "
275
293
294
+ # TODO: Remove the manifest.
295
+ # If we fail to remove rustlib below, then the installed manifest will
296
+ # still be full; the installed manifest needs to be empty before install.
297
+
276
298
# Remove 'rustlib' directory
277
299
rm -r " ${CFG_LIBDIR} /rustlib"
278
300
if [ $? -ne 0 ]
@@ -346,6 +368,20 @@ while read p; do
346
368
# The manifest lists all files to install
347
369
done < " ${CFG_SRC_DIR} /lib/rustlib/manifest.in"
348
370
371
+ # Sanity check: can we run the installed binaries?
372
+ if [ -z " ${CFG_DISABLE_VERIFY} " ]
373
+ then
374
+ msg " verifying installed binaries are executable"
375
+ " ${CFG_PREFIX} /bin/rustc" --version > /dev/null
376
+ if [ $? -ne 0 ]
377
+ then
378
+ err " can't execute installed rustc binary. installation may be broken. " \
379
+ " if this is expected then rerun install.sh with \` --disable-verify\` " \
380
+ " or \` make install\` with \` --disable-verify-install\` "
381
+ fi
382
+ fi
383
+
384
+
349
385
echo
350
386
echo " Rust is ready to roll."
351
387
echo
0 commit comments