summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fd1fe936902cdf9835e0b829102339c3a4b453cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Maintainer: qr243vbi

pkgname=(nekobox nekobox-core)
pkgver=5.10.36
pkgrel=10
pkgdesc="Cross-platform GUI proxy utility (Empowered by sing-box)"
arch=('x86_64' 'aarch64' 'riscv64' 'pentium4' 'i686' 'armv7h')
url="https://github.com/qr243vbi/nekobox"
license=('GPL-3.0-or-later')
makedepends=('bash' 'gcc-libs' 'glibc' 'libx11' 'qt6-base' 'qt6-declarative' 'thrift' 'boost' 'pkgconfig' 'ccache' 'ninja' 'jq' 'curl' 'coreutils' 'git' 'cmake' 'gendesk' 'go' 'qt6-tools' 'vulkan-headers' 'cpio' 'boost-libs' 'acl' 'patchelf' 'ccache')
source=("https://github.com/qr243vbi/nekobox/releases/download/${pkgver}/nekobox-unified-source-${pkgver}.tar.xz")
sha256sums=("f7dcb494901628127ffb412b6dd829334131e609c1cf8b7d4c94c6d9f2f63ee9")

nekobox_source_directory="nekobox-unified-source-${pkgver}"

build() {
    export NEKOBOX_QT_BUILD=$PWD/build
    export NEKOBOX_CORE_BUILD=$PWD/build_go
    pushd "${nekobox_source_directory}"

    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOARCH=""
    export GOOS=linux

    if [[ -d "core/server/vendor" ]]
    then
      export GO_MOD_TIDY=OFF
    else
      export GO_MOD_TIDY=ON
    fi


    cmake -B "${NEKOBOX_CORE_BUILD}" -S ./core \
        -D SKIP_UPDATER=ON \
        -D GO_MOD_TIDY="${GO_MOD_TIDY}"
    
    cmake -B "${NEKOBOX_QT_BUILD}" -S . \
        -D BUILD_GO_PARTS=OFF \
        -D SKIP_UPDATER=ON \
        -D "NKR_DEFAULT_VERSION=${pkgver}" \
        -W no-dev -GNinja

    for i in "${NEKOBOX_CORE_BUILD}" "${NEKOBOX_QT_BUILD}"
    do
        cmake --build "${i}" -j "$(nproc)" -v
    done

    popd
}

packagecore() {
    depends=('gcc-libs' 'glibc')
    provides=('sing-box')
    conflicts=('sing-box')
    DESTDIR="${pkgdir}/usr/libexec" cmake --install "${NEKOBOX_CORE_BUILD}"
}

packageapp() {
    depends=('acl' 'bash' 'gcc-libs' 'glibc' 'libx11' 'qt6-base' 'qt6-declarative' "$1" 'thrift' 'boost-libs')
    provides=('nekoray')
    conflicts=('nekoray')
    DESTDIR="${pkgdir}" cmake --install "${NEKOBOX_QT_BUILD}"
}

clearsources(){
    unset source ||:
    unset sha256sums ||:
    typeset -a "source" ||:
    typeset -a "sha256sums" ||:
}

if [[ "${#source[@]}" == "0" || "${#source[0]}" == "" || "${NEKOBOX_BRANCH}" != "" ]]
then
nekobox_source_directory="nekobox-git"
pkgname=(nekobox-git nekobox-core-git)
clearsources

package_nekobox-core-git() {
    packagecore
}
package_nekobox-git() {
    packageapp 'nekobox-core-git'
}
prepare() {
    local BRANCH="${NEKOBOX_BRANCH:-main}"
    local REPO="qr243vbi/nekobox"

    if [[ -d "${nekobox_source_directory}" ]]
    then
        pushd "${nekobox_source_directory}"
        git pull
        popd
    else
        git clone --recurse-submodules --depth 1 --single-branch --branch "${BRANCH}" https://github.com/"${REPO}" "${nekobox_source_directory}"
    fi
}
pkgver(){
    local BRANCH="${NEKOBOX_BRANCH:-main}"
    local REPO="qr243vbi/nekobox"
    local LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name')
    local COMMIT_TIMESTAMP=$(curl -s "https://api.github.com/repos/$REPO/commits/$BRANCH" | jq -r '.commit.committer.date' | xargs -I{} date -d "{}" +%s)
    local SHORT_SHA=$(curl -s "https://api.github.com/repos/$REPO/commits/$BRANCH" | jq -r '.sha[0:7]')
    local VERSION_STRING="${LATEST_TAG}.git${COMMIT_TIMESTAMP}.${SHORT_SHA}"
    echo $VERSION_STRING
}
else
package_nekobox-core() {
    packagecore
}

package_nekobox() {
    packageapp 'nekobox-core'
}
fi