diff options
author | zxp19821005 | 2025-01-06 23:45:27 +0800 |
---|---|---|
committer | zxp19821005 | 2025-01-06 23:45:27 +0800 |
commit | 12733eacb27723f6942d192ebe94e121183b63eb (patch) | |
tree | 2e2dc0a0216b76e8a7d989e2ea38d4e88bfdb28f | |
download | aur-openhud-git.tar.gz |
update to 3.0.1.r1.g741af0c
-rw-r--r-- | .SRCINFO | 21 | ||||
-rw-r--r-- | PKGBUILD | 87 | ||||
-rw-r--r-- | openhud.sh | 29 |
3 files changed, 137 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..41d43e6449fd --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,21 @@ +pkgbase = openhud-git + pkgdesc = Uses the CS2 GSI and a node server with websockets to send data to a react client.(Use system-wide electron) + pkgver = 3.0.1.r1.g741af0c + pkgrel = 1 + url = https://github.com/JohnTimmermann/OpenHud + arch = any + license = MIT + makedepends = npm + makedepends = nvm + makedepends = git + makedepends = curl + makedepends = gendesk + depends = electron33 + provides = openhud=3.0.1 + conflicts = openhud + source = openhud.git::git+https://github.com/JohnTimmermann/OpenHud.git + source = openhud.sh + sha256sums = SKIP + sha256sums = 291f50480f5a61bc9c68db7d44cd0412071128706baa868a9cb854f8779a1980 + +pkgname = openhud-git diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..bbe81a666789 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,87 @@ +# Maintainer: zxp19821005 <zxp19821005 at 163 dot com> +pkgname=openhud-git +_pkgname=OpenHud +pkgver=3.0.1.r1.g741af0c +_electronversion=33 +_nodeversion=20 +pkgrel=1 +pkgdesc="Uses the CS2 GSI and a node server with websockets to send data to a react client.(Use system-wide electron)" +arch=('any') +url="https://github.com/JohnTimmermann/OpenHud" +license=('MIT') +provides=("${pkgname%-git}=${pkgver%.r*}") +conflicts=("${pkgname%-git}") +depends=( + "electron${_electronversion}" +) +makedepends=( + 'npm' + 'nvm' + 'git' + 'curl' + 'gendesk' +) +source=( + "${pkgname//-/.}::git+${url}.git" + "${pkgname%-git}.sh" +) +sha256sums=('SKIP' + '291f50480f5a61bc9c68db7d44cd0412071128706baa868a9cb854f8779a1980') +pkgver() { + cd "${srcdir}/${pkgname//-/.}" + set -o pipefail + git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/v//g' || + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" +} +_ensure_local_nvm() { + local NVM_DIR="${srcdir}/.nvm" + source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]] + nvm install "${_nodeversion}" + nvm use "${_nodeversion}" +} +prepare() { + sed -e " + s/@electronversion@/${_electronversion}/g + s/@appname@/${pkgname%-git}/g + s/@runname@/app.asar/g + s/@cfgdirname@/${pkgname%-git}/g + s/@options@/env ELECTRON_OZONE_PLATFORM_HINT=auto/g + " -i "${srcdir}/${pkgname%-git}.sh" + _ensure_local_nvm + gendesk -q -f -n --pkgname="${pkgname%-git}" --pkgdesc="${pkgdesc}" --categories="Game" --name="${_pkgname}" --exec="${pkgname%-git} %U" + cd "${srcdir}/${pkgname//-/.}" + electronDist="/usr/lib/electron${_electronversion}" + export ELECTRON_SKIP_BINARY_DOWNLOAD=1 + export SYSTEM_ELECTRON_VERSION="$(electron${_electronversion} -v | sed 's/v//g')" + HOME="${srcdir}/.electron-gyp" + { + echo -e '\n' + #echo 'build_from_source=true' + echo "cache=${srcdir}/.npm_cache" + } >> .npmrc + if [[ "$(curl -s ipinfo.io/country)" == *"CN"* ]]; then + { + echo 'registry=https://registry.npmmirror.com' + echo 'electron_mirror=https://registry.npmmirror.com/-/binary/electron/' + echo 'electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/' + } >> .npmrc + find ./ -type f -name "package-lock.json" -exec sed -i "s/registry.npmjs.org/registry.npmmirror.com/g" {} + + fi + find src -type f -exec sed -i "s/process.resourcesPath/\'\/usr\/lib\/${pkgname%-git}\'/g" {} + + sed -i "s/\"electron\": \"[^\"]*\"/\"electron\": \"${SYSTEM_ELECTRON_VERSION}\"/g" package.json + NODE_ENV=development npm install +} +build() { + cd "${srcdir}/${pkgname//-/.}" + NODE_ENV=production npm run transpile:electron + NODE_ENV=production npm run build + NODE_ENV=production npm exec -c "electron-builder --linux dir -c.electronDist=${electronDist} --config=electron-builder.json" +} +package() { + install -Dm755 "${srcdir}/${pkgname%-git}.sh" "${pkgdir}/usr/bin/${pkgname%-git}" + install -Dm644 "${srcdir}/${pkgname//-/.}/dist/linux-"*/resources/app.asar -t "${pkgdir}/usr/lib/${pkgname%-git}" + cp -Pr --no-preserve=ownership "${srcdir}/${pkgname//-/.}/dist/linux-"*/resources/{app.asar.unpacked,dist-electron,src} "${pkgdir}/usr/lib/${pkgname%-git}" + install -Dm644 "${srcdir}/${pkgname//-/.}/desktopIcon.png" "${pkgdir}/usr/share/pixmaps/${pkgname%-git}.png" + install -Dm644 "${srcdir}/${pkgname%-git}.desktop" -t "${pkgdir}/usr/share/applications" + install -Dm644 "${srcdir}/${pkgname//-/.}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}" +}
\ No newline at end of file diff --git a/openhud.sh b/openhud.sh new file mode 100644 index 000000000000..40e422ca2ee7 --- /dev/null +++ b/openhud.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -o pipefail +_APPDIR="/usr/lib/@appname@" +_RUNNAME="${_APPDIR}/@runname@" +_CFGDIR="@cfgdirname@/" +_OPTIONS="@options@" +export PATH="${_APPDIR}:${PATH}" +export LD_LIBRARY_PATH="${_APPDIR}/swiftshader:${_APPDIR}/lib:${LD_LIBRARY_PATH}" +export ELECTRON_IS_DEV=0 +export ELECTRON_FORCE_IS_PACKAGED=true +export ELECTRON_DISABLE_SECURITY_WARNINGS=true +export ELECTRON_OVERRIDE_DIST_PATH="/usr/bin/electron@electronversion@" +export NODE_ENV=production +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export _FLAGS_FILE="${XDG_CONFIG_HOME}/${_CFGDIR}@appname@-flags.conf" +declare -a _USER_FLAGS +if [[ -f "${_FLAGS_FILE}" ]]; then + while read -r line; do + if [[ ! "${line}" =~ ^[[:space:]]*#.* ]]; then + _USER_FLAGS+=("${line}") + fi + done < "${_FLAGS_FILE}" +fi +cd "${_APPDIR}" || { echo "Failed to change directory to ${_APPDIR}"; exit 1; } +if [[ "${EUID}" -ne 0 ]] || [[ "${ELECTRON_RUN_AS_NODE}" ]]; then + exec electron@electronversion@ "${_RUNNAME}" ${_OPTIONS} "${_USER_FLAGS[@]}" "$@" +else + exec electron@electronversion@ "${_RUNNAME}" ${_OPTIONS} --no-sandbox "${_USER_FLAGS[@]}" "$@" +fi
\ No newline at end of file |