Skip to content

Commit b63cd00

Browse files
committed
auto merge of #12793 : brson/rust/installer, r=alexcrichton
Work towards #9876. Several minor things here: * Fix the `need_ok` function in `configure` * Install man pages with non-executable permissions * Use the correct directory for man pages when installing (this was a recent regression) * Put all distributables in a new `dist/` directory in the build directory (there are soon to be significantly more of these) Finally, this also creates a new, more precise way to install and uninstall Rust's files, the `install.sh` script, and creates a build target (currently `dist-tar-bins`) that creates a binary tarball containing all the installable files, boilerplate and license docs, and `install.sh`. This binary tarball is the lowest-common denominator way to install Rust on Unix. We'll use it as the default installer on Linux (OS X will use .pkg). ## How `install.sh` works * First, the makefiles (`prepare.mk` and `dist.mk`) put all the stuff that needs to be installed in a new directory in `dist/`. * Then it puts `install.sh` in that same directory and a list of all the files to install at `rustlib/manifest`. * Then the directory can be packaged and distributed. * When `install.sh` runs it does some sanity checking then copies everything in the manifest to the install prefix, then copies the manifest as well. * When `install.sh` runs again in the future it first looks for the existing manifest at the install prefix, and if it exists deletes everything in it. This is how the core distribution is upgraded - cargo is responsible for the rest. * `install.sh --uninstall` will uninstall Rust ## Future work: * Modify `install.sh` to accept `--man-dir` etc * Rewrite `install.mk` to delegate to `install.sh` * Investigate how `install.sh` does or doesn't work with .pkg on Mac * Modify `dist.mk` to create `.pkg` files for all hosts * Possibly use [makeself](http://www.megastep.org/makeself/) to create self-extracting installers * Modify dist-snap bots run on mac as well, uploading binary tarballs and .pkg files for the four combos of linux, mac, x86, and x86_64. * Adjust build system to be able to augment versions with '-nightly' * Adjust build system to name dist artifacts without version numbers e.g. `rust-nightly-...pkg`. This is so we don't leave a huge trail of old nightly binaries on S3 - they just get overwritten. * Create new dist-nightly builder * Give the build master a new cron job to push to dist-nightly every night * Add docs to distributables * Update README.md to reflect the new reality * Modernize the website to promote new installers
2 parents 294d3dd + 9523809 commit b63cd00

File tree

5 files changed

+349
-25
lines changed

5 files changed

+349
-25
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ config.mk
6565
/mingw-build/
6666
src/.DS_Store
6767
/tmp/
68+
/dist/
6869
/stage0/
6970
/dl/
7071
/stage1/

configure

