diff --git a/node-v37.10.0-headers.tar.gz b/node-v37.10.0-headers.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..158ab19f61164ccfae31dc5ba3b2ab8bf1082e9e Binary files /dev/null and b/node-v37.10.0-headers.tar.gz differ diff --git a/polymind-1.0.0.tar.gz b/polymind-1.0.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..423b47c94f7de2b1a595049d9daa4798fd5f7f65 Binary files /dev/null and b/polymind-1.0.0.tar.gz differ diff --git a/polymind.spec b/polymind.spec new file mode 100644 index 0000000000000000000000000000000000000000..2d1834e1bac32cc96f1340d688724d11c5c83a09 --- /dev/null +++ b/polymind.spec @@ -0,0 +1,228 @@ +%global debug_package %{nil} + +Name: polymind +Version: 1.0.0 +Release: 1 +Summary: PolyMind - A simple and easy-to-use AI client + +Group: Applications/Productivity +License: Apache-2.0 +URL: https://gitee.com/openeuler/polymind +Source0: %{name}-%{version}.tar.gz + +# Build dependencies +BuildRequires: nodejs >= 20.19.0 + +# Exclude Electron app directory from automatic dependency analysis +%global __provides_exclude_from ^/opt/polymind/app/.*$ +%global __requires_exclude_from ^/opt/polymind/app/.*$ +# Exclude specific Electron app shared library dependencies + +%description +PolyMind is a feature-rich AI assistant that supports mainstream language models, +providing environment awareness and powerful tool scheduling capabilities. + +As a cross-platform AI assistant application, it not only supports basic chat +functionality but also provides advanced features such as search enhancement, +tool calling, multimodal interaction, making AI capabilities more convenient and efficient. + +# Runtime dependencies +Requires: google-noto-emoji-fonts + +%prep +%setup -q -n %{name}-%{version} +# Extract node headers for native modules +mkdir -p /tmp/node-headers +tar -xzf %{_sourcedir}/node-*-headers.tar.gz -C /tmp/node-headers --strip-components=1 + +%build + +# Get current architecture +case "%{_arch}" in + x86_64) + TARGET_ARCH="x64" + ;; + aarch64|arm64) + TARGET_ARCH="arm64" + ;; + *) + echo "Unsupported architecture: %{_arch}" + exit 1 + ;; +esac + +echo "Target architecture: $TARGET_ARCH" + +npm config set prefix '~/.npm-global' +npm config set registry https://mirrors.huaweicloud.com/repository/npm/ +npm install -g pnpm +export PATH=~/.npm-global/bin:$PATH + +# Install dependencies +pnpm install + +# Install runtime dependencies +# if [ "$TARGET_ARCH" = "arm64" ]; then +# pnpm run installRuntime:linux:arm64 +# else +# pnpm run installRuntime:linux:x64 +# fi + +# Build application +pnpm run build +pnpm run copy:binaries + +# Set environment variables to ensure correct architecture build +export TARGET_ARCH=$TARGET_ARCH + +# Select correct build command based on architecture, only build unpacked directory +if [ "$TARGET_ARCH" = "arm64" ]; then + npx electron-builder --linux dir --arm64 +else + npx electron-builder --linux dir --x64 +fi + +# Check build results +if [ "$TARGET_ARCH" = "arm64" ]; then + EXPECTED_DIR="dist/linux-arm64-unpacked" +else + EXPECTED_DIR="dist/linux-unpacked" +fi + +if [ ! -d "$EXPECTED_DIR" ]; then + echo "Build failed, $EXPECTED_DIR directory not found" + ls -la dist/ || true + exit 1 +fi + +echo "Build completed" + +%install +# Create installation directory structure +mkdir -p %{buildroot}/opt/polymind/app +mkdir -p %{buildroot}/usr/bin +mkdir -p %{buildroot}/usr/share/applications +mkdir -p %{buildroot}/usr/share/icons/hicolor/512x512/apps +mkdir -p %{buildroot}/usr/share/doc/%{name} + +# Get current architecture to determine build result directory +case "%{_arch}" in + x86_64) + BUILD_DIR="dist/linux-unpacked" + ;; + aarch64|arm64) + BUILD_DIR="dist/linux-arm64-unpacked" + ;; + *) + echo "Unsupported architecture: %{_arch}" + exit 1 + ;; +esac + +# Install application files +cp -rf $BUILD_DIR/* %{buildroot}/opt/polymind/app/ + +# Create startup script +cat > %{buildroot}/usr/bin/polymind << 'EOF' +#!/bin/bash +exec /opt/polymind/app/polymind "$@" +EOF + +# Install desktop file +cat > %{buildroot}/usr/share/applications/%{name}.desktop << 'EOF' +[Desktop Entry] +Name=PolyMind +Comment=AI Client Application +Exec=polymind +Icon=polymind +Terminal=false +Type=Application +Categories=Utility; +StartupWMClass=PolyMind +MimeType=x-scheme-handler/polymind; +EOF + +# Install icon file +if [ -f "resources/icon.png" ]; then + cp resources/icon.png %{buildroot}/usr/share/icons/hicolor/512x512/apps/%{name}.png +else + # If icon not found, create a placeholder + echo "Warning: Icon file not found, creating placeholder" + touch %{buildroot}/usr/share/icons/hicolor/512x512/apps/%{name}.png +fi + +# Install documentation files +cp README.md %{buildroot}/usr/share/doc/%{name}/ + +# Set file permissions +chmod 755 %{buildroot}/opt/polymind/app/polymind +chmod 755 %{buildroot}/usr/bin/polymind +chmod 644 %{buildroot}/usr/share/applications/%{name}.desktop +chmod 644 %{buildroot}/usr/share/icons/hicolor/512x512/apps/%{name}.png + +%files +%defattr(-,root,root,-) +%license LICENSE +%doc README.md + +# Application files - based on actual build output +%attr(755,root,root) /opt/polymind/app/polymind +%attr(755,root,root) /opt/polymind/app/chrome-sandbox +%attr(755,root,root) /opt/polymind/app/chrome_crashpad_handler +/opt/polymind/app/*.pak +/opt/polymind/app/*.dat +/opt/polymind/app/*.bin +/opt/polymind/app/*.json +/opt/polymind/app/*.html +/opt/polymind/app/*.txt +/opt/polymind/app/*.so* +/opt/polymind/app/locales/ +/opt/polymind/app/resources/ + +# Startup script +%attr(755,root,root) /usr/bin/polymind + +# Desktop file +%attr(644,root,root) /usr/share/applications/polymind.desktop + +# Icon file +%attr(644,root,root) /usr/share/icons/hicolor/512x512/apps/polymind.png + +%post +# Post-installation script +# Update desktop database (if command exists) +if command -v update-desktop-database >/dev/null 2>&1; then + update-desktop-database /usr/share/applications +fi + +# Update icon cache (if command exists) +if command -v gtk-update-icon-cache >/dev/null 2>&1; then + gtk-update-icon-cache -f -t /usr/share/icons/hicolor +fi + +echo "PolyMind has been installed successfully." +echo "You can start PolyMind by running: polymind" +echo "Or find it in your application menu." + +%preun +# Pre-uninstallation script +# Clean up temporary files (if needed) + +%postun +# Post-uninstallation script +if [ $1 -eq 0 ]; then + # Execute when completely uninstalled + if command -v update-desktop-database >/dev/null 2>&1; then + update-desktop-database /usr/share/applications + fi + if command -v gtk-update-icon-cache >/dev/null 2>&1; then + gtk-update-icon-cache -f -t /usr/share/icons/hicolor + fi + echo "PolyMind has been completely removed." +fi + +%changelog +* Thu Nov 27 2025 PolyMind ftboy - 1.0.0-1 +- Initial package for openEuler +- Support for both x86_64 and aarch64 architectures +- Built with electron-builder for Linux \ No newline at end of file