Skip to content

Commit b8329e5

Browse files
authored
Merge pull request #166 from FolkComputer/osnr/folk-live-build
Bring folk-live-build into this repo
2 parents fde512c + a7ed382 commit b8329e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+982
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "live-build/config/includes.chroot_after_packages/etc/skel/apriltag"]
2+
path = live-build/config/includes.chroot_after_packages/home/folk/apriltag
3+
url = https://github.com/FolkComputer/apriltag

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ See <https://folk.computer/pilot/>
3737
**Experimental:** If you have an amd64 PC, you can use the live USB
3838
image which has Folk and all dependencies pre-installed.
3939

40-
**See <https://github.com/FolkComputer/folk-live-build/releases> to
40+
**See <https://github.com/FolkComputer/folk/releases> to
4141
get the Linux live USB image.**
4242

4343
You can update Folk by running `git pull` in the `folk` subfolder of

live-build/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.img
2+
*.img.zip
3+
chroot
4+
binary
5+
cache
6+
.build
7+
binary.modified_timestamps
8+
chroot.files
9+
chroot.packages.install
10+
chroot.packages.live
11+
live-image-amd64.contents
12+
live-image-amd64.files
13+
live-image-amd64.packages

live-build/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
IMG_FILENAME := folk-$(shell date -I)-$(shell git rev-parse HEAD | head -c 7)-live-amd64.img
2+
3+
$(IMG_FILENAME).zip: $(IMG_FILENAME)
4+
zip $@ $<
5+
6+
$(IMG_FILENAME): live-image-amd64.img
7+
./make-folk-amd64-img.sh $< $@
8+
9+
live-image-amd64.img:
10+
sudo sh -c 'lb clean && lb config && lb build'
11+
12+
clean:
13+
rm -f *amd64.img

