Skip to content

Instantly share code, notes, and snippets.

@willnode
Last active August 28, 2025 23:46
Show Gist options
  • Select an option

  • Save willnode/1afad349551716aed4ebc4a13d2aa011 to your computer and use it in GitHub Desktop.

Select an option

Save willnode/1afad349551716aed4ebc4a13d2aa011 to your computer and use it in GitHub Desktop.
Fully offline Redox build system

There are three things you need to know in Redox build system to achieve full offline build system.

Fetch source files as much as possible

The first thing that you need to do is fetch as many package sources that you might want to download before going offline. I recommend following these steps:

  1. Set CONFIG_NAME=ci. It will match to all packages proven to build correctly
  2. Run make fetch. It will download all of them without building it

After fetch is done you can revert CONFIG_NAME to a kind of image you wish to build.

REPO_OFFLINE cookbook config

This is an environment flag that you can enable via .config, simply add REPO_OFFLINE=1 to that file to make it work.

What it does is to prevent git recipes reupdating automatically, and also tar recipes from downloading new tar files. However, if the source files is not available, it will throw in an error, prompting you to disable the flag first before continuing.

The flag will not affect make r.recipe, since in doing so you always want to make sure it's on the latest update, or atleast to not confuse people who are forgetting to unset REPO_OFFLINE. To make it respect REPO_OFFLINE, change this in mk/repo.mk:

# Invoke repo.sh for one or more targets separated by comma
r.%: $(FSTOOLS_TAG) FORCE
ifeq ($(PODMAN_BUILD),1)
	$(PODMAN_RUN) make $@
else
	@if echo "$*" | grep -q ','; then \
		$(MAKE) $(foreach f,$(subst $(comma), ,$*),r.$(f)); \
	else \
		export PATH="$(PREFIX_PATH):$$PATH" && \
		export COOKBOOK_HOST_SYSROOT="$(ROOT)/$(PREFIX_INSTALL)" && \
		cd cookbook && \
-		./repo.sh $*; \
+		./repo.sh $(REPO_OFFLINE) $*; \
	fi
endif

prefer_cache pkgutils/installer config

The installer uses the same code with pkgutils, which is a software that also responsible for pkg cli inside Redox. It has a hidden flag proposed in this MR, allowing to use caches as much as possible.

It is hidden because there's currently no standarized config or a mechanism to avoid stale caches, even I don't like it much, but anyway it works. The installer also has a problem that even if you do fully build your packages locally, it still asks for download public repo keys, So I'll tell you how to enable it.

First things first, until the MR merged, currently it's not pushed into crates.io, so you need to clone it manually. Inside the installer repo, clone the latest pkgutils:

cd installer
git clone https://gitlab.redox-os.org/redox-os/pkgutils

Then add it as the patches in installer/Cargo.toml, and perform rebuild for it:

[patch.crates-io]
cc-11 = { git = "https://github.com/tea/cc-rs", branch="riscv-abi-arch-fix", package = "cc" }
ring = { git = "https://gitlab.redox-os.org/redox-os/ring.git", branch = "redox-0.17.8" }
+redox-pkg = { path = "./pkgutils/pkg-lib" }
rm -rf build/fstools
make build/fstools

After that, the installer should have the capability to install fully offline. Here's how you enable the flags (do this in your host system not in podman):

mkdir -p /tmp/pkg_download/
touch /tmp/pkg_download/prefer_cache

Wait why the config was designed that way? See, I don't like that much either, but currently the download cache is hardcoded in /tmp. And /tmp has a problem where it will gone everytime you reboot, so I don't like the concept where you set this config but forget to save your packages cache.

After you have set the flag and run make rebuild, notice these two folders:

/tmp/pkg_download
/tmp/pkg

You need to backup these two folders and restore it when you've reboot your device.

Done

These stuff should get you up to build Redox fully offline, please test it before you actually going offline, maybe try disconnect the WiFi then rebuild the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment