diff --git a/mk/dist.mk b/mk/dist.mk index 10c1636a03a..a2048f7fb8f 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -199,9 +199,11 @@ dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) dist-install-dir-$(1): PREPARE_CLEAN=true dist-install-dir-$(1): prepare-base-dir-$(1) +# Write the install manifest, making sure the manifest contains itself + $$(Q)touch $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest-$(1).in $$(Q)(cd $$(PREPARE_DEST_DIR)/ && find -type f | sed 's/^\.\///') \ - > tmp/manifest-$(1) # NB Use a tmp file so `find` doesn't *find the manifest* - $$(Q)cp tmp/manifest-$(1) $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest + > $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest-$(1).in +# Add remaining non-installed files $$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR) $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR) $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR) diff --git a/mk/install.mk b/mk/install.mk index 6545441a405..e360afe291b 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -11,6 +11,8 @@ install: dist-install-dir-$(CFG_BUILD) $(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)" +# Remove tmp files while we can because they may have been created under sudo + $(Q)rm -R tmp/dist/$(PKG_NAME)-$(CFG_BUILD/ uninstall: dist-install-dir-$(CFG_BUILD) $(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)" diff --git a/src/etc/install.sh b/src/etc/install.sh index 3ae028d9713..8bcb04eec90 100644 --- a/src/etc/install.sh +++ b/src/etc/install.sh @@ -229,15 +229,16 @@ validate_opt # Sanity check: can we can write to the destination? umask 022 && mkdir -p "${CFG_LIBDIR}" -need_ok "directory creation failed" +need_ok "can't write to destination. consider `sudo`." touch "${CFG_LIBDIR}/rust-install-probe" 2> /dev/null if [ $? -ne 0 ] then - err "can't write to destination. try again with 'sudo'." + err "can't write to destination. consider `sudo`." fi rm "${CFG_LIBDIR}/rust-install-probe" need_ok "failed to remove install probe" +# The file name of the manifest we're going to create during install INSTALLED_MANIFEST="${CFG_LIBDIR}/rustlib/manifest" # First, uninstall from the installation prefix. @@ -267,6 +268,7 @@ then warn "failed to remove rustlib" fi else + # There's no manifest. If we were asked to uninstall, then that's a problem. if [ -n "${CFG_UNINSTALL}" ] then err "unable to find installation manifest at ${CFG_LIBDIR}/rustlib" @@ -304,7 +306,7 @@ while read p; do FILE_INSTALL_PATH="${CFG_MANDIR}/$pp" fi - # Make sure ther's a directory for it + # Make sure there's a directory for it umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})" need_ok "directory creation failed" @@ -330,7 +332,7 @@ while read p; do need_ok "failed to update manifest" # The manifest lists all files to install -done < "${CFG_SRC_DIR}/lib/rustlib/manifest" +done < "${CFG_SRC_DIR}/lib/rustlib/manifest.in" echo echo " Rust is ready to roll."