Unverified Commit 97d95da2 authored by chillcicada's avatar chillcicada
Browse files

wpsoffice-cn: improve packaging

parent de69d2ba
Loading
Loading
Loading
Loading
+34 −29
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  dpkg,
  autoPatchelfHook,
  runCommandLocal,
  curl,
  coreutils,
  cacert,
  # wpsoffice dependencies
  alsa-lib,
  at-spi2-core,
  libjpeg,
  libtool,
  libxkbcommon,
  nss,
  nspr,
  udev,
  gtk3,
  libgbm,
  libusb1,
  unixODBC,
  libmysqlclient,
  libsForQt5,
  xorg,
  # wpsoffice runtime dependencies
  cups,
  pango,
  bzip2,
  libmysqlclient,
  runCommandLocal,
  curl,
  coreutils,
  cacert,
}:

let
@@ -32,10 +34,9 @@ let
  fetch =
    {
      url,
      uri,
      hash,
    }:
    runCommandLocal "wpsoffice-cn-${version}-src"
    runCommandLocal "wpsoffice-cn-${version}.deb"
      {
        outputHashAlgo = "sha256";
        outputHash = hash;
@@ -50,9 +51,10 @@ let
      }
      ''
        readonly SECURITY_KEY="7f8faaaa468174dc1c9cd62e5f218a5b"
        prefix="https://wps-linux-personal.wpscdn.cn"

        timestamp10=$(date '+%s')
        md5hash=($(printf '%s' "$SECURITY_KEY${uri}$timestamp10" | md5sum))
        md5hash=($(printf '%s' "$SECURITY_KEY''${${url}#$prefix}$timestamp10" | md5sum))

        curl --retry 3 --retry-delay 3 "${url}?t=$timestamp10&k=$md5hash" > $out
      '';
@@ -68,24 +70,20 @@ in
stdenv.mkDerivation {
  inherit pname src version;

  unpackCmd = "dpkg -x $src .";
  sourceRoot = ".";

  nativeBuildInputs = [
    dpkg
    autoPatchelfHook
  ];
  nativeBuildInputs = [ autoPatchelfHook ];

  buildInputs = [
    alsa-lib
    at-spi2-core
    libjpeg
    libtool
    libxkbcommon
    nss
    nspr
    udev
    gtk3
    libgbm
    libusb1
    unixODBC
    libsForQt5.qtbase
    xorg.libXdamage
    xorg.libXtst
@@ -101,9 +99,17 @@ stdenv.mkDerivation {
    pango
  ];

  autoPatchelfIgnoreMissingDeps = [
    "libpeony.so.3"
  ];
  unpackPhase = ''
    # Unpack the .deb file
    ar x $src
    tar -xf data.tar.xz

    # Remove unneeded files
    rm -rf usr/share/{fonts,locale}
    rm -f usr/bin/misc
    rm -rf opt/kingsoft/wps-office/{desktops,INSTALL}
    rm -f opt/kingsoft/wps-office/office6/lib{peony-wpsprint-menu-plugin,bz2,jpeg,stdc++,gcc_s,odbc*,nss*,dbus-1}.so*
  '';

  installPhase = ''
    runHook preInstall
@@ -127,8 +133,6 @@ stdenv.mkDerivation {
  '';

  preFixup = ''
    # libbz2 dangling symlink
    ln -sf ${bzip2.out}/lib/libbz2.so $out/opt/kingsoft/wps-office/office6/libbz2.so
    # dlopen dependency
    patchelf --add-needed libudev.so.1 $out/opt/kingsoft/wps-office/office6/addons/cef/libcef.so
    # libmysqlclient dependency
@@ -138,19 +142,20 @@ stdenv.mkDerivation {

  passthru.updateScript = ./update.sh;

  meta = with lib; {
  meta = {
    description = "Office suite, formerly Kingsoft Office";
    homepage = "https://www.wps.com";
    homepage = "https://www.wps.cn";
    platforms = [ "x86_64-linux" ];
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    hydraPlatforms = [ ];
    license = licenses.unfree;
    maintainers = with maintainers; [
    license = lib.licenses.unfree;
    maintainers = with lib.maintainers; [
      mlatus
      th0rgal
      wineee
      pokon548
      chillcicada
    ];
    mainProgram = "wps";
  };
}
+1 −2
Original line number Diff line number Diff line
# Generated by ./update.sh - do not update manually!
# Last updated: 2025-09-15
# Last updated: 2025-10-27
{
  version = "12.1.2.22571";
  x86_64 = {
    url = "https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2023/22571/wps-office_12.1.2.22571.AK.preread.sw_480057_amd64.deb";
    uri = "/wps/download/ep/Linux2023/22571/wps-office_12.1.2.22571.AK.preread.sw_480057_amd64.deb";
    hash = "sha256-aB1EWP0Ev5WuAuzih3ybD23qaRRTUjlES1emas+sUDA=";
  };
}
+2 −4
Original line number Diff line number Diff line
@@ -13,12 +13,11 @@ payload=$(curl -s "https://www.wps.cn/product/wpslinux")
version=$(echo "$payload" | grep -oP '(?<=banner_txt">)[^<]+')

amd64_url=$(echo "$payload" | grep -oP "downLoad\('[^']*'" | head -1 | sed "s/downLoad('//;s/'$//")
amd64_uri="${amd64_url#$prefix}"

timestamp10=$(date '+%s')
md5hash=($(printf '%s' "$SECURITY_KEY$amd64_uri$timestamp10" | md5sum))
amd64_md5hash=($(printf '%s' "$SECURITY_KEY${amd64_url#$prefix}$timestamp10" | md5sum))

amd64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$version.deb" "$amd64_url?t=$timestamp10&k=$md5hash")
amd64_hash=$(nix-prefetch-url --name "wpsoffice-cn-$version.deb" "$amd64_url?t=$timestamp10&k=$amd64_md5hash")

amd64_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$amd64_hash")

@@ -29,7 +28,6 @@ cat > sources.nix << EOF
  version = "$version";
  x86_64 = {
    url = "$amd64_url";
    uri = "$amd64_uri";
    hash = "$amd64_hash";
  };
}