Skip to content

Commit

Permalink
auto merge of #17009 : kballard/rust/install_no_sudo, r=pnkfelix
Browse files Browse the repository at this point in the history
When running `sudo make install`, we only want to run the actual install
as root, the building of the documentation and the distribution folder
should happen as the non-root user.

Related to #13728.
  • Loading branch information
bors committed Oct 17, 2014
2 parents 4694b99 + 23c2661 commit 9b80efd
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,34 @@ else
MAYBE_DISABLE_VERIFY=
endif

install: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir
install:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
# Build the dist as the original user
$(Q)sudo -u "$$SUDO_USER" $(MAKE) prepare_install
else
$(Q)$(MAKE) prepare_install
endif
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
# Remove tmp files while we can because they may have been created under sudo
# Remove tmp files because it's a decent amount of disk space
$(Q)rm -R tmp/dist

uninstall: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir
prepare_install: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir

uninstall:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
# Build the dist as the original user
$(Q)sudo -u "$$SUDO_USER" $(MAKE) prepare_uninstall
else
$(Q)$(MAKE) prepare_uninstall
endif
$(Q)cd tmp/empty_dir && sh ../../tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
# Remove tmp files while we can because they may have been created under sudo
# Remove tmp files because it's a decent amount of disk space
$(Q)rm -R tmp/dist

prepare_uninstall: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir

.PHONY: install prepare_install uninstall prepare_uninstall

tmp/empty_dir:
mkdir -p $@

Expand Down

0 comments on commit 9b80efd

Please sign in to comment.