media-gfx/zwcad: use tiff subslot 0/0
[gentoo-zh.git] / media-gfx / zwcad / zwcad-2023.23.0.3.4-r1.ebuild
blobafcee5eecfe2c1035f8f3d536461e1d5702a9a1d
1 # Copyright 1999-2022 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 SRC_URI="
15 https://home-store-packages.uniontech.com/appstore/pool/appstore/c/${MY_PGK_NAME}/${MY_PGK_NAME}_${MY_PV}_amd64.deb -> ${P}.deb
16 https://anaconda.org/anaconda/python/3.7.13/download/linux-64/python-3.7.13-h12debd9_0.tar.bz2 -> ${PN}-python-3.7.13.tar.bz2
19 LICENSE="all-rights-reserved"
20 SLOT="0"
21 KEYWORDS="-* ~amd64"
23 RESTRICT="strip mirror bindist"
25 RDEPEND="
26 media-libs/fontconfig
27 media-libs/libglvnd
28 || ( media-libs/tiff:0/0 media-libs/tiff-compat:4 )
29 sys-apps/util-linux
30 sys-libs/zlib
31 virtual/libcrypt:=
34 DEPEND="${RDEPEND}"
36 BDEPEND="dev-util/patchelf"
38 S=${WORKDIR}
40 QA_PREBUILT="*"
42 src_unpack() {
43 unpack_deb "${DISTDIR}/${P}.deb"
44 tar -xf "${DISTDIR}/${PN}-python-3.7.13.tar.bz2" -C "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.7/" || die
47 src_install() {
48 # Install scalable icons
49 doicon -s scalable "${S}"/opt/apps/${MY_PGK_NAME}/files/Icons/ZWCAD.svg
51 # Fix python and QA problems about python
52 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.6/" || die
53 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad6.so" || die
54 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.5/" || die
55 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad5.so" || die
56 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.4/" || die
57 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/libZwPythonLoad4.so" || die
58 rm -rf "${S}/opt/apps/"${MY_PGK_NAME}"/files/ZwPyRuntime/python3.7/compiler_compat" || die
60 # Set RPATH for preserve-libs handling
61 pushd "${S}"/opt/apps/${MY_PGK_NAME}/files || die
62 local x
63 for x in $(find) ; do
64 # Use \x7fELF header to separate ELF executables and libraries
65 [[ -f "${x}" && "${x: -2}" != ".o" && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
66 local RPATH_ROOT="/opt/apps/${MY_PGK_NAME}/files"
67 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"
68 patchelf --set-rpath "${RPATH_S}" "${x}" || \
69 die "patchelf failed on ${x}"
70 done
71 popd || die
73 # Fix desktop files
74 sed -E -i 's/^Exec=.*$/Exec=zwcad %F/g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
75 sed -E -i 's/^Icon=.*$/Icon=ZWCAD/g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
76 sed -E -i 's/Application;//g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
77 # The Version entry in a .desktop file doesn't refer to the version of the
78 # target program. It's the version of the desktop file specification that
79 # this desktop file conforms to.
80 sed -E -i 's/^Version=.*$/Version=1.0/g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
81 sed -E -i 's/^Categories=.*$/Categories=Graphics;VectorGraphics;Engineering;Construction;2DGraphics;/g' "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop" || die
82 domenu "${S}/opt/apps/${MY_PGK_NAME}/entries/applications/${MY_PGK_NAME}.desktop"
84 sed -i "1i\\export MONO_PATH=/opt/apps/${MY_PGK_NAME}/files/lib/mono/lib/mono/4.5\n" "${S}/opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh" || die
85 sed -E -i 's/export QT_IM_MODULE=fcitx//g' "${S}/opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh" || die
87 # Add zw3d command
88 mkdir -p "${S}"/usr/bin/ || die
90 cat >> "${S}"/opt/apps/${MY_PGK_NAME}/zwcad <<- EOF || die
91 #!/bin/sh
92 if [ -z "\${QT_IM_MODULE}" ]
93 then
94 if [ -n "\$(pidof fcitx5)" ]
95 then
96 export XMODIFIERS="@im=fcitx"
97 export QT_IM_MODULE=fcitx
98 elif [ -n "\$(pidof ibus-daemon)" ]
99 then
100 export XMODIFIERS="@im=ibus"
101 export QT_IM_MODULE=ibus
102 elif [ -n "\$(pidof fcitx)" ]
103 then
104 export XMODIFIERS="@im=fcitx"
105 export QT_IM_MODULE=fcitx
108 export MONO_PATH=/opt/apps/${MY_PGK_NAME}/files/lib/mono/lib/mono/4.5
109 sh /opt/apps/${MY_PGK_NAME}/files/ZWCADRUN.sh \$*
112 ln -s /opt/apps/${MY_PGK_NAME}/zwcad "${S}"/usr/bin/zwcad || die
114 # Install package and fix permissions
115 insinto /opt/apps/
116 doins -r opt/apps/${MY_PGK_NAME}
117 insinto /usr
118 doins -r usr/*
120 fperms 0755 /opt/apps/${MY_PGK_NAME}/zwcad
122 pushd "${S}" || die
123 for x in $(find "opt/apps/${MY_PGK_NAME}") ; do
124 # Fix shell script permissions
125 [[ "${x: -3}" == ".sh" ]] && fperms 0755 "/${x}"
126 # Use \x7fELF header to separate ELF executables and libraries
127 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] && fperms 0755 "/${x}"
128 done
129 popd || die