SHA256
Compare commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
b4127f2fe8 | ||
|
|
1bf3ef0e15 |
@@ -1,43 +0,0 @@
|
||||
name: "Build Release Binary"
|
||||
run-name: "Build Release: ${{ inputs.tag_name }}"
|
||||
|
||||
on:
|
||||
# Allows triggering from another workflow
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag_name:
|
||||
description: 'Git tag to build (e.g., v1.0.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
workflow_dispatch: # Enables manual triggering
|
||||
inputs:
|
||||
tag_name:
|
||||
description: 'Git tag to build (e.g., v1.0.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
env:
|
||||
GIT_DEFAULT_HASH: sha256
|
||||
with:
|
||||
# If triggered manually, use the input tag.
|
||||
# If triggered by push, GITHUB_REF_NAME is the tag.
|
||||
ref: ${{ inputs.tag_name || gitea.ref_name }}
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- name: Build Release Binary
|
||||
run: cargo build --release
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: nyanit-${{ inputs.tag_name || gitea.ref_name }}
|
||||
path: target/release/nyanit
|
||||
@@ -1,40 +0,0 @@
|
||||
name: Create Release with Binary
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Enables manual triggering
|
||||
inputs:
|
||||
tag_name:
|
||||
description: 'Git tag to build (e.g., v1.0.0)'
|
||||
required: true
|
||||
type: string
|
||||
rel_description:
|
||||
description: 'Release description'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
|
||||
jobs:
|
||||
# This job calls the reusable workflow
|
||||
build-binary:
|
||||
uses: ./.gitea/workflows/build-release-binary.yml
|
||||
with:
|
||||
tag_name: "${{ inputs.tag_name }}"
|
||||
|
||||
create-release:
|
||||
needs: build-binary # Wait for the reusable workflow to finish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nyanit-${{ inputs.tag_name }}
|
||||
|
||||
- name: Create Release and Attach Binary
|
||||
uses: actions/release-action@main
|
||||
with:
|
||||
artifacts: "nyanit-${{ inputs.tag_name }}"
|
||||
api_key: ${{ secrets.bzzpss_release_psszz }}
|
||||
tag_name: ${{ inputs.tag_name }}
|
||||
name: Release ${{ inputs.tag_name }}
|
||||
body: "Automated release for ${{ inputs.tag_name }}\n${{ inputs.rel_description }}"
|
||||
|
||||
Generated
+64
-34
@@ -34,9 +34,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.0"
|
||||
version = "2.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
||||
|
||||
[[package]]
|
||||
name = "by_address"
|
||||
@@ -59,6 +59,12 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
||||
|
||||
[[package]]
|
||||
name = "compact_str"
|
||||
version = "0.9.1"
|
||||
@@ -93,7 +99,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -104,7 +110,7 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -190,7 +196,7 @@ dependencies = [
|
||||
"indoc",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -255,6 +261,18 @@ version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.31.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.2.2"
|
||||
@@ -287,8 +305,9 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
||||
|
||||
[[package]]
|
||||
name = "nyanit"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"nix",
|
||||
"ratatui",
|
||||
"ratatui-textarea",
|
||||
"regex",
|
||||
@@ -316,14 +335,14 @@ dependencies = [
|
||||
"by_address",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.13.1"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
||||
checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
@@ -333,18 +352,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.106"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.46"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -429,9 +448,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.13.0"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a0e75113e14dc5acb068cd0786884f214f1312650a3d36d269f5c4f3cdee8a2"
|
||||
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -441,9 +460,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.15"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f388202e4b80542a0921078cc23b6333bcf1409c1e3f86404cae4766a6131db"
|
||||
checksum = "8fcfdb36bda0c880c5931cdc7a2bcdc8ba4556847b9d912bca70bc94708711ad"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -470,9 +489,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
@@ -480,22 +499,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.228"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 3.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -528,14 +547,25 @@ dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.118"
|
||||
version = "2.0.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
|
||||
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -554,29 +584,29 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.18"
|
||||
version = "2.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
|
||||
checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.18"
|
||||
version = "2.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
|
||||
checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 3.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.53"
|
||||
version = "0.3.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18dfaaeddcb932337b5e7866ee7d0ce9b76d2fd092997146f187ec09b4558a50"
|
||||
checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"libc",
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
[package]
|
||||
name = "nyanit"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
nix = { version = "0.31", features = ["mount"] }
|
||||
ratatui = { version = "0.30", default-features = false, features = ["termion"] }
|
||||
ratatui-textarea = { version = "0.9", default-features = false, features = ["termion"] }
|
||||
regex = "1.1"
|
||||
|
||||
+4
-7
@@ -123,16 +123,13 @@ impl NyanitTUI<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
// pub fn bzz_unwrap<T,E>(&mut self, val: Result<T,E>) -> T {
|
||||
// match val {
|
||||
// Ok(v) => v,
|
||||
// }
|
||||
// }
|
||||
/// runs the application's main loop until the user quits
|
||||
pub fn run(&mut self) -> io::Result<()> {
|
||||
self.state = match init_stage() {
|
||||
Ok(st) => st,
|
||||
Err(ex) => NyanitState::Error(format!("Error while trying to bzzz-pss things: {}", ex)),
|
||||
Err(ex) => {
|
||||
NyanitState::Error(format!("Error while trying to bzzz-pss things:\n{}", ex))
|
||||
},
|
||||
};
|
||||
|
||||
// if drive unencrypted and there is no root snapshots finish boot
|
||||
@@ -340,7 +337,7 @@ impl NyanitTUI<'_> {
|
||||
|
||||
|
||||
fn main() -> ExitCode {
|
||||
nyan_system::set_env_vars_unsafe();
|
||||
// nyan_system::set_env_vars_unsafe();
|
||||
let mut app = NyanitTUI::new().unwrap();
|
||||
app.run().unwrap();
|
||||
// Terminal restores automatically when `stdout` (RawTerminal) is dropped
|
||||
|
||||
+49
-15
@@ -18,6 +18,7 @@
|
||||
Functions fot system interaction
|
||||
*/
|
||||
|
||||
use nix;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -101,9 +102,7 @@ impl std::error::Error for ExecCommandError {}
|
||||
|
||||
/// exec given command with arguments, capturing stderr in case or failure
|
||||
pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> {
|
||||
// For testing shake lets assume all binaries is in /usr/bin
|
||||
let ex_cmd = format!("/usr/bin/{}", cmd);
|
||||
let out = Command::new(ex_cmd).args(args).output()?;
|
||||
let out = Command::new(cmd).args(args).output()?;
|
||||
if out.status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
@@ -149,18 +148,24 @@ pub fn bcachefs_unlock(pass: String, dev: &str) -> Result<bool, ExecCommandError
|
||||
use std::process::Stdio;
|
||||
// "-k", "session" is important as it stores key in sessyin keyring what allows
|
||||
// system to mount filesystem after switch_root
|
||||
let mut child = Command::new("bcachefs")
|
||||
.args(&vec!["unlock", "-k", "session", dev])
|
||||
let mut child = Command::new("/usr/bin/bcachefs")
|
||||
.args(&vec!["unlock", "-k", "session", dev])
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()?;
|
||||
|
||||
let mut c_stderr = child.stderr.take().ok_or_else(||{"Unable to get child process STDERR".to_string()})?;
|
||||
let mut c_stderr = child
|
||||
.stderr
|
||||
.take()
|
||||
.ok_or_else(|| "Unable to get child process STDERR".to_string())?;
|
||||
|
||||
// Write password to STDIN in a limited scope
|
||||
{
|
||||
let mut c_stdin = child.stdin.take().ok_or_else(||{"Unable to get child process STDIN".to_string()})?;
|
||||
let mut c_stdin = child
|
||||
.stdin
|
||||
.take()
|
||||
.ok_or_else(|| "Unable to get child process STDIN".to_string())?;
|
||||
// neccessery to use thread or we may be deadlocking
|
||||
c_stdin.write_all(pass.as_bytes())?;
|
||||
let bytes_written = c_stdin.write(b"\n")?;
|
||||
@@ -186,7 +191,7 @@ pub fn bcachefs_unlock(pass: String, dev: &str) -> Result<bool, ExecCommandError
|
||||
|
||||
/// Cheking if device is encripted
|
||||
pub fn bzzpss_dev_encrypted(dev_name: &str) -> Result<bool, ExecCommandError> {
|
||||
match exec_command("bcachefs", &vec!["unlock", "--check", dev_name]) {
|
||||
match exec_command("/usr/bin/bcachefs", &vec!["unlock", "--check", dev_name]) {
|
||||
Ok(_) => Ok(true), // if status OK - dev encrypted
|
||||
Err(ExecCommandError::CommandFailed(_)) => Ok(false), // if bcachefs returned error - unencrypted
|
||||
Err(ex) => Err(ex), // othervice its error
|
||||
@@ -218,11 +223,40 @@ pub fn list_bzzpss_snaps(snaps_dir: &str) -> Result<Vec<String>, ExecCommandErro
|
||||
// mount -t proc none /proc
|
||||
// mount -t sysfs none /sys
|
||||
// modprobe bcachefs
|
||||
pub fn prepare_env() -> Result<(), ExecCommandError> {
|
||||
pub fn prepare_env() -> Result<(), String> {
|
||||
use nix::mount::{mount, MsFlags};
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
// Mount proc filesystem
|
||||
// mount -t proc none /proc
|
||||
exec_command("mount", &vec!["-t", "proc", "none", "/proc"])?;
|
||||
mount(
|
||||
Some("proc"),
|
||||
Path::new("/proc"),
|
||||
Some("proc"),
|
||||
MsFlags::empty(),
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|ex| format!("Error mounting /proc: {}", ex.to_string()))?;
|
||||
|
||||
// mount -t sysfs none /sys
|
||||
exec_command("mount", &vec!["-t", "sysfs", "none", "/sys"])?;
|
||||
mount(
|
||||
Some("sysfs"),
|
||||
Path::new("/sys"),
|
||||
Some("sysfs"),
|
||||
MsFlags::empty(),
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|ex| format!("Error mounting /sys: {}", ex.to_string()))?;
|
||||
|
||||
mount(
|
||||
Some("devtmpfs"),
|
||||
"/dev",
|
||||
Some("devtmpfs"),
|
||||
MsFlags::empty(),
|
||||
None::<&str>,
|
||||
)
|
||||
.map_err(|ex| format!("Error mounting /dev: {}", ex.to_string()))?;
|
||||
|
||||
// modprobe bcachefs
|
||||
// exec_command("modprobe", &vec!["bcachefs"])?;
|
||||
@@ -241,12 +275,12 @@ pub fn set_env_vars_unsafe() -> () {
|
||||
// 3. Construct new path strings
|
||||
let new_path = match env::var("PATH") {
|
||||
Err(_) => custom_bin.to_string(),
|
||||
Ok(v) => format!("{}:{}", v, custom_bin)
|
||||
Ok(v) => format!("{}:{}", custom_bin, v),
|
||||
};
|
||||
|
||||
let new_ld_path = match env::var("LD_LIBRARY_PATH") {
|
||||
Err(_) => custom_lib.to_string(),
|
||||
Ok(v) => format!("{}:{}", v, custom_lib)
|
||||
Ok(v) => format!("{}:{}", custom_lib, v),
|
||||
};
|
||||
|
||||
// 4. Set environment variables (UNSAFE in Rust 2024+)
|
||||
@@ -259,7 +293,7 @@ pub fn set_env_vars_unsafe() -> () {
|
||||
|
||||
// # Mount the real root filesystem
|
||||
pub fn mount_bee_root(mount_point: &str, dev_name: &str) -> Result<(), ExecCommandError> {
|
||||
exec_command("mount", &vec!["-o", "ro", dev_name, mount_point])?;
|
||||
exec_command("/usr/bin/mount", &vec!["-o", "ro", dev_name, mount_point])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -281,7 +315,7 @@ pub fn hand_off_control(mnt_root: &str, init_path: &str) -> Result<(), ExecComma
|
||||
// 3. Execute switch_root.
|
||||
// This call replaces the current Rust process.
|
||||
// It only returns if an error occurs.
|
||||
let err = Command::new("switch_root")
|
||||
let err = Command::new("/usr/bin/switch_root")
|
||||
.arg(mnt_root)
|
||||
.arg(init_path)
|
||||
.exec();
|
||||
|
||||
Reference in New Issue
Block a user