Merge branch 'full-podman' into 'master'

Move installer behind podman

See merge request redox-os/redox!1674
This commit is contained in:
Jeremy Soller 2025-11-11 06:49:11 -07:00
commit b2d7d89a0f
8 changed files with 103 additions and 170 deletions

View File

@ -28,26 +28,44 @@ rebuild:
rm -rf $(BUILD)/repo.tag $(BUILD)/harddrive.img $(BUILD)/redox-live.iso
$(MAKE) all
clean: $(CONTAINER_TAG)
# To tell that it's not safe
# to execute the cookbook binary
NOT_ON_PODMAN?=0
clean:
ifeq ($(PODMAN_BUILD),1)
ifneq ("$(wildcard $(CONTAINER_TAG))","")
$(PODMAN_RUN) make $@
else
$(info will not run cookbook clean as container is not built)
$(MAKE) clean PODMAN_BUILD=0 NOT_ON_PODMAN=1
endif # CONTAINER_TAG
else
ifneq ($(NOT_ON_PODMAN),1)
$(MAKE) c.--all
-rm -rf cookbook/repo
$(MAKE) fstools_clean
$(HOST_CARGO) clean --manifest-path relibc/Cargo.toml
endif
-$(FUMOUNT) $(BUILD)/filesystem/ || true
-$(FUMOUNT) /tmp/redox_installer/ || true
endif # NOT_ON_PODMAN
rm -rf cookbook/repo
rm -rf relibc/target
rm -rf $(BUILD) $(PREFIX)
$(MAKE) fstools_clean
endif # PODMAN_BUILD
distclean: $(CONTAINER_TAG)
distclean:
ifeq ($(PODMAN_BUILD),1)
ifneq ("$(wildcard $(CONTAINER_TAG))","")
$(PODMAN_RUN) make $@
else
$(info will not run cookbook unfetch as container is not built)
$(MAKE) distclean PODMAN_BUILD=0 NOT_ON_PODMAN=1
endif # CONTAINER_TAG
else
ifneq ($(NOT_ON_PODMAN),1)
$(MAKE) u.--all
$(MAKE) clean
endif
endif # NOT_ON_PODMAN
$(MAKE) clean NOT_ON_PODMAN=1
endif # PODMAN_BUILD
pull:
git pull

View File

@ -46,6 +46,7 @@ CONTAINERFILE?=podman/redox-base-containerfile
export NPROC=nproc
export REDOX_MAKE=make
ifneq ($(PODMAN_BUILD),1)
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)
@ -60,6 +61,7 @@ ifneq ($(HOST_TARGET),x86_64-unknown-linux-gnu)
PREFIX_BINARY=0
endif
endif
endif
ifeq ($(SCCACHE_BUILD),1)
ifeq (,$(shell command -v sccache))
@ -132,13 +134,13 @@ else
endif
BUILD=build/$(ARCH)/$(CONFIG_NAME)
MOUNT_DIR=$(BUILD)/filesystem
HOST_FSTOOLS=build/fstools
INSTALLER=$(HOST_FSTOOLS)/bin/redox_installer
FSTOOLS=build/fstools
INSTALLER=$(FSTOOLS)/bin/redox_installer
REDOXFS=$(FSTOOLS)/bin/redoxfs
REDOXFS_MKFS=$(FSTOOLS)/bin/redoxfs-mkfs
INSTALLER_OPTS=
LIST_PACKAGES=installer/target/release/list_packages
LIST_PACKAGES_OPTS=
REDOXFS=$(HOST_FSTOOLS)/bin/redoxfs
REDOXFS_MKFS=$(HOST_FSTOOLS)/bin/redoxfs-mkfs
ifeq ($(REPO_BINARY),0)
INSTALLER_OPTS+=--cookbook=cookbook
else

View File

