Mahdi-zarei / nekoray

Qt based cross-platform GUI proxy configuration manager (backend: sing-box)
GNU General Public License v3.0
477 stars 31 forks source link

提供 PKGBUILD #82

Open Jisu-Woniu opened 3 months ago

Jisu-Woniu commented 3 months ago

描述建议 / Suggestion

请提供一套 PKGBUILD 文件,以便 Arch Linux 用户可在自己的设备上编译该程序。

Please provide a set of PKGBUILD files so that Arch Linux users can compile the program on their own devices.

参考:Refer to: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=nekoray

建议的必要性 / Necessity

本仓库的 Release 构建中捆绑了 Qt 6 相关的动态链接库,但这导致了一些系统特性无法正常使用,如 #59 #61。如果使用 PKGBUILD 本地构建,或许可以解决这些问题。

The Release build of this repository bundles Qt 6 related libraries, but this causes some system features to not work properly, e.g. #59 #61. These issues may be resolved by a local build with PKGBUILD.

Mahdi-zarei commented 3 months ago

I am not familiar with PKGBUILD, and even though I might be able to figure something out, I am almost sure the said issues won't be resolved by a local build. I have my own local build that I use for testing on my Ubuntu system, and dark mode does not work there either, it is a problem that originates in Qt's faulty style manager. Also Nekoray needs a set of libraries to run, by having the libraries and building it locally you can run the executable, but the exact same effect is achieved by running the launcher in the bundled app. In short, I have built Nekoray locally and there is no difference between my local build and the one provided in the release page, so I doubt anything can be achieved by building Nekoray locally.

Jisu-Woniu commented 3 months ago

I have made a working PKGBUILD based on the linked one. And it fixes #59 as expected.

screenshot

Jisu-Woniu commented 3 months ago

If anyone is interested and willing to give a try, download the tarball below:

nekoray-pkgbuild.tar.gz

Jisu-Woniu commented 3 months ago

Dark mode is also supported, however a restart of the program is needed.

Screenshot

Mahdi-zarei commented 3 months ago

Dark mode is also supported, however a restart of the program is needed.

Screenshot

That's interesting. I can't test it myself, but if it solved dark mode issue for other users as well please submit the PKGBUILD through a PR and I will merge it.

Jisu-Woniu commented 3 months ago

I have my own local build that I use for testing on my Ubuntu system, and dark mode does not work there either

Maybe your theme setting works for Qt 5 only.

For example, the latest version of breeze on Debian stable is 5.27.5 as of now. It supports Qt 5 only.

On Arch Linux, it is 6.1.2, which supports Qt 6. There is also a breeze5 (also 6.1.2) for Qt 5 apps.

Jisu-Woniu commented 3 months ago

That's interesting. I can't test it myself, but if it solved dark mode issue for other users as well please submit the PKGBUILD through a PR and I will merge it.

It does nothing different than the GitHub Action workflow, just a shorthand for makepkg on Arch Linux. But maybe we can build a deb package with it for Debian and Ubuntu users?

build() {
    cd "${pkgname}/"
    git submodule init
    git submodule update

    (
        mkdir -p build
        cd build
        cmake -GNinja -DQT_VERSION_MAJOR=6 -DNKR_PACKAGE=ON ..
        ninja
    )

    export GOARCH

    case $CARCH in
    x86_64) GOARCH=amd64 ;;
    aarch64) GOARCH=arm64 ;;
    riscv64) GOARCH=riscv64 ;;
    esac

    ./libs/build_public_res.sh
    GOOS=linux ./libs/build_go.sh
}

package() {
    install -dm755 "${pkgdir}/usr/bin/"

    # assets
    install -Dm644 "${pkgname}.desktop" -t "${pkgdir}/usr/share/applications/"
    install -Dm644 ${pkgname}/res/public/{nekoray,nekobox}.png -t "${pkgdir}/usr/share/pixmaps/"

    # core
    local core_srcdir

    case $CARCH in
    x86_64) core_srcdir=linux64 ;;
    aarch64) core_srcdir=linux-arm64 ;;
    riscv64) core_srcdir=linux-riscv64 ;;
    esac

    install -Dm755 ${pkgname}/deployment/${core_srcdir}/nekobox_core -t "${pkgdir}/usr/lib/${pkgname}/"

    # app
    install -Dm755 "${pkgname}/build/${pkgname}" -t "${pkgdir}/usr/lib/${pkgname}/"

    ln -s "/usr/lib/${pkgname}/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
}
Mahdi-zarei commented 3 months ago

