@@ -213,6 +213,10 @@ VAL_OPTIONS=""
213213
214214flag uninstall " only uninstall from the installation prefix"
215215valopt prefix " /usr/local" " set installation prefix"
216+ # NB This isn't quite the same definition as in `configure`.
217+ # just using 'lib' instead of CFG_LIBDIR_RELATIVE
218+ valopt libdir " ${CFG_PREFIX} /lib" " install libraries"
219+ valopt mandir " ${CFG_PREFIX} /share/man" " install man pages in PATH"
216220
217221if [ $HELP -eq 1 ]
218222then
@@ -224,47 +228,48 @@ step_msg "validating $CFG_SELF args"
224228validate_opt
225229
226230# Sanity check: can we can write to the destination?
227- umask 022 && mkdir -p " ${CFG_PREFIX} /lib "
231+ umask 022 && mkdir -p " ${CFG_LIBDIR} "
228232need_ok " directory creation failed"
229- touch " ${CFG_PREFIX} /lib /rust-install-probe" 2> /dev/null
233+ touch " ${CFG_LIBDIR} /rust-install-probe" 2> /dev/null
230234if [ $? -ne 0 ]
231235then
232236 err " can't write to destination. try again with 'sudo'."
233237fi
234- rm " ${CFG_PREFIX} /lib /rust-install-probe"
238+ rm " ${CFG_LIBDIR} /rust-install-probe"
235239need_ok " failed to remove install probe"
236240
241+ INSTALLED_MANIFEST=" ${CFG_LIBDIR} /rustlib/manifest"
237242
238243# First, uninstall from the installation prefix.
239244# Errors are warnings - try to rm everything in the manifest even if some fail.
240- if [ -f " ${CFG_PREFIX} /lib/rustlib/manifest " ]
245+ if [ -f " ${INSTALLED_MANIFEST} " ]
241246then
242247 # Iterate through installed manifest and remove files
243248 while read p; do
244- msg " removing ${CFG_PREFIX} /$p "
245- if [ -f " ${CFG_PREFIX} /$p " ]
249+ # The installed manifest contains absolute paths
250+ msg " removing $p "
251+ if [ -f " $p " ]
246252 then
247- rm " ${CFG_PREFIX} / $ p"
253+ rm " $p "
248254 if [ $? -ne 0 ]
249255 then
250- warn " failed to remove ${CFG_PREFIX} / $ p"
256+ warn " failed to remove $p "
251257 fi
252258 else
253- warn " supposedly installed file ${CFG_PREFIX} / $ p does not exist!"
259+ warn " supposedly installed file $p does not exist!"
254260 fi
255- done < " ${CFG_PREFIX} /lib/rustlib/manifest "
261+ done < " ${INSTALLED_MANIFEST} "
256262
257263 # Remove 'rustlib' directory
258- msg " removing ${CFG_PREFIX} /lib/rustlib"
259- rm -r " ${CFG_PREFIX} /lib/rustlib"
264+ rm -r " ${CFG_LIBDIR} /rustlib"
260265 if [ $? -ne 0 ]
261266 then
262267 warn " failed to remove rustlib"
263268 fi
264269else
265270 if [ -n " ${CFG_UNINSTALL} " ]
266271 then
267- err " unable to find installation manifest at ${CFG_PREFIX} /lib /rustlib"
272+ err " unable to find installation manifest at ${CFG_LIBDIR} /rustlib"
268273 fi
269274fi
270275
@@ -277,22 +282,53 @@ then
277282 exit 0
278283fi
279284
285+ # Create the installed manifest, which we will fill in with absolute file paths
286+ mkdir -p " ${CFG_LIBDIR} /rustlib"
287+ touch " ${INSTALLED_MANIFEST} "
280288
281289# Now install, iterate through the new manifest and copy files
282290while read p; do
283291
284- umask 022 && mkdir -p " ${CFG_PREFIX} /$( dirname $p ) "
292+ # Decide the destination of the file
293+ FILE_INSTALL_PATH=" ${CFG_PREFIX} /$p "
294+
295+ if echo " $p " | grep " ^lib/" > /dev/null
296+ then
297+ pp=` echo $p | sed ' s/^lib\///' `
298+ FILE_INSTALL_PATH=" ${CFG_LIBDIR} /$pp "
299+ fi
300+
301+ if echo " $p " | grep " ^share/man/" > /dev/null
302+ then
303+ pp=` echo $p | sed ' s/^share\/man\///' `
304+ FILE_INSTALL_PATH=" ${CFG_MANDIR} /$pp "
305+ fi
306+
307+ # Make sure ther's a directory for it
308+ umask 022 && mkdir -p " $( dirname ${FILE_INSTALL_PATH} ) "
285309 need_ok " directory creation failed"
286310
287- msg " ${CFG_PREFIX} /$p "
288- if echo " $p " | grep " /bin/" > /dev/null
311+ # Make the path absolute so we can uninstall it later without
312+ # starting from the installation cwd
313+ FILE_INSTALL_PATH_DIRNAME=" $( dirname ${FILE_INSTALL_PATH} ) "
314+ FILE_INSTALL_PATH_BASENAME=" $( basename ${FILE_INSTALL_PATH} ) "
315+ FILE_INSTALL_ABS_PATH=" $( cd ${FILE_INSTALL_PATH_DIRNAME} && pwd) "
316+ FILE_INSTALL_PATH=" ${FILE_INSTALL_ABS_PATH} /${FILE_INSTALL_PATH_BASENAME} "
317+
318+ # Install the file
319+ msg " ${FILE_INSTALL_PATH} "
320+ if echo " $p " | grep " ^bin/" > /dev/null
289321 then
290- install -m755 " ${CFG_SRC_DIR} /$p " " ${CFG_PREFIX} / $p "
322+ install -m755 " ${CFG_SRC_DIR} /$p " " ${FILE_INSTALL_PATH} "
291323 else
292- install -m644 " ${CFG_SRC_DIR} /$p " " ${CFG_PREFIX} / $p "
324+ install -m644 " ${CFG_SRC_DIR} /$p " " ${FILE_INSTALL_PATH} "
293325 fi
294326 need_ok " file creation failed"
295327
328+ # Update the manifest
329+ echo " ${FILE_INSTALL_PATH} " >> " ${INSTALLED_MANIFEST} "
330+ need_ok " failed to update manifest"
331+
296332# The manifest lists all files to install
297333done < " ${CFG_SRC_DIR} /lib/rustlib/manifest"
298334
0 commit comments