Repository navigation
Expand file tree
/
Copy pathmisl
More file actions
executable file
·298 lines (286 loc) · 10.4 KB
/
Copy pathmisl
File metadata and controls
executable file
·298 lines (286 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#!/bin/bash
# SPDX-FileCopyrightText: 2026 ALKONTEK <git@alkontek.com>
# SPDX-License-Identifier: BSD-2-Clause
# MIS Linux bootstrap entrypoint
set -euo pipefail
MISL_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
export MISL_ROOT
# shellcheck source=lib/common.sh
. "$MISL_ROOT/lib/common.sh"
# shellcheck source=lib/config.sh
. "$MISL_ROOT/lib/config.sh"
misl_load_config
# shellcheck source=lib/host.sh
. "$MISL_ROOT/lib/host.sh"
# shellcheck source=lib/disk.sh
. "$MISL_ROOT/lib/disk.sh"
# shellcheck source=lib/sources.sh
. "$MISL_ROOT/lib/sources.sh"
# shellcheck source=lib/env.sh
. "$MISL_ROOT/lib/env.sh"
# shellcheck source=lib/recipe.sh
. "$MISL_ROOT/lib/recipe.sh"
# shellcheck source=lib/chroot.sh
. "$MISL_ROOT/lib/chroot.sh"
# shellcheck source=lib/pkglog.sh
. "$MISL_ROOT/lib/pkglog.sh"
# shellcheck source=lib/version.sh
. "$MISL_ROOT/lib/version.sh"
# shellcheck source=lib/overlay.sh
. "$MISL_ROOT/lib/overlay.sh"
# shellcheck source=lib/cloud.sh
. "$MISL_ROOT/lib/cloud.sh"
# shellcheck source=lib/img.sh
. "$MISL_ROOT/lib/img.sh"
# shellcheck source=lib/iso.sh
. "$MISL_ROOT/lib/iso.sh"
misl_help() {
cat <<EOF
MIS Linux $MISL_VERSION bootstrap
usage: misl <command> [args]
version print bootstrap version and os-release identity
bump minor|major|undo|X.Y rewrite VERSION + misl.conf (+ example)
env [list|export] print resolved site pins (export: shell assignments)
os-release print the composed /etc/os-release text
help this text
doctor host qualification (Fedora 44)
doctor pkgs print Fedora 44 dnf install line
doctor install dnf install host deps (root, Fedora)
disk plan print partition/mount plan (no writes)
disk apply gates + plan only (policy A; does not format)
sources fetch refresh catalog, create \$MISL_SNAPSHOT, wget wget-list files
sources refresh replace snapshot wget-list + md5sums from \$MISL_MIRROR
sources integrate [--reintegrate] <name>
host only: refresh catalog, fetch one package, stage
(prints chroot build next; does not compile)
sources check verify wget-list files against md5sums
sources stage hardlink verified files into \$LFS/usr/src/misl
sources remote HEAD-check \$MISL_MIRROR wget-list + md5sums (no download)
integrate alias for sources integrate
prep chapter 4 layout + lfs user + env + grant \$LFS
prep publish also copy mislinux/ into ~lfs (not the tarball tree)
build <recipe> run a stages/* recipe (stage/name if ambiguous)
build-stage <stage> run every packages.manifest row for that stage
logs [name] tail recipe log (default: newest under \$LFS/var/lib/misl/logs)
status package graph + stamps
config print last chapter-9 config report
config apply re-run 09-config/systemd-config (MISL_FORCE=1)
chroot prep ch7 owner + virtfs + files + publish scripts into $LFS
enter [--net] chroot into $LFS as root (--net: host DNS for the session)
net on|off|status bind host resolv.conf into \$LFS (host only, not permanent)
overlay list|status|apply|undo|install
named extras on the base tree (cloud, do, …)
cloud apply overlay apply cloud do (compat)
cloud undo overlay undo do then cloud
cloud install chroot: meson-install cloud-init (cloud overlay)
cloud status print \$LFS/var/lib/misl/cloud.report
cloud sanitize drop machine-id / ssh host keys / cloud-init seed
cloud wheels host: pip download deps into incoming/ (needs DNS)
img pack host root: pack \$LFS into a BIOS GPT .img
img test host qemu of that .img (--virtio default, --ide to compare)
iso pack host root: live ISO from a packed .img (--uefi default)
iso test host qemu of that .iso (--uefi default, --bios for SeaBIOS)
iso test --inspect mount ISO, unpack initramfs, list /init + libs (no qemu)
iso inspect same as iso test --inspect
iso usb --list USB disk nodes under /dev/disk/by-id/usb-* (no -part)
iso usb ISO DISK wipe that stick as GPT+ESP and copy a --uefi ISO
MISL_FORCE=1 ; example:
MISL_FORCE=1 ./misl iso usb FILE.iso /dev/disk/by-id/usb-SanDisk_Cruzer_Blade_...-0:0
Sources: $MISL_WGET_LIST
Snapshot: $MISL_SNAPSHOT
Mirror: $MISL_MIRROR
EOF
}
# Manifest column 2 is pkg_name (binutils). The file can be
# binutils-pass1.sh or libstdcxx.sh (pkg_name=libstdc++).
misl_recipe_in_stage() {
local stage=$1 want=$2 f cand pname
f=$MISL_ROOT/stages/$stage/${want}.sh
[[ -f $f ]] && { printf '%s\n' "$f"; return 0; }
for cand in "$MISL_ROOT/stages/$stage"/*.sh; do
[[ -f $cand ]] || continue
pname=$(awk -F= '/^pkg_name=/{gsub(/["\047]/,"",$2); print $2; exit}' "$cand")
[[ $pname == "$want" ]] || continue
printf '%s\n' "$cand"
return 0
done
return 1
}
misl_build() {
local name=${1:-} f
[[ -n $name ]] || die "usage: misl build <recipe|stage/recipe>"
case $name in
05-cross/*|06-temp/*)
if [[ ${EUID:-$(id -u)} -eq 0 && ${MISL_AS_LFS:-0} != 1 ]]; then
misl_reexec_as_lfs build "$name"
fi
;;
esac
if [[ $name == */* ]]; then
f=$(misl_recipe_in_stage "${name%%/*}" "${name#*/}") \
|| die "no recipe $name"
else
local matches n
matches=$(find "$MISL_ROOT/stages" -type f -name "${name}.sh" | sort)
n=$(printf '%s\n' "$matches" | grep -c . || true)
if (( n == 0 )); then
die "no recipe named $name"
elif (( n == 1 )); then
f=$matches
else
# Bare name: only stages this uid may run. lfs stays in 05/06 so
# `misl build glibc` after pass1 skips instead of jumping to 08.
f=""
local stage cand stamp pname ppass stages first
first=""
if [[ ${EUID:-$(id -u)} -eq 0 ]]; then
stages="07-chroot-temp 08-system 09-config 10-boot"
else
stages="05-cross 06-temp"
fi
for stage in $stages; do
cand=$MISL_ROOT/stages/$stage/${name}.sh
[[ -f $cand ]] || continue
[[ -n $first ]] || first=$cand
pname=$(awk -F= "/^pkg_name=/{gsub(/[\"\047]/,\"\",\$2); print \$2; exit}" "$cand")
ppass=$(awk -F= "/^pkg_pass=/{gsub(/[\"\047]/,\"\",\$2); print \$2; exit}" "$cand")
pname=${pname:-$name}
ppass=${ppass:-1}
stamp=${LFS:?}/var/lib/misl/stamps/${stage}-${pname}-${ppass}.done
if [[ ! -f $stamp ]]; then
f=$cand
info "using $f (also: $(printf '%s' "$matches" | tr '\n' ' '))"
break
fi
done
[[ -n $f ]] || f=$first
if [[ -z $f ]]; then
die "no $name recipe for this user; use stage/name (found: $(printf '%s' "$matches" | tr '\n' ' '))"
fi
fi
fi
recipe_reset
# shellcheck disable=SC1090
. "$f"
recipe_main
}
misl_logs() {
require_lfs_set
local dir name f
dir=$(misl_lfs_join var/lib/misl/logs)
name=${1:-}
if [[ -n $name ]]; then
f=$(ls -1t "$dir"/*"${name}"* 2>/dev/null | head -1 || true)
else
f=$(ls -1t "$dir"/*.log 2>/dev/null | head -1 || true)
fi
[[ -n $f && -f $f ]] || die "no log in $dir"
info "log $f"
tail -n 80 "$f"
}
misl_build_stage() {
local stage=${1:-} line name
[[ -n $stage ]] || die "usage: misl build-stage <05-cross|06-temp|07-chroot-temp|08-system|09-config|10-boot>"
require_lfs_set
case $stage in
05-cross|06-temp)
if [[ ${EUID:-$(id -u)} -eq 0 && ${MISL_AS_LFS:-0} != 1 ]]; then
misl_reexec_as_lfs build-stage "$stage"
fi
;;
esac
while read -r line; do
[[ $line == ${stage}\ * ]] || continue
name=$(awk "{print \$2}" <<<"$line")
info "stage $stage -> $name"
misl_build "$stage/$name"
done < "$MISL_ROOT/config/packages.manifest"
}
cmd=${1:-help}
shift || true
case $cmd in
bump) misl_bump "$@" ;;
env) misl_env "${1:-list}" ;;
version|-v|--version)
printf 'MIS Linux %s\n' "$MISL_VERSION"
printf 'NAME="%s" ID=%s VERSION_ID="%s" VARIANT="%s" VARIANT_ID=%s\n' \
"$MISL_NAME" "$MISL_ID" "$MISL_VERSION_ID" "$MISL_VARIANT" "$MISL_VARIANT_ID"
printf 'PRETTY_NAME="%s"\n' "$MISL_PRETTY_NAME"
printf 'DIST_VERSION=%s DIST_CODENAME=%s\n' "$MISL_DIST_VERSION" "$MISL_DIST_CODENAME"
if [[ -n ${LFS:-} ]]; then
names=$(misl_overlay_active_qnames 2>/dev/null | tr '\n' ' ')
names=${names%% }
[[ -n $names ]] && printf 'MISL_OVERLAYS="%s"\n' "$names"
fi
;;
os-release) misl_os_release_text ;;
help|-h|--help) misl_help ;;
doctor)
sub=${1:-check}; shift || true
case $sub in
check|"") misl_doctor ;;
pkgs|packages) misl_doctor_pkgs ;;
install) misl_doctor_install ;;
*) die "usage: misl doctor [check|pkgs|install]" ;;
esac
;;
disk)
sub=${1:-plan}; shift || true
case $sub in
plan) misl_disk_plan ;;
apply) misl_disk_apply ;;
*) die "usage: misl disk plan|apply" ;;
esac
;;
sources)
sub=${1:-check}; shift || true
case $sub in
check) misl_sources_check ;;
stage) misl_sources_stage ;;
fetch) misl_sources_fetch ;;
refresh) misl_catalog_refresh ;;
integrate) misl_sources_integrate "$@" ;;
remote) misl_sources_remote ;;
*) die "usage: misl sources check|stage|fetch|refresh|integrate|remote" ;;
esac
;;
prep) misl_prep "${1:-}" ;;
build) misl_build "${1:-}" ;;
build-stage) misl_build_stage "${1:-}" ;;
integrate) misl_sources_integrate "$@" ;;
status) misl_status ;;
config)
sub=${1:-show}
case $sub in
show|"")
f=$(misl_lfs_join var/lib/misl/09-config.report)
if [[ -f $f ]]; then
cat "$f"
else
die "no 09-config report at $f — run: MISL_FORCE=1 ./misl build 09-config/systemd-config"
fi
;;
apply)
MISL_FORCE=1 misl_build 09-config/systemd-config
;;
*) die "usage: misl config [show|apply]" ;;
esac
;;
logs) misl_logs "${1:-}" ;;
chroot)
sub=${1:-enter}; shift || true
case $sub in
prep) misl_chroot_prep ;;
enter|"") misl_enter "$@" ;;
mounts) misl_kernfs_mount ;;
*) die "usage: misl chroot [prep|enter|mounts]" ;;
esac
;;
enter) misl_enter "$@" ;;
net) misl_net "$@" ;;
overlay|overlays) misl_overlay "$@" ;;
cloud) misl_cloud "$@" ;;
img|image) misl_img "$@" ;;
iso) misl_iso "$@" ;;
*) die "unknown command: $cmd (try: misl help)" ;;
esac