From cf04f50d86f9875cfc6d9cf708aa39e6da9f355b Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:09:31 +0100 Subject: [PATCH 1/2] Use sparse files for the generated disk images on all OSes Rather than just on macOS. This can save quite a bit of space depending on the amount of free space on the root filesystem of the disk image. --- mk/config.mk | 3 --- mk/disk.mk | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/mk/config.mk b/mk/config.mk index 4df9fc3..7f540c1 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -41,7 +41,6 @@ ifeq ($(UNAME),Darwin) VB_AUDIO=coreaudio VBM=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage HOST_TARGET ?= $(HOST_ARCH)-apple-darwin - ALLOC_FILE=truncate -s "$(FILESYSTEM_SIZE)m" else ifeq ($(UNAME),FreeBSD) FUMOUNT=sudo umount export NPROC=sysctl -n hw.ncpu @@ -49,7 +48,6 @@ else ifeq ($(UNAME),FreeBSD) VB_AUDIO=pulse # To check, will probaly be OSS on most setups VBM=VBoxManage HOST_TARGET ?= $(HOST_ARCH)-unknown-freebsd - ALLOC_FILE=fallocate --posix --length "$(FILESYSTEM_SIZE)MiB" else # Detect which version of the fusermount binary is available. ifneq (, $(shell which fusermount3)) @@ -63,7 +61,6 @@ else VB_AUDIO=pulse VBM=VBoxManage HOST_TARGET ?= $(HOST_ARCH)-unknown-linux-gnu - ALLOC_FILE=fallocate --posix --length "$(FILESYSTEM_SIZE)MiB" endif ifneq ($(UNAME),Linux) diff --git a/mk/disk.mk b/mk/disk.mk index 9353883..7acfed4 100644 --- a/mk/disk.mk +++ b/mk/disk.mk @@ -2,7 +2,7 @@ $(BUILD)/harddrive.img: $(FSTOOLS_TAG) $(REPO_TAG) mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true - ${ALLOC_FILE} $@.partial + truncate -s "$(FILESYSTEM_SIZE)m" $@.partial umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) $@.partial mv $@.partial $@ @@ -10,7 +10,7 @@ $(BUILD)/livedisk.iso: $(FSTOOLS_TAG) $(REPO_TAG) mkdir -p $(BUILD) rm -rf $@ $@.partial -$(FUMOUNT) /tmp/redox_installer || true - ${ALLOC_FILE} $@.partial + truncate -s "$(FILESYSTEM_SIZE)m" $@.partial umask 002 && $(INSTALLER) -c $(FILESYSTEM_CONFIG) --live $@.partial mv $@.partial $@ @@ -19,7 +19,7 @@ $(BUILD)/filesystem.img: $(FSTOOLS_TAG) $(REPO_TAG) -$(FUMOUNT) $(BUILD)/filesystem/ || true rm -rf $@ $@.partial $(BUILD)/filesystem/ -$(FUMOUNT) /tmp/redox_installer || true - ${ALLOC_FILE} $@.partial + 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/ From 5ce30e6da627e0cbd034648ee1c1a0e2ee63259a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:24:14 +0100 Subject: [PATCH 2/2] Somewhat simplify config.mk * nproc exists on FreeBSD too * REDOX_MAKE is generally make, so use that as default with per-OS override if necessary. * HOST_TARGET can be fetched directly from rustc. --- mk/config.mk | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mk/config.mk b/mk/config.mk index 7f540c1..5f05d95 100644 --- a/mk/config.mk +++ b/mk/config.mk @@ -33,21 +33,20 @@ CONTAINERFILE?=podman/redox-base-containerfile # Per host variables HOST_CARGO=env -u RUSTUP_TOOLCHAIN cargo +export NPROC=nproc +export REDOX_MAKE=make +HOST_TARGET := $(shell rustc -vV | grep host | cut -d: -f2 | tr -d " ") UNAME := $(shell uname) ifeq ($(UNAME),Darwin) FUMOUNT=umount export NPROC=sysctl -n hw.ncpu - export REDOX_MAKE=make VB_AUDIO=coreaudio VBM=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage - HOST_TARGET ?= $(HOST_ARCH)-apple-darwin else ifeq ($(UNAME),FreeBSD) FUMOUNT=sudo umount - export NPROC=sysctl -n hw.ncpu export REDOX_MAKE=gmake - VB_AUDIO=pulse # To check, will probaly be OSS on most setups + VB_AUDIO=pulse # To check, will probably be OSS on most setups VBM=VBoxManage - HOST_TARGET ?= $(HOST_ARCH)-unknown-freebsd else # Detect which version of the fusermount binary is available. ifneq (, $(shell which fusermount3)) @@ -56,11 +55,8 @@ else FUMOUNT=fusermount -u endif - export NPROC=nproc - export REDOX_MAKE=make VB_AUDIO=pulse VBM=VBoxManage - HOST_TARGET ?= $(HOST_ARCH)-unknown-linux-gnu endif ifneq ($(UNAME),Linux)