@ -1,6 +1,9 @@
# Configuration file with the commands configuration of the Redox image
$(BUILD)/harddrive.img: $(HOST_FSTOOLS) $(REPO_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(BUILD)
rm -rf $@ $@.partial
-$(FUMOUNT) /tmp/redox_installer || true
@ -11,8 +14,12 @@ $(BUILD)/harddrive.img: $(HOST_FSTOOLS) $(REPO_TAG)
truncate -s "$$FILESYSTEM_SIZE"m $@.partial
umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) $@.partial
mv $@.partial $@
endif
$(BUILD)/redox-live.iso: $(HOST_FSTOOLS) $(REPO_TAG) redox.ipxe
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(BUILD)
rm -rf $@ $@.partial
-$(FUMOUNT) /tmp/redox_installer || true
@ -24,8 +31,12 @@ $(BUILD)/redox-live.iso: $(HOST_FSTOOLS) $(REPO_TAG) redox.ipxe
umask 002 && $(INSTALLER) $(INSTALLER_OPTS) -c $(FILESYSTEM_CONFIG) --write-bootloader="$(BUILD)/bootloader-live.efi" --live $@.partial
mv $@.partial $@
cp redox.ipxe $(BUILD)/redox.ipxe
endif
$(BUILD)/filesystem.img: $(HOST_FSTOOLS) $(REPO_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(BUILD)
-$(FUMOUNT) $(MOUNT_DIR) || true
rm -rf $@ $@.partial $(MOUNT_DIR)
@ -45,27 +56,44 @@ $(BUILD)/filesystem.img: $(HOST_FSTOOLS) $(REPO_TAG)
-$(FUMOUNT) $(MOUNT_DIR) || true
rm -rf $(MOUNT_DIR)
mv $@.partial $@
endif
mount: $(HOST_FSTOOLS) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(MOUNT_DIR)
$(REDOXFS) $(BUILD)/harddrive.img $(MOUNT_DIR)
sleep 2
pgrep redoxfs
endif
mount_extra: $(HOST_FSTOOLS) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(MOUNT_DIR)
$(REDOXFS) $(BUILD)/extra.img $(MOUNT_DIR)
sleep 2
pgrep redoxfs
endif
mount_live: $(HOST_FSTOOLS) FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p $(MOUNT_DIR)
$(REDOXFS) $(BUILD)/redox-live.iso $(MOUNT_DIR)
sleep 2
pgrep redoxfs
endif
unmount: FORCE
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
sync
-$(FUMOUNT) $(MOUNT_DIR) || true
rm -rf $(MOUNT_DIR)
-$(FUMOUNT) /tmp/redox_installer || true
endif

View File

@ -3,34 +3,32 @@
fstools: $(FSTOOLS_TAG) $(HOST_FSTOOLS)
# These tools run inside Podman if it is used, or on the host if Podman is not used
$(FSTOOLS_TAG): cookbook installer $(CONTAINER_TAG)
$(FSTOOLS): cookbook installer $(CONTAINER_TAG)
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
$(HOST_CARGO) build --manifest-path installer/Cargo.toml --bin list_packages --release
mkdir -p build
touch $@
endif
## The installer and redoxfs run on the host, even when using Podman build
$(HOST_FSTOOLS): installer redoxfs
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 redoxfs --bin redoxfs --bin redoxfs-mkfs --bin redoxfs-resize
mv $@.partial $@
touch $@
endif
fstools_clean: FORCE $(CONTAINER_TAG)
## TODO: remove this
$(FSTOOLS_TAG): $(FSTOOLS)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
$(HOST_CARGO) clean --manifest-path cookbook/Cargo.toml
$(HOST_CARGO) clean --manifest-path cookbook/pkgar/Cargo.toml
$(HOST_CARGO) clean --manifest-path installer/Cargo.toml
$(HOST_CARGO) clean --manifest-path redoxfs/Cargo.toml
rm -rf $(HOST_FSTOOLS)
rm -f $(FSTOOLS_TAG)
touch $@
endif
fstools_clean: FORCE
rm -rf cookbook/target
rm -rf cookbook/pkgar/target
rm -rf installer/target
rm -rf redoxfs/target
rm -rf $(FSTOOLS)
rm -f $(FSTOOLS_TAG)

View File

@ -17,10 +17,10 @@ endif
## Podman Home Directory
PODMAN_HOME?=$(ROOT)/build/podman
## Podman command with its many arguments
PODMAN_VOLUMES?=--volume $(ROOT):$(CONTAINER_WORKDIR)$(PODMAN_VOLUME_FLAG) --volume $(PODMAN_HOME):/home$(PODMAN_VOLUME_FLAG)
PODMAN_ENV?=--env PATH=/home/poduser/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env PODMAN_BUILD=0
PODMAN_VOLUMES?=--volume $(ROOT):$(CONTAINER_WORKDIR)$(PODMAN_VOLUME_FLAG) --volume $(PODMAN_HOME):/root$(PODMAN_VOLUME_FLAG)
PODMAN_ENV?=--env PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env PODMAN_BUILD=0
PODMAN_CONFIG?=--env ARCH=$(ARCH) --env BOARD=$(BOARD) --env CONFIG_NAME=$(CONFIG_NAME) --env FILESYSTEM_CONFIG=$(FILESYSTEM_CONFIG) --env REPO_APPSTREAM=$(REPO_APPSTREAM) --env REPO_NONSTOP=$(REPO_NONSTOP) --env REPO_OFFLINE=$(REPO_OFFLINE) --env CI=$(CI)
PODMAN_OPTIONS?=--rm --workdir $(CONTAINER_WORKDIR) --userns keep-id --user `id -u` --interactive --tty --env TERM=$(TERM)
PODMAN_OPTIONS?=--rm --workdir $(CONTAINER_WORKDIR) --interactive --tty --cap-add SYS_ADMIN --device /dev/fuse --network=host --env TERM=$(TERM)
PODMAN_RUN?=podman run $(PODMAN_OPTIONS) $(PODMAN_VOLUMES) $(PODMAN_ENV) $(PODMAN_CONFIG) $(IMAGE_TAG)
container_shell: build/container.tag
@ -56,12 +56,12 @@ container_kill: FORCE
build/container.tag: $(CONTAINERFILE)
ifeq ($(PODMAN_BUILD),1)
rm -f build/container.tag
@echo "If podman_home dir cannot be removed, remove with \"sudo rm\"."
-chmod -R 0700 $(PODMAN_HOME) || true
-rm -rf $(PODMAN_HOME) || true
-podman image rm --force $(IMAGE_TAG) || true
mkdir -p $(PODMAN_HOME)
@echo "Building Podman image. This may take some time."
sed s/_UID_/`id -u`/ $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) --tag $(IMAGE_TAG)
cat $(CONTAINERFILE) | podman build --file - $(PODMAN_VOLUMES) --tag $(IMAGE_TAG)
@echo "Mapping Podman user space. Please wait."
$(PODMAN_RUN) bash -e podman/rustinstall.sh
mkdir -p build

View File

@ -70,7 +70,10 @@ $(PREFIX)/relibc-install.tar.gz: $(PREFIX)/relibc-install
--directory="$<" \
.
$(PREFIX)/libtool:
$(PREFIX)/libtool: | $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
rm -rf "$@.partial" "$@"
mkdir -p "$@.partial"
@ -85,8 +88,9 @@ $(PREFIX)/libtool:
touch "$@.partial"
echo $(LIBTOOL_VERSION) > $@.partial/.tarball-version
mv "$@.partial" "$@"
endif
$(PREFIX)/libtool-build: $(PREFIX)/libtool $(PREFIX)/rust-install
$(PREFIX)/libtool-build: $(PREFIX)/libtool $(PREFIX)/rust-install $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
@ -100,7 +104,7 @@ else
--gnulib-srcdir=./gnulib
PATH="$(ROOT)/$(PREFIX)/rust-install/bin:$$PATH" && \
cd "$@.partial" && \
cp -rp $(abspath $<)/. ./ && \
cp -r $(abspath $<)/. ./ && \
"$(ROOT)/$</configure" \
--target="$(TARGET)" \
--prefix=$(abspath $(PREFIX)/sysroot) && \
@ -125,18 +129,26 @@ endif
ifeq ($(PREFIX_BINARY),1)
$(PREFIX)/rust-install.tar.gz:
$(PREFIX)/rust-install.tar.gz: | $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
mkdir -p "$(@D)"
#TODO: figure out why rust-install.tar.gz is missing /lib/rustlib/$(HOST_TARGET)/lib
wget -O $@.partial "https://static.redox-os.org/toolchain/$(HOST_TARGET)/$(TARGET)/relibc-install.tar.gz"
mv $@.partial $@
endif
$(PREFIX)/rust-install: $(PREFIX)/rust-install.tar.gz
$(PREFIX)/rust-install: $(PREFIX)/rust-install.tar.gz $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
rm -rf "$@.partial" "$@"
mkdir -p "$@.partial"
tar --extract --file "$<" --directory "$@.partial" --strip-components=1
touch "$@.partial"
mv "$@.partial" "$@"
endif
else

View File

@ -2,12 +2,7 @@
FROM docker.io/library/debian:trixie
# _UID_ must be replaced with the user's uid on host
# podman root is mapped to your user id on host during build,
# poduser is mapped to your user id during podman run
RUN useradd --create-home --no-log-init --uid _UID_ poduser \
&& chown -R root:root /home \
&& apt-get update \
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ant \
appstream \

130
podman_bootstrap.sh Normal file → Executable file
View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash
# This script setup the Redox build system with Podman
# It install the Podman dependencies, Rustup, recipes dependencies for cross-compilation
# It install the Podman dependencies for cross-compilation
# and download the build system configuration files
set -e
@ -100,7 +100,6 @@ osx_macports()
install_macports_pkg "git"
install_macports_pkg "gmake"
install_macports_pkg "curl"
install_macports_pkg "osxfuse"
install_macports_pkg "podman"
install_macports_pkg "gdb +multiarch"
@ -129,8 +128,6 @@ osx_homebrew()
install_brew_pkg "git"
install_brew_pkg "make"
install_brew_pkg "curl"
install_brew_pkg "osxfuse"
install_brew_pkg "fuse-overlayfs"
install_brew_pkg "slirp4netns"
install_brew_pkg "podman"
install_brew_pkg "gdb"
@ -159,7 +156,6 @@ freebsd()
install_freebsd_pkg "git"
install_freebsd_pkg "gmake"
install_freebsd_pkg "curl"
install_freebsd_pkg "fusefs-libs3"
install_freebsd_pkg "podman"
install_freebsd_pkg "gdb"
@ -486,7 +482,6 @@ usage()
echo " -h,--help Show this prompt"
echo " -u [branch] Update git repo and update rust"
echo " If blank defaults to master"
echo " -s Check the status of the current travis build"
echo " -e [emulator] Install specific emulator, virtualbox or qemu"
echo " -p [package Choose an Ubuntu package manager, apt-fast or"
echo " manager] aptitude"
@ -497,111 +492,6 @@ usage()
exit
}
#############################################################
# Looks for and installs a cargo-managed binary or subcommand
#############################################################
cargoInstall()
{
if [[ "`cargo install --list`" != *"$1 v$2"* ]]; then
cargo install --force --version "$2" "$1"
else
echo "You have $1 version $2 installed already!"
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
####################################################################
statusCheck()
{
for i in $(echo "$(curl -sf https://api.travis-ci.org/repositories/redox-os/redox.json)" | tr "," "\n")
do
if echo "$i" | grep -iq "last_build_status" ;then
if echo "$i" | grep -iq "0" ;then
echo
echo "********************************************"
echo "Travis reports that the last build succeeded!"
echo "Looks like you are good to go!"
echo "********************************************"
elif echo "$i" | grep -iq "null" ;then
echo
echo "******************************************************************"
echo "The Travis build did not finish, this is an error with its config."
echo "I cannot reliably determine whether the build is succeeding or not."
echo "Consider checking for and maybe opening an issue on gitlab"
echo "******************************************************************"
else
echo
echo "**************************************************"
echo "Travis reports that the last build *FAILED* :("
echo "Might want to check out the issues before building"
echo "**************************************************"
fi
fi
done
}
###########################################################################
# This function is the main logic for the bootstrap; it clones the git repo
# then it installs the dependent packages
@ -618,22 +508,19 @@ boot()
echo "---------------------------------------"
echo "Well it looks like you are ready to go!"
echo "---------------------------------------"
statusCheck
echo "The file redox/.config was created with PODMAN_BUILD=1."
echo "If you need a much quicker installation, run: "
echo " echo REPO_BINARY=1 >> redox/.config"
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 "cd redox"
MAKE="make"
if [[ "$(uname)" == "FreeBSD" ]]; then
MAKE="gmake"
echo "kldload fuse.ko # This loads the kernel module for FUSE"
fi
echo "$MAKE all"
echo "$MAKE virtualbox or qemu"
echo "$MAKE $emulator"
echo
echo " Good luck!"
@ -645,10 +532,6 @@ if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
elif [ "$1" == "-u" ]; then
git pull upstream master
git submodule update --recursive --init
rustup update nightly
exit
elif [ "$1" == "-s" ]; then
statusCheck
exit
fi
@ -664,15 +547,12 @@ do
d) dependenciesonly=true;;
u) update=true;;
h) usage;;
s) statusCheck && exit;;
\?) echo "I don't know what to do with that option, try -h for help"; exit 1;;
esac
done
banner
rustInstall "$noninteractive"
if [ "$update" == "true" ]; then
git pull upstream master
git submodule update --recursive --init