Make installer compile on host, list_packages compile in Podman when PODMAN_BUILD=1

This commit is contained in:
Ron Williams 2024-08-17 23:59:37 +00:00 committed by Jeremy Soller
parent 61a4f0ab6c
commit f51dee2ea1
6 changed files with 108 additions and 18 deletions

View file

@ -986,6 +986,10 @@ boot()
echo "Well it looks like you are ready to go!" echo "Well it looks like you are ready to go!"
echo "---------------------------------------" echo "---------------------------------------"
statusCheck 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 "Run the following commands to build Redox:"
echo "cd redox" echo "cd redox"
MAKE="make" MAKE="make"

View file

@ -26,7 +26,7 @@ FILESYSTEM_CONFIG?=config/$(ARCH)/$(BOARD)/$(CONFIG_NAME).toml
endif endif
HOST_CARGO=env -u RUSTUP_TOOLCHAIN -u CC -u TARGET cargo 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 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 ## Flags to pass to redoxfs-mkfs. Add --encrypt to set up disk encryption
REDOXFS_MKFS_FLAGS?= REDOXFS_MKFS_FLAGS?=
## Set to 1 to enable Podman build, any other value will disable it ## 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 export TARGET=$(ARCH)-unknown-redox
BUILD=build/$(ARCH)/$(CONFIG_NAME) BUILD=build/$(ARCH)/$(CONFIG_NAME)
INSTALLER=installer/target/release/redox_installer INSTALLER=installer/target/release/redox_installer
INSTALLER_OPTS=
LIST_PACKAGES=installer/target/release/list_packages
LIST_PACKAGES_OPTS=
ifeq ($(REPO_BINARY),0) ifeq ($(REPO_BINARY),0)
INSTALLER+=--cookbook=cookbook INSTALLER_OPTS+=--cookbook=cookbook
REPO_TAG=$(BUILD)/repo.tag
else else
INSTALLER+=--cookbook=cookbook --repo-binary INSTALLER_OPTS+=--cookbook=cookbook --repo-binary
REPO_TAG=$(BUILD)/repo.tag LIST_PACKAGES_OPTS+=--repo-binary
endif endif
REPO_TAG=$(BUILD)/repo.tag
FSTOOLS_TAG=build/fstools.tag FSTOOLS_TAG=build/fstools.tag
export BOARD export BOARD

View file

@ -1,33 +1,45 @@
# Configuration file with the commands configuration of the Redox image # 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) mkdir -p $(BUILD)
rm -rf $@ $@.partial rm -rf $@ $@.partial
-$(FUMOUNT) /tmp/redox_installer || true -$(FUMOUNT) /tmp/redox_installer || true
truncate -s "$(FILESYSTEM_SIZE)m" $@.partial FILESYSTEM_SIZE=$(FILESYSTEM_SIZE) && \
umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) $@.partial 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 $@ mv $@.partial $@
$(BUILD)/livedisk.iso: $(FSTOOLS_TAG) $(REPO_TAG) $(BUILD)/livedisk.iso: $(INSTALLER) $(FSTOOLS_TAG) $(REPO_TAG)
mkdir -p $(BUILD) mkdir -p $(BUILD)
rm -rf $@ $@.partial rm -rf $@ $@.partial
-$(FUMOUNT) /tmp/redox_installer || true -$(FUMOUNT) /tmp/redox_installer || true
truncate -s "$(FILESYSTEM_SIZE)m" $@.partial FILESYSTEM_SIZE=$(FILESYSTEM_SIZE) && \
umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) --live $@.partial 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 $@ mv $@.partial $@
$(BUILD)/filesystem.img: $(FSTOOLS_TAG) $(REPO_TAG) $(BUILD)/filesystem.img: $(INSTALLER) $(FSTOOLS_TAG) $(REPO_TAG)
mkdir -p $(BUILD) mkdir -p $(BUILD)
-$(FUMOUNT) $(BUILD)/filesystem/ || true -$(FUMOUNT) $(BUILD)/filesystem/ || true
rm -rf $@ $@.partial $(BUILD)/filesystem/ rm -rf $@ $@.partial $(BUILD)/filesystem/
-$(FUMOUNT) /tmp/redox_installer || true -$(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 redoxfs/target/release/redoxfs-mkfs $(REDOXFS_MKFS_FLAGS) $@.partial
mkdir -p $(BUILD)/filesystem/ mkdir -p $(BUILD)/filesystem/
redoxfs/target/release/redoxfs $@.partial $(BUILD)/filesystem/ redoxfs/target/release/redoxfs $@.partial $(BUILD)/filesystem/
sleep 1 sleep 1
pgrep redoxfs pgrep redoxfs
umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) $(BUILD)/filesystem/ umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) $(BUILD)/filesystem/
sync sync
-$(FUMOUNT) $(BUILD)/filesystem/ || true -$(FUMOUNT) $(BUILD)/filesystem/ || true
rm -rf $(BUILD)/filesystem/ rm -rf $(BUILD)/filesystem/

