1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 MY_PGK_NAME
="com.zwsoft.zw3dprofessional"
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"
17 RESTRICT
="strip mirror bindist"
30 dev-qt/qtprintsupport:5
37 media-libs/opencollada
39 media-libs/tiff-compat:4
47 x11-libs/libXcomposite
69 # Fix zw3d coredump when run
70 cat >> "${T}"/zw3d.c
<<- EOF || die
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);
80 cat >> "${T}"/Makefile
<<- EOF || die
83 ${TAB}\$(CC) \$(LDFLAGS) \
84 -o "\$(S)/opt/apps/\$(MY_PGK_NAME)/files/zw3d" \
86 -L"\$(S)/opt/apps/\$(MY_PGK_NAME)/files/lib" \
91 -Wl,--unresolved-symbols=ignore-all
94 emake S
="${S}" MY_PGK_NAME="${MY_PGK_NAME}" -C "${T}" || die
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
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}"
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
125 mkdir
-p "${S}"/usr
/bin
/ || die
127 cat >> "${S}"/opt
/apps
/${MY_PGK_NAME}/zw3d
<<- EOF || die
129 sh /opt/apps/${MY_PGK_NAME}/files/zw3drun.sh \$*
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
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
163 doins
-r opt
/apps
/${MY_PGK_NAME}
167 fperms
0755 /opt
/apps
/${MY_PGK_NAME}/zw3d
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}"