live-build/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# folk-live-build
2+
3+
Builds a bootable Folk OS image.
4+
5+
To run Folk on a PC, [download the latest pre-built Folk image for USB
6+
stick from the Releases
7+
page.](https://github.com/FolkComputer/folk-live-build/releases)
8+
Follow the instructions there.
9+
10+
---
11+
12+
Below are details on how the Folk OS image is constructed; **you don't
13+
need to worry about any of the below if you're just trying to install
14+
Folk.**
15+
16+
## Key files
17+
18+
- `folk-live/`: becomes writable partition on disk, including Folk repo
19+
- `config/package-lists/folk.list.chroot`: apt packages
20+
- `config/hooks/normal/9999-setup-folk.hook.chroot`: executed in
21+
`/` chroot at image construction time
22+
- `config/includes.chroot_after_packages/`: copied into `/` at boot
23+
- `config/includes.chroot_after_packages/lib/live/config/9999-folk`:
24+
executed at boot
25+
26+
## How to build folk-amd64.img from scratch
27+
28+
You need to build on a computer running amd64 Debian Bookworm. (Use a
29+
virtual machine if you need to. A Folk system built by folk-live-build
30+
itself should work, though, whether on a virtual or physical machine.)
31+
32+
In this live-build/ subdirectory of the Folk repo:
33+
34+
```
35+
# apt install live-build parted dosfstools zip
36+
$ git submodule update --init
37+
$ make -C config/includes.chroot_after_packages/home/folk/apriltag libapriltag.a libapriltag.so
38+
$ make
39+
```
40+
41+
emits `folk-amd64.img`.
42+
43+
(It runs from scratch each time -- can take 30 minutes or more.)
44+
45+
## How it works
46+
47+
Image (-> USB drive) contains Master Boot Record with:
48+
49+
1. 'Binary' ext4 partition (~1.3GB)
50+
- Contains a bunch of stuff (?), including the SquashFS file of
51+
the chroot filesystem, which ultimately maps to / in the
52+
running system
53+
- Could be fat32 or iso9660 I think but ext4 is reliable
54+
55+
2. EFI system partition (100MB)
56+
- syslinux-efi bootloader
57+
- Linux kernel image (annoying if you update kernel but this is a
58+
sealed live USB so that shouldn't be an issue)
59+
60+
3. Writable FAT32 partition (~500MB)
61+
- Contains /folk with Folk evaluator code and virtual programs,
62+
/folk-printed-programs, etc.
63+
- Contains setup.folk which you can edit to set runtime settings
64+
(Wi-Fi credentials)
65+
- Designed to automount on all operating systems when the USB is
66+
plugged in, to make it easy to configure Wi-Fi and other stuff
67+
before boot
68+
69+
Cannot have FAT32 partition be same as efi partition (and use iso
70+
loopback) because macOS (and probably other OSes?) won't automount an
71+
efi partition.
72+
73+
#### Build process
74+
75+
The build process uses Debian live-build to build a live image, then
76+
appends EFI system partition (to make it bootable on UEFI machines)
77+
and a writable partition (to make it easy for end-user to set config
78+
settings and update Folk).
79+
80+
(live-build can make a complete bootable disk image on its own, but
81+
only in iso-hybrid mode, which doesn't let you modify the partition
82+
table to add the writable partition, so we instead use hdd mode and
83+
modify the partition table ourselves.)
84+
85+
1. Run live-build, emit a disk image (with MBR with only a binary
86+
partition. not bootable on many modern systems)
87+
88+
2. Use parted to mutate the disk image to add EFI system partition
89+
90+
3. Copy syslinux-efi bootloader and bootloader config and Linux kernel
91+
etc onto EFI system partition
92+
93+
4. Use parted to mutate the disk image to add the writable FAT32 partition
94+
95+
## References
96+
97+
- <https://ianlecorbeau.github.io/blog/debian-live-build.html>
98+
- <https://manpages.debian.org/testing/live-build/lb_config.1.en.html>
99+
- <https://live-team.pages.debian.net/live-manual/html/live-manual/index.en.html>
100+
101+
## License
102+
103+
Apache 2.0
104+
105+
## TODO
106+
107+
- ~~Replace "NO NAME" title of FAT32 writable partition with Folk name~~
108+
- Test MBR+EFI on various systems (BIOS, UEFI, Chromebook, Beelink,
109+
NUC, UTM)
110+
- ~~Make fstab automount the writable partition (how do we know it's
111+
/dev/sdb2?)~~
112+
- ~~Put Wi-Fi config on writable partition~~
113+
- Allow setting display and webcam from setup.folk
114+
- Figure out disk installation process
115+
- ~~Handle printed programs~~, ~~calibration (make folk prefix that goes to folk-live?)~~
116+

live-build/config/binary

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# config/binary - options for live-build(7), binary stage
2+
3+
# Set image type
4+
LB_IMAGE_TYPE="hdd"
5+
6+
# Set image filesystem
7+
LB_BINARY_FILESYSTEM="ext4"
8+
9+
# Set apt/aptitude generic indices
10+
LB_APT_INDICES="true"
11+
12+
# Set boot parameters
13+
LB_BOOTAPPEND_LIVE="boot=live components hostname=folk-live username=folk live-config.user-default-groups=adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,render,netdev,lpadmin,gpio,i2c,spi,lpadmin"
14+
15+
# Set boot parameters
16+
LB_BOOTAPPEND_INSTALL=""
17+
18+
# Set boot parameters
19+
LB_BOOTAPPEND_LIVE_FAILSAFE="boot=live components memtest noapic noapm nodma nomce nolapic nosmp nosplash vga=788"
20+
21+
# Set BIOS bootloader
22+
LB_BOOTLOADER_BIOS="syslinux"
23+
24+
# Set EFI bootloader
25+
LB_BOOTLOADER_EFI="grub-efi"
26+
27+
# Set bootloaders
28+
LB_BOOTLOADERS=""
29+
30+
# Set checksums
31+
LB_CHECKSUMS="sha256 md5"
32+
33+
# Set compression
34+
LB_COMPRESSION="none"
35+
36+
# Support dm-verity on rootfs
37+
LB_DM_VERITY=""
38+
39+
# Support FEC on dm-verity rootfs
40+
LB_DM_VERITY_FEC_ROOTS=""
41+
42+
# Set sign script for roothash for dm-verity rootfs
43+
LB_DM_VERITY_SIGN=""
44+
45+
# Set zsync
46+
LB_ZSYNC="true"
47+
48+
# Control if we build binary images chrooted
49+
# NEVER, *EVER*, *E*V*E*R* SET THIS OPTION to false.
50+
LB_BUILD_WITH_CHROOT="true"
51+
52+
# Set debian-installer
53+
LB_DEBIAN_INSTALLER="live"
54+
55+
# Set debian-installer suite
56+
LB_DEBIAN_INSTALLER_DISTRIBUTION="bookworm"
57+
58+
# Set debian-installer preseed filename/url
59+
LB_DEBIAN_INSTALLER_PRESEEDFILE=""
60+
61+
# Toggle use of GUI debian-installer
62+
LB_DEBIAN_INSTALLER_GUI="true"
63+
64+
# Set hdd label
65+
LB_HDD_LABEL="DEBIAN_LIVE"
66+
67+
# Set hdd filesystem size
68+
LB_HDD_SIZE="auto"
69+
70+
# Set start of partition for the hdd target for BIOSes that expect a specific boot partition start (e.g. "63s"). If empty, use optimal layout.
71+
LB_HDD_PARTITION_START=""
72+
73+
# Set iso author
74+
LB_ISO_APPLICATION="Debian Live"
75+
76+
# Set iso preparer
77+
LB_ISO_PREPARER="live-build @LB_VERSION@; https://salsa.debian.org/live-team/live-build"
78+
79+
# Set iso publisher
80+
LB_ISO_PUBLISHER="Debian Live project; https://wiki.debian.org/DebianLive; [email protected]"
81+
82+
# Set iso volume (max 32 chars)
83+
LB_ISO_VOLUME="Debian bookworm @ISOVOLUME_TS@"
84+
85+
# Set jffs2 eraseblock size
86+
LB_JFFS2_ERASEBLOCK=""
87+
88+
# Set memtest
89+
LB_MEMTEST="none"
90+
91+
# Set loadlin
92+
LB_LOADLIN="true"
93+
94+
# Set win32-loader
95+
LB_WIN32_LOADER="false"
96+
97+
# Set net tarball
98+
LB_NET_TARBALL="true"
99+
100+
# Set onie
101+
LB_ONIE="false"
102+
103+
# Set onie additional kernel cmdline options
104+
LB_ONIE_KERNEL_CMDLINE=""
105+
106+
# Set inclusion of firmware packages in debian-installer
107+
LB_FIRMWARE_BINARY="true"
108+
109+
# Set inclusion of firmware packages in the live image
110+
LB_FIRMWARE_CHROOT="true"
111+
112+
# Set swap file path
113+
LB_SWAP_FILE_PATH=""
114+
115+
# Set swap file size
116+
LB_SWAP_FILE_SIZE="512"
117+
118+
# Enable/disable UEFI secure boot support
119+
LB_UEFI_SECURE_BOOT="auto"

live-build/config/bootstrap

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# config/bootstrap - options for live-build(7), bootstrap stage
2+
3+
# Select architecture to use
4+
LB_ARCHITECTURE="amd64"
5+
6+
# Select distribution to use
7+
LB_DISTRIBUTION="bookworm"
8+
9+
# Select parent distribution to use
10+
LB_PARENT_DISTRIBUTION=""
11+
12+
# Select distribution to use in the chroot
13+
LB_DISTRIBUTION_CHROOT="bookworm"
14+
15+
# Select parent distribution to use in the chroot
16+
LB_PARENT_DISTRIBUTION_CHROOT="bookworm"
17+
18+
# Select distribution to use in the final image
19+
LB_DISTRIBUTION_BINARY="bookworm"
20+
21+
# Select parent distribution to use in the final image
22+
LB_PARENT_DISTRIBUTION_BINARY="bookworm"
23+
24+
# Select parent distribution for debian-installer to use
25+
LB_PARENT_DEBIAN_INSTALLER_DISTRIBUTION="bookworm"
26+
27+
# Select archive areas to use
28+
LB_ARCHIVE_AREAS="main contrib non-free non-free-firmware"
29+
30+
# Select parent archive areas to use
31+
LB_PARENT_ARCHIVE_AREAS="main contrib non-free non-free-firmware"
32+
33+
# Set parent mirror to bootstrap from
34+
LB_PARENT_MIRROR_BOOTSTRAP="http://deb.debian.org/debian/"
35+
36+
# Set parent mirror to fetch packages from
37+
LB_PARENT_MIRROR_CHROOT="http://deb.debian.org/debian/"
38+
39+
# Set security parent mirror to fetch packages from
40+
LB_PARENT_MIRROR_CHROOT_SECURITY="http://security.debian.org/"
41+
42+
# Set parent mirror which ends up in the image
43+
LB_PARENT_MIRROR_BINARY="http://deb.debian.org/debian/"
44+
45+
# Set security parent mirror which ends up in the image
46+
LB_PARENT_MIRROR_BINARY_SECURITY="http://security.debian.org/"
47+
48+
# Set debian-installer parent mirror
49+
LB_PARENT_MIRROR_DEBIAN_INSTALLER="http://deb.debian.org/debian/"
50+
51+
# Set mirror to bootstrap from
52+
LB_MIRROR_BOOTSTRAP="http://deb.debian.org/debian/"
53+
54+
# Set mirror to fetch packages from
55+
LB_MIRROR_CHROOT="http://deb.debian.org/debian/"
56+
57+
# Set security mirror to fetch packages from
58+
LB_MIRROR_CHROOT_SECURITY="http://security.debian.org/"
59+
60+
# Set mirror which ends up in the image
61+
LB_MIRROR_BINARY="http://deb.debian.org/debian/"
62+
63+
# Set security mirror which ends up in the image
64+
LB_MIRROR_BINARY_SECURITY="http://security.debian.org/"
65+
66+
# Set debian-installer mirror
67+
LB_MIRROR_DEBIAN_INSTALLER="http://deb.debian.org/debian/"
68+
69+
# Set architectures to use foreign bootstrap
70+
LB_BOOTSTRAP_QEMU_ARCHITECTURE=""
71+
72+
# Set packages to exclude during foreign bootstrap
73+
LB_BOOTSTRAP_QEMU_EXCLUDE=""
74+
75+
# Set static qemu binary for foreign bootstrap
76+
LB_BOOTSTRAP_QEMU_STATIC=""

live-build/config/chroot

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# config/chroot - options for live-build(7), chroot stage
2+
3+
# Set chroot filesystem
4+
LB_CHROOT_FILESYSTEM="squashfs"
5+
6+
# Set chroot squashfs compression level
7+
LB_CHROOT_SQUASHFS_COMPRESSION_LEVEL=""
8+
9+
# Set chroot squashfs compression type
10+
LB_CHROOT_SQUASHFS_COMPRESSION_TYPE=""
11+
12+
# Set union filesystem
13+
LB_UNION_FILESYSTEM="overlay"
14+
15+
# Set interactive build
16+
LB_INTERACTIVE="false"
17+
18+
# Set keyring packages
19+
LB_KEYRING_PACKAGES="debian-archive-keyring"
20+
21+
# Set kernel flavour to use (with arch)
22+
LB_LINUX_FLAVOURS_WITH_ARCH="amd64"
23+
24+
# Set kernel packages to use
25+
LB_LINUX_PACKAGES="linux-image"
26+
27+
# Enable security updates
28+
LB_SECURITY="true"
29+
30+
# Enable updates updates
31+
LB_UPDATES="true"
32+
33+
# Enable backports updates
34+
LB_BACKPORTS="false"

0 commit comments

Comments
 (0)