From 1e657f7c21f11299464d2b0611072d3189abe71d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Mon, 13 Mar 2023 14:28:32 +0700
Subject: [PATCH] fcitx5: update to 5.0.23.

---
 srcpkgs/fcitx5/patches/no-which.patch         | 188 ------------------
 .../fcitx5/patches/xbps-src-download.patch    |  10 +
 srcpkgs/fcitx5/template                       |   4 +-
 3 files changed, 12 insertions(+), 190 deletions(-)
 delete mode 100644 srcpkgs/fcitx5/patches/no-which.patch
 create mode 100644 srcpkgs/fcitx5/patches/xbps-src-download.patch

diff --git a/srcpkgs/fcitx5/patches/no-which.patch b/srcpkgs/fcitx5/patches/no-which.patch
deleted file mode 100644
index 4ef85bc5415..00000000000
--- a/srcpkgs/fcitx5/patches/no-which.patch
+++ /dev/null
@@ -1,188 +0,0 @@
---- a/data/fcitx5-configtool.sh
-+++ b/data/fcitx5-configtool.sh
-@@ -5,14 +5,14 @@
- 
- export TEXTDOMAIN=fcitx5
- 
--if which kdialog > /dev/null 2>&1; then
-+if command -v kdialog > /dev/null 2>&1; then
-     message() {
-         kdialog --msgbox "$1"
-     }
-     error() {
-         kdialog --error "$1"
-     }
--elif which zenity > /dev/null 2>&1; then
-+elif command -v zenity > /dev/null 2>&1; then
-     message() {
-         zenity --info --text="$1"
-     }
-@@ -28,7 +28,7 @@ else
-     }
- fi
- 
--if which gettext > /dev/null 2>&1; then
-+if command -v gettext > /dev/null 2>&1; then
-     _() {
-         gettext "$@"
-     }
-@@ -108,7 +108,7 @@ detectDE() {
-     if [ x"$DE" = x"gnome" ]; then
-       # gnome-default-applications-properties is only available in GNOME 2.x
-       # but not in GNOME 3.x
--      which gnome-default-applications-properties > /dev/null 2>&1  || DE="gnome3"
-+      command -v gnome-default-applications-properties > /dev/null 2>&1  || DE="gnome3"
-     fi
- }
- 
-@@ -119,7 +119,7 @@ run_kde() {
- }
- 
- run_qt() {
--    if which fcitx5-config-qt > /dev/null 2>&1; then
-+    if command -v fcitx5-config-qt > /dev/null 2>&1; then
-         exec fcitx5-config-qt
-     fi
-     return 1
-@@ -135,13 +135,13 @@ run_xdg() {
-             ;;
-     esac
- 
--    if command="$(which xdg-open 2>/dev/null)"; then
-+    if command="$(command -v xdg-open 2>/dev/null)"; then
-         exec "$command" "$HOME/.config/fcitx5"
-     fi
- }
- 
- _which_cmdline() {
--    cmd="$(which "$1")" || return 1
-+    cmd="$(command -v "$1")" || return 1
-     shift
-     echo "$cmd $*"
- }
---- a/data/fcitx5-diagnose.sh
-+++ b/data/fcitx5-diagnose.sh
-@@ -123,7 +123,7 @@ __get_pretty_name() {
-     fi
- }
- 
--fcitx_exe="$(which fcitx5 2> /dev/null)"
-+fcitx_exe="$(command -v fcitx5 2> /dev/null)"
- 
- __conf_dir_init() {
-     # Don't do any fancy check here, it's the user's fault, which we should detect
-@@ -214,9 +214,9 @@ if type dbus-send &> /dev/null; then
-             /controller org.fcitx.Fcitx.Controller1.DebugInfo 2> /dev/null) || return 1
-         echo -n "${debuginfo}"
-     }
--elif qdbus_exe=$(which qdbus 2> /dev/null) || \
--        qdbus_exe=$(which qdbus-qt4 2> /dev/null) || \
--        qdbus_exe=$(which qdbus-qt5 2> /dev/null); then
-+elif qdbus_exe=$(command -v qdbus 2> /dev/null) || \
-+        qdbus_exe=$(command -v qdbus-qt4 2> /dev/null) || \
-+        qdbus_exe=$(command -v qdbus-qt5 2> /dev/null); then
-     dbus_exe=${qdbus_exe}
-     dbus_get_name_owner() {
-         "${qdbus_exe}" org.freedesktop.DBus /org/freedesktop/DBus \
-@@ -345,15 +345,15 @@ detectDE() {
-     if [ x"$DE" = x"gnome" ]; then
-         # gnome-default-applications-properties is only available in GNOME 2.x
-         # but not in GNOME 3.x
--        which gnome-default-applications-properties > /dev/null 2>&1 || \
-+        command -v gnome-default-applications-properties > /dev/null 2>&1 || \
-             DE="gnome3"
--        which gnome-shell &> /dev/null && DE="gnome3"
-+        command -v gnome-shell &> /dev/null && DE="gnome3"
-     fi
- }
- 
- maybe_gnome3() {
-     [[ $DE = gnome3 ]] && return 0
--    [[ $DE = generic ]] && which gnome-shell &> /dev/null && return 0
-+    [[ $DE = generic ]] && command -v gnome-shell &> /dev/null && return 0
-     return 1
- }
- 
-@@ -362,7 +362,7 @@ detectDE
- # user and uid
- 
- detect_user() {
--    if which id &> /dev/null; then
-+    if command -v id &> /dev/null; then
-         cur_user=$(id -un)
-         cur_uid=$(id -u)
-     else
-@@ -373,7 +373,7 @@ detect_user() {
-         else
-             cur_uid=""
-         fi
--        if which whoami &> /dev/null; then
-+        if command -v whoami &> /dev/null; then
-             cur_user=$(whoami)
-         elif [[ -d /proc/$$/ ]]; then
-             cur_user=$(stat -c %U /proc/$$/)
-@@ -395,7 +395,7 @@ _check_open_root() {
-     for f in /proc/1/environ /proc/1/mem /proc/kcore /proc/kmem; do
-         try_open "$f" && return 0
-     done
--    if which readlink &> /dev/null; then
-+    if command -v readlink &> /dev/null; then
-         for f in /proc/1/exe /proc/1/cwd /proc/1/root; do
-             readlink "$f" &> /dev/null && return 0
-         done
-@@ -992,7 +992,7 @@ _find_config_gtk() {
-         return 0
-     }
-     local config_gtk
--    config_gtk="$(which "fcitx5-config-gtk" 2> /dev/null)" || return 1
-+    config_gtk="$(command -v "fcitx5-config-gtk" 2> /dev/null)" || return 1
-     echo "${config_gtk}"
-     _config_tool_gtk_exe="${config_gtk}"
- }
-@@ -1019,7 +1019,7 @@ _check_config_gtk() {
-     local version=$1
-     local config_gtk config_gtk_name
-     write_order_list_eval "$(_ 'Config GUI for gtk${1}:')" "${version}"
--    if ! config_gtk="$(which "fcitx5-config-gtk${version}" 2> /dev/null)"; then
-+    if ! config_gtk="$(command -v "fcitx5-config-gtk${version}" 2> /dev/null)"; then
-         if ! _check_config_gtk_version "${version}"; then
-             write_error_eval \
-                 "$(_ 'Config GUI for gtk${1} not found.')" "${version}"
-@@ -1040,7 +1040,7 @@ _check_config_qt() {
-     local config_qt config_qt_name
-     config_qt_name="fcitx5-config-qt"
-     write_order_list_eval "$(_ 'Config GUI for qt:')" "${version}"
--    if ! config_qt="$(which "${config_qt_name}" 2> /dev/null)"; then
-+    if ! config_qt="$(command -v "${config_qt_name}" 2> /dev/null)"; then
-         write_error "$(_ 'Config GUI for qt not found.')"
-         return 1
-     fi
-@@ -1053,7 +1053,7 @@ _check_config_kcm() {
-     local version=$1
-     local kcm_shell config_kcm
-     write_order_list "$(_ 'Config GUI for kde:')"
--    if ! kcm_shell="$(which "kcmshell${version}" 2> /dev/null)"; then
-+    if ! kcm_shell="$(command -v "kcmshell${version}" 2> /dev/null)"; then
-         write_error "$(print_not_found "kcmshell${version}")"
-         return 1
-     fi
-@@ -1069,7 +1069,7 @@ check_config_ui() {
-     local IFS=$'\n'
-     write_title 1 "$(_ 'Fcitx Configure UI:')"
-     write_order_list "$(_ 'Config Tool Wrapper:')"
--    if ! fcitx_configtool="$(which fcitx5-configtool 2> /dev/null)"; then
-+    if ! fcitx_configtool="$(command -v fcitx5-configtool 2> /dev/null)"; then
-         write_error_eval "$(_ 'Cannot find ${1} executable!')" fcitx5-configtool
-     else
-         write_eval "$(_ 'Found ${1} at ${2}.')" \
---- a/test/xvfb_wrapper.sh
-+++ b/test/xvfb_wrapper.sh
-@@ -20,7 +20,7 @@ finish()
- 
- trap finish EXIT
- 
--if which xprop >/dev/null 2>&1; then
-+if command -v xprop >/dev/null 2>&1; then
-     i=1
-     while [ "$i" -lt 5 ]; do
-         if xprop -root >/dev/null 2>&1; then
diff --git a/srcpkgs/fcitx5/patches/xbps-src-download.patch b/srcpkgs/fcitx5/patches/xbps-src-download.patch
new file mode 100644
index 00000000000..2a380fb6445
--- /dev/null
+++ b/srcpkgs/fcitx5/patches/xbps-src-download.patch
@@ -0,0 +1,10 @@
+--- a/src/lib/fcitx-utils/Fcitx5Download.cmake.in
++++ b/src/lib/fcitx-utils/Fcitx5Download.cmake.in
+@@ -1,4 +1,7 @@
+ if (NOT EXISTS "@FCITX5_DOWNLOAD_DEST@")
++    if (DEFINED ENV{XBPS_MACHINE})
++        message(FATAL_ERROR "Downloading @FCITX5_DOWNLOAD_URL@ is forbidden inside xbps-src")
++    endif()
+     message(STATUS "Downloading '@FCITX5_DOWNLOAD_URL@' to '@FCITX5_DOWNLOAD_DEST@'...")
+     file(DOWNLOAD
+          "@FCITX5_DOWNLOAD_URL@"
diff --git a/srcpkgs/fcitx5/template b/srcpkgs/fcitx5/template
index 88a52d3063d..1a6a8456239 100644
--- a/srcpkgs/fcitx5/template
+++ b/srcpkgs/fcitx5/template
@@ -1,6 +1,6 @@
 # Template file for 'fcitx5'
 pkgname=fcitx5
-version=5.0.21
+version=5.0.23
 revision=1
 build_style=cmake
 build_helper=qemu
@@ -21,7 +21,7 @@ homepage="https://fcitx-im.org/wiki/Fcitx"
 _en_dict_ver=20121020
 distfiles="https://download.fcitx-im.org/fcitx5/fcitx5/fcitx5-${version}.tar.xz
  https://download.fcitx-im.org/data/en_dict-${_en_dict_ver}.tar.gz"
-checksum="4e31c3ae5588134e2ef33494d6f71aa047a5c407edbcba27b016a74567308dbe
+checksum="04f209a6406225ce19785f8d9d3bdb253944586edcfa9601414fcdda8a1b13a0
  c44a5d7847925eea9e4d2d04748d442cd28dd9299a0b572ef7d91eac4f5a6ceb"
 skip_extraction=en_dict-${_en_dict_ver}.tar.gz
 lib32disabled=yes