x11-terms/ghostty: add missing depend dev-libs/oniguruma
[gentoo-zh.git] / media-gfx / zwcad / zwcad-2023.23.0.3.4-r2.ebuild
blob2f722467413888a9b40cf4f82aeb99f0b0ac810b
1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 MY_PV_YEAR="$(ver_cut 1)"
7 MY_PV="$(ver_cut 2).$(ver_cut 3).$(ver_cut 4).$(ver_cut 5)"
8 MY_PGK_NAME="com.zwsoft.${PN}${MY_PV_YEAR}"
9 inherit desktop unpacker xdg
11 DESCRIPTION="CAD software for 2D drawing, reviewing and printing work"
12 HOMEPAGE="https://www.zwsoft.cn/product/zwcad/linux"
14 URI_UNIONTECH="https://home-store-packages.uniontech.com/appstore/pool/appstore/c"
15 URI_ANACONDA="https://anaconda.org/anaconda"
16 SRC_URI="
17 ${URI_UNIONTECH}/${MY_PGK_NAME}/${MY_PGK_NAME}_${MY_PV}_amd64.deb -> ${P}.deb
18 ${URI_ANACONDA}/python/3.7.13/download/linux-64/python-3.7.13-h12debd9_0.tar.bz2 -> ${PN}-python-3.7.13.tar.bz2
21 LICENSE="all-rights-reserved"
22 SLOT="0"
23 KEYWORDS="-* ~amd64"
25 RESTRICT="bindist mirror preserve-libs strip"
27 RDEPEND="
28 media-libs/fontconfig
29 media-libs/libglvnd
30 media-libs/tiff-compat:4
31 sys-apps/util-linux
32 sys-libs/zlib
33 virtual/libcrypt:=
36 DEPEND="${RDEPEND}"
38 BDEPEND="dev-util/patchelf"
40 S=${WORKDIR}
42 QA_PREBUILT="*"
44 src_unpack() {
45 unpack_deb "${DISTDIR}/${P}.deb"
46 tar -xf "${DISTDIR}/${PN}-python-3.7.13.tar.bz2" \
47 -C "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.7/" || die
50 src_install() {
51 # Install scalable icons
52 doicon -s scalable "${S}"/opt/apps/${MY_PGK_NAME}/files/Icons/ZWCAD.svg
54 # Fix python and QA problems about python
55 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.6/" || die
56 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad6.so" || die
57 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.5/" || die
58 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad5.so" || die
59 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.4/" || die
60 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad4.so" || die
61 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.7/compiler_compat" || die
63 # Set RPATH for preserve-libs handling
64 pushd "${S}"/opt/apps/${MY_PGK_NAME}/files || die
65 local x
66 for x in $(find) ; do
67 # Use \x7fELF header to separate ELF executables and libraries
68 [[ -f "${x}" && "${x: -2}" != ".o" && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
69 local RPATH_ROOT="/opt/apps/${MY_PGK_NAME}/files"
70 local RPATH_S="${RPATH_ROOT}/:${RPATH_ROOT}/lib/:${RPATH_ROOT}/lib/mono/lib/:${RPATH_ROOT}/plugins/:${RPATH_ROOT}/zh-CN/:${RPATH_ROOT}/ZwPyRuntime/python3.7/lib"
71 patchelf --set-rpath "${RPATH_S}" "${x}" || \
72 die "patchelf failed on ${x}"
73 done
74 popd || die
76 # Fix desktop files
77 sed -E -i 's/^Exec=.*$/Exec=zwcad %F/g' \
78 "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
79 sed -E -i 's/^Icon=.*$/Icon=ZWCAD/g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
80 sed -E -i 's/Application;//g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
81 # The Version entry in a .desktop file doesn't refer to the version of the
82 # target program. It's the version of the desktop file specification that
83 # this desktop file conforms to.
84 sed -E -i 's/^Version=.*$/Version=1.0/g' \
85 "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
86 sed -E -i 's/^Categories=.*$/Categories=Graphics;VectorGraphics;Engineering;Construction;2DGraphics;/g' \
87 "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
88 domenu "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop"
90 sed -i "1i\\export MONO_PATH=/opt/apps/${MY_PGK_NAME}/files/lib/mono/lib/mono/4.5\n" \
91 "${S}/opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh" || die
92 sed -E -i 's/export QT_IM_MODULE=fcitx//g' "${S}/opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh" || die
94 # Add zw3d command
95 mkdir -p "${S}"/usr/bin/ || die
97 cat >> "${S}"/opt/apps/${MY_PGK_NAME}/zwcad <<- EOF || die
98 #!/bin/sh
99 if [ -z "\${QT_IM_MODULE}" ]
100 then
101 if [ -n "\$(pidof fcitx5)" ]
102 then
103 export XMODIFIERS="@im=fcitx"
104 export QT_IM_MODULE=fcitx
105 elif [ -n "\$(pidof ibus-daemon)" ]
106 then
107 export XMODIFIERS="@im=ibus"
108 export QT_IM_MODULE=ibus
109 elif [ -n "\$(pidof fcitx)" ]
110 then
111 export XMODIFIERS="@im=fcitx"
112 export QT_IM_MODULE=fcitx
115 export MONO_PATH=/opt/apps/${MY_PGK_NAME}/files/lib/mono/lib/mono/4.5
116 sh /opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh \$*
119 ln -s /opt/apps/${MY_PGK_NAME}/zwcad "${S}"/usr/bin/zwcad || die
121 # Install package and fix permissions
122 insinto /opt/apps/
123 doins -r opt/apps/${MY_PGK_NAME}
124 insinto /usr
125 doins -r usr/*
127 fperms 0755 /opt/apps/${MY_PGK_NAME}/zwcad
129 pushd "${S}" || die
130 for x in $(find "opt/apps/${MY_PGK_NAME}") ; do
131 # Fix shell script permissions
132 [[ "${x: -3}" == ".sh" ]] && fperms 0755 "/${x}"
133 # Use \x7fELF header to separate ELF executables and libraries
134 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] && fperms 0755 "/${x}"
135 done
136 popd || die