notepad/NotePad/build-appimage.sh
2026-02-14 22:24:29 +00:00

107 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Build AppImage for NotePad
# Requires appimagetool: https://github.com/AppImage/AppImageKit/releases
set -e
APP_NAME="NotePad"
VERSION="${1:-0.1.0}" # Use first argument or default to 0.1.0
ARCH="x86_64"
# Directories
PUBLISH_DIR="../publish/linux-x64"
APPDIR="NotePad.AppDir"
OUTPUT_DIR="../publish/appimage"
ICON_SOURCE="img/notepad-icon.svg"
echo "============================================================"
echo "Building AppImage for $APP_NAME v$VERSION"
echo "============================================================"
# Check if publish directory exists
if [ ! -d "$PUBLISH_DIR" ]; then
echo "❌ ERROR: $PUBLISH_DIR not found. Run 'python3 publish.py linux' first."
exit 1
fi
# Clean and create AppDir structure
echo "Creating AppDir structure..."
rm -rf "$APPDIR"
mkdir -p "$APPDIR/usr/bin"
mkdir -p "$APPDIR/usr/share/applications"
mkdir -p "$APPDIR/usr/share/icons/hicolor/256x256/apps"
# Copy application files
echo "Copying application files..."
cp -r "$PUBLISH_DIR"/* "$APPDIR/usr/bin/"
# Create desktop entry
echo "Creating desktop entry..."
cat > "$APPDIR/usr/share/applications/notepad.desktop" << EOF
[Desktop Entry]
Name=NotePad
Comment=Simple text editor
Exec=NotePad
Icon=notepad
Type=Application
Categories=Utility;TextEditor;
Terminal=false
EOF
# Copy application icon
echo "Copying application icon..."
if [ ! -f "$ICON_SOURCE" ]; then
echo "❌ ERROR: Icon not found at $ICON_SOURCE"
exit 1
fi
mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps"
cp "$ICON_SOURCE" "$APPDIR/usr/share/icons/hicolor/scalable/apps/notepad.svg"
# Create AppRun script
echo "Creating AppRun script..."
cat > "$APPDIR/AppRun" << 'EOF'
#!/bin/bash
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
export PATH="${HERE}/usr/bin:${PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib:${LD_LIBRARY_PATH}"
exec "${HERE}/usr/bin/NotePad" "$@"
EOF
chmod +x "$APPDIR/AppRun"
# Copy desktop file and icon to root of AppDir
cp "$APPDIR/usr/share/applications/notepad.desktop" "$APPDIR/"
cp "$APPDIR/usr/share/icons/hicolor/scalable/apps/notepad.svg" "$APPDIR/notepad.svg"
# Check for appimagetool
if ! command -v appimagetool &> /dev/null; then
echo "⚠️ WARNING: appimagetool not found."
echo " Download from: https://github.com/AppImage/AppImageKit/releases"
echo " Or run: wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
echo " chmod +x appimagetool-x86_64.AppImage"
echo ""
echo " AppDir created at: $APPDIR"
echo " You can manually run: appimagetool $APPDIR"
exit 1
fi
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Build AppImage
echo "Building AppImage..."
ARCH=$ARCH appimagetool "$APPDIR" "$OUTPUT_DIR/$APP_NAME-$VERSION-$ARCH.AppImage"
# Clean up
echo "Cleaning up..."
rm -rf "$APPDIR"
echo ""
echo "============================================================"
echo "✅ AppImage created successfully!"
echo "📦 Output: $OUTPUT_DIR/$APP_NAME-$VERSION-$ARCH.AppImage"
echo "============================================================"
echo ""
echo "To run: chmod +x $OUTPUT_DIR/$APP_NAME-$VERSION-$ARCH.AppImage"
echo " ./$OUTPUT_DIR/$APP_NAME-$VERSION-$ARCH.AppImage"