If the theme issue on arch can be solved by building the app locally, I will be glad to include the pkgbuild. If i get it right, to solve the dark theme issue users have to link Nekoray to their own libraries instead of those shipped with the app, am I right? I am not familiar with packaging yet, but is there any way to package and publish the app ( in snap, apt etc ) so that users can simply install the app without the need to compile it?

Jisu-Woniu commented 3 months ago

Currently the seemingly best option is to upload the PKGBUILD to AUR, and also build the package with GitHub Action in an Arch Linux container.

Most Arch users are familiar with the build-and-install process with AUR, so the compilation isn't really a problem. But there is already a package for the original nekoray repo, which seems still being maintained. I am not sure what to do next.

Jisu-Woniu commented 3 months ago

I cannot use the routing correctly, it complains this when I switch to Bypass China:

图片

Jisu-Woniu commented 3 months ago

I cannot use the routing correctly, it complains this when I switch to Bypass China:

图片

This error seems from this code:

https://github.com/Mahdi-zarei/sing-box-extra/blob/907408da09594450bfd9b268e0956a40e387c819/boxmain/cmd_geoip.go#L14

Mahdi-zarei commented 3 months ago

Currently the seemingly best option is to upload the PKGBUILD to AUR, and also build the package with GitHub Action in an Arch Linux container.

Most Arch users are familiar with the build-and-install process with AUR, so the compilation isn't really a problem. But there is already a package for the original nekoray repo, which seems still being maintained. I am not sure what to do next.

Then I guess i just include the pkgbuild in the repo so that users can clone and build it.

I cannot use the routing correctly, it complains this when I switch to Bypass China:

图片

The geoip.db and geosite.db should be beside Nekoray's executable, they will be used to generate rule-sets.

Jisu-Woniu commented 3 months ago

I think the geoip and geosite database should be updated separately, and two packages named sing-geoip and sing-geosite already take care of this.

Mahdi-zarei commented 3 months ago

The assets provided in the bundle are from sing-geoip and sing-geosite, and you can manually update the databases. The only point is that their location for the time being is needed to be beside the Nekoray executable and their names should match geoip.db and geosite.db.

Jisu-Woniu commented 3 months ago

I tried to link the geoip.db and geosite.db with symlink, but the error message is still there.

Is there anything I missed in the package?

The /usr/share/nekoray directory looks like this:

content in /usr/share/nekoray directory

The working directory is not set to the /usr/share/nekoray directory, this may be the cause of the problem.

Edit: Still not working.

Jisu-Woniu commented 3 months ago

Maybe you should update the code to respect the resource file path in nekobox Basic setting -> Core:

Resource File Path

Mahdi-zarei commented 3 months ago

I tried to link the geoip.db and geosite.db with symlink, but the error message is still there.

~Is there anything I missed in the package?~

The /usr/share/nekoray directory looks like this:

content in /usr/share/nekoray directory

The working directory is not set to the /usr/share/nekoray directory, this may be the cause of the problem.

Edit: Still not working.

I need to look it into it, I had not changed the code around reading the assets too much, might have caused a bug by changing other parts.

Maybe you should update the code to respect the resource file path in nekobox Basic setting -> Core:

Resource File Path

Yes this option has also been left behind, I will try to fix it in the next release.

Mahdi-zarei commented 2 months ago

I made some changes to the LD path passed to the app. Can you check if it resolves dark theme issues on arch devices?

Goosegit11 commented 2 weeks ago

Maybe you should update the code to respect the resource file path in nekobox Basic setting -> Core:

Resource File Path

It's basically a one-line patch, here's how I fixed it for official nekoray (Arch Linux)

