From 6fec26db275acb32b58ef7b381402fdeb2e220e3 Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Mon, 25 Nov 2024 02:44:41 +0700 Subject: [PATCH] Replaces Flatpak with normal binary (#1140) --- .github/workflows/ci-linux.yml | 64 +++++++++------------------------- flatpak.yml | 38 -------------------- gui/core.h | 5 --- gui/initialize_wizard.cpp | 19 ---------- gui/src/lib.rs | 1 - gui/src/main.rs | 1 - gui/src/system/ffi.rs | 18 ---------- gui/src/system/mod.rs | 2 -- gui/system.cpp | 43 ----------------------- gui/system.hpp | 1 - 10 files changed, 17 insertions(+), 175 deletions(-) delete mode 100644 flatpak.yml delete mode 100644 gui/src/system/ffi.rs delete mode 100644 gui/src/system/mod.rs diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index aee19e904..3259c0a2e 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -4,69 +4,39 @@ on: jobs: build: name: Linux - runs-on: ubuntu-22.04 + runs-on: ubuntu-22.04 # Lowest version that support Vulkan 1.3. steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install System Packages run: | sudo apt-get update - sudo apt-get install -y flatpak flatpak-builder + sudo apt-get install -y libvulkan-dev - name: Update Rust run: rustup update stable - name: Add additional Rust targets run: rustup target add x86_64-unknown-none - name: Lint Rust sources run: cargo clippy --package obkrnl --target x86_64-unknown-none -- -D warnings + - name: Build + run: ./build.py -r - name: Run tests run: cargo test --workspace --exclude gui --exclude kernel - - name: Add Flathub - run: flatpak remote-add --user flathub https://flathub.org/repo/flathub.flatpakrepo - - name: Generate cache keys + - name: Generate launch script run: | - echo "flatpak-runtime=${{ runner.os }}-flatpak-runtime-${{ hashFiles('flatpak.yml') }}" >> $GITHUB_OUTPUT - id: cache-keys - - name: Restore Flatpak runtimes - uses: actions/cache/restore@v4 - with: - path: ~/.local/share/flatpak/runtime - key: ${{ steps.cache-keys.outputs.flatpak-runtime }} - id: flatpak-runtime - - name: Install Flatpak runtimes - run: | - flatpak install --noninteractive flathub \ - org.freedesktop.Platform//24.08 org.freedesktop.Sdk//24.08 - if: ${{ steps.flatpak-runtime.outputs.cache-hit != 'true' }} - - name: Generate Flatpak branch - run: | - my $name; + #!/bin/sh -e + this=$(readlink -f "$0") + root=$(dirname "$this") - if ($ENV{GITHUB_REF} =~ /^refs\/pull\/(\d+)\//) { - $name = "pr-$1"; - } else { - $name = 'dev'; - } - - open(my $fh, '>>', $ENV{GITHUB_OUTPUT}) || die "Cannot open $ENV{GITHUB_OUTPUT}: $!\n"; - print $fh "flatpak-branch=$name\n"; - shell: perl {0} - id: flatpak-branch - - name: Change KVM permission - run: sudo chmod o+rw /dev/kvm - - name: Build Flatpak - run: flatpak-builder --default-branch ${{ steps.flatpak-branch.outputs.flatpak-branch }} build flatpak.yml - - name: Export Flatpak - run: flatpak build-export flatpak build - - name: Bundle Flatpak - run: flatpak build-bundle flatpak obliteration.flatpak io.github.obhq.Obliteration --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo - - name: Cache Flatpak runtimes - uses: actions/cache/save@v4 - with: - path: ~/.local/share/flatpak/runtime - key: ${{ steps.cache-keys.outputs.flatpak-runtime }}-${{ github.run_id }} - if: startsWith(github.ref, 'refs/heads/') - - name: Upload Flatpak + exec "$root/bin/obliteration" + shell: cp {0} dist/obliteration.sh + - name: Create distribution tarball + run: | + mv dist obliteration + chmod +x obliteration/obliteration.sh + tar -cvf obliteration.tar obliteration + - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: obliteration-linux-amd64 - path: obliteration.flatpak + path: obliteration.tar diff --git a/flatpak.yml b/flatpak.yml deleted file mode 100644 index 84e22caf6..000000000 --- a/flatpak.yml +++ /dev/null @@ -1,38 +0,0 @@ -app-id: io.github.obhq.Obliteration -default-branch: stable -runtime: org.freedesktop.Platform -runtime-version: '24.08' -platform-extensions: -- org.freedesktop.Platform.GL.default -sdk: org.freedesktop.Sdk -command: obliteration -build-options: - build-args: - - --share=network -finish-args: - - --filesystem=home - - --share=network - - --share=ipc - - --socket=fallback-x11 - - --socket=wayland - - --device=dri - - --device=kvm - - --socket=pulseaudio -modules: -- name: obliteration - build-options: - env: - RUSTUP_HOME: /run/build/obliteration/.rustup - CARGO_HOME: /run/build/obliteration/.cargo - append-path: /run/build/obliteration/.cargo/bin - buildsystem: simple - build-commands: - - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - - | - if [ ${FLATPAK_ARCH} == 'x86_64' ]; then - rustup target add x86_64-unknown-none - fi - - ./build.py -r --root "$FLATPAK_DEST" - sources: - - type: dir - path: . diff --git a/gui/core.h b/gui/core.h index 72948b359..b09771ec7 100644 --- a/gui/core.h +++ b/gui/core.h @@ -68,11 +68,6 @@ void profile_set_display_resolution(struct Profile *p, enum DisplayResolution v) struct RustError *profile_save(const struct Profile *p, const char *path); -struct RustError *update_firmware(const char *root, - const char *fw, - void *cx, - void (*status)(const char*, uint64_t, uint64_t, void*)); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/gui/initialize_wizard.cpp b/gui/initialize_wizard.cpp index 6206b36a2..951626f7d 100644 --- a/gui/initialize_wizard.cpp +++ b/gui/initialize_wizard.cpp @@ -215,25 +215,6 @@ class FirmwarePage : public QWizardPage { setLayout(layout); } - - bool validatePage() override - { - // Check file path. - QFileInfo path(m_input->text()); - - if (!path.isFile()) { - QMessageBox::critical(this, "Error", "The specified file does not exist."); - return false; - } - - // Get system path. - auto systemPath = wizard()->hasVisitedPage(PageSystem) - ? field(FIELD_SYSTEM_LOCATION).toString() - : readSystemDirectorySetting(); - - // Install. - return initSystem(systemPath, path.canonicalFilePath(), this); - } private: QLayout *setupInputRow() { diff --git a/gui/src/lib.rs b/gui/src/lib.rs index 8296256c0..31fdbf06e 100644 --- a/gui/src/lib.rs +++ b/gui/src/lib.rs @@ -7,7 +7,6 @@ mod graphics; mod hv; mod profile; mod string; -mod system; mod vmm; #[cfg(feature = "qt")] diff --git a/gui/src/main.rs b/gui/src/main.rs index 7b6278c1d..a374d5f53 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -25,7 +25,6 @@ mod profile; mod rlim; mod setup; mod string; -mod system; mod ui; mod vmm; diff --git a/gui/src/system/ffi.rs b/gui/src/system/ffi.rs deleted file mode 100644 index 1211d05f2..000000000 --- a/gui/src/system/ffi.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::error::RustError; -use std::ffi::{c_char, c_void, CStr}; -use std::ptr::null_mut; - -#[no_mangle] -pub unsafe extern "C-unwind" fn update_firmware( - root: *const c_char, - fw: *const c_char, - cx: *mut c_void, - status: unsafe extern "C-unwind" fn(*const c_char, u64, u64, *mut c_void), -) -> *mut RustError { - let _root_path = CStr::from_ptr(root); - let _fw_path = CStr::from_ptr(fw); - let _cx = cx; - let _status = status; - - null_mut() -} diff --git a/gui/src/system/mod.rs b/gui/src/system/mod.rs deleted file mode 100644 index 9b77bb3c5..000000000 --- a/gui/src/system/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[cfg(feature = "qt")] -mod ffi; diff --git a/gui/system.cpp b/gui/system.cpp index ba6e95283..26dedf6b8 100644 --- a/gui/system.cpp +++ b/gui/system.cpp @@ -1,7 +1,5 @@ #include "system.hpp" -#include "core.hpp" #include "path.hpp" -#include "progress_dialog.hpp" #include "settings.hpp" #include @@ -28,44 +26,3 @@ bool isSystemInitialized(const QString &path) return status.type() == std::filesystem::file_type::regular; } - -bool initSystem(const QString &path, const QString &firmware, QWidget *parent) -{ - // Setup progress dialog. - ProgressDialog progress("Initializing system", QString("Opening %1").arg(firmware), parent); - - // Update firmware. - auto root = path.toStdString(); - auto fw = firmware.toStdString(); - Rust error; - - error = update_firmware( - root.c_str(), - fw.c_str(), - &progress, [](const char *status, std::uint64_t total, std::uint64_t written, void *cx) { - auto progress = reinterpret_cast(cx); - - if (progress->statusText() != status) { - progress->setStatusText(status); - progress->setValue(0); - progress->setMaximum(total); - } else { - progress->setValue(written); - } - }); - - progress.complete(); - - // Check result. - if (error) { - QMessageBox::critical( - parent, - "Error", - QString("Failed to install %1 to %2: %3").arg(firmware).arg(path).arg(error_message(error))); - return false; - } - - QMessageBox::information(parent, "Success", "Firmware installed successfully."); - - return true; -} diff --git a/gui/system.hpp b/gui/system.hpp index 4bf5a664e..5e5709ff6 100644 --- a/gui/system.hpp +++ b/gui/system.hpp @@ -6,4 +6,3 @@ class QWidget; bool isSystemInitialized(); bool isSystemInitialized(const QString &path); -bool initSystem(const QString &path, const QString &firmware, QWidget *parent = nullptr);