Compare commits

...

7 Commits

Author SHA1 Message Date
ecad003fc0 change to linux612
All checks were successful
Rust / build (push) Successful in 2m16s
update yay command
2025-05-23 19:54:10 +02:00
624b50eb8c polishing
All checks were successful
Rust / build (push) Successful in 2m2s
2025-05-22 04:35:05 +02:00
fd50d22ad4 polishing
All checks were successful
Rust / build (push) Successful in 1m58s
2025-05-22 04:31:25 +02:00
6e2e87c1dc add workflow badge 2025-05-22 04:26:57 +02:00
f2cb66ec29 code cleaning & clippy fix
All checks were successful
Rust / build (push) Successful in 2m4s
2025-05-22 03:32:48 +02:00
0c13a7b258 Byte to u64
Some checks failed
Rust / build (push) Failing after 1m20s
2025-05-22 02:36:06 +02:00
201a936b4b remove
Some checks failed
Rust / build (push) Failing after 45s
2025-05-22 02:15:01 +02:00
18 changed files with 133 additions and 106 deletions

View File

@@ -1,31 +0,0 @@
name: Rust
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
name: Check format
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
name: Run clippy
with:
command: clippy
args: --all-targets --locked -- -D warnings
- uses: actions-rs/cargo@v1
name: Run tests
with:
command: test

102
Cargo.lock generated
View File

@@ -24,7 +24,7 @@ dependencies = [
[[package]] [[package]]
name = "alma" name = "alma"
version = "0.11.0" version = "0.11.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"byte-unit", "byte-unit",
@@ -91,12 +91,12 @@ dependencies = [
[[package]] [[package]]
name = "anstyle-wincon" name = "anstyle-wincon"
version = "3.0.7" version = "3.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" checksum = "6680de5231bd6ee4c6191b8a1325daa282b415391ec9d3a37bd34f2060dc73fa"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"once_cell", "once_cell_polyfill",
"windows-sys", "windows-sys",
] ]
@@ -176,6 +176,12 @@ dependencies = [
"syn 2.0.101", "syn 2.0.101",
] ]
[[package]]
name = "bumpalo"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]] [[package]]
name = "byte-unit" name = "byte-unit"
version = "5.1.6" version = "5.1.6"
@@ -481,6 +487,16 @@ dependencies = [
"syn 2.0.101", "syn 2.0.101",
] ]
[[package]]
name = "js-sys"
version = "0.3.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.5.0" version = "1.5.0"
@@ -538,6 +554,12 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "once_cell_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
[[package]] [[package]]
name = "portable-atomic" name = "portable-atomic"
version = "1.11.0" version = "1.11.0"
@@ -781,6 +803,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "rustversion"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.20" version = "1.0.20"
@@ -1049,9 +1077,13 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.16.0" version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "vec_map" name = "vec_map"
@@ -1080,6 +1112,64 @@ dependencies = [
"wit-bindgen-rt", "wit-bindgen-rt",
] ]
[[package]]
name = "wasm-bindgen"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn 2.0.101",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.101",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
dependencies = [
"unicode-ident",
]
[[package]] [[package]]
name = "which" name = "which"
version = "7.0.3" version = "7.0.3"

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "alma" name = "alma"
version = "0.11.0" version = "0.11.1"
authors = ["Roey Darwish Dror, PurpleCow"] authors = ["Roey Darwish Dror, PurpleCow"]
edition = "2021" edition = "2021"

View File

