feat: new update logic

- feat: update xmrig and p2pool only if bundle button is checked
- feat: default value for bundle button depends of bundle or standalone
version, with feature bundle.
- feat: update CI to use the feature bundle and produce different Gupaxx
binairies for standalone and bundle version.
- feat: ask user to restart Gupaxx after updating.
- feat: prevent user to update twice without restart
- feat: use bundled XMRig and P2Pool of Gupaxx instead of upstream
version.
- feat: update test
- feat: update DIFFERENCES and ARCHITECTURE to reflect updates
differences
- fix: temporary directories of updates not deleted introduced in fork
- fix: #4
This commit is contained in:
Cyrix126 2024-04-21 14:59:04 +02:00
parent 697fd99124
commit 6b27ff499f
12 changed files with 317 additions and 689 deletions

View file

@ -54,12 +54,22 @@ jobs:
cargo bundle --release --target aarch64-apple-darwin
mv target/release/bundle/osx/Gupaxx.app Gupaxx-macos-x64.app
mv target/aarch64-apple-darwin/release/bundle/osx/Gupaxx.app Gupaxx-macos-arm64.app
tar -cf macos.tar Gupaxx-macos-arm64.app Gupaxx-macos-x64.app
cargo bundle --release --features=bundle
cargo bundle --release --target aarch64-apple-darwin --features=bundle
mv target/release/bundle/osx/Gupaxx.app Gupaxx-macos-x64.app_b
mv target/aarch64-apple-darwin/release/bundle/osx/Gupaxx.app Gupaxx-macos-arm64.app_b
tar -cf macos.tar Gupaxx-macos-arm64.app Gupaxx-macos-x64.app Gupaxx-macos-arm64_b.app Gupaxx-macos-x64_b.app
elif [ "$RUNNER_OS" == "Linux" ]; then
cargo build --release --target x86_64-unknown-linux-gnu
mv target/x86_64-unknown-linux-gnu/release/gupaxx .
tar -cf linux.tar gupaxx
cargo build --release --target x86_64-unknown-linux-gnu --features=bundle
mv target/x86_64-unknown-linux-gnu/release/gupaxx gupaxx_b
tar -cf linux.tar gupaxx gupaxx_b
cargo build --release --target x86_64-pc-windows-gnu
mv target/x86_64-pc-windows-gnu/release/gupaxx.exe .
cargo build --release --target x86_64-pc-windows-gnu --features=bundle
mv target/x86_64-pc-windows-gnu/release/gupaxx.exe gupaxx_b.exe
tar -cf windows.tar gupaxx.exe gupaxx_b.exe
fi
shell: bash
@ -68,7 +78,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: windows
path: target/x86_64-pc-windows-gnu/release/gupaxx.exe
path: windows.tar
- name: Archive
if: ${{ runner.os == 'macOS' }}

View file

@ -29,3 +29,14 @@ Status of process for Xmrig use for some information an image of data when the p
The node of xmrig in upstream can not change without a restart of the process.In this fork, the node used by xmrig needs to be updated without restart (using the config HTTP API of xmrig).
So Gupaxx need to refresh the value of status tab submenu process for xmrig where before the values could not change without a restart of the process.
The field node from ImgXmrig needs to be moved to PubXvbApi. This value must be updated by xmrig at start and by XvB process at runtime.
## Updates
A new option in Gupaxx tab advanced will enable bundled updates.
The binary included of gupaxx will have default value for bundled updates depending if it is coming from standalone or bundle release.
Updates from Gupaxx will do the following differently from upstream:
- check if using bundled or standalone with state. Update only Gupaxx binary if the latter or xmrig and p2pool from bundle version if the former.
- prevent user to run updates twice without restart.
- ask the user to restart Gupaxx
- do not verify if file p2pool or xmrig exist. (so that the update can create them).

1
Cargo.lock generated
View file

