sys-apps/isd: new package
[gentoo-zh.git] / media-gfx / zw3d / zw3d-2023.0.3.1.ebuild
blob0c655df9757bf145a986de3b21bce3291bdd0763
1 # Copyright 1999-2023 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
39         media-libs/tiff-compat:4
40         net-libs/zeromq
41         sys-libs/zlib
42         x11-libs/cairo
43         x11-libs/gdk-pixbuf:2
44         x11-libs/gtk+:3
45         x11-libs/libX11
46         x11-libs/libxcb
47         x11-libs/libXcomposite
48         x11-libs/libXext
49         x11-libs/libxkbcommon
50         x11-libs/libXmu
51         x11-libs/libXrender
52         x11-libs/libXt
53         x11-libs/pango
56 DEPEND="${RDEPEND}"
58 BDEPEND="
59         dev-util/bbe
60         dev-util/patchelf
63 S=${WORKDIR}
65 QA_PREBUILT="*"
67 src_compile() {
68         default
69         # Fix zw3d coredump when run
70 cat >> "${T}"/zw3d.c <<- EOF || die
71 #include <stdint.h>
72 extern int DiModuleEntryPoint(uint64_t argc, uint64_t argv, uint64_t envp);
73 int main(int argc, char* argv[], char* envp[])
75 return DiModuleEntryPoint((uint64_t)(uintptr_t)&argc, (uint64_t)(uintptr_t)argv, (uint64_t)(uintptr_t)envp);
77         EOF
79 TAB=$'\t'
80 cat >> "${T}"/Makefile <<- EOF || die
81 .PHONY: all
82 all:
83 ${TAB}\$(CC) \$(LDFLAGS) \
84 -o "\$(S)/opt/apps/\$(MY_PGK_NAME)/files/zw3d" \
85 zw3d.c \
86 -L"\$(S)/opt/apps/\$(MY_PGK_NAME)/files/lib" \
87 -lDrawingInstance \
88 -lstdc++ \
89 -lm \
90 -lgcc_s \
91 -Wl,--unresolved-symbols=ignore-all
92         EOF
94         emake S="${S}" MY_PGK_NAME="${MY_PGK_NAME}" -C "${T}" || die
97 src_install() {
98         # Install scalable icons, desktop files, mimes
99         mkdir -p "${S}"/usr/share || die
100         mv "${S}"/opt/apps/${MY_PGK_NAME}/entries/* "${S}"/usr/share || die
102         # Set RPATH for preserve-libs handling
103         pushd "${S}"/opt/apps/${MY_PGK_NAME}/files || die
104         local x
105         for x in $(find) ; do
106                 # Use \x7fELF header to separate ELF executables and libraries
107                 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
108                 local RPATH_ROOT="/opt/apps/${MY_PGK_NAME}/files"
109                 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/"
110                 patchelf --set-rpath "${RPATH_S}" "${x}" || \
111                         die "patchelf failed on ${x}"
112                 # patchelf --replace-needed libMagickCore-6.Q16.so.7 libMagickCore-7.Q16.so "${x}" || \
113                 #       die "patchelf failed on ${x}"
114                 patchelf --replace-needed libjbig.so.0 libjbig.so "${x}" || \
115                         die "patchelf failed on ${x}"
116         done
117         popd || die
119         # Fix desktop files
120         sed -E -i 's/^Exec=.*$/Exec=zw3d %F/g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
121         sed -E -i 's/^Icon=.*$/Icon=ZW3Dprofessional/g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
122         sed -E -i 's/Application;//g' "${S}/usr/share/applications/${MY_PGK_NAME}.desktop" || die
124         # Add zw3d command
125         mkdir -p "${S}"/usr/bin/ || die
127         cat >> "${S}"/opt/apps/${MY_PGK_NAME}/zw3d <<- EOF || die
128 #!/bin/sh
129 sh /opt/apps/${MY_PGK_NAME}/files/zw3drun.sh \$*
130         EOF
132         ln -s /opt/apps/${MY_PGK_NAME}/zw3d "${S}"/usr/bin/zw3d || die
134         # Fix zw3d startup file
135 cat >> insert.txt <<- EOF || die
136 unset WAYLAND_DISPLAY
137 export XDG_SESSION_TYPE=x11
138 export QT_QPA_PLATFORM=xcb
139 export QT_AUTO_SCREEN_SCALE_FACTOR=1
140 export QT_STYLE_OVERRIDE=fusion
141 export IBUS_USE_PORTAL=1
142         EOF
144         sed -i \
145                 -e '/export LD_LIBRARY_PATH/r insert.txt' \
146                 "${S}"/opt/apps/${MY_PGK_NAME}/files/zw3drun.sh || die
148         # Use system libraries
149         # rm -rf "${S}"/opt/apps/${MY_PGK_NAME}/files/lib3rd/libMagickCore* || die
150         # rm -rf "${S}"/opt/apps/${MY_PGK_NAME}/files/lib3rd/libjpeg* || die
152         # Fix coredump while draw 2D sketch due to not find fonts
153         # media-fonts/noto-cjk is required
154         # and should use /usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc
155         local MY_FONT_PATH_OLD="/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc"
156         local MY_FONT_PATH_NEW="//////usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc"
157         bbe -e "s|${MY_FONT_PATH_OLD}|${MY_FONT_PATH_NEW}|" "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so" \
158                 > "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so.tmp" && \
159         mv "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so.tmp" "${S}/opt/apps/${MY_PGK_NAME}/files/lib/libdisp.so" || die
161         # Install package and fix permissions
162         insinto /opt/apps
163         doins -r opt/apps/${MY_PGK_NAME}
164         insinto /usr
165         doins -r usr/*
167         fperms 0755 /opt/apps/${MY_PGK_NAME}/zw3d
169         pushd "${S}" || die
170         for x in $(find "opt/apps/${MY_PGK_NAME}") ; do
171                 # Fix shell script permissions
172                 [[ "${x: -3}" == ".sh" ]] && fperms 0755 "/${x}"
173                 # Use \x7fELF header to separate ELF executables and libraries
174                 [[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] && fperms 0755 "/${x}"
175         done
176         popd || die