@@ -1,5 +1,6 @@
# ALMA - Arch Linux Mobile Appliance # ALMA - Arch Linux Mobile Appliance
![rust event push](https://git.spaeth.biz/Lila-Kuh/alma/actions/workflows/rust.yml/badge.svg?branch=master&event=push)
---
Almost every live Linux distribution out there is meant for a specific purpose, whether it's data Almost every live Linux distribution out there is meant for a specific purpose, whether it's data
rescue, privacy, penetration testing or anything else. There are some more generic distributions rescue, privacy, penetration testing or anything else. There are some more generic distributions
but all of them are based on squashfs, meaning that changes don't persist reboots. but all of them are based on squashfs, meaning that changes don't persist reboots.
@@ -33,7 +34,6 @@ date without having to boot it. Encrypting the root partition is as easy as prov
- [Similar projects](#similar-projects) - [Similar projects](#similar-projects)
- [Useful Resources](#useful-resources) - [Useful Resources](#useful-resources)
--- ---
## Installation ## Installation
You can either build the project using cargo build or install the `alma-aur` package. You can either build the project using cargo build or install the `alma-aur` package.

View File

@@ -1,31 +0,0 @@
name: Rust
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
name: Check format
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
name: Run clippy
with:
command: clippy
args: --all-targets --locked -- -D warnings
- uses: actions-rs/cargo@v1
name: Run tests
with:
command: test

View File

@@ -37,10 +37,10 @@ impl FromStr for AurHelper {
install_command: vec![ install_command: vec![
String::from("yay"), String::from("yay"),
String::from("-S"), String::from("-S"),
String::from("--nocleanmenu"), String::from("--cleanmenu=false"),
String::from("--nodiffmenu"), String::from("--diffmenu=false"),
String::from("--noeditmenu"), String::from("--editmenu=false"),
String::from("--noupgrademenu"), String::from(""),
String::from("--useask"), String::from("--useask"),
String::from("--removemake"), String::from("--removemake"),
String::from("--norebuild"), String::from("--norebuild"),
@@ -49,7 +49,7 @@ impl FromStr for AurHelper {
String::from("--answerclean"), String::from("--answerclean"),
String::from("None"), String::from("None"),
String::from("--mflags"), String::from("--mflags"),
String::from("--noconfirm"), String::from(""),
], ],
}), }),
_ => Err(anyhow!("Error parsing AUR helper string: {}", s)), _ => Err(anyhow!("Error parsing AUR helper string: {}", s)),

View File

@@ -9,8 +9,8 @@ SystemMaxUse=16M
pub const BASE_PACKAGES: [&str; 9] = [ pub const BASE_PACKAGES: [&str; 9] = [
"base", "base",
"linux61", "linux612",
"linux61-broadcom-wl", "linux612-broadcom-wl",
"linux-firmware", "linux-firmware",
"grub", "grub",
"efibootmgr", "efibootmgr",

View File

@@ -166,7 +166,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
sgdisk sgdisk
.execute() .execute()
.args(&[ .args([
"-Z", "-Z",
"-o", "-o",
&format!("--new=1::+{}M", boot_size), &format!("--new=1::+{}M", boot_size),
@@ -175,7 +175,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
"--typecode=1:EF00", "--typecode=1:EF00",
"--typecode=2:EF02", "--typecode=2:EF02",
]) ])
.arg(&disk_path) .arg(disk_path)
.run() .run()
.context("Partitioning error")?; .context("Partitioning error")?;
@@ -270,14 +270,14 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["passwd", "-d", "root"]) .args(["passwd", "-d", "root"])
.run() .run()
.context("Failed to delete the root password")?; .context("Failed to delete the root password")?;
info!("Setting locale"); info!("Setting locale");
fs::OpenOptions::new() fs::OpenOptions::new()
.append(true) .append(true)
.write(true) //.write(true)
.open(mount_point.path().join("etc/locale.gen")) .open(mount_point.path().join("etc/locale.gen"))
.and_then(|mut locale_gen| locale_gen.write_all(b"en_US.UTF-8 UTF-8\n")) .and_then(|mut locale_gen| locale_gen.write_all(b"en_US.UTF-8 UTF-8\n"))
.context("Failed to create locale.gen")?; .context("Failed to create locale.gen")?;
@@ -298,7 +298,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["useradd", "-m", "aur"]) .args(["useradd", "-m", "aur"])
.run() .run()
.context("Failed to create temporary user to install AUR packages")?; .context("Failed to create temporary user to install AUR packages")?;
@@ -309,7 +309,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["sudo", "-u", "aur"]) .args(["sudo", "-u", "aur"])
.arg("git") .arg("git")
.arg("clone") .arg("clone")
.arg(format!( .arg(format!(
@@ -323,7 +323,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&[ .args([
"bash", "bash",
"-c", "-c",
&format!( &format!(
@@ -337,7 +337,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["sudo", "-u", "aur"]) .args(["sudo", "-u", "aur"])
.args(&command.aur_helper.install_command) .args(&command.aur_helper.install_command)
.args(aur_pacakges) .args(aur_pacakges)
.run() .run()
@@ -347,7 +347,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["userdel", "-r", "aur"]) .args(["userdel", "-r", "aur"])
.run() .run()
.context("Failed to delete temporary aur user")?; .context("Failed to delete temporary aur user")?;
@@ -413,7 +413,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["systemctl", "enable", "NetworkManager"]) .args(["systemctl", "enable", "NetworkManager"])
.run() .run()
.context("Failed to enable NetworkManager")?; .context("Failed to enable NetworkManager")?;
@@ -433,7 +433,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["mkinitcpio", "-p", "linux61"]) .args(["mkinitcpio", "-p", "linux612"])
.run() .run()
.context("Failed to run mkinitcpio - do you have the base and linux packages installed?")?; .context("Failed to run mkinitcpio - do you have the base and linux packages installed?")?;
@@ -444,7 +444,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
.expect("No tool for blkid") .expect("No tool for blkid")
.execute() .execute()
.arg(root_partition_base.path()) .arg(root_partition_base.path())
.args(&["-o", "value", "-s", "UUID"]) .args(["-o", "value", "-s", "UUID"])
.run_text_output() .run_text_output()
.context("Failed to run blkid")?; .context("Failed to run blkid")?;
let trimmed = uuid.trim(); let trimmed = uuid.trim();
@@ -467,7 +467,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
arch_chroot arch_chroot
.execute() .execute()
.arg(mount_point.path()) .arg(mount_point.path())
.args(&["bash", "-c"]) .args(["bash", "-c"])
.arg(format!("grub-install --target=i386-pc --boot-directory /boot {} && grub-install --target=x86_64-efi --efi-directory /boot --boot-directory /boot --removable && grub-mkconfig -o /boot/grub/grub.cfg", disk_path.display())) .arg(format!("grub-install --target=i386-pc --boot-directory /boot {} && grub-install --target=x86_64-efi --efi-directory /boot --boot-directory /boot --removable && grub-mkconfig -o /boot/grub/grub.cfg", disk_path.display()))
.run().context("Failed to install grub")?; .run().context("Failed to install grub")?;

View File

@@ -73,7 +73,7 @@ impl<'t, 'o> EncryptedDevice<'t, 'o> {
} }
} }
impl<'t, 'o> Drop for EncryptedDevice<'t, 'o> { impl Drop for EncryptedDevice<'_, '_> {
fn drop(&mut self) { fn drop(&mut self) {
if self._close().is_err() { if self._close().is_err() {
warn!("Error closing {}", self.name); warn!("Error closing {}", self.name);
@@ -81,7 +81,7 @@ impl<'t, 'o> Drop for EncryptedDevice<'t, 'o> {
} }
} }
impl<'t, 'o> BlockDevice for EncryptedDevice<'t, 'o> { impl BlockDevice for EncryptedDevice<'_, '_> {
fn path(&self) -> &Path { fn path(&self) -> &Path {
&self.path &self.path
} }

View File

@@ -14,7 +14,7 @@ impl LoopDevice {
let losetup = Tool::find("losetup")?; let losetup = Tool::find("losetup")?;
let output = losetup let output = losetup
.execute() .execute()
.args(&["--find", "-P", "--show"]) .args(["--find", "-P", "--show"])
.arg(file) .arg(file)
.output() .output()
.context("Error creating the image")?; .context("Error creating the image")?;

View File

@@ -78,7 +78,7 @@ impl<'a> MountStack<'a> {
} }
} }
impl<'a> Drop for MountStack<'a> { impl Drop for MountStack<'_> {
fn drop(&mut self) { fn drop(&mut self) {
self._umount().ok(); self._umount().ok();
} }

View File

@@ -17,7 +17,7 @@ impl<'a> Partition<'a> {
} }
} }
impl<'a> BlockDevice for Partition<'a> { impl BlockDevice for Partition<'_> {
fn path(&self) -> &Path { fn path(&self) -> &Path {
&self.path &self.path
} }

View File

@@ -60,14 +60,14 @@ pub fn get_storage_devices(allow_non_removable: bool) -> anyhow::Result<Vec<Devi
vendor: fs::read_to_string(entry.path().join("device/vendor")) vendor: fs::read_to_string(entry.path().join("device/vendor"))
.map(trimmed) .map(trimmed)
.context("Error querying storage devices")?, .context("Error querying storage devices")?,
size: Byte::from_u128( size: Byte::from_u64(
fs::read_to_string(entry.path().join("size")) fs::read_to_string(entry.path().join("size"))
.context("Error querying storage devices")? .context("Error querying storage devices")?
.trim() .trim()
.parse::<u128>() .parse::<u64>()
.context("Could not parse block size to unsigned integer (u128)")? .context("Could not parse block size to unsigned integer (u128)")?
* 512, * 512,
).expect("Invalid byte size"), ),
}); });
} }