+6-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ err() {
2222
need_ok() {
2323
if [ $? -ne 0 ]
2424
then
25-
err $1
25+
err "$1"
2626
fi
2727
}
2828

@@ -340,7 +340,7 @@ DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"
340340

341341
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
342342
CFG_BUILD_DIR="$(pwd)/"
343-
CFG_SELF=${CFG_SRC_DIR}$(basename $0)
343+
CFG_SELF="$0"
344344
CFG_CONFIGURE_ARGS="$@"
345345

346346
OPTIONS=""
@@ -412,16 +412,15 @@ fi
412412
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"
413413
valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries"
414414

415-
# Validate Options
416-
step_msg "validating $CFG_SELF args"
417-
validate_opt
418-
419415
if [ $HELP -eq 1 ]
420416
then
421417
echo
422418
exit 0
423419
fi
424420

421+
# Validate Options
422+
step_msg "validating $CFG_SELF args"
423+
validate_opt
425424

426425
step_msg "looking for build programs"
427426

@@ -728,7 +727,7 @@ step_msg "making directories"
728727

729728
for i in \
730729
doc doc/std doc/extra \
731-
dl tmp
730+
dl tmp dist
732731
do
733732
make_dir $i
734733
done

mk/dist.mk

+41-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
PKG_NAME := rust
66
PKG_DIR = $(PKG_NAME)-$(CFG_RELEASE)
7-
PKG_TAR = $(PKG_DIR).tar.gz
7+
PKG_TAR = dist/$(PKG_DIR).tar.gz
88

99
ifdef CFG_ISCC
1010
PKG_ISS = $(wildcard $(S)src/etc/pkg/*.iss)
1111
PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
12-
PKG_EXE = $(PKG_DIR)-install.exe
12+
PKG_EXE = dist/$(PKG_DIR)-install.exe
1313
endif
1414

1515
ifeq ($(CFG_OSTYPE), apple-darwin)
16-
PKG_OSX = $(PKG_DIR).pkg
16+
PKG_OSX = dist/$(PKG_DIR).pkg
1717
endif
1818

1919
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
@@ -71,14 +71,15 @@ dist-prepare-win: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
7171
dist-prepare-win: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
7272
dist-prepare-win: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
7373
dist-prepare-win: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
74+
dist-prepare-win: PREPARE_CLEAN=true
7475
dist-prepare-win: prepare-base
7576

7677
endif
7778

7879
$(PKG_TAR): $(PKG_FILES)
7980
@$(call E, making dist dir)
80-
$(Q)rm -Rf dist
81-
$(Q)mkdir -p dist/$(PKG_DIR)
81+
$(Q)rm -Rf tmp/dist/$(PKG_DIR)
82+
$(Q)mkdir -p tmp/dist/$(PKG_DIR)
8283
$(Q)tar \
8384
-C $(S) \
8485
--exclude-vcs \
@@ -89,9 +90,9 @@ $(PKG_TAR): $(PKG_FILES)
8990
--exclude=*/llvm/test/*/*/*.ll \
9091
--exclude=*/llvm/test/*/*/*.td \
9192
--exclude=*/llvm/test/*/*/*.s \
92-
-c $(UNROOTED_PKG_FILES) | tar -x -C dist/$(PKG_DIR)
93-
$(Q)tar -czf $(PKG_TAR) -C dist $(PKG_DIR)
94-
$(Q)rm -Rf dist
93+
-c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_DIR)
94+
$(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_DIR)
95+
$(Q)rm -Rf tmp/dist/$(PKG_DIR)
9596

9697
.PHONY: dist distcheck
9798

@@ -156,3 +157,35 @@ distcheck-osx: $(PKG_OSX)
156157
@echo -----------------------------------------------
157158

158159
endif
160+
161+
dist-install-dir: $(foreach host,$(CFG_HOST),dist-install-dir-$(host))
162+
163+
dist-tar-bins: $(foreach host,$(CFG_HOST),dist/$(PKG_DIR)-$(host).tar.gz)
164+
165+
define DEF_INSTALLER
166+
dist-install-dir-$(1): PREPARE_HOST=$(1)
167+
dist-install-dir-$(1): PREPARE_TARGETS=$(1)
168+
dist-install-dir-$(1): PREPARE_STAGE=2
169+
dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_DIR)-$(1)
170+
dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
171+
dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
172+
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
173+
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
174+
dist-install-dir-$(1): PREPARE_CLEAN=true
175+
dist-install-dir-$(1): prepare-base
176+
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find -type f) \
177+
> $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/$$(CFG_RUSTLIBDIR)/manifest
178+
$$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)
179+
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)
180+
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)
181+
$$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)
182+
$$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)
183+
184+
dist/$$(PKG_DIR)-$(1).tar.gz: dist-install-dir-$(1)
185+
@$(call E, build: $$@)
186+
$$(Q)tar -czf dist/$$(PKG_DIR)-$(1).tar.gz -C tmp/dist $$(PKG_DIR)-$(1)
187+
188+
endef
189+
190+
$(foreach host,$(CFG_HOST),\
191+
$(eval $(call DEF_INSTALLER,$(host))))

mk/prepare.mk

+18-10
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ prepare-base: PREPARE_SOURCE_LIB_DIR=$(PREPARE_SOURCE_DIR)/$(CFG_LIBDIR_RELATIVE
3333
prepare-base: PREPARE_SOURCE_MAN_DIR=$(S)/man
3434
prepare-base: PREPARE_DEST_BIN_DIR=$(PREPARE_DEST_DIR)/bin
3535
prepare-base: PREPARE_DEST_LIB_DIR=$(PREPARE_DEST_DIR)/$(CFG_LIBDIR_RELATIVE)
36-
prepare-base: PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR)/man1
36+
prepare-base: PREPARE_DEST_MAN_DIR=$(PREPARE_DEST_DIR)/man/man1
3737
prepare-base: prepare-host prepare-targets
3838

3939
prepare-everything: prepare-host prepare-targets
4040

4141
DEFAULT_PREPARE_DIR_CMD = umask 022 && mkdir -p
4242
DEFAULT_PREPARE_BIN_CMD = install -m755
4343
DEFAULT_PREPARE_LIB_CMD = install -m644
44-
DEFAULT_PREPARE_MAN_CMD = install -m755
44+
DEFAULT_PREPARE_MAN_CMD = install -m644
4545

4646
# On windows we install from stage3, but on unix only stage2
4747
# Because of the way these rules are organized, preparing from any
@@ -55,14 +55,14 @@ endif
5555
# Create a directory
5656
# $(1) is the directory
5757
define PREPARE_DIR
58-
@$(Q)$(call E, install: $(1))
58+
@$(Q)$(call E, prepare: $(1))
5959
$(Q)$(PREPARE_DIR_CMD) $(1)
6060
endef
6161

6262
# Copy an executable
6363
# $(1) is the filename/libname-glob
6464
define PREPARE_BIN
65-
@$(call E, install: $(PREPARE_DEST_BIN_DIR)/$(1))
65+
@$(call E, prepare: $(PREPARE_DEST_BIN_DIR)/$(1))
6666
$(Q)$(PREPARE_BIN_CMD) $(PREPARE_SOURCE_BIN_DIR)/$(1) $(PREPARE_DEST_BIN_DIR)/$(1)
6767
endef
6868

