sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

commit 7ad4d4dc3ea362a19572d68240ebe9cdbcce895c
parent 88bb072f949499864200700f6bc3ff530392999f
Author: Divan Visagie <me@divanv.com>
Date:   Sat, 21 Nov 2026 09:39:42 +0100

installer: pkexec with a listed SHELL, flask redrawn at 20 fps, try.sh click and 4 cores (ADR-0014, step 3)

Diffstat:
Minstaller/src/app.rs | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Minstaller/src/backend.rs | 6+++++-
Minstaller/src/flask.rs | 25++++++++++++++++++++-----
Minstaller/src/system.rs | 29++++++++++++++++++++++++-----
Mlinux/live/try.sh | 20+++++++++++++++++---
5 files changed, 140 insertions(+), 29 deletions(-)

diff --git a/installer/src/app.rs b/installer/src/app.rs @@ -89,7 +89,11 @@ impl App { /// Puts a screen up for the screenshots (`PATINA_INSTALLER_DEMO`). pub fn demo(&mut self, what: &str) { - let first = self.drives.iter().find(|d| d.unusable.is_none()).map(|d| d.path.clone()); + let first = self + .drives + .iter() + .find(|d| d.unusable.is_none()) + .map(|d| d.path.clone()); match what { "choose" => self.chosen = first, "confirm" => { @@ -113,7 +117,9 @@ impl App { fn chosen_drive(&self) -> Option<&Drive> { let path = self.chosen.as_deref()?; - self.drives.iter().find(|d| d.path == path && d.unusable.is_none()) + self.drives + .iter() + .find(|d| d.path == path && d.unusable.is_none()) } fn start_install(&mut self) { @@ -187,13 +193,17 @@ impl App { }); let busy = self.screen == Screen::Installing || self.screenshot.is_some(); ui.ctx() - .request_repaint_after(Duration::from_millis(if busy { 16 } else { 500 })); + .request_repaint_after(Duration::from_millis(if busy { 50 } else { 500 })); } fn heading(ui: &mut Ui, title: &str, sub: &str) { ui.label(RichText::new(title).size(34.0).strong()); ui.add_space(8.0); - ui.label(RichText::new(sub).size(17.0).color(ui.visuals().weak_text_color())); + ui.label( + RichText::new(sub) + .size(17.0) + .color(ui.visuals().weak_text_color()), + ); ui.add_space(26.0); } @@ -219,7 +229,14 @@ impl App { } ui.add_space(16.0); let enter = events.iter().any(|e| { - matches!(e, egui::Event::Key { key: egui::Key::Enter, pressed: true, .. }) + matches!( + e, + egui::Event::Key { + key: egui::Key::Enter, + pressed: true, + .. + } + ) }); let ready = self.chosen_drive().is_some(); if (pill_button(ui, "Continue", ready, false, false).clicked() || enter) && ready { @@ -237,7 +254,10 @@ impl App { &format!("Erase {}?", drive.model), &format!("{} ยท {}", gigabytes(drive.bytes), drive.path), ); - ui.label(format!("This deletes everything on it: {}.", drive.contents.join(", "))); + ui.label(format!( + "This deletes everything on it: {}.", + drive.contents.join(", ") + )); ui.add_space(6.0); ui.label("It cannot be undone."); ui.add_space(28.0); @@ -246,7 +266,14 @@ impl App { } ui.add_space(12.0); let back = events.iter().any(|e| { - matches!(e, egui::Event::Key { key: egui::Key::Escape, pressed: true, .. }) + matches!( + e, + egui::Event::Key { + key: egui::Key::Escape, + pressed: true, + .. + } + ) }); if ui.button("Back").clicked() || back { self.screen = Screen::Choose; @@ -258,9 +285,17 @@ impl App { ui.add_space(10.0); flask::show(ui, seconds, 200.0, true); ui.add_space(28.0); - ui.label(RichText::new("Installing Sector F Linux").size(26.0).strong()); + ui.label( + RichText::new("Installing Sector F Linux") + .size(26.0) + .strong(), + ); ui.add_space(8.0); - ui.label(RichText::new(&self.step).size(16.0).color(ui.visuals().weak_text_color())); + ui.label( + RichText::new(&self.step) + .size(16.0) + .color(ui.visuals().weak_text_color()), + ); ui.add_space(20.0); // A bar only when the progress is real (a bar that lies is worse than none). if let Some(p) = self.progress { @@ -290,7 +325,10 @@ impl App { } if let Some(e) = &self.restart_error { ui.add_space(10.0); - ui.colored_label(ui.visuals().error_fg_color, format!("Could not restart: {e}")); + ui.colored_label( + ui.visuals().error_fg_color, + format!("Could not restart: {e}"), + ); } } @@ -366,7 +404,11 @@ fn drive_card(ui: &mut Ui, drive: &Drive, chosen: bool) -> egui::Response { let width = ui.available_width().min(COLUMN); let (rect, response) = ui.allocate_exact_size( vec2(width, 78.0), - if usable { Sense::click() } else { Sense::hover() }, + if usable { + Sense::click() + } else { + Sense::hover() + }, ); if usable && response.hovered() { ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); @@ -383,7 +425,12 @@ fn drive_card(ui: &mut Ui, drive: &Drive, chosen: bool) -> egui::Response { let painter = ui.painter(); painter.rect_filled(rect, radius, fill); if chosen { - painter.rect_stroke(rect, radius, Stroke::new(2.0, v.selection.bg_fill), StrokeKind::Inside); + painter.rect_stroke( + rect, + radius, + Stroke::new(2.0, v.selection.bg_fill), + StrokeKind::Inside, + ); } let (ink, dim) = if usable { (v.text_color(), v.weak_text_color()) @@ -432,10 +479,22 @@ fn pill_button(ui: &mut Ui, text: &str, ready: bool, busy: bool, danger: bool) - if ready && response.hovered() { ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); } - let accent = if danger { v.error_fg_color } else { v.selection.bg_fill }; - let ink = if danger { v.panel_fill } else { v.selection.stroke.color }; + let accent = if danger { + v.error_fg_color + } else { + v.selection.bg_fill + }; + let ink = if danger { + v.panel_fill + } else { + v.selection.stroke.color + }; let (fill, ink) = if ready { - let fill = if response.hovered() { accent.gamma_multiply(0.85) } else { accent }; + let fill = if response.hovered() { + accent.gamma_multiply(0.85) + } else { + accent + }; (fill, ink) } else { (v.widgets.inactive.weak_bg_fill, v.weak_text_color()) diff --git a/installer/src/backend.rs b/installer/src/backend.rs @@ -74,7 +74,11 @@ impl Backend for Mock { model: "Samsung SSD 980 500GB".into(), serial: "S64DNX0T123456".into(), bytes: 500_107_862_016, - contents: vec!["EFI System".into(), "Windows (ntfs)".into(), "Recovery".into()], + contents: vec![ + "EFI System".into(), + "Windows (ntfs)".into(), + "Recovery".into(), + ], unusable: None, }, Drive { diff --git a/installer/src/flask.rs b/installer/src/flask.rs @@ -38,9 +38,14 @@ pub fn frame_svg(i: usize, glass: Color32, liquid: Color32, background: Color32) } let liquid_path = format!("M200,1000 L200,{first:.1}{wave} L820,1000 Z"); let mut bubbles = String::new(); - for (k, (bx, speed, r)) in [(420.0, 1.0, 17), (520.0, 2.0, 12), (600.0, 1.0, 20), (470.0, 3.0, 9)] - .into_iter() - .enumerate() + for (k, (bx, speed, r)) in [ + (420.0, 1.0, 17), + (520.0, 2.0, 12), + (600.0, 1.0, 20), + (470.0, 3.0, 9), + ] + .into_iter() + .enumerate() { let u = (t * speed + k as f64 * 0.23) % 1.0; let y = 870.0 - u * (870.0 - level); @@ -83,13 +88,23 @@ pub fn show(ui: &mut Ui, seconds: f64, height: f32, animate: bool) { let (glass, liquid, bg) = (v.text_color(), v.selection.bg_fill, v.panel_fill); let i = frame_at(seconds); let svg = frame_svg(i, glass, liquid, bg); - let uri = format!("bytes://flask-{i}-{}{}{}.svg", hex(glass), hex(liquid), hex(bg)); + let uri = format!( + "bytes://flask-{i}-{}{}{}.svg", + hex(glass), + hex(liquid), + hex(bg) + ); ui.add( egui::Image::from_bytes(uri, svg.into_bytes()) .fit_to_exact_size(vec2(height * 700.0 / 835.0, height)), ); if animate { - ui.ctx().request_repaint(); + // One frame of the loop is 50 ms: no need to draw faster, and on a computer with no GPU + // (software rendering) drawing at the screen's rate takes the CPU from the install. + ui.ctx() + .request_repaint_after(std::time::Duration::from_millis( + 1000 * LOOP as u64 / FRAMES as u64, + )); } } diff --git a/installer/src/system.rs b/installer/src/system.rs @@ -27,7 +27,9 @@ impl Backend for System { fn drives(&self) -> Vec<Drive> { let out = Command::new("lsblk") .args([ - "-J", "-b", "-o", + "-J", + "-b", + "-o", "NAME,PATH,TYPE,SIZE,MODEL,SERIAL,RO,FSTYPE,LABEL,PARTLABEL,MOUNTPOINTS", ]) .output(); @@ -64,8 +66,15 @@ fn live_disk() -> Option<String> { if src.is_empty() { return None; } - let parent = Command::new("lsblk").args(["-no", "PKNAME", &src]).output().ok()?; - let parent = String::from_utf8_lossy(&parent.stdout).lines().next()?.trim().to_string(); + let parent = Command::new("lsblk") + .args(["-no", "PKNAME", &src]) + .output() + .ok()?; + let parent = String::from_utf8_lossy(&parent.stdout) + .lines() + .next()? + .trim() + .to_string(); Some(if parent.is_empty() { src.rsplit('/').next()?.to_string() } else { @@ -165,8 +174,15 @@ fn sectors_written(disk: &str) -> Option<u64> { fn run_install(path: &str, tx: &Sender<Event>) { let disk = path.rsplit('/').next().unwrap_or(path).to_string(); + // pkexec refuses a caller whose SHELL is not in /etc/shells, and the greeter user's is nologin. let child = Command::new("sh") - .args(["-c", &format!("exec pkexec {INSTALL} \"$1\" 2>&1"), "sh", path]) + .args([ + "-c", + &format!("exec pkexec {INSTALL} \"$1\" 2>&1"), + "sh", + path, + ]) + .env("SHELL", "/bin/sh") .stdout(Stdio::piped()) .spawn(); let mut child = match child { @@ -247,7 +263,10 @@ mod tests { d[0].contents, ["EFI System Partition (vfat)", "Windows (ntfs)"] ); - assert_eq!(d[1].unusable.as_deref(), Some("The install disc is on this drive")); + assert_eq!( + d[1].unusable.as_deref(), + Some("The install disc is on this drive") + ); assert!(d[2].unusable.as_deref().unwrap().starts_with("Smaller")); assert_eq!(d[2].model, "sdb"); assert_eq!(d[3].contents, ["Empty"]); diff --git a/linux/live/try.sh b/linux/live/try.sh @@ -6,6 +6,7 @@ # linux/live/try.sh start boot it (in the background) # linux/live/try.sh screenshot save the screen to out/iso/screen.png # linux/live/try.sh type 'text' type into it (\t Tab, \n Enter) +# linux/live/try.sh click X Y click at a pixel of the 1280x800 screen # linux/live/try.sh ssh [cmd] root over SSH (a LIVE_DEBUG=1 ISO only), localhost:2223 # linux/live/try.sh disk [a|b] boot an installed drive on its own, without the ISO # linux/live/try.sh stop power it off @@ -26,13 +27,13 @@ case "${1:-}" in for d in a b; do [[ -f "$OUT/drive-$d.qcow2" ]] || qemu-img create -q -f qcow2 "$OUT/drive-$d.qcow2" 16G; done cp -n /usr/share/OVMF/OVMF_VARS_4M.fd "$VARS" rm -f "$MON" - qemu-system-x86_64 -enable-kvm -cpu host -m 4096 -smp 2 -machine q35 \ + qemu-system-x86_64 -enable-kvm -cpu host -m 4096 -smp 4 -machine q35 \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \ -drive if=pflash,format=raw,file="$VARS" \ -drive file="$ISO",media=cdrom,readonly=on \ -drive file="$OUT/drive-a.qcow2",if=none,id=a -device virtio-blk-pci,drive=a,serial=DRIVE-A \ -drive file="$OUT/drive-b.qcow2",if=none,id=b -device virtio-blk-pci,drive=b,serial=DRIVE-B \ - -device virtio-vga -vnc 127.0.0.1:2 -monitor "unix:$MON,server,nowait" \ + -device qemu-xhci -device usb-tablet -device virtio-vga -vnc 127.0.0.1:2 -monitor "unix:$MON,server,nowait" \ -netdev user,id=n0,hostfwd=tcp:127.0.0.1:2223-:22 -device virtio-net-pci,netdev=n0 \ -daemonize -pidfile "$PID" echo "booting: VNC localhost:5902; $0 screenshot" @@ -58,6 +59,19 @@ for ch in sys.argv[1].encode().decode("unicode_escape"): except Exception: pass PY ;; + click) + MON="$MON" python3 -I - "$2" "$3" <<'PY' +import os, socket, sys, time +s = socket.socket(socket.AF_UNIX); s.connect(os.environ["MON"]); s.settimeout(1) +try: s.recv(4096) +except Exception: pass +x, y = int(int(sys.argv[1]) * 32767 / 1280), int(int(sys.argv[2]) * 32767 / 800) +for cmd in (f"mouse_move {x} {y}", "mouse_button 1", "mouse_button 0"): + s.sendall((cmd + "\n").encode()); time.sleep(0.15) + try: s.recv(4096) + except Exception: pass +PY + ;; ssh) shift; exec ssh -i "$ROOT/out/id_ed25519" -p 2223 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR root@127.0.0.1 "$@" ;; disk) @@ -65,7 +79,7 @@ PY d=${2:-a} cp -n /usr/share/OVMF/OVMF_VARS_4M.fd "$OUT/OVMF_VARS_disk.fd" 2>/dev/null || true rm -f "$MON" - qemu-system-x86_64 -enable-kvm -cpu host -m 4096 -smp 2 -machine q35 \ + qemu-system-x86_64 -enable-kvm -cpu host -m 4096 -smp 4 -machine q35 \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd \ -drive if=pflash,format=raw,file="$OUT/OVMF_VARS_disk.fd" \ -drive file="$OUT/drive-$d.qcow2",if=none,id=a -device virtio-blk-pci,drive=a,serial=DRIVE-A \