media-sound/listen1_desktop-bin: version bump
[gentoo-zh.git] / media-gfx / zw3d / zw3d-2022.0.3.1-r2.ebuild
blobe5729f7993fd8533abc17866407efa870cbc4460
1 # Copyright 1999-2022 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 MY_PGK_NAME="com.zwsoft.zw3dprofessional"
7 inherit unpacker xdg
9 DESCRIPTION="CAD/CAM software for 3D design and processing"
10 HOMEPAGE="https://www.zwsoft.cn/product/zw3d/linux"
11 SRC_URI="https://home-store-packages.uniontech.com/appstore/pool/appstore/c/${MY_PGK_NAME}/${MY_PGK_NAME}_${PV}_amd64.deb -> ${P}.deb"
13 LICENSE="all-rights-reserved"
14 SLOT="0"
15 KEYWORDS="-* ~amd64"
17 RESTRICT="strip mirror bindist"
19 RDEPEND="
20 app-arch/bzip2
21 app-arch/xz-utils
22 app-text/djvu
23 dev-db/sqlite:3
24 dev-libs/glib:2
25 dev-libs/libpcre
26 dev-libs/libxml2
27 dev-qt/qtcore:5
28 dev-qt/qtgui:5
29 dev-qt/qtnetwork:5
30 dev-qt/qtprintsupport:5
31 dev-qt/qtsvg:5
32 media-fonts/noto-cjk
33 media-gfx/imagemagick
34 media-libs/jbigkit
35 media-libs/libglvnd
36 media-libs/libpng
37 media-libs/opencollada
38 || ( media-libs/tiff:0/0 media-libs/tiff-compat:4 )
39 net-libs/zeromq
40 sys-libs/zlib
41 x11-libs/cairo
42 x11-libs/gdk-pixbuf:2
43 x11-libs/gtk+:3
44 x11-libs/libX11
45 x11-libs/libxcb
46 x11-libs/libXcomposite
47 x11-libs/libXext
48 x11-libs/libxkbcommon
49 x11-libs/libXmu
50 x11-libs/libXrender
51 x11-libs/libXt
52 x11-libs/pango
55 DEPEND="${RDEPEND}"
57 BDEPEND="
58 dev-util/bbe
59 dev-util/patchelf
62 S=${WORKDIR}
64 QA_PREBUILT="*"
66 src_install() {
67 # Install scalable icons
68 mkdir -p "${S}"/usr/share/icons/hicolor/scalable/apps || die
69 mv "${S}"/opt/apps/${MY_PGK_NAME}/entries/icons/hicolor/scalable/apps/*.svg "${S}"/usr/share/icons/hicolor/scalable/apps || die
71 # Set RPATH for preserve-libs handling
72 pushd "${S}"/opt/apps/${MY_PGK_NAME}/files || die
73 local x
74 for x in $(find) ; do
75 # Use \x7fELF header to separate ELF executables and libraries
76 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
77 local RPATH_ROOT="/opt/apps/${MY_PGK_NAME}/files"
78 local RPATH_S="${RPATH_ROOT}/:${RPATH_ROOT}/lib/:${RPATH_ROOT}/lib/xlator/:${RPATH_ROOT}/lib/xlator/InterOp/:${RPATH_ROOT}/libqt/:${RPATH_ROOT}/libqt/plugins/designer/:${RPATH_ROOT}/lib3rd/:/usr/lib64/"
79 patchelf --set-rpath "${RPATH_S}" "${x}" || \
80 die "patchelf failed on ${x}"
81 # patchelf --replace-needed libMagickCore-6.Q16.so.7 libMagickCore-7.Q16.so "${x}" || \
82 # die "patchelf failed on ${x}"
83 patchelf --replace-needed libjbig.so.0 libjbig.so "${x}" || \
84 die "patchelf failed on ${x}"
85 done
86 popd || die
88 # Fix desktop files
89 sed -E -i 's/^Exec=.*$/Exec=zw3d %F/g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
90 sed -E -i 's/^Icon=.*$/Icon=ZW3Dprofessional/g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
91 sed -E -i 's/Application;//g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
93 # Add zw3d command
94 mkdir -p "${S}"/usr/bin/ || die
96 cat >> "${S}"/opt/apps/${MY_PGK_NAME}/zw3d <<- EOF || die
97 #!/bin/sh
98 sh /opt/apps/${MY_PGK_NAME}/files/zw3drun.sh \$*
99 EOF
101 ln -s /opt/apps/${MY_PGK_NAME}/zw3d "${S}"/usr/bin/zw3d || die
103 # Use system libraries
104 # rm -rf "${S}"/opt/apps/${MY_PGK_NAME}/files/lib3rd/libMagickCore* || die
105 # rm -rf "${S}"/opt/apps/${MY_PGK_NAME}/files/lib3rd/libjpeg* || die
107 # Fix coredump while draw 2D sketch due to not find fonts
108 # media-fonts/noto-cjk is required
109 # and should use /usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc
110 local MY_FONT_PATH_OLD="/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc"
111 local MY_FONT_PATH_NEW="//////usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"
112 bbe -e "s|${MY_FONT_PATH_OLD}|${MY_FONT_PATH_NEW}|" "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so" > "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so.tmp" && \
113 mv "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so.tmp" "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so" || die
115 # Install package and fix permissions
116 insinto /opt/apps
117 doins -r opt/apps/${MY_PGK_NAME}
118 insinto /usr
119 doins -r usr/*
121 fperms 0755 /opt/apps/${MY_PGK_NAME}/zw3d
123 pushd "${S}" || die
124 for x in $(find "opt/apps/${MY_PGK_NAME}") ; do
125 # Fix shell script permissions
126 [[ "${x: -3}" == ".sh" ]] && fperms 0755 "/${x}"
127 # Use \x7fELF header to separate ELF executables and libraries
128 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] && fperms 0755 "/${x}"
129 done
130 popd || die