4.1. Sources
Source archives should be staged in a dedicated directory using a repeatable POSIX shell fetch workflow.
LBI_SOURCES (or another deliberate directory) before package builds begin.
This section introduces a POSIX sh helper that uses curl for source archives and git archive for pinned source-control snapshots. It is intended for repeatable source staging, not for package management.
All command examples in this section are intended for a normal user shell, not a root shell.
Provided Files
The source staging files are distributed with this website and can be downloaded here:
- Download
fetch-sources.sh - Download
sources.manifest - Download
sources.b2sums - Download
linux-by-intent-patches.zip
The helper accepts URLs directly, or a manifest file containing one source per line. The patch zip contains the book's local patch files; extract it into LBI_SOURCES before building packages that list a distributed patch in their input assumptions.
Direct URL Usage
After downloading the script into your current working directory, run it with one or more source URLs:
sh ./fetch-sources.sh "https://mirror.example.org/sources/pkg-a-1.0.tar.xz" "https://mirror.example.org/sources/pkg-b-2.3.tar.gz"
When a source needs an explicit local filename, place the output name immediately after that URL:
sh ./fetch-sources.sh \
"git+https://git.example.org/pkg#0123456789abcdef" \
"pkg-0123456789ab.tar.gz"
By default, downloads are written to LBI_SOURCES when that variable is set; otherwise they are written to ./sources.
Manifest Usage
A manifest is a plain text file with one entry per line:
# URL [OUTPUT_NAME]
https://mirror.example.org/sources/pkg-a-1.0.tar.xz
https://mirror.example.org/sources/pkg-b-2.3.tar.gz pkg-b.tar.gz
git+https://git.example.org/pkg#0123456789abcdef pkg-0123456789ab.tar.gz
The provided starter manifest currently includes:
musl-1.2.6.tar.gzllvm-project-22.1.3.src.tar.xzmimalloc-v3.3.0.tar.gz(downloaded from the upstreamv3.3.0.tar.gztag URL but saved with this explicit output name)linux-7.0.tar.xzom4-6.7.tar.gzncurses-6.6-20260418.tgzlibedit-20251016-3.1.tar.gzbheaded-0.0.1-mk2.tar.gzsbase-c1341583c963.tar.gz(generated from the pinned upstream git commit insources.manifest)BSD-Diffutils-main.zipfile-5.47.tar.gzzstd-1.5.7.tar.gzbsdgrep-master.zipzlib-ng-2.3.3.tar.gzbyacc-20260126.tgzbfs-4.1.tar.gzbmake-20260406.tar.gzawk-20251225.tar.gzsamurai-1.3.tar.gzmake-4.4.1.tar.gzbsdpatch-v0.99.1.tar.gzmandoc-1.14.6.tar.gzbsdsed-v0.99.2.tar.gzlibarchive-3.8.7.tar.xzxz-5.8.3.tar.xzgettext-tiny-0.3.3.tar.xzubase-e8249b49ca3e.tar.gz(generated from the pinned upstream git commit insources.manifest)Python-3.14.4.tar.xzpigz-2.8.tar.gzdash-0.5.13.3.tar.gzoksh-7.8.tar.gzbc-7.0.3.tar.xzpkgconf-2.5.1.tar.xziana-etc-20260409.tar.gzlibressl-4.2.1.tar.gzcacert-2026-03-19.pemcurl-8.19.0.tar.xzcmake-4.3.2.tar.gzflex-2.6.4.tar.gzsqlite-autoconf-3530000.tar.gzflit_core-3.12.0.tar.gzrustc-1.95.0-src.tar.xzcoreutils-0.8.0.tar.gzred-v1.0.2.tar.gzdinit-0.21.0.tar.xzlimine-5be26a73d7b7.tar.gz(generated from the pinned upstream git commit insources.manifest)
Then fetch everything listed in that file:
sh ./fetch-sources.sh --manifest ./sources.manifest
Checksum File
The provided sources.b2sums file records BLAKE2b checksums for the files named in sources.manifest, including explicit output names such as mimalloc-v3.3.0.tar.gz and the generated git snapshot archives. It also includes the checksum for linux-by-intent-patches.zip.
Keeping the manifest and checksum file in sync makes source staging auditable and repeatable as this chapter grows.
Script Behavior
The helper uses curl --fail --location --retry 3 --continue-at - so downloads follow redirects, retry on transient failures, and resume partial files when possible.
Entries beginning with git+ must include a pinned ref after #. The helper clones that repository, checks out the ref, and writes a deterministic gzip archive using git archive and gzip -n.
Existing non-empty files are skipped by default. Use --force to re-download existing archives.
Once source archives are staged, later build steps can consume them from LBI_SOURCES without mixing fetch policy into each package section.