From 6c8a9c894ac0f41daf2152ff0283e30ef38af3cf Mon Sep 17 00:00:00 2001 From: Wildan M Date: Wed, 19 Nov 2025 11:18:48 -0800 Subject: [PATCH] Make fstools in podman opt in and install rust on host again --- mk/config.mk | 3 +++ mk/depends.mk | 5 ++++ mk/disk.mk | 26 +++++++++---------- mk/fstools.mk | 17 ++++++++----- podman_bootstrap.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 20 deletions(-) diff --git a/mk/config.mk b/mk/config.mk index 2d00610d..d38ab647 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -40,6 +40,8 @@ HOST_CARGO=env -u RUSTUP_TOOLCHAIN -u CC -u TARGET cargo REDOXFS_MKFS_FLAGS?= ## Set to 1 to enable Podman build, any other value will disable it PODMAN_BUILD?=1 +## Set to 1 to put filesystem tools inside podman, any other value will install it to host +FSTOOLS_IN_PODMAN?=0 ## Enable sccache to speed up cargo builds ## only do this by default if this is inside podman SCCACHE_BUILD?=$(shell [ -f /run/.containerenv ] && echo 1 || echo 0) @@ -51,6 +53,7 @@ export NPROC=nproc export REDOX_MAKE=make ifneq ($(PODMAN_BUILD),1) +FSTOOLS_IN_PODMAN=0 HOST_TARGET := $(shell env -u RUSTUP_TOOLCHAIN rustc -vV | grep host | cut -d: -f2 | tr -d " ") # x86_64 linux hosts have all toolchains ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu) diff --git a/mk/depends.mk b/mk/depends.mk index 2c974628..3bc95d0e 100644 --- a/mk/depends.mk +++ b/mk/depends.mk @@ -12,6 +12,9 @@ endif endif +# don’t check for compile tools, used internally when installing fstools on host +ifneq ($(SKIP_CHECK_TOOLS),1) + ifeq ($(shell which cbindgen),) $(error cbindgen not found, install from crates.io or from your package manager) endif @@ -25,3 +28,5 @@ $(error 'just' not found, install from crates.io or from your package manager) endif endif + +endif diff --git a/mk/disk.mk b/mk/disk.mk index 092862d5..9702cb9a 100644 --- a/mk/disk.mk +++ b/mk/disk.mk @@ -1,7 +1,7 @@ # Configuration file with the commands configuration of the Redox image -$(BUILD)/harddrive.img: $(HOST_FSTOOLS) $(REPO_TAG) -ifeq ($(PODMAN_BUILD),1) +$(BUILD)/harddrive.img: $(FSTOOLS) $(REPO_TAG) +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(BUILD) @@ -16,8 +16,8 @@ else mv $@.partial $@ endif -$(BUILD)/redox-live.iso: $(HOST_FSTOOLS) $(REPO_TAG) redox.ipxe -ifeq ($(PODMAN_BUILD),1) +$(BUILD)/redox-live.iso: $(FSTOOLS) $(REPO_TAG) redox.ipxe +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(BUILD) @@ -33,8 +33,8 @@ else cp redox.ipxe $(BUILD)/redox.ipxe endif -$(BUILD)/filesystem.img: $(HOST_FSTOOLS) $(REPO_TAG) -ifeq ($(PODMAN_BUILD),1) +$(BUILD)/filesystem.img: $(FSTOOLS) $(REPO_TAG) +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(BUILD) @@ -58,8 +58,8 @@ else mv $@.partial $@ endif -mount: $(HOST_FSTOOLS) FORCE -ifeq ($(PODMAN_BUILD),1) +mount: $(FSTOOLS) FORCE +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(MOUNT_DIR) @@ -68,8 +68,8 @@ else pgrep redoxfs endif -mount_extra: $(HOST_FSTOOLS) FORCE -ifeq ($(PODMAN_BUILD),1) +mount_extra: $(FSTOOLS) FORCE +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(MOUNT_DIR) @@ -78,8 +78,8 @@ else pgrep redoxfs endif -mount_live: $(HOST_FSTOOLS) FORCE -ifeq ($(PODMAN_BUILD),1) +mount_live: $(FSTOOLS) FORCE +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else mkdir -p $(MOUNT_DIR) @@ -89,7 +89,7 @@ else endif unmount: FORCE -ifeq ($(PODMAN_BUILD),1) +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ else sync diff --git a/mk/fstools.mk b/mk/fstools.mk index b7c231fc..7453cc14 100644 --- a/mk/fstools.mk +++ b/mk/fstools.mk @@ -1,27 +1,30 @@ # Configuration file for redox-installer, Cookbook and RedoxFS FUSE -fstools: $(FSTOOLS_TAG) $(HOST_FSTOOLS) +fstools: $(FSTOOLS_TAG) $(FSTOOLS) # These tools run inside Podman if it is used, or on the host if Podman is not used -$(FSTOOLS): cookbook installer $(CONTAINER_TAG) +$(FSTOOLS): installer redoxfs $(CONTAINER_TAG) ifeq ($(PODMAN_BUILD),1) +ifeq ($(FSTOOLS_IN_PODMAN),1) $(PODMAN_RUN) make $@ +else + $(MAKE) $@ PODMAN_BUILD=0 SKIP_CHECK_TOOLS=1 +endif else rm -rf $@ $@.partial mkdir -p $@.partial - $(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release - $(HOST_CARGO) build --manifest-path cookbook/pkgar/Cargo.toml --release - $(HOST_CARGO) install --root $@.partial --path installer --bin redox_installer + $(HOST_CARGO) install --root $@.partial --path installer --bin redox_installer -Zgit=shallow-deps $(HOST_CARGO) install --root $@.partial --path redoxfs --bin redoxfs --bin redoxfs-mkfs --bin redoxfs-resize mv $@.partial $@ touch $@ endif -## TODO: remove this -$(FSTOOLS_TAG): $(FSTOOLS) +$(FSTOOLS_TAG): cookbook $(FSTOOLS) ifeq ($(PODMAN_BUILD),1) $(PODMAN_RUN) make $@ else + $(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release + $(HOST_CARGO) build --manifest-path cookbook/pkgar/Cargo.toml --release touch $@ endif diff --git a/podman_bootstrap.sh b/podman_bootstrap.sh index 120cec7a..26b9fe0f 100755 --- a/podman_bootstrap.sh +++ b/podman_bootstrap.sh @@ -491,6 +491,66 @@ usage() exit } +############################################################################# +# 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 is the main logic for the bootstrap; it clones the git repo # then it installs the dependent packages @@ -556,6 +616,8 @@ done banner +rustInstall "$noninteractive" + if [ "$update" == "true" ]; then git pull upstream master git submodule update --recursive --init