Compare commits
10 Commits
c617f59461
...
3622c75567
Author | SHA1 | Date |
---|---|---|
|
3622c75567 | |
|
26817b0e3c | |
|
8f41d83a3d | |
|
0434d3749c | |
|
064f2fb4fc | |
|
25b2118d49 | |
|
0b5e1bb0a7 | |
|
2299514559 | |
|
fbc5155c85 | |
|
6a8b9604c2 |
4
.env
4
.env
|
@ -1,2 +1,2 @@
|
||||||
RUN="sudo"
|
RUN="/usr/bin/pacman"
|
||||||
PARAM="/usr/bin/pacman -Syu --needed --noconfirm --noprogressbar"
|
PARAM="-Syu --needed --noconfirm --noprogressbar"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# RUN="sudo"
|
# RUN="/usr/bin/pacman"
|
||||||
# PARAM="/usr/bin/pacman -Syu --needed --noconfirm"
|
# PARAM="/usr/bin/pacman -Syu --needed --noconfirm --noprogressbar"
|
||||||
RUN="find"
|
RUN="find"
|
||||||
PARAM=".git"
|
PARAM=".git"
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
*.lock
|
*.lock
|
||||||
|
.trunk/
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
*out
|
||||||
|
*logs
|
||||||
|
*actions
|
||||||
|
*notifications
|
||||||
|
*tools
|
||||||
|
plugins
|
||||||
|
user_trunk.yaml
|
||||||
|
user.yaml
|
||||||
|
tmp
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Prettier friendly markdownlint config (all formatting rules disabled)
|
||||||
|
extends: markdownlint/style/prettier
|
|
@ -0,0 +1 @@
|
||||||
|
edition = "2021"
|
|
@ -0,0 +1,7 @@
|
||||||
|
enable=all
|
||||||
|
source-path=SCRIPTDIR
|
||||||
|
disable=SC2154
|
||||||
|
|
||||||
|
# If you're having issues with shellcheck following source, disable the errors via:
|
||||||
|
# disable=SC1090
|
||||||
|
# disable=SC1091
|
|
@ -0,0 +1,14 @@
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
{
|
||||||
|
name: "preset-default",
|
||||||
|
params: {
|
||||||
|
overrides: {
|
||||||
|
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
|
||||||
|
sortAttrs: true,
|
||||||
|
removeOffCanvasPaths: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
|
@ -0,0 +1,39 @@
|
||||||
|
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
|
||||||
|
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
|
||||||
|
version: 0.1
|
||||||
|
cli:
|
||||||
|
version: 1.22.0
|
||||||
|
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
|
||||||
|
plugins:
|
||||||
|
sources:
|
||||||
|
- id: trunk
|
||||||
|
ref: v1.5.0
|
||||||
|
uri: https://github.com/trunk-io/plugins
|
||||||
|
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
||||||
|
runtimes:
|
||||||
|
enabled:
|
||||||
|
- go@1.21.0
|
||||||
|
- node@18.12.1
|
||||||
|
- python@3.10.8
|
||||||
|
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
|
||||||
|
lint:
|
||||||
|
enabled:
|
||||||
|
- clippy@1.65.0
|
||||||
|
- dotenv-linter@3.3.0
|
||||||
|
- git-diff-check
|
||||||
|
- markdownlint@0.41.0
|
||||||
|
- oxipng@9.1.1
|
||||||
|
- prettier@3.3.2
|
||||||
|
- rustfmt@1.65.0
|
||||||
|
- shellcheck@0.10.0
|
||||||
|
- shfmt@3.6.0
|
||||||
|
- svgo@3.3.2
|
||||||
|
- taplo@0.8.1
|
||||||
|
- trufflehog@3.79.0
|
||||||
|
actions:
|
||||||
|
disabled:
|
||||||
|
- trunk-announce
|
||||||
|
- trunk-check-pre-push
|
||||||
|
- trunk-fmt-pre-commit
|
||||||
|
enabled:
|
||||||
|
- trunk-upgrade-available
|
14
Cargo.toml
14
Cargo.toml
|
@ -1,15 +1,15 @@
|
||||||
[package]
|
[package]
|
||||||
authors = ["Valeria Fadeeva <valeria@fadeeva.me>"]
|
authors = ["Valeria Fadeeva <valeria@fadeeva.me>"]
|
||||||
name = "arch-linux-updater"
|
name = "melawy-linux-updater"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = "^0.3"
|
futures = "0.3"
|
||||||
fltk = { version = "^1.4", features = ["fltk-bundled"] }
|
fltk = { version = "1.5", features = ["fltk-bundled"] }
|
||||||
fltk-theme = "^0.7"
|
fltk-theme = "0.7"
|
||||||
tokio = { version = "^1.33", features = ["full"] }
|
tokio = { version = "^1", features = ["full"] }
|
||||||
# bytes = "^1.4"
|
# bytes = "1.9"
|
||||||
dotenv = "^0.15"
|
dotenv = "0.15"
|
||||||
|
|
|
@ -6,6 +6,4 @@ Arch linux updater for Melawy Linux
|
||||||
|
|
||||||
[YooMoney](https://yoomoney.ru/to/4100115921160758)
|
[YooMoney](https://yoomoney.ru/to/4100115921160758)
|
||||||
|
|
||||||
[Qiwi](https://qiwi.com/n/VALERIAFADEEVA)
|
|
||||||
|
|
||||||
Etherium 0x981FBf878fe451BDB83BEaF68078394d4B13213f
|
Etherium 0x981FBf878fe451BDB83BEaF68078394d4B13213f
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
Cmnd_Alias UPDATES = /usr/bin/pacman (-Sy|-Su|-Syyu|-Syuu), /usr/bin/arch-linux-updater
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/arch-linux-updater
|
||||||
%whell ALL=(ALL:ALL) NOPASSWD: UPDATES
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Sy
|
||||||
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Su
|
||||||
# %wheel ALL = NOPASSWD: /usr/bin/arch-linux-updater
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syu
|
||||||
# %whell ALL=(ALL:ALL) ALL
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syyu
|
||||||
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syuu
|
||||||
|
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/pacman -Syyuu
|
||||||
|
|
3
push.sh
3
push.sh
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
git add . && git commit -m "Update" && git push
|
git add . && git commit -m "Update"
|
||||||
|
git push
|
||||||
|
|
||||||
echo "Ready"
|
echo "Ready"
|
||||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -2,20 +2,22 @@
|
||||||
|
|
||||||
extern crate dotenv;
|
extern crate dotenv;
|
||||||
|
|
||||||
use fltk::{prelude::*, app, text::SimpleTerminal, enums::Color, frame, window, /*button,*/ image};
|
use fltk::{app, enums::Color, frame, /*button,*/ image, prelude::*, terminal::Terminal, window,};
|
||||||
use fltk_theme::{/*ColorTheme, color_themes, widget_themes, */WidgetTheme, ThemeType, WidgetScheme, SchemeType};
|
use fltk_theme::{
|
||||||
|
SchemeType, ThemeType, WidgetScheme,
|
||||||
|
/*ColorTheme, color_themes, widget_themes, */ WidgetTheme,
|
||||||
|
};
|
||||||
|
|
||||||
use tokio::io::{self, BufReader, AsyncBufReadExt};
|
use tokio::io::{self, AsyncBufReadExt, BufReader};
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::Stdio;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::process::Stdio;
|
||||||
|
|
||||||
async fn run_process() -> tokio::process::Child {
|
async fn run_process() -> tokio::process::Child {
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
let env_path = Path::new("/etc/arch-linux-updater/.env");
|
let env_path = Path::new("/etc/melawy-linux-updater/.env");
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
let env_path = Path::new(".env_debug");
|
let env_path = Path::new(".env_debug");
|
||||||
|
@ -31,48 +33,47 @@ async fn run_process() -> tokio::process::Child {
|
||||||
println!("{cmd_line} {par}");
|
println!("{cmd_line} {par}");
|
||||||
|
|
||||||
let child: tokio::process::Child = Command::new(cmd_line)
|
let child: tokio::process::Child = Command::new(cmd_line)
|
||||||
.args(v)
|
.args(v)
|
||||||
.stderr(Stdio::piped()) // don't care about stderr
|
.stderr(Stdio::piped()) // don't care about stderr
|
||||||
.stdout(Stdio::piped()) // set up stdout so we can read it
|
.stdout(Stdio::piped()) // set up stdout so we can read it
|
||||||
.stdin(Stdio::piped()) // set up stdin so we can write on it
|
.stdin(Stdio::piped()) // set up stdin so we can write on it
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Could not run the command"); // finally run the command
|
.expect("Could not run the command"); // finally run the command
|
||||||
|
|
||||||
child
|
child
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn get_stdout() -> tokio::process::ChildStdout {
|
async fn get_stdout() -> tokio::process::ChildStdout {
|
||||||
let mut child: tokio::process::Child = run_process().await;
|
let mut child: tokio::process::Child = run_process().await;
|
||||||
|
|
||||||
let stdout: tokio::process::ChildStdout = child.stdout.take()
|
let stdout: tokio::process::ChildStdout = child
|
||||||
|
.stdout
|
||||||
|
.take()
|
||||||
.expect("child did not have a handle to stdout");
|
.expect("child did not have a handle to stdout");
|
||||||
|
|
||||||
stdout
|
stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn get_buffer() -> BufReader<tokio::process::ChildStdout> {
|
async fn get_buffer() -> BufReader<tokio::process::ChildStdout> {
|
||||||
let buffer: BufReader<tokio::process::ChildStdout> = BufReader::new(get_stdout().await);
|
let buffer: BufReader<tokio::process::ChildStdout> = BufReader::new(get_stdout().await);
|
||||||
|
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn get_lines() -> io::Lines<BufReader<tokio::process::ChildStdout>> {
|
async fn get_lines() -> io::Lines<BufReader<tokio::process::ChildStdout>> {
|
||||||
let lines: io::Lines<BufReader<tokio::process::ChildStdout>> = get_buffer().await.lines();
|
let lines: io::Lines<BufReader<tokio::process::ChildStdout>> = get_buffer().await.lines();
|
||||||
|
|
||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_line(
|
||||||
async fn get_line(lines: &mut io::Lines<BufReader<tokio::process::ChildStdout>>) -> io::Result<Option<String>> {
|
lines: &mut io::Lines<BufReader<tokio::process::ChildStdout>>,
|
||||||
|
) -> io::Result<Option<String>> {
|
||||||
let line: Result<Option<String>, io::Error> = lines.next_line().await;
|
let line: Result<Option<String>, io::Error> = lines.next_line().await;
|
||||||
|
|
||||||
line
|
line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn gui() -> io::Result<()> {
|
async fn gui() -> io::Result<()> {
|
||||||
let width = 1100;
|
let width = 1100;
|
||||||
let height = 700;
|
let height = 700;
|
||||||
|
@ -89,22 +90,22 @@ async fn gui() -> io::Result<()> {
|
||||||
let mut wind: fltk::window::DoubleWindow = window::Window::default()
|
let mut wind: fltk::window::DoubleWindow = window::Window::default()
|
||||||
.with_size(width, height)
|
.with_size(width, height)
|
||||||
.center_screen()
|
.center_screen()
|
||||||
.with_label("Arch Linux Updater");
|
.with_label("Melawy Linux Updater");
|
||||||
|
|
||||||
// let image = image::PngImage::load("assets/icons/Melawy.png").unwrap();
|
let image =
|
||||||
let image = image::PngImage::load("/usr/share/arch-linux-updater/assets/icons/Melawy.png").unwrap();
|
image::SvgImage::load("/usr/share/melawy-linux-updater/assets/icons/Melawy.svg").unwrap();
|
||||||
// let image = image::PngImage::load(&std::path::Path::new("assets/icons/Melawy.png")).unwrap();
|
|
||||||
wind.set_icon(Some(image));
|
wind.set_icon(Some(image));
|
||||||
|
|
||||||
let frame = frame::Frame::default_fill()
|
let frame = frame::Frame::default_fill()
|
||||||
.with_size(width, height)
|
.with_size(width, height)
|
||||||
.center_of(&wind);
|
.center_of(&wind);
|
||||||
|
|
||||||
let mut terminal: SimpleTerminal = SimpleTerminal::default_fill()
|
let mut term: Terminal = Terminal::default_fill()
|
||||||
.with_size(width, height)
|
.with_size(width, height)
|
||||||
.center_of(&frame);
|
.center_of(&frame);
|
||||||
terminal.set_color(Color::Background2);
|
term.set_color(Color::Background2);
|
||||||
terminal.set_text_color(Color::Light2);
|
term.set_text_color(Color::Light2);
|
||||||
|
term.set_history_rows(5000);
|
||||||
|
|
||||||
wind.make_resizable(true);
|
wind.make_resizable(true);
|
||||||
wind.end();
|
wind.end();
|
||||||
|
@ -114,11 +115,10 @@ async fn gui() -> io::Result<()> {
|
||||||
|
|
||||||
let mut lines: io::Lines<BufReader<tokio::process::ChildStdout>> = get_lines().await;
|
let mut lines: io::Lines<BufReader<tokio::process::ChildStdout>> = get_lines().await;
|
||||||
|
|
||||||
|
|
||||||
// app.run().unwrap();
|
// app.run().unwrap();
|
||||||
while app.wait() {
|
while app.wait() {
|
||||||
if let Some(line) = get_line(&mut lines).await? {
|
if let Some(line) = get_line(&mut lines).await? {
|
||||||
terminal.append(format!("{}\n", line).as_str());
|
term.append(format!("{}\n", line).as_str());
|
||||||
} else {
|
} else {
|
||||||
if printed_close_msg == false {
|
if printed_close_msg == false {
|
||||||
let lang_key = "LANG";
|
let lang_key = "LANG";
|
||||||
|
@ -134,7 +134,7 @@ async fn gui() -> io::Result<()> {
|
||||||
"Now this window may close"
|
"Now this window may close"
|
||||||
};
|
};
|
||||||
|
|
||||||
terminal.append(format!("\n{}\n", text_to_close).as_str());
|
term.append(format!("\n{}\n", text_to_close).as_str());
|
||||||
printed_close_msg = true;
|
printed_close_msg = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,6 @@ async fn gui() -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> io::Result<()> {
|
async fn main() -> io::Result<()> {
|
||||||
gui().await
|
gui().await
|
||||||
|
|
Loading…
Reference in New Issue