View File

@@ -73,10 +73,9 @@ impl<'a> StorageDevice<'a> {
let name = if self let name = if self
.name .name
.chars() .chars()
.rev() .next_back()
.next()
.expect("Storage device name is empty") .expect("Storage device name is empty")
.is_digit(10) .is_ascii_digit()
{ {
format!("{}p{}", self.name, index) format!("{}p{}", self.name, index)
} else { } else {
@@ -93,10 +92,10 @@ impl<'a> StorageDevice<'a> {
} }
} }
impl<'a> BlockDevice for StorageDevice<'a> { impl BlockDevice for StorageDevice<'_> {
fn path(&self) -> &Path { fn path(&self) -> &Path {
&self.path &self.path
} }
} }
impl<'a> Origin for StorageDevice<'a> {} impl Origin for StorageDevice<'_> {}

View File

@@ -12,7 +12,7 @@ pub fn qemu(command: args::QemuCommand) -> anyhow::Result<()> {
let qemu = Tool::find("qemu-system-x86_64")?; let qemu = Tool::find("qemu-system-x86_64")?;
let mut run = qemu.execute(); let mut run = qemu.execute();
run.args(&[ run.args([
"-m", "-m",
"4G", "4G",
"-netdev", "-netdev",
@@ -33,7 +33,7 @@ pub fn qemu(command: args::QemuCommand) -> anyhow::Result<()> {
if PathBuf::from("/dev/kvm").exists() { if PathBuf::from("/dev/kvm").exists() {
debug!("KVM is enabled"); debug!("KVM is enabled");
run.args(&["-enable-kvm", "-cpu", "host"]); run.args(["-enable-kvm", "-cpu", "host"]);
} }
let err = run.exec(); let err = run.exec();