View file

@ -2,17 +2,21 @@
fstools: $(FSTOOLS_TAG) fstools: $(FSTOOLS_TAG)
## The installer runs on the host, even when using Podman build
$(FSTOOLS_TAG): cookbook installer redoxfs $(CONTAINER_TAG) $(FSTOOLS_TAG): cookbook installer redoxfs $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1) ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) $(MAKE) $@ $(PODMAN_RUN) $(MAKE) $@
else else
$(HOST_CARGO) build --manifest-path cookbook/Cargo.toml --release $(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 $(HOST_CARGO) build --manifest-path redoxfs/Cargo.toml --release --bin redoxfs --bin redoxfs-mkfs
mkdir -p build mkdir -p build
touch $@ touch $@
endif endif
$(INSTALLER): installer
$(HOST_CARGO) build --bin redox_installer --manifest-path installer/Cargo.toml --release
fstools_clean: FORCE $(CONTAINER_TAG) fstools_clean: FORCE $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1) ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) $(MAKE) $@ $(PODMAN_RUN) $(MAKE) $@

View file

@ -4,19 +4,19 @@ $(BUILD)/fetch.tag: prefix $(FSTOOLS_TAG) $(FILESYSTEM_CONFIG) $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1) ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) $(MAKE) $@ $(PODMAN_RUN) $(MAKE) $@
else else
PACKAGES="$$($(INSTALLER) --list-packages -c $(FILESYSTEM_CONFIG))" && \ PACKAGES="$$($(LIST_PACKAGES) $(LIST_PACKAGES_OPTS) -c $(FILESYSTEM_CONFIG))" && \
cd cookbook && \ cd cookbook && \
./fetch.sh "$${PACKAGES}" ./fetch.sh "$${PACKAGES}"
mkdir -p $(BUILD) mkdir -p $(BUILD)
touch $@ touch $@
endif endif
$(BUILD)/repo.tag: $(BUILD)/fetch.tag $(FSTOOLS_TAG) $(CONTAINER_TAG) $(REPO_TAG): $(BUILD)/fetch.tag $(FSTOOLS_TAG) $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1) ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) $(MAKE) $@ $(PODMAN_RUN) $(MAKE) $@
else else
export PATH="$(PREFIX_PATH):$$PATH" && \ export PATH="$(PREFIX_PATH):$$PATH" && \
PACKAGES="$$($(INSTALLER) --list-packages -c $(FILESYSTEM_CONFIG))" && \ PACKAGES="$$($(LIST_PACKAGES) $(LIST_PACKAGES_OPTS) -c $(FILESYSTEM_CONFIG))" && \
cd cookbook && \ cd cookbook && \
./repo.sh $(REPO_NONSTOP) "$${PACKAGES}" ./repo.sh $(REPO_NONSTOP) "$${PACKAGES}"
mkdir -p $(BUILD) mkdir -p $(BUILD)

View file

@ -501,6 +501,67 @@ cargoInstall() {
fi 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 # This function gets the current build status from travis and prints
# a message to the user # a message to the user
@ -551,6 +612,10 @@ boot()
echo "---------------------------------------" echo "---------------------------------------"
statusCheck statusCheck
echo "The file redox/.config was created with PODMAN_BUILD=1." 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 "Run the following commands to build redox using Podman:"
echo echo
echo "cd redox" echo "cd redox"
@ -598,6 +663,8 @@ done
banner banner
rustInstall "$noninteractive"
if [ "$update" == "true" ]; then if [ "$update" == "true" ]; then
git pull upstream master git pull upstream master
git submodule update --recursive --init git submodule update --recursive --init