From 1ae8c47392d613c941d9248bf4b39587c40002e0 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Tue, 8 Apr 2025 22:01:02 +0200 Subject: [PATCH] arm --- PKGBUILD | 7 ++++--- src/install/kernel.rs | 15 +++++++++------ src/install/mod.rs | 10 +++++++--- src/install/virt.rs | 4 ++-- src/linux.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ src/pkg.rs | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 14 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 6daa18b..3547f9c 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,12 +1,13 @@ # Maintainer: JMARyA pkgname=navinstall -pkgver=main +pkgver=2025.04.08_5d23197 pkgrel=1 pkgdesc="navOS Installer" -arch=('x86_64') +arch=('x86_64' 'aarch64') url="https://git.hydrar.de/navos/navinstall" license=("MIT") -depends=("arch-install-scripts" "archiso" "sbctl" "sbsigntools" "git") +depends=("arch-install-scripts" "archiso" "git") +optdepends=('sbctl' 'sbsigntools') makedepends=("rustup" "git") source=("${pkgname}::git+https://git.hydrar.de/navos/navinstall.git") sha256sums=("SKIP") diff --git a/src/install/kernel.rs b/src/install/kernel.rs index 5372233..601ee0f 100644 --- a/src/install/kernel.rs +++ b/src/install/kernel.rs @@ -8,12 +8,15 @@ use crate::{ /// Setup initramfs pub fn setup_mkinitcpio(conf: &DriveConfig) { - print_status("Writing /etc/mkinitcpio.d/linux.preset"); - install_file( - "/mnt/etc/mkinitcpio.d/linux.preset", - include_str!("../root/mkinitcpio/linux.preset"), - 0o644, - ); + #[cfg(target_arch = "x86_64")] + { + print_status("Writing /etc/mkinitcpio.d/linux.preset"); + install_file( + "/mnt/etc/mkinitcpio.d/linux.preset", + include_str!("../root/mkinitcpio/linux.preset"), + 0o644, + ); + } // Set kernel cmdline std::fs::create_dir_all("/mnt/etc/kernel").unwrap(); diff --git a/src/install/mod.rs b/src/install/mod.rs index 786de74..50e7c7f 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -51,7 +51,7 @@ pub mod zram; use crate::{ config::InstallConfig, - pkg::{install_pkgs, pacstrap}, + pkg::{self, install_pkgs, pacstrap}, }; /// Uncomment the first occurrence of a specified value in a file. @@ -127,6 +127,11 @@ pub fn install_mnt(conf: InstallConfig, bare: bool) { // Configuration first_boot_values(&conf.general); + + if !matches!(conf.general.mode, crate::config::InstallMode::Base) { + setup_navos(); + } + setup_skel(&conf.general); setup_users(&conf.user.as_ref().unwrap_or(&Vec::new())); setup_ssh(&conf.ssh); @@ -138,8 +143,7 @@ pub fn install_mnt(conf: InstallConfig, bare: bool) { setup_desktop(&conf); } crate::config::InstallMode::Server => { - setup_navos(); - install_pkgs(&["navos_server"]); + install_pkgs(&pkg::SERVER_PKG); } crate::config::InstallMode::Kiosk => { // TODO diff --git a/src/install/virt.rs b/src/install/virt.rs index 584e96e..d410875 100644 --- a/src/install/virt.rs +++ b/src/install/virt.rs @@ -1,6 +1,6 @@ use crate::{ config::{InstallConfig, InstallMode}, - linux::{arch_chroot, run_command, systemd_service_enable}, + linux::{arch_chroot, run_command_noerr, systemd_service_enable}, pkg::install_pkgs, print_status, }; @@ -33,7 +33,7 @@ pub fn setup_virtualization(conf: &InstallConfig) { /// Setup guest utils if running inside a VM pub fn setup_vm() { - let res = run_command(&["systemd-detect-virt", "--vm"], None, false); + let res = run_command_noerr(&["systemd-detect-virt", "--vm"], None, false); let is_vm = res.0.trim(); match is_vm { diff --git a/src/linux.rs b/src/linux.rs index 5cfd3ef..ac41592 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -7,6 +7,49 @@ pub fn is_root() -> bool { getuid() == Uid::from_raw(0) } +pub fn run_command_noerr(cmd: &[&str], input: Option<&str>, inherit: bool) -> (String, String) { + print_status(&cmd.join(" ")); + + let mut cmd_setup = std::process::Command::new(cmd[0]); + let mut cmd_setup = cmd_setup.args(cmd.iter().skip(1).collect::>()); + + if inherit { + assert!(input.is_none()); + cmd_setup = cmd_setup + .stdout(std::process::Stdio::inherit()) + .stdin(std::process::Stdio::inherit()); + } else { + cmd_setup = cmd_setup.stdout(std::process::Stdio::piped()); + } + + if input.is_some() { + cmd_setup = cmd_setup.stdin(std::process::Stdio::piped()); + } + + let mut child = cmd_setup.spawn().unwrap(); + + if let Some(input) = input { + let stdin = child.stdin.as_mut().unwrap(); + stdin.write_all(input.as_bytes()).unwrap(); + stdin.flush().unwrap(); + } + + let status = child.wait_with_output().unwrap(); + + let output = String::from_utf8(status.stdout).unwrap(); + let stderr = String::from_utf8(status.stderr).unwrap(); + + if !stderr.trim().is_empty() && !inherit { + eprintln!("{stderr}"); + } + + if !inherit { + println!("{output}"); + } + + (output, stderr) +} + pub fn run_command(cmd: &[&str], input: Option<&str>, inherit: bool) -> (String, String) { print_status(&cmd.join(" ")); diff --git a/src/pkg.rs b/src/pkg.rs index b89d423..d1c023c 100644 --- a/src/pkg.rs +++ b/src/pkg.rs @@ -3,6 +3,32 @@ use crate::{ linux::{arch_chroot, run_command}, }; +pub const DESKTOP_PKG: [&str; 17] = [ + // Desktop + "plasma", + "sddm", + // Sound + "pipewire", + "pipewire-alsa", + "pipewire-pulse", + "pipewire-jack", + "wireplumber", + // Applications + "konsole", + "dolphin", + "ffmpegthumbs", + "kate", + "okular", + "gwenview", + "ark", + "flatpak", + // Misc + "navos/navos", + "man", +]; + +pub const SERVER_PKG: [&str; 2] = ["tmux", "navos/navos"]; + /// Install packages to the chroot environment at `/mnt` pub fn install_pkgs(pkg: &[&str]) { let mut cmd = vec!["pacman", "-Syu"]; @@ -32,8 +58,14 @@ pub fn pacstrap(conf: &PackageConfig) { "zsh", "zsh-completions", "zsh-autosuggestions", + "plymouth", ]; + #[cfg(target_arch = "aarch64")] + { + cmd.extend(&["archlinuxarm-keyring"]); + } + cmd.extend( &conf .pkg