@ -2075,6 +2075,7 @@ dependencies = [
"benri",
"bounded-vec-deque",
"bytes",
"cfg-if",
"chrono",
"derive_more",
"dirs",

View file

@ -25,6 +25,7 @@ incremental = true
[features]
default = []
bundle = []
distro = []
[dependencies]
@ -73,6 +74,7 @@ readable = "0.16"
chrono = {version="0.4.37", default-features=false, features=["clock", "std"]}
enclose = "1.1.8"
bounded-vec-deque = {version="0.1.1", default-features=false}
cfg-if = "1.0"
# Unix dependencies
[target.'cfg(unix)'.dependencies]
eframe = { version = "0.27.2", features = ["wgpu"] }

View file

@ -23,6 +23,10 @@ The rendering of Tabs has been modified so that the minimum stated size of the w
The rendering of the benchmark table and of console outputs were calculating every line at the same time. Now it only renders what you see. It is a significant improvement for your processor, and you can feel the difference if it is not very powerful.
Updates from Gupaxx does not retrieve xmrig and p2pool from upstream anymore, but use versions in the bundled version. This modification prevent bad surprise (see #3).
It also allows advanced users to use your their own version of p2pool and xmrig.The standalone version of Gupaxx will not replace them.
## Security
With the upgrade of dependencies, cargo audit show no warnings instead of 5 vulnerabilities and 4 allowed warnings for Gupax.

View file

@ -49,7 +49,7 @@ impl Gupax {
ui.add_sized([width, button], Button::new("Updates are disabled"))
.on_disabled_hover_text(DISTRO_NO_UPDATE);
#[cfg(not(feature = "distro"))]
ui.set_enabled(!updating);
ui.set_enabled(!updating && *lock!(restart) == Restart::No);
#[cfg(not(feature = "distro"))]
if ui
.add_sized([width, button], Button::new("Check for updates"))
@ -78,7 +78,7 @@ impl Gupax {
debug!("Gupaxx Tab | Rendering bool buttons");
ui.horizontal(|ui| {
ui.group(|ui| {
let width = (size.x - SPACE * 12.0) / 6.0;
let width = (size.x - SPACE * 15.0) / 7.0;
let height = if self.simple {
size.y / 10.0
} else {
@ -89,6 +89,9 @@ impl Gupax {
ui.add_sized(size, Checkbox::new(&mut self.auto_update, "Auto-Update"))
.on_hover_text(GUPAX_AUTO_UPDATE);
ui.separator();
ui.add_sized(size, Checkbox::new(&mut self.bundled, "Bundle"))
.on_hover_text(GUPAX_BUNDLED_UPDATE);
ui.separator();
ui.add_sized(size, Checkbox::new(&mut self.auto_p2pool, "Auto-P2Pool"))
.on_hover_text(GUPAX_AUTO_P2POOL);
ui.separator();
@ -100,13 +103,13 @@ impl Gupax {
ui.separator();
ui.add_sized(
size,
Checkbox::new(&mut self.ask_before_quit, "Ask before quit"),
Checkbox::new(&mut self.ask_before_quit, "Confirm quit"),
)
.on_hover_text(GUPAX_ASK_BEFORE_QUIT);
ui.separator();
ui.add_sized(
size,
Checkbox::new(&mut self.save_before_quit, "Save before quit"),
Checkbox::new(&mut self.save_before_quit, "Save on quit"),
)
.on_hover_text(GUPAX_SAVE_BEFORE_QUIT);
});

View file

@ -15,13 +15,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::components::update::Pkg;
use crate::components::update::get_user_agent;
use crate::{constants::*, macros::*};
use egui::Color32;
use log::*;
use rand::{thread_rng, Rng};
use reqwest::{Client, RequestBuilder};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
@ -384,7 +383,7 @@ impl Ping {
let client = Client::new();
// Random User Agent
let rand_user_agent = Pkg::get_user_agent();
let rand_user_agent = get_user_agent();
// Handle vector
let mut handles = Vec::with_capacity(REMOTE_NODE_LENGTH);
let node_vec = arc_mut!(Vec::with_capacity(REMOTE_NODE_LENGTH));
@ -486,8 +485,7 @@ mod test {
use crate::components::node::{
format_ip, REMOTE_NODES, REMOTE_NODE_LENGTH, REMOTE_NODE_MAX_CHARS,
};
use crate::components::update::Pkg;
use crate::components::update::get_user_agent;
#[test]
fn validate_node_ips() {
for (ip, location, rpc, zmq) in REMOTE_NODES {
@ -524,7 +522,7 @@ mod test {
let client = Client::new();
// Random User Agent
let rand_user_agent = Pkg::get_user_agent();
let rand_user_agent = get_user_agent();
// Only fail this test if >50% of nodes fail.
const HALF_REMOTE_NODES: usize = REMOTE_NODE_LENGTH / 2;

File diff suppressed because it is too large Load diff

View file

@ -191,6 +191,7 @@ pub struct Gupax {
pub selected_scale: f32,
pub tab: Tab,
pub ratio: Ratio,
pub bundled: bool,
}
#[derive(Clone, Eq, PartialEq, Debug, Deserialize, Serialize)]
@ -288,6 +289,10 @@ impl Default for Gupax {
selected_scale: APP_DEFAULT_SCALE,
ratio: Ratio::Width,
tab: Tab::Xvb,
#[cfg(feature = "bundle")]
bundled: true,
#[cfg(not(feature = "bundle"))]
bundled: false,
}
}
}

View file

@ -43,6 +43,7 @@ mod test {
selected_scale = 0.0
tab = "About"
ratio = "Width"
bundled = false
[status]
submenu = "P2pool"

View file

@ -141,7 +141,7 @@ pub fn get_exe_dir() -> Result<String, std::io::Error> {
#[cold]
#[inline(never)]
pub fn clean_dir() -> Result<(), anyhow::Error> {
let regex = Regex::new("^gupax_update_[A-Za-z0-9]{10}$").unwrap();
let regex = Regex::new("^gupaxx_update_[A-Za-z0-9]{10}$").unwrap();
for entry in std::fs::read_dir(get_exe_dir()?)? {
let entry = entry?;
if !entry.path().is_dir() {

View file

@ -264,8 +264,10 @@ pub const STATUS_SUBMENU_OTHER_BENCHMARKS: &str =
// Gupaxx
pub const GUPAX_UPDATE: &str =
"Check for updates on Gupaxx, P2Pool, and XMRig via GitHub's API and upgrade automatically";
"Check for updates on Gupaxx and bundled versions of P2Pool and XMRig via GitHub's API and upgrade automatically";
pub const GUPAX_AUTO_UPDATE: &str = "Automatically check for updates at startup";
pub const GUPAX_BUNDLED_UPDATE: &str =
"Update XMRig and P2Pool with bundled versions of latest Gupaxx. It will replace any present xmrig and p2pool binary in their specified path.";
pub const GUPAX_SHOULD_RESTART: &str =
"Gupaxx was updated. A restart is recommended but not required";
// #[cfg(not(target_os = "macos"))]