@@ -75,7 +75,7 @@ endef
7575
# problem. I'm sorry, just don't remove the $(nop), alright?
7676
define PREPARE_LIB
7777
$(nop)
78-
@$(call E, install: $(PREPARE_WORKING_DEST_LIB_DIR)/$(1))
78+
@$(call E, prepare: $(PREPARE_WORKING_DEST_LIB_DIR)/$(1))
7979
$(Q)LIB_NAME="$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1))))"; \
8080
MATCHES="$(filter-out %$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1)))),\
8181
$(wildcard $(PREPARE_WORKING_DEST_LIB_DIR)/$(1)))"; \
@@ -91,7 +91,7 @@ endef
9191
# Copy a man page
9292
# $(1) - source dir
9393
define PREPARE_MAN
94-
@$(call E, install: $(PREPARE_DEST_MAN_DIR)/$(1))
94+
@$(call E, prepare: $(PREPARE_DEST_MAN_DIR)/$(1))
9595
$(Q)$(PREPARE_MAN_CMD) $(PREPARE_SOURCE_MAN_DIR)/$(1) $(PREPARE_DEST_MAN_DIR)/$(1)
9696
endef
9797

@@ -106,7 +106,7 @@ prepare-host-tools: \
106106
$(foreach host,$(CFG_HOST),\
107107
prepare-host-tool-$(tool)-$(stage)-$(host))))
108108

109-
prepare-host-dirs:
109+
prepare-host-dirs: prepare-maybe-clean
110110
$(call PREPARE_DIR,$(PREPARE_DEST_BIN_DIR))
111111
$(call PREPARE_DIR,$(PREPARE_DEST_LIB_DIR))
112112
$(call PREPARE_DIR,$(PREPARE_DEST_MAN_DIR))
@@ -115,7 +115,8 @@ prepare-host-dirs:
115115
# $(2) is stage
116116
# $(3) is host
117117
define DEF_PREPARE_HOST_TOOL
118-
prepare-host-tool-$(1)-$(2)-$(3): $$(foreach dep,$$(TOOL_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3)) \
118+
prepare-host-tool-$(1)-$(2)-$(3): prepare-maybe-clean \
119+
$$(foreach dep,$$(TOOL_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3)) \
119120
$$(HBIN$(2)_H_$(3))/$(1)$$(X_$(3)) \
120121
prepare-host-dirs
121122
$$(if $$(findstring $(2), $$(PREPARE_STAGE)),\
@@ -140,7 +141,8 @@ $(foreach tool,$(PREPARE_TOOLS),\
140141
define DEF_PREPARE_HOST_LIB
141142
prepare-host-lib-$(1)-$(2)-$(3): PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR)
142143
prepare-host-lib-$(1)-$(2)-$(3): PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR)
143-
prepare-host-lib-$(1)-$(2)-$(3): $$(foreach dep,$$(RUST_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3))\
144+
prepare-host-lib-$(1)-$(2)-$(3): prepare-maybe-clean \
145+
$$(foreach dep,$$(RUST_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3))\
144146
$$(HLIB$(2)_H_$(3))/stamp.$(1) \
145147
prepare-host-dirs
146148
$$(if $$(findstring $(2), $$(PREPARE_STAGE)),\
@@ -166,7 +168,7 @@ define DEF_PREPARE_TARGET_N
166168
# Rebind PREPARE_*_LIB_DIR to point to rustlib, then install the libs for the targets
167169
prepare-target-$(2)-host-$(3)-$(1): PREPARE_WORKING_SOURCE_LIB_DIR=$$(PREPARE_SOURCE_LIB_DIR)/$$(CFG_RUSTLIBDIR)/$(2)/lib
168170
prepare-target-$(2)-host-$(3)-$(1): PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR)/$$(CFG_RUSTLIBDIR)/$(2)/lib
169-
prepare-target-$(2)-host-$(3)-$(1): \
171+
prepare-target-$(2)-host-$(3)-$(1): prepare-maybe-clean \
170172
$$(foreach crate,$$(TARGET_CRATES), \
171173
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
172174
$$(if $$(findstring $(2),$$(CFG_HOST)), \
@@ -194,3 +196,9 @@ $(foreach host,$(CFG_HOST),\
194196
$(foreach target,$(CFG_TARGET), \
195197
$(foreach stage,$(PREPARE_STAGES),\
196198
$(eval $(call DEF_PREPARE_TARGET_N,$(stage),$(target),$(host))))))
199+
200+
prepare-maybe-clean:
201+
$(if $(findstring true,$(PREPARE_CLEAN)),\
202+
@$(call E, cleaning destination $@),)
203+
$(if $(findstring true,$(PREPARE_CLEAN)),\
204+
$(Q)rm -rf $(PREPARE_DEST_DIR),)

0 commit comments

Comments
 (0)