From 99746d43c1a8645b4e655c68a834c37dbc44ded4 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 1 Mar 2014 21:39:05 -0800 Subject: [PATCH 01/12] Bugfixes and cleanup to configure script --- configure | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configure b/configure index a69069183e76..c9fa978c8fd9 100755 --- a/configure +++ b/configure @@ -22,7 +22,7 @@ err() { need_ok() { if [ $? -ne 0 ] then - err $1 + err "$1" fi } @@ -340,7 +340,7 @@ DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}" CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_BUILD_DIR="$(pwd)/" -CFG_SELF=${CFG_SRC_DIR}$(basename $0) +CFG_SELF="$0" CFG_CONFIGURE_ARGS="$@" OPTIONS="" @@ -412,16 +412,15 @@ fi valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries" valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries" -# Validate Options -step_msg "validating $CFG_SELF args" -validate_opt - if [ $HELP -eq 1 ] then echo exit 0 fi +# Validate Options +step_msg "validating $CFG_SELF args" +validate_opt step_msg "looking for build programs" From c8bc65f19ffdf31d0a322c3d6a57472689337889 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 1 Mar 2014 21:39:36 -0800 Subject: [PATCH 02/12] mk: Put man pages in correct directory --- mk/prepare.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/prepare.mk b/mk/prepare.mk index 356ce2e908ed..fcd7b7e363da 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -33,7 +33,7 @@ prepare-base: PREPARE_SOURCE_LIB_DIR=$(PREPARE_SOURCE_DIR)/$(CFG_LIBDIR_RELATIVE prepare-base: PREPARE_SOURCE_MAN_DIR=$(S)/man prepare-base: PREPARE_DEST_BIN_DIR=$(PREPARE_DEST_DIR)/bin prepare-base: PREPARE_DEST_LIB_DIR=$(PREPARE_DEST_DIR)/$(CFG_LIBDIR_RELATIVE) -prepare-base: PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR)/man1 +prepare-base: PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR)/man/man1 prepare-base: prepare-host prepare-targets prepare-everything: prepare-host prepare-targets From 111137b5f5d6ed1a633edd319244e69457609f25 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 1 Mar 2014 21:39:55 -0800 Subject: [PATCH 03/12] mk: Optionally clean the destination when preparing install image --- mk/prepare.mk | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mk/prepare.mk b/mk/prepare.mk index fcd7b7e363da..59d78065eb81 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -106,7 +106,7 @@ prepare-host-tools: \ $(foreach host,$(CFG_HOST),\ prepare-host-tool-$(tool)-$(stage)-$(host)))) -prepare-host-dirs: +prepare-host-dirs: prepare-maybe-clean $(call PREPARE_DIR,$(PREPARE_DEST_BIN_DIR)) $(call PREPARE_DIR,$(PREPARE_DEST_LIB_DIR)) $(call PREPARE_DIR,$(PREPARE_DEST_MAN_DIR)) @@ -115,7 +115,8 @@ prepare-host-dirs: # $(2) is stage # $(3) is host define DEF_PREPARE_HOST_TOOL -prepare-host-tool-$(1)-$(2)-$(3): $$(foreach dep,$$(TOOL_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3)) \ +prepare-host-tool-$(1)-$(2)-$(3): prepare-maybe-clean \ + $$(foreach dep,$$(TOOL_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3)) \ $$(HBIN$(2)_H_$(3))/$(1)$$(X_$(3)) \ prepare-host-dirs $$(if $$(findstring $(2), $$(PREPARE_STAGE)),\ @@ -140,7 +141,8 @@ $(foreach tool,$(PREPARE_TOOLS),\ define DEF_PREPARE_HOST_LIB prepare-host-lib-$(1)-$(2)-$(3): PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR) prepare-host-lib-$(1)-$(2)-$(3): PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR) -prepare-host-lib-$(1)-$(2)-$(3): $$(foreach dep,$$(RUST_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3))\ +prepare-host-lib-$(1)-$(2)-$(3): prepare-maybe-clean \ + $$(foreach dep,$$(RUST_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3))\ $$(HLIB$(2)_H_$(3))/stamp.$(1) \ prepare-host-dirs $$(if $$(findstring $(2), $$(PREPARE_STAGE)),\ @@ -166,7 +168,7 @@ define DEF_PREPARE_TARGET_N # Rebind PREPARE_*_LIB_DIR to point to rustlib, then install the libs for the targets prepare-target-$(2)-host-$(3)-$(1): PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR)/$$(CFG_RUSTLIBDIR)/$(2)/lib prepare-target-$(2)-host-$(3)-$(1): PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR)/$$(CFG_RUSTLIBDIR)/$(2)/lib -prepare-target-$(2)-host-$(3)-$(1): \ +prepare-target-$(2)-host-$(3)-$(1): prepare-maybe-clean \ $$(foreach crate,$$(TARGET_CRATES), \ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \ $$(if $$(findstring $(2),$$(CFG_HOST)), \ @@ -194,3 +196,9 @@ $(foreach host,$(CFG_HOST),\ $(foreach target,$(CFG_TARGET), \ $(foreach stage,$(PREPARE_STAGES),\ $(eval $(call DEF_PREPARE_TARGET_N,$(stage),$(target),$(host)))))) + +prepare-maybe-clean: + $(if $(findstring true,$(PREPARE_CLEAN)),\ + @$(call E, cleaning destination $@),) + $(if $(findstring true,$(PREPARE_CLEAN)),\ + $(Q)rm -r $(PREPARE_DEST_DIR),) From 67ebf8abdf3323d3201691a21c7d5ddda73bd9cf Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 1 Mar 2014 21:38:13 -0800 Subject: [PATCH 04/12] mk: dist-installer builds a binary installer --- mk/dist.mk | 22 ++++ src/etc/install.sh | 264 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 src/etc/install.sh diff --git a/mk/dist.mk b/mk/dist.mk index 17afeaae3773..b5fd9d1b2290 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -71,6 +71,7 @@ dist-prepare-win: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD) dist-prepare-win: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD) dist-prepare-win: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) dist-prepare-win: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) +dist-prepare-win: PREPARE_CLEAN=true dist-prepare-win: prepare-base endif @@ -156,3 +157,24 @@ distcheck-osx: $(PKG_OSX) @echo ----------------------------------------------- endif + +dist-installer: $(foreach host,$(CFG_HOST),dist-installer-$(host)) + +define DEF_INSTALLER +dist-installer-$(1): PREPARE_HOST=$(1) +dist-installer-$(1): PREPARE_TARGETS=$(1) +dist-installer-$(1): PREPARE_STAGE=2 +dist-installer-$(1): PREPARE_DEST_DIR=tmp/dist/installer-$(1) +dist-installer-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD) +dist-installer-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD) +dist-installer-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) +dist-installer-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) +dist-installer-$(1): PREPARE_CLEAN=true +dist-installer-$(1): prepare-base + $$(Q)(cd $$(PREPARE_DEST_DIR)/ && find -type f) \ + > $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/$$(CFG_RUSTLIBDIR)/manifest + $$(Q)cp $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR) +endef + +$(foreach host,$(CFG_HOST),\ + $(eval $(call DEF_INSTALLER,$(host)))) diff --git a/src/etc/install.sh b/src/etc/install.sh new file mode 100644 index 000000000000..28e971959738 --- /dev/null +++ b/src/etc/install.sh @@ -0,0 +1,264 @@ +#!/bin/sh +# Copyright 2014 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +msg() { + echo "install: $1" +} + +step_msg() { + msg + msg "$1" + msg +} + +warn() { + echo "install: WARNING: $1" +} + +err() { + echo "install: error: $1" + exit 1 +} + +need_ok() { + if [ $? -ne 0 ] + then + err "$1" + fi +} + +putvar() { + local T + eval T=\$$1 + eval TLEN=\${#$1} + if [ $TLEN -gt 35 ] + then + printf "install: %-20s := %.35s ...\n" $1 "$T" + else + printf "install: %-20s := %s %s\n" $1 "$T" "$2" + fi + printf "%-20s := %s\n" $1 "$T" >>config.tmp +} + +valopt() { + VAL_OPTIONS="$VAL_OPTIONS $1" + + local OP=$1 + local DEFAULT=$2 + shift + shift + local DOC="$*" + if [ $HELP -eq 0 ] + then + local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_') + local V="CFG_${UOP}" + eval $V="$DEFAULT" + for arg in $CFG_ARGS + do + if echo "$arg" | grep -q -- "--$OP=" + then + val=$(echo "$arg" | cut -f2 -d=) + eval $V=$val + fi + done + putvar $V + else + if [ -z "$DEFAULT" ] + then + DEFAULT="" + fi + OP="${OP}=[${DEFAULT}]" + printf " --%-30s %s\n" "$OP" "$DOC" + fi +} + +opt() { + BOOL_OPTIONS="$BOOL_OPTIONS $1" + + local OP=$1 + local DEFAULT=$2 + shift + shift + local DOC="$*" + local FLAG="" + + if [ $DEFAULT -eq 0 ] + then + FLAG="enable" + else + FLAG="disable" + DOC="don't $DOC" + fi + + if [ $HELP -eq 0 ] + then + for arg in $CFG_ARGS + do + if [ "$arg" = "--${FLAG}-${OP}" ] + then + OP=$(echo $OP | tr 'a-z-' 'A-Z_') + FLAG=$(echo $FLAG | tr 'a-z' 'A-Z') + local V="CFG_${FLAG}_${OP}" + eval $V=1 + putvar $V + fi + done + else + if [ ! -z "$META" ] + then + OP="$OP=<$META>" + fi + printf " --%-30s %s\n" "$FLAG-$OP" "$DOC" + fi +} + +flag() { + BOOL_OPTIONS="$BOOL_OPTIONS $1" + + local OP=$1 + shift + local DOC="$*" + + if [ $HELP -eq 0 ] + then + for arg in $CFG_ARGS + do + if [ "$arg" = "--${OP}" ] + then + OP=$(echo $OP | tr 'a-z-' 'A-Z_') + local V="CFG_${OP}" + eval $V=1 + putvar $V + fi + done + else + if [ ! -z "$META" ] + then + OP="$OP=<$META>" + fi + printf " --%-30s %s\n" "$OP" "$DOC" + fi +} + +validate_opt () { + for arg in $CFG_ARGS + do + isArgValid=0 + for option in $BOOL_OPTIONS + do + if test --disable-$option = $arg + then + isArgValid=1 + fi + if test --enable-$option = $arg + then + isArgValid=1 + fi + if test --$option = $arg + then + isArgValid=1 + fi + done + for option in $VAL_OPTIONS + do + if echo "$arg" | grep -q -- "--$option=" + then + isArgValid=1 + fi + done + if [ "$arg" = "--help" ] + then + echo + echo "No more help available for Configure options," + echo "check the Wiki or join our IRC channel" + break + else + if test $isArgValid -eq 0 + then + err "Option '$arg' is not recognized" + fi + fi + done +} + +CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" +CFG_SELF="$0" +CFG_ARGS="$@" + +HELP=0 +if [ "$1" = "--help" ] +then + HELP=1 + shift + echo + echo "Usage: $CFG_SELF [options]" + echo + echo "Options:" + echo +else + step_msg "processing $CFG_SELF args" +fi + +OPTIONS="" +BOOL_OPTIONS="" +VAL_OPTIONS="" + +flag uninstall "only uninstall from the installation prefix" +valopt prefix "/usr/local" "set installation prefix" + +if [ $HELP -eq 1 ] +then + echo + exit 0 +fi + +step_msg "validating $CFG_SELF args" +validate_opt + +# First, uninstall from the installation prefix +# FIXME: Hardcoded 'rustlib' ignores CFG_RUSTLIBDIR +if [ -f "${CFG_PREFIX}/lib/rustlib/manifest" ] +then + while read p; do + msg "uninstall ${CFG_PREFIX}/$p" + rm "${CFG_PREFIX}/$p" + need_ok "failed to remove file" + done < "${CFG_PREFIX}/lib/rustlib/manifest" + + # Remove 'rustlib' directory + msg "uninstall ${CFG_PREFIX}/lib/rustlib" + rm -r "${CFG_PREFIX}/lib/rustlib" + need_ok "failed to remove rustlib" +fi + +# If we're only uninstalling then exit +if [ -n "${CFG_UNINSTALL}" ] +then + exit 0 +fi + +# Iterate through the new manifest and install files +while read p; do + + umask 022 && mkdir -p "${CFG_PREFIX}/$(dirname $p)" + need_ok "directory creation failed" + + msg "${CFG_PREFIX}/$p" + if echo "$p" | grep "/bin/" > /dev/null + then + install -m755 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" + else + install -m644 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" + fi + need_ok "file creation failed" + +# The manifest lists all files to install +done < "${CFG_SRC_DIR}/lib/rustlib/manifest" From 16ec0ab542c1d6bb243e18b6705a80e7af54ef75 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:10:42 -0700 Subject: [PATCH 05/12] configure: Create the dist directory --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index c9fa978c8fd9..11edfbca655c 100755 --- a/configure +++ b/configure @@ -727,7 +727,7 @@ step_msg "making directories" for i in \ doc doc/std doc/extra \ - dl tmp + dl tmp dist do make_dir $i done From 60a2aedbbb564c6cd3a2653efe80cf5ffe9e19ae Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:11:24 -0700 Subject: [PATCH 06/12] Add /dist/ to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a72ba1be0df9..9ed279d9d74a 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ config.mk /mingw-build/ src/.DS_Store /tmp/ +/dist/ /stage0/ /dl/ /stage1/ From e302bbe63514f3f514cd10b966dad42ff8fa735c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:12:11 -0700 Subject: [PATCH 07/12] mk: Use the correct permissions for man pages --- mk/prepare.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/prepare.mk b/mk/prepare.mk index 59d78065eb81..c275715ae9e8 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -41,7 +41,7 @@ prepare-everything: prepare-host prepare-targets DEFAULT_PREPARE_DIR_CMD = umask 022 && mkdir -p DEFAULT_PREPARE_BIN_CMD = install -m755 DEFAULT_PREPARE_LIB_CMD = install -m644 -DEFAULT_PREPARE_MAN_CMD = install -m755 +DEFAULT_PREPARE_MAN_CMD = install -m644 # On windows we install from stage3, but on unix only stage2 # Because of the way these rules are organized, preparing from any From b2eef52ce30f1b9a482f20a5d2227e6687afa4a0 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:13:48 -0700 Subject: [PATCH 08/12] mk: Tweak the status messages for prepare.mk to say 'prepare', not 'install' --- mk/prepare.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mk/prepare.mk b/mk/prepare.mk index c275715ae9e8..69da49669190 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -55,14 +55,14 @@ endif # Create a directory # $(1) is the directory define PREPARE_DIR - @$(Q)$(call E, install: $(1)) + @$(Q)$(call E, prepare: $(1)) $(Q)$(PREPARE_DIR_CMD) $(1) endef # Copy an executable # $(1) is the filename/libname-glob define PREPARE_BIN - @$(call E, install: $(PREPARE_DEST_BIN_DIR)/$(1)) + @$(call E, prepare: $(PREPARE_DEST_BIN_DIR)/$(1)) $(Q)$(PREPARE_BIN_CMD) $(PREPARE_SOURCE_BIN_DIR)/$(1) $(PREPARE_DEST_BIN_DIR)/$(1) endef @@ -75,7 +75,7 @@ endef # problem. I'm sorry, just don't remove the $(nop), alright? define PREPARE_LIB $(nop) - @$(call E, install: $(PREPARE_WORKING_DEST_LIB_DIR)/$(1)) + @$(call E, prepare: $(PREPARE_WORKING_DEST_LIB_DIR)/$(1)) $(Q)LIB_NAME="$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1))))"; \ MATCHES="$(filter-out %$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1)))),\ $(wildcard $(PREPARE_WORKING_DEST_LIB_DIR)/$(1)))"; \ @@ -91,7 +91,7 @@ endef # Copy a man page # $(1) - source dir define PREPARE_MAN - @$(call E, install: $(PREPARE_DEST_MAN_DIR)/$(1)) + @$(call E, prepare: $(PREPARE_DEST_MAN_DIR)/$(1)) $(Q)$(PREPARE_MAN_CMD) $(PREPARE_SOURCE_MAN_DIR)/$(1) $(PREPARE_DEST_MAN_DIR)/$(1) endef From 5e66af6bccacc2e77c055899441fd90729dbd53e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:14:34 -0700 Subject: [PATCH 09/12] mk: forcibly delete dest dir when PREPARE_CLEAN --- mk/prepare.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/prepare.mk b/mk/prepare.mk index 69da49669190..304806f12ad9 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -201,4 +201,4 @@ prepare-maybe-clean: $(if $(findstring true,$(PREPARE_CLEAN)),\ @$(call E, cleaning destination $@),) $(if $(findstring true,$(PREPARE_CLEAN)),\ - $(Q)rm -r $(PREPARE_DEST_DIR),) + $(Q)rm -rf $(PREPARE_DEST_DIR),) From 364d4ad1e55b74522c7ddf1244ec39b23d6f5a60 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:15:33 -0700 Subject: [PATCH 10/12] mk: Put all distribution artifacts in dist/ Also, add license docs to installers --- mk/dist.mk | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/mk/dist.mk b/mk/dist.mk index b5fd9d1b2290..01ee7a7947ba 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -4,16 +4,16 @@ PKG_NAME := rust PKG_DIR = $(PKG_NAME)-$(CFG_RELEASE) -PKG_TAR = $(PKG_DIR).tar.gz +PKG_TAR = dist/$(PKG_DIR).tar.gz ifdef CFG_ISCC PKG_ISS = $(wildcard $(S)src/etc/pkg/*.iss) PKG_ICO = $(S)src/etc/pkg/rust-logo.ico -PKG_EXE = $(PKG_DIR)-install.exe +PKG_EXE = dist/$(PKG_DIR)-install.exe endif ifeq ($(CFG_OSTYPE), apple-darwin) -PKG_OSX = $(PKG_DIR).pkg +PKG_OSX = dist/$(PKG_DIR).pkg endif PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt @@ -78,8 +78,8 @@ endif $(PKG_TAR): $(PKG_FILES) @$(call E, making dist dir) - $(Q)rm -Rf dist - $(Q)mkdir -p dist/$(PKG_DIR) + $(Q)rm -Rf tmp/dist/$(PKG_DIR) + $(Q)mkdir -p tmp/dist/$(PKG_DIR) $(Q)tar \ -C $(S) \ --exclude-vcs \ @@ -90,9 +90,9 @@ $(PKG_TAR): $(PKG_FILES) --exclude=*/llvm/test/*/*/*.ll \ --exclude=*/llvm/test/*/*/*.td \ --exclude=*/llvm/test/*/*/*.s \ - -c $(UNROOTED_PKG_FILES) | tar -x -C dist/$(PKG_DIR) - $(Q)tar -czf $(PKG_TAR) -C dist $(PKG_DIR) - $(Q)rm -Rf dist + -c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_DIR) + $(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_DIR) + $(Q)rm -Rf tmp/dist/$(PKG_DIR) .PHONY: dist distcheck @@ -158,22 +158,33 @@ distcheck-osx: $(PKG_OSX) endif -dist-installer: $(foreach host,$(CFG_HOST),dist-installer-$(host)) +dist-install-dir: $(foreach host,$(CFG_HOST),dist-install-dir-$(host)) + +dist-tar-bins: $(foreach host,$(CFG_HOST),dist/$(PKG_DIR)-$(host).tar.gz) define DEF_INSTALLER -dist-installer-$(1): PREPARE_HOST=$(1) -dist-installer-$(1): PREPARE_TARGETS=$(1) -dist-installer-$(1): PREPARE_STAGE=2 -dist-installer-$(1): PREPARE_DEST_DIR=tmp/dist/installer-$(1) -dist-installer-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD) -dist-installer-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD) -dist-installer-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD) -dist-installer-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD) -dist-installer-$(1): PREPARE_CLEAN=true -dist-installer-$(1): prepare-base +dist-install-dir-$(1): PREPARE_HOST=$(1) +dist-install-dir-$(1): PREPARE_TARGETS=$(1) +dist-install-dir-$(1): PREPARE_STAGE=2 +dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_DIR)-$(1) +dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD) +dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD) +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 $$(Q)(cd $$(PREPARE_DEST_DIR)/ && find -type f) \ > $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/$$(CFG_RUSTLIBDIR)/manifest - $$(Q)cp $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR) + $$(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) + $$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR) + $$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR) + +dist/$$(PKG_DIR)-$(1).tar.gz: dist-install-dir-$(1) + @$(call E, build: $$@) + $$(Q)tar -czf dist/$$(PKG_DIR)-$(1).tar.gz -C tmp/dist $$(PKG_DIR)-$(1) + endef $(foreach host,$(CFG_HOST),\ From 1f7de380ce85aed2917c5bf801c68170403559e8 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:16:41 -0700 Subject: [PATCH 11/12] install.sh: Improve error handling --- src/etc/install.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/etc/install.sh b/src/etc/install.sh index 28e971959738..eb344bb59e33 100644 --- a/src/etc/install.sh +++ b/src/etc/install.sh @@ -223,6 +223,19 @@ fi step_msg "validating $CFG_SELF args" validate_opt +# Sanity check: can we can write to the destination? +touch "${CFG_PREFIX}/lib/rust-install-probe" 2> /dev/null +if [ $? -ne 0 ] +then + err "can't write to destination. try again with 'sudo'." +fi +rm -r "${CFG_PREFIX}/lib/rust-install-probe" +need_ok "failed to remove install probe" + +# Sanity check: can we run these binaries? +"${CFG_SRC_DIR}/bin/rustc" --version > /dev/null +need_ok "can't run these binaries on this platform" + # First, uninstall from the installation prefix # FIXME: Hardcoded 'rustlib' ignores CFG_RUSTLIBDIR if [ -f "${CFG_PREFIX}/lib/rustlib/manifest" ] @@ -262,3 +275,9 @@ while read p; do # The manifest lists all files to install done < "${CFG_SRC_DIR}/lib/rustlib/manifest" + +echo +echo " Rust is ready to roll." +echo + + From 952380904b8e925851d96b55a959232ef360aede Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 9 Mar 2014 14:56:37 -0700 Subject: [PATCH 12/12] install.sh: untabify --- src/etc/install.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/etc/install.sh b/src/etc/install.sh index eb344bb59e33..9e718a61d889 100644 --- a/src/etc/install.sh +++ b/src/etc/install.sh @@ -240,38 +240,38 @@ need_ok "can't run these binaries on this platform" # FIXME: Hardcoded 'rustlib' ignores CFG_RUSTLIBDIR if [ -f "${CFG_PREFIX}/lib/rustlib/manifest" ] then - while read p; do - msg "uninstall ${CFG_PREFIX}/$p" - rm "${CFG_PREFIX}/$p" - need_ok "failed to remove file" - done < "${CFG_PREFIX}/lib/rustlib/manifest" + while read p; do + msg "uninstall ${CFG_PREFIX}/$p" + rm "${CFG_PREFIX}/$p" + need_ok "failed to remove file" + done < "${CFG_PREFIX}/lib/rustlib/manifest" # Remove 'rustlib' directory - msg "uninstall ${CFG_PREFIX}/lib/rustlib" - rm -r "${CFG_PREFIX}/lib/rustlib" - need_ok "failed to remove rustlib" + msg "uninstall ${CFG_PREFIX}/lib/rustlib" + rm -r "${CFG_PREFIX}/lib/rustlib" + need_ok "failed to remove rustlib" fi # If we're only uninstalling then exit if [ -n "${CFG_UNINSTALL}" ] then - exit 0 + exit 0 fi # Iterate through the new manifest and install files while read p; do - umask 022 && mkdir -p "${CFG_PREFIX}/$(dirname $p)" - need_ok "directory creation failed" - - msg "${CFG_PREFIX}/$p" - if echo "$p" | grep "/bin/" > /dev/null - then - install -m755 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" - else - install -m644 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" - fi - need_ok "file creation failed" + umask 022 && mkdir -p "${CFG_PREFIX}/$(dirname $p)" + need_ok "directory creation failed" + + msg "${CFG_PREFIX}/$p" + if echo "$p" | grep "/bin/" > /dev/null + then + install -m755 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" + else + install -m644 "${CFG_SRC_DIR}/$p" "${CFG_PREFIX}/$p" + fi + need_ok "file creation failed" # The manifest lists all files to install done < "${CFG_SRC_DIR}/lib/rustlib/manifest"