assets-dir.patch ``` diff --git a/main/NekoGui.cpp b/main/NekoGui.cpp index 520275a..2750b3a 100644 --- a/main/NekoGui.cpp +++ b/main/NekoGui.cpp @@ -419,6 +419,7 @@ namespace NekoGui { search << QApplication::applicationDirPath(); search << "/usr/share/sing-geoip"; search << "/usr/share/sing-geosite"; + search << "/usr/share/sing-box"; search << "/usr/lib/nekobox"; search << "/usr/share/nekobox"; for (const auto &dir: search) { ```
PKGBUILD that uses it (for official nekoray, not this fork) ``` # Maintainer: Chi_Tang # Maintainer: Integral pkgname=nekoray pkgver=4.0.beta3 _pkgver=${pkgver/.beta/-beta} pkgrel=3 pkgdesc="Qt based cross-platform GUI proxy configuration manager (backend: sing-box)" arch=('x86_64' 'aarch64' 'riscv64') url="https://matsuridayo.github.io" license=('GPL-3.0-or-later') makedepends=('cmake' 'git' 'ninja' 'go') depends=( 'qt6-base' 'qt6-svg' 'qt6-tools' 'protobuf' 'yaml-cpp' 'zxing-cpp' 'abseil-cpp' ) optdepends=( 'sing-geoip: geoip data for NekoBox' 'sing-geosite: geosite data for NekoBox' ) source=( "git+https://github.com/MatsuriDayo/${pkgname}.git#tag=${_pkgver}" "nekobox.sh" "nekobox.desktop" "assets-dir.patch" ) sha512sums=('86a5bd9c86b12b1bee5678917bf9c3da744b02141589cc737b3ba65dc918f7abb881a899aed47be11b0a0ae09511be1bedd0a8a8819a20efe6a2874efe942bb0' '3a65300520462bd6a5667c50b7db1ccbf7107b9d5c65959d00451a68cdd77d9e13288da03ccb0d712cd4fb076cdfb3c635490d6148268f920cde7ba11b7237a9' 'f99795f5f82fca74bbc36569d3595bc141c3fef00a0c6076585da683f0a5144dbfdbbe4525cf82576e9010262f74f462ae40f5a7b95dafc01033763a9b1711bd' '06bf3acc2984f3007c9aafd468c6c424a4d4a3ba386bc3dc3a6ac4e16811bcda10853491fccc22c9c7c3e1cd0ac9554ed3ed6063dff3d273feaa4f73f8a6c6d6') build() { cd "${pkgname}/" git submodule init git submodule update bash libs/get_source.sh patch -p1 -i ../assets-dir.patch mkdir build cd build cmake -GNinja -DQT_VERSION_MAJOR=6 -DNKR_PACKAGE=ON .. ninja cd .. export GOARCH case $CARCH in x86_64) GOARCH=amd64 ;; aarch64) GOARCH=arm64 ;; riscv64) GOARCH=riscv64 ;; esac GOOS=linux ./libs/build_go.sh } package() { install -dm755 "${pkgdir}/usr/bin/" # Assets install -Dm644 nekobox.desktop -t "${pkgdir}/usr/share/applications/" install -Dm644 "${pkgname}/res/public/nekobox.png" -t "${pkgdir}/usr/share/pixmaps/" # Core local core_srcdir=linux case $CARCH in x86_64) core_srcdir+=64 ;; aarch64) core_srcdir+=-arm64 ;; riscv64) core_srcdir+=-riscv64 ;; esac install -Dm755 "${pkgname}/deployment/${core_srcdir}/nekobox_core" -t "${pkgdir}/usr/lib/nekobox/" # Binary file install -Dm755 "${pkgname}/build/nekobox" -t "${pkgdir}/usr/lib/nekobox/" # Launcher install -Dm755 nekobox.sh "${pkgdir}/usr/bin/nekobox" } ```
Goosegit11 commented 2 weeks ago

Basically you get nekoray PKGBUILD, put the patch file in the folder, and change the sources variable in PKGBUILD to include the sha256sum of the patch

Goosegit11 commented 2 weeks ago

made a pr that fixes the issue #188