diff --git a/bootstrap.sh b/bootstrap.sh index 04e9e91..61ad7a8 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -986,6 +986,10 @@ boot() echo "Well it looks like you are ready to go!" echo "---------------------------------------" statusCheck + echo + echo "** Be sure to update your path to include Rust - run the following command: **" + echo 'source $HOME/.cargo/env' + echo echo "Run the following commands to build Redox:" echo "cd redox" MAKE="make" diff --git a/mk/config.mk b/mk/config.mk index 5a7adfd..c23b57f 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -26,7 +26,7 @@ FILESYSTEM_CONFIG?=config/$(ARCH)/$(BOARD)/$(CONFIG_NAME).toml endif HOST_CARGO=env -u RUSTUP_TOOLCHAIN -u CC -u TARGET cargo ## Filesystem size in MB (default comes from filesystem_size in the FILESYSTEM_CONFIG) -FILESYSTEM_SIZE?=$(shell $(HOST_CARGO) run --release --manifest-path installer/Cargo.toml -- --filesystem-size -c $(FILESYSTEM_CONFIG)) +## FILESYSTEM_SIZE?=$(shell $(HOST_CARGO) run --release --manifest-path installer/Cargo.toml -- --filesystem-size -c $(FILESYSTEM_CONFIG)) ## Flags to pass to redoxfs-mkfs. Add --encrypt to set up disk encryption REDOXFS_MKFS_FLAGS?= ## Set to 1 to enable Podman build, any other value will disable it @@ -80,14 +80,17 @@ export RUST_COMPILER_RT_ROOT=$(ROOT)/rust/src/llvm-project/compiler-rt export TARGET=$(ARCH)-unknown-redox BUILD=build/$(ARCH)/$(CONFIG_NAME) INSTALLER=installer/target/release/redox_installer +INSTALLER_OPTS= +LIST_PACKAGES=installer/target/release/list_packages +LIST_PACKAGES_OPTS= ifeq ($(REPO_BINARY),0) -INSTALLER+=--cookbook=cookbook -REPO_TAG=$(BUILD)/repo.tag +INSTALLER_OPTS+=--cookbook=cookbook else -INSTALLER+=--cookbook=cookbook --repo-binary -REPO_TAG=$(BUILD)/repo.tag +INSTALLER_OPTS+=--cookbook=cookbook --repo-binary +LIST_PACKAGES_OPTS+=--repo-binary endif +REPO_TAG=$(BUILD)/repo.tag FSTOOLS_TAG=build/fstools.tag export BOARD diff --git a/mk/disk.mk b/mk/disk.mk index 9b37e94..2b24da3 100644 --- a/mk/disk.mk +++ b/mk/disk.mk @@ -1,33 +1,45 @@ # Configuration file with the commands configuration of the Redox image -$(BUILD)/harddrive.img: $(FSTOOLS_TAG) $(REPO_TAG) +$(BUILD)/harddrive.img: $(INSTALLER) $(FSTOOLS_TAG) $(REPO_TAG) mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true - truncate -s "$(FILESYSTEM_SIZE)m" $@.partial - umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) $@.partial + FILESYSTEM_SIZE=$(FILESYSTEM_SIZE) && \ + if [ -z "$$FILESYSTEM_SIZE" ] ; then \ + FILESYSTEM_SIZE=$(shell $(INSTALLER) --filesystem-size -c $(FILESYSTEM_CONFIG)); \ + fi && \ + truncate -s "$$FILESYSTEM_SIZE"m $@.partial + umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) $@.partial mv $@.partial $@ -$(BUILD)/livedisk.iso: $(FSTOOLS_TAG) $(REPO_TAG) +$(BUILD)/livedisk.iso: $(INSTALLER) $(FSTOOLS_TAG) $(REPO_TAG) mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true - truncate -s "$(FILESYSTEM_SIZE)m" $@.partial - umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) --live $@.partial + FILESYSTEM_SIZE=$(FILESYSTEM_SIZE) && \ + if [ -z "$$FILESYSTEM_SIZE" ] ; then \ + FILESYSTEM_SIZE=$(shell $(INSTALLER) --filesystem-size -c $(FILESYSTEM_CONFIG)); \ + fi && \ + truncate -s "$$FILESYSTEM_SIZE"m $@.partial + umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) --live $@.partial mv $@.partial $@ -$(BUILD)/filesystem.img: $(FSTOOLS_TAG) $(REPO_TAG) +$(BUILD)/filesystem.img: $(INSTALLER) $(FSTOOLS_TAG) $(REPO_TAG) mkdir -p $(BUILD) -$(FUMOUNT) $(BUILD)/filesystem/ || true rm -rf $@ $@.partial $(BUILD)/filesystem/ -$(FUMOUNT) /tmp/redox_installer || true - truncate -s "$(FILESYSTEM_SIZE)m" $@.partial + FILESYSTEM_SIZE=$(FILESYSTEM_SIZE) && \ + if [ -z "$$FILESYSTEM_SIZE" ] ; then \ + FILESYSTEM_SIZE=$(shell $(INSTALLER) --filesystem-size -c $(FILESYSTEM_CONFIG)); \ + fi && \ + truncate -s "$$FILESYSTEM_SIZE"m $@.partial redoxfs/target/release/redoxfs-mkfs $(REDOXFS_MKFS_FLAGS) $@.partial mkdir -p $(BUILD)/filesystem/ redoxfs/target/release/redoxfs $@.partial $(BUILD)/filesystem/ sleep 1 pgrep redoxfs - umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) $(BUILD)/filesystem/ + umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) $(BUILD)/filesystem/ sync -$(FUMOUNT) $(BUILD)/filesystem/ || true rm -rf $(BUILD)/filesystem/ diff --git a/mk/fstools.mk b/mk/fstools.mk index 9a55984..f7c92b4 100644 --- a/mk/fstools.mk +++ b/mk/fstools.mk @@ -2,17 +2,21 @@ fstools: $(FSTOOLS_TAG) +## The installer runs on the host, even when using Podman build $(FSTOOLS_TAG): cookbook installer redoxfs $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) $(MAKE) $@ else $(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release - $(HOST_CARGO) build --manifest-path installer/Cargo.toml --release + $(HOST_CARGO) build --bin list_packages --manifest-path installer/Cargo.toml --release $(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs --bin redoxfs-mkfs mkdir -p build touch $@ endif +$(INSTALLER): installer + $(HOST_CARGO) build --bin redox_installer --manifest-path installer/Cargo.toml --release + fstools_clean: FORCE $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) $(MAKE) $@ diff --git a/mk/repo.mk b/mk/repo.mk index 3f6753d..d5c482f 100644 --- a/mk/repo.mk +++ b/mk/repo.mk @@ -4,19 +4,19 @@ $(BUILD)/fetch.tag: prefix $(FSTOOLS_TAG) $(FILESYSTEM_CONFIG) $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) $(MAKE) $@ else - PACKAGES="$$($(INSTALLER) --list-packages -c $(FILESYSTEM_CONFIG))" && \ + PACKAGES="$$($(LIST_PACKAGES) $(LIST_PACKAGES_OPTS) -c $(FILESYSTEM_CONFIG))" && \ cd cookbook && \ ./fetch.sh "$${PACKAGES}" mkdir -p $(BUILD) touch $@ endif -$(BUILD)/repo.tag: $(BUILD)/fetch.tag $(FSTOOLS_TAG) $(CONTAINER_TAG) +$(REPO_TAG): $(BUILD)/fetch.tag $(FSTOOLS_TAG) $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) $(MAKE) $@ else export PATH="$(PREFIX_PATH):$$PATH" && \ - PACKAGES="$$($(INSTALLER) --list-packages -c $(FILESYSTEM_CONFIG))" && \ + PACKAGES="$$($(LIST_PACKAGES) $(LIST_PACKAGES_OPTS) -c $(FILESYSTEM_CONFIG))" && \ cd cookbook && \ ./repo.sh $(REPO_NONSTOP) "$${PACKAGES}" mkdir -p $(BUILD) diff --git a/podman_bootstrap.sh b/podman_bootstrap.sh index 1a4ff3b..eb30f43 100755 --- a/podman_bootstrap.sh +++ b/podman_bootstrap.sh @@ -501,6 +501,67 @@ cargoInstall() { fi } + +#################################################################################### +# This function takes care of everything associated to rust, and the version manager +# That controls it, it can install rustup and uninstall multirust as well as making +# sure that the correct version of rustc is selected by rustup +# @params: $1 install non-interactively, boolean +#################################################################################### +rustInstall() { + noninteractive=$1 + # Check to see if multirust is installed, we don't want it messing with rustup + # In the future we can probably remove this but I believe it's good to have for now + if [ -e /usr/local/lib/rustlib/uninstall.sh ] ; then + echo "It appears that multirust is installed on your system." + echo "This tool has been deprecated by the maintainer, and will cause issues." + echo "This script can remove multirust from your system if you wish." + printf "Uninstall multirust (y/N):" + read multirust + if echo "$multirust" | grep -iq "^y" ;then + sudo /usr/local/lib/rustlib/uninstall.sh + else + echo "Please manually uninstall multirust and any other versions of rust, then re-run bootstrap." + exit 1 + fi + fi + # If rustup is not installed we should offer to install it for them + if [ -z "$(which rustup)" ]; then + rustup_options="--default-toolchain stable" + echo "You do not have rustup installed." + if [ "$noninteractive" = true ]; then + rustup="y" + rustup_options+=" -y" + else + echo "We HIGHLY recommend using rustup." + echo "Would you like to install it now?" + echo "*WARNING* this involves a 'curl | sh' style command" + printf "(y/N): " + read rustup + fi + if echo "$rustup" | grep -iq "^y" ;then + #install rustup + curl https://sh.rustup.rs -sSf | sh -s -- $rustup_options + # You have to add the rustup variables to the $PATH + echo "export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> ~/.bashrc + # source the variables so that we can execute rustup commands in the current shell + source ~/.cargo/env + else + echo "Rustup will not be installed!" + fi + fi + # + if [ -z "$(which rustc)" ]; then + echo "Rust is not installed" + echo "Please either run the script again, accepting rustup install" + echo "or install rustc stable manually (not recommended) via:" + echo "\#curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=stable" + exit 1 + else + echo "Your Rust install looks good!" + fi +} + #################################################################### # This function gets the current build status from travis and prints # a message to the user @@ -551,6 +612,10 @@ boot() echo "---------------------------------------" statusCheck echo "The file redox/.config was created with PODMAN_BUILD=1." + echo + echo "** Be sure to update your path to include Rust - run the following command: **" + echo 'source $HOME/.cargo/env' + echo echo "Run the following commands to build redox using Podman:" echo echo "cd redox" @@ -598,6 +663,8 @@ done banner +rustInstall "$noninteractive" + if [ "$update" == "true" ]; then git pull upstream master git submodule update --recursive --init