diff options
author | zzy-ac | 2022-10-19 23:54:17 +0800 |
---|---|---|
committer | zzy-ac | 2022-10-19 23:54:17 +0800 |
commit | ac0720cc94970dd0e60a199da50613319d11efa3 (patch) | |
tree | d6e580e293276917db16cafa5729a83097e983bf | |
download | aur-ac0720cc94970dd0e60a199da50613319d11efa3.tar.gz |
2022-10-19_23:54:17
-rw-r--r-- | .SRCINFO | 35 | ||||
-rw-r--r-- | PKGBUILD | 80 | ||||
-rw-r--r-- | cfw | 3 | ||||
-rw-r--r-- | cfw-start-pre.sh | 20 | ||||
-rw-r--r-- | clash-core-service@.service | 13 | ||||
-rw-r--r-- | clash-for-windows-bin.install | 15 | ||||
-rw-r--r-- | clash-for-windows.desktop | 10 |
7 files changed, 176 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d6ab9b599c1d --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,35 @@ +pkgbase = clash-for-windows-electron-zh + pkgdesc = A Windows/macOS/Linux GUI based on Clash and Electron. Using system clash and electron + pkgver = 0.20.5 + pkgrel = 1 + url = https://github.com/Fndroid/clash_for_windows_pkg + install = clash-for-windows-bin.install + arch = x86_64 + arch = aarch64 + license = unknown + makedepends = asar + makedepends = npm + depends = electron + depends = clash-geoip + optdepends = nftables: TUN mode required. + optdepends = iproute2: TUN mode required. + optdepends = clash-premium-bin>=2022.04.01: clash core + optdepends = clash-meta: clash core + provides = clash-for-windows + provides = clash-for-windows-electron-zh + conflicts = clash-for-windows + conflicts = clash-for-windows-bin + source = clash-for-windows.desktop + source = cfw + source = cfw-start-pre.sh + source = clash-core-service@.service + source = https://github.com/ender-zhao/Clash-for-Windows_Chinese/releases/download/CFW-V0.20.5_CN/app.asar + sha256sums = 9a84b05b718913d3d1fbe462a2da671abff2cb94bb2ded75a3af12204cebe32f + sha256sums = db2e160e5d5cf82ed69d0926ac51c0eccb9efc541f89be3bb467d85be509f735 + sha256sums = 4bea2fe6e8580a4316451ca5c8b921bd908422d839f8bd9ceaddd709f9178153 + sha256sums = d55c2f4088505116a5bad6d09f5ebe232e7c6a269ea6bf46daada02bc3a9f961 + sha256sums = b3de4b33406e611b090c929203914a555631214b7b500c97fbb7d24a54ad8450 + source_x86_64 = clash-for-windows-electron-zh-0.20.5-x86_64-linux.tar.gz::https://github.com/Fndroid/clash_for_windows_pkg/releases/download/0.20.5/Clash.for.Windows-0.20.5-x64-linux.tar.gz + sha256sums_x86_64 = df597d26b22fdd03fe252299afbb8ab73a7762e46a20eb9947adf94295d56de9 + +pkgname = clash-for-windows-electron-zh diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..fed0f26a46ef --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,80 @@ +# Maintainer: sukanka <su975853527 [AT] gmail.com> +pkgname=clash-for-windows-electron-zh +_pkgname=${pkgname%-bin} +pkgver=0.20.5 +pkgrel=1 +pkgdesc="A Windows/macOS/Linux GUI based on Clash and Electron. Using system clash and electron" +arch=("x86_64" "aarch64") +license=('unknown') +url="https://github.com/Fndroid/clash_for_windows_pkg" +install=clash-for-windows-bin.install +provides=('clash-for-windows' ${_pkgname}) +conflicts=('clash-for-windows' 'clash-for-windows-bin') +depends=('electron' +'clash-geoip' +) +optdepends=( + 'nftables: TUN mode required.' + 'iproute2: TUN mode required.' + 'clash-premium-bin>=2022.04.01: clash core' + 'clash-meta: clash core' +) +makedepends=('asar' 'npm') +source_x86_64=("${pkgname}-${pkgver}-x86_64-linux.tar.gz::${url}/releases/download/${pkgver}/Clash.for.Windows-${pkgver}-x64-linux.tar.gz") +source=( + "clash-for-windows.desktop" + "cfw" + "cfw-start-pre.sh" + "clash-core-service@.service" + "https://github.com/ender-zhao/Clash-for-Windows_Chinese/releases/download/CFW-V${pkgver}_CN/app.asar" + ) +sha256sums=('9a84b05b718913d3d1fbe462a2da671abff2cb94bb2ded75a3af12204cebe32f' + 'db2e160e5d5cf82ed69d0926ac51c0eccb9efc541f89be3bb467d85be509f735' + '4bea2fe6e8580a4316451ca5c8b921bd908422d839f8bd9ceaddd709f9178153' + 'd55c2f4088505116a5bad6d09f5ebe232e7c6a269ea6bf46daada02bc3a9f961' + 'b3de4b33406e611b090c929203914a555631214b7b500c97fbb7d24a54ad8450') +sha256sums_x86_64=('df597d26b22fdd03fe252299afbb8ab73a7762e46a20eb9947adf94295d56de9') + +_parch=$(echo ${arch} | sed "s/x86_64/x64/;s/aarch64/arm64/") +build() { + cd $srcdir + sed -i "s/pkgver/${pkgver}/" clash-for-windows.desktop + cp app.asar "Clash for Windows-${pkgver}-${_parch}-linux"/resources/ + cd "Clash for Windows-${pkgver}-${_parch}-linux"/resources/ + + asar e app.asar apps + + # fix for autostart and system electron + cd apps + sed -i 's|r=n\[1\],|r="cfw\\nIcon=clash\\n",|g' dist/electron/renderer.js + # force local mode + sed -i 's|200===a.status|true|g' dist/electron/renderer.js + sed -i 's|"electron-log": "^4.1.0",|"electron-log": "^4.4.6",|g' package.json + + export HOME=$srcdir + npm install + cd .. + asar p apps app.asar +} + +package() { + cd $srcdir + + install -Dm755 cfw -t ${pkgdir}/usr/bin + install -Dm644 "clash-for-windows.desktop" -t ${pkgdir}/usr/share/applications + install -Dm644 "clash-core-service@.service" -t ${pkgdir}/usr/lib/systemd/system/ + install -Dm755 cfw-start-pre.sh -t ${pkgdir}/opt/clash-for-windows + + cd "Clash for Windows-${pkgver}-${_parch}-linux" + install -Dm644 resources/app.asar -t ${pkgdir}/opt/clash-for-windows/ + + cp -pvr resources/static ${pkgdir}/opt/clash-for-windows/ + + cd resources/apps/dist/electron/static/imgs + install -Dm644 logo.png ${pkgdir}/usr/share/icons/hicolor/512x512/apps/clash.png + + cd ${pkgdir}/opt/clash-for-windows/static/files + rm -rf linux/{common,${_parch}/clash-linux} default/Country.mmdb + ln -s /usr/bin/clash linux/${_parch}/clash-linux + ln -s /etc/clash/Country.mmdb default/Country.mmdb +} @@ -0,0 +1,3 @@ +#!/bin/sh +cd /opt/clash-for-windows +electron app.asar "$@" diff --git a/cfw-start-pre.sh b/cfw-start-pre.sh new file mode 100644 index 000000000000..0a5383c22bad --- /dev/null +++ b/cfw-start-pre.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +_parch=$(uname -m | sed "s/x86_64/x64/;s/aarch64/arm64/") + +install -d "/home/$1/.config/clash" +ln -sf /etc/clash/Country.mmdb -t "/home/$1/.config/clash" + +install -d "/home/$1/.config/clash/service" +ln -sf "/opt/clash-for-windows/static/files/linux/${_parch}/service/clash-core-service" \ + -t "/home/$1/.config/clash/service" + +# fix permissions of directories +chown -R "$1:$1" "/home/$1/.config/clash" + +# setcap everytime to prevent the case clash is updated. +for clsh in {clash,clash-meta}; +do + if [ -z /usr/bin/$clsh ]; then + setcap cap_net_admin,cap_net_bind_service=ep /usr/bin/$clsh + fi +done diff --git a/clash-core-service@.service b/clash-core-service@.service new file mode 100644 index 000000000000..e5d929811bd8 --- /dev/null +++ b/clash-core-service@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Clash core service created by Clash for Windows for normal user. +After=network-online.target nftables.service iptabels.service + +[Service] +Type=simple +ExecStartPre=/opt/clash-for-windows/cfw-start-pre.sh %i +ExecStart=/home/%i/.config/clash/service/clash-core-service +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/clash-for-windows-bin.install b/clash-for-windows-bin.install new file mode 100644 index 000000000000..abf26ab0bd7b --- /dev/null +++ b/clash-for-windows-bin.install @@ -0,0 +1,15 @@ +post_install() { + echo 'Clash for Windows has it own built-in autostart since 0.18.1.' + echo 'Enable it will create .desktop file under $HOME/.config/autostart/' + + _parch=$(uname -m | sed "s/x86_64/x64/;s/aarch64/arm64/") + echo -e "\033[32m If you want to use clash-meta, install it and run \033[0m" + echo -e "\033[32m sudo ln -sf /usr/bin/clash-meta /opt/clash-for-windows/static/files/linux/${_parch}/clash-linux \033[0m\n" + echo -e "\033[32m To use the TUN mode, you need to run \033[0m" + echo -e "\033[32m sudo systemctl start clash-core-service@\$USER \033[0m" + echo -e "\033[32m sudo systemctl enable clash-core-service@\$USER \033[0m" + +} +post_upgrade(){ + post_install +} diff --git a/clash-for-windows.desktop b/clash-for-windows.desktop new file mode 100644 index 000000000000..cbb0bfce8812 --- /dev/null +++ b/clash-for-windows.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Version=pkgver +Name=Clash For Windows +Comment=Clash GUI +Exec=cfw +Icon=clash +Terminal=false +Keywords=clash +Categories=Network;Utility; |