1 # Copyright 1999-2022 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 MY_PGK_NAME
="com.alibabainc.dingtalk"
7 inherit desktop unpacker xdg
9 DESCRIPTION
="Communication platform that supports video and audio conferencing"
10 HOMEPAGE
="https://gov.dingtalk.com"
12 https://dtapp-pub.dingtalk.com/dingtalk-desktop/xc_dingtalk_update/linux_deb/Release/com.alibabainc.${PN}_${PV}_amd64.deb
13 https://archive.archlinux.org/packages/c/cairo/cairo-1.17.4-5-x86_64.pkg.tar.zst
16 LICENSE
="all-rights-reserved"
20 RESTRICT
="strip mirror bindist"
25 || ( media-libs/tiff:0/0 media-libs/tiff-compat:4 )
26 media-sound/pulseaudio
34 x11-libs/libXScrnSaver
39 BDEPEND
="dev-util/patchelf"
46 # Install scalable icon
47 doicon
-s scalable
"${FILESDIR}"/dingtalk.svg
48 # Remove the libraries that break compatibility in modern systems
49 # Dingtalk will use the system libs instead
50 MY_VERSION
=$
(cat "${S}"/opt
/apps
/"${MY_PGK_NAME}"/files
/version
)
52 rm -f "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}"/libstdc
++* || die
54 rm -f "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}"/libm.so
* || die
56 rm -f "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}"/libz
* || die
57 # Use system libcurl, fix preserved depend problem
58 rm -f "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}"/libcurl.so
* || die
59 # Fix cairo version mismatch
60 mv "${WORKDIR}"/usr/lib/libcairo.* "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}"/ || die
61 rm -rf "${WORKDIR}"/usr || die
62 # Set RPATH for preserve-libs handling
63 pushd "${S}"/opt/apps/"${MY_PGK_NAME}"/files/"${MY_VERSION}" || die
66 # Use \x7fELF header to separate ELF executables and libraries
67 [[ -f ${x} && $
(od -t x1
-N 4 "${x}") == *"7f 45 4c 46"* ]] ||
continue
68 local RPATH_ROOT
="/opt/apps/${MY_PGK_NAME}/files/${MY_VERSION}"
69 patchelf
--set-rpath "${RPATH_ROOT}/:${RPATH_ROOT}/swiftshader/:${RPATH_ROOT}/platforminputcontexts/:${RPATH_ROOT}/imageformats/" "${x}" || \
70 die
"patchelf failed on ${x}"
74 sed -i "s/export XMODIFIERS/#export XMODIFIERS/g" "${S}"/opt
/apps
/"${MY_PGK_NAME}"/files
/Elevator.sh || die
75 sed -i "s/export QT_IM_MODULE/#export QT_IM_MODULE/g" "${S}"/opt
/apps
/"${MY_PGK_NAME}"/files
/Elevator.sh || die
77 cat >> "${S}"/opt
/apps
/"${MY_PGK_NAME}"/files
/Elevator.sh.
head <<- EOF || die
79 if [ -z "\${QT_IM_MODULE}" ]
81 if [ -n "\$(pidof fcitx5)" ]
83 export XMODIFIERS="@im=fcitx"
84 export QT_IM_MODULE=fcitx
85 elif [ -n "\$(pidof ibus-daemon)" ]
87 export XMODIFIERS="@im=ibus"
88 export QT_IM_MODULE=ibus
89 elif [ -n "\$(pidof fcitx)" ]
91 export XMODIFIERS="@im=fcitx"
92 export QT_IM_MODULE=fcitx
97 cat "${S}"/opt/apps/"${MY_PGK_NAME}"/files/Elevator.sh.head "${S}"/opt/apps/"${MY_PGK_NAME}"/files/Elevator.sh > "${S}"/opt/apps/"${MY_PGK_NAME}"/files
/Elevator.sh.new || die
98 cat "${S}"/opt/apps/"${MY_PGK_NAME}"/files/Elevator.sh.new > "${S}"/opt/apps/"${MY_PGK_NAME}"/files
/Elevator.sh || die
99 rm "${S}"/opt/apps/"${MY_PGK_NAME}"/files/Elevator.sh.head "${S}"/opt/apps/"${MY_PGK_NAME}"/files
/Elevator.sh.new || die
101 # Add dingtalk command
102 mkdir
-p "${S}"/usr
/bin
/ || die
103 ln -s /opt
/apps
/"${MY_PGK_NAME}"/files
/Elevator.sh
"${S}"/usr
/bin
/dingtalk || die
105 # Fix file path and desktop files
106 sed -E -i 's/^Icon=.*$/Icon=dingtalk/g' "${S}"/opt
/apps
/"${MY_PGK_NAME}"/entries
/applications
/*.desktop || die
108 mkdir
-p usr
/share
/applications || die
109 mv "${S}"/opt/apps/"${MY_PGK_NAME}"/entries/applications/"${MY_PGK_NAME}".desktop usr
/share
/applications
/ || die
111 # Install package and fix permissions
113 doins
-r opt
/apps
/${MY_PGK_NAME}
118 for x
in $
(find "opt/apps/${MY_PGK_NAME}") ; do
119 # Fix shell script permissions
120 [[ "${x: -3}" == ".sh" ]] && fperms
0755 "/${x}"
121 # Use \x7fELF header to separate ELF executables and libraries
122 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] && fperms 0755 "/${x}"