From 18bda71559931dca9855dbbd041d4410ec59b9a3 Mon Sep 17 00:00:00 2001 From: linuxwhata <5351697+linuxwhata@user.noreply.gitee.com> Date: Wed, 19 Mar 2025 22:01:29 +0800 Subject: [PATCH] xunlei-uos: init at 1.0.0.5 --- pkgs/by-name/xu/xunlei-uos/package.nix | 102 +++++++++++++++++++++++++ pkgs/by-name/xu/xunlei-uos/sources.nix | 11 +++ pkgs/by-name/xu/xunlei-uos/update.sh | 60 +++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 pkgs/by-name/xu/xunlei-uos/package.nix create mode 100644 pkgs/by-name/xu/xunlei-uos/sources.nix create mode 100644 pkgs/by-name/xu/xunlei-uos/update.sh diff --git a/pkgs/by-name/xu/xunlei-uos/package.nix b/pkgs/by-name/xu/xunlei-uos/package.nix new file mode 100644 index 000000000000..02cc121439c3 --- /dev/null +++ b/pkgs/by-name/xu/xunlei-uos/package.nix @@ -0,0 +1,102 @@ +{ + lib, + dpkg, + stdenv, + fetchurl, + buildFHSEnv, + autoPatchelfHook, + writeShellScript, + zenity, + nss, + gtk2, + alsa-lib, + dbus-glib, + libXtst, + libXdamage, + libXScrnSaver, +}: + +let + sources = import ./sources.nix; + + xunlei-unwrapped = stdenv.mkDerivation rec { + pname = "xunlei-uos"; + version = sources.version; + + src = + { + x86_64-linux = fetchurl { + url = sources.amd64_url; + hash = sources.amd64_hash; + }; + aarch64-linux = fetchurl { + url = sources.arm64_url; + hash = sources.arm64_hash; + }; + loongarch64-linux = fetchurl { + url = sources.loongarch64_url; + hash = sources.loongarch64_hash; + }; + } + .${stdenv.hostPlatform.system} + or (throw "${pname}-${version}: ${stdenv.hostPlatform.system} is unsupported."); + + buildInputs = [ + nss + gtk2 + alsa-lib + dbus-glib + libXtst + libXdamage + libXScrnSaver + ]; + + nativeBuildInputs = [ + dpkg + autoPatchelfHook + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib + cp -r opt/apps/com.xunlei.download/files $out/lib/xunlei + cp -r opt/apps/com.xunlei.download/entries $out/share + mv $out/share/icons/hicolor/scalable/apps/com.thunder.download.svg \ + $out/share/icons/hicolor/scalable/apps/com.xunlei.download.svg + substituteInPlace $out/share/applications/com.xunlei.download.desktop \ + --replace-fail "Categories=net" "Categories=Network" \ + --replace-fail "/opt/apps/com.xunlei.download/files/start.sh" "xunlei-uos" \ + --replace-fail "/opt/apps/com.xunlei.download/entries/icons/hicolor/256x256/apps/com.xunlei.download.png" "com.xunlei.download" + + runHook postInstall + ''; + + meta = { + description = "Download manager supporting HTTP, FTP, BitTorrent, and eDonkey network protocols"; + homepage = "https://www.xunlei.com"; + license = lib.licenses.unfree; + maintainers = [ lib.maintainers.linuxwhata ]; + platforms = [ + "x86_64-linux" + "aarch64-linux" + "loongarch64-linux" + ]; + }; + }; +in +buildFHSEnv { + inherit (xunlei-unwrapped) pname version meta; + runScript = writeShellScript "xunlei-launcher" '' + exec ${xunlei-unwrapped}/lib/xunlei/thunder -start $1 "$@" + ''; + extraInstallCommands = '' + mkdir -p $out + ln -s ${xunlei-unwrapped}/share $out/share + ''; + + passthru.updateScript = ./update.sh; + + includeClosures = true; + targetPkgs = pkgs: [ zenity ]; # system tray click events +} diff --git a/pkgs/by-name/xu/xunlei-uos/sources.nix b/pkgs/by-name/xu/xunlei-uos/sources.nix new file mode 100644 index 000000000000..eb08be168268 --- /dev/null +++ b/pkgs/by-name/xu/xunlei-uos/sources.nix @@ -0,0 +1,11 @@ +# Generated by ./update.sh - do not update manually! +# Last updated: 2025-03-19 +{ + version = "1.0.0.5"; + amd64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.xunlei.download/com.xunlei.download_1.0.0.5_amd64.deb"; + arm64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.xunlei.download/com.xunlei.download_1.0.0.5_arm64.deb"; + loongarch64_url = "https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.xunlei.download/com.xunlei.download_1.0.0.5_loongarch64.deb"; + amd64_hash = "sha256-K+eHPmG2tT5Z+RWxigg03itw6Rcnk5MZlODqS/JtAnk="; + arm64_hash = "sha256-iA9mbp0wSe66qC5lphMTFPzmOJjzHfWKubGRPiKcVdg="; + loongarch64_hash = "sha256-44QPnB/1uWHaQkd3DBMDvYXfXwch9HywZUvg71z8fts="; +} diff --git a/pkgs/by-name/xu/xunlei-uos/update.sh b/pkgs/by-name/xu/xunlei-uos/update.sh new file mode 100644 index 000000000000..d931853a1c3d --- /dev/null +++ b/pkgs/by-name/xu/xunlei-uos/update.sh @@ -0,0 +1,60 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash --pure --keep GITHUB_TOKEN -p nix git curl cacert nix-prefetch-git gzip + +base_url_suffix="https://pro-store-packages.uniontech.com/appstore/dists/eagle/appstore/binary-" +base_url_appendix="/Packages.gz" +target_package="com.xunlei.download" +packages_file="Packages.gz" + +url=() +version=() # TODO: Currently, there is no version differences between archs. This is reserved for future use. +hash=() + +for i in amd64 arm64 loongarch64 +do + current_url=$base_url_suffix$i$base_url_appendix + curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0" -v -L -O $current_url + current_version=$(zgrep -A 20 "Package: $target_package" "$packages_file" | awk -v pkg="$target_package" ' + BEGIN { found = 0 } + { + if ($0 ~ "^Package: "pkg) { + found = 1; + } + if (found && $1 == "Version:") { + print $2; + exit; + } + } + ') + version+=("$current_version") + sha256sum=$(zgrep -A 20 "Package: $target_package" "$packages_file" | awk -v pkg="$target_package" ' + BEGIN { found = 0 } + { + if ($0 ~ "^Package: "pkg) { + found = 1; + } + if (found && $1 == "SHA256:") { + print $2; + exit; + } + } + ') + url+=("https://pro-store-packages.uniontech.com/appstore/pool/appstore/c/com.xunlei.download/com.xunlei.download_"$version"_"$i".deb") + hash+=("$(nix hash convert --to sri --hash-algo sha256 $sha256sum)") +done + +cat >sources.nix <