Move installer behind podman

This commit is contained in:
Wildan M 2025-11-10 13:22:42 +07:00
parent a63583fe5f
commit 154c7bf4bf
6 changed files with 56 additions and 27 deletions

View File

@ -132,13 +132,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,25 +3,27 @@
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
## TODO: remove this
$(FSTOOLS_TAG): $(FSTOOLS)
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
touch $@
endif
fstools_clean: FORCE $(CONTAINER_TAG)
ifeq ($(PODMAN_BUILD),1)
@ -31,6 +33,6 @@ else
$(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 -rf $(FSTOOLS)
rm -f $(FSTOOLS_TAG)
endif

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 --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

@ -71,6 +71,9 @@ $(PREFIX)/relibc-install.tar.gz: $(PREFIX)/relibc-install
.
$(PREFIX)/libtool:
ifeq ($(PODMAN_BUILD),1)
$(PODMAN_RUN) make $@
else
rm -rf "$@.partial" "$@"
mkdir -p "$@.partial"
@ -85,6 +88,7 @@ $(PREFIX)/libtool:
touch "$@.partial"
echo $(LIBTOOL_VERSION) > $@.partial/.tarball-version
mv "$@.partial" "$@"
endif
$(PREFIX)/libtool-build: $(PREFIX)/libtool $(PREFIX)/rust-install
ifeq ($(PODMAN_BUILD),1)
@ -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) && \

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 \