diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index d3c6153..afb5c58 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -105,6 +105,9 @@ jobs: mv Ciyue-x86_64.AppImage Ciyue-latest-x86_64.AppImage mv Ciyue-x86_64.AppImage.zsync Ciyue-latest-x86_64.AppImage.zsync + - name: Install fastforge + run: dart pub global activate fastforge + - name: Build Deb if: ${{ inputs.package_release_artifacts }} run: | @@ -112,6 +115,13 @@ jobs: mv dist/*/*.deb . mv *.deb ciyue-x86_64.deb + - name: Build rpm + if: ${{ inputs.package_release_artifacts }} + run: | + pacman -S --noconfirm rpmdevtools + ./tools/build_rpm.sh + mv ciyue-*.x86_64.rpm ciyue.x86_64.rpm + - name: Upload bundle if: ${{ !inputs.package_release_artifacts }} uses: actions/upload-artifact@v4 @@ -129,3 +139,4 @@ jobs: Ciyue-latest-x86_64.AppImage *.zsync ciyue-x86_64.deb + ciyue-x86_64.rpm diff --git a/.gitignore b/.gitignore index 2654f80..049aa35 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ appimagetool # fastforge dist/ + +# rpm +*.rpm diff --git a/GEMINI.md b/GEMINI.md index deb9630..00846de 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -40,6 +40,8 @@ The project uses `justfile` to manage common development tasks. | **Migrations** | `just make-migrations` | Generates database migrations using Drift. | | **Icons** | `just icon` | Generates app launcher icons. | | **Count Code** | `just count-codes` | Counts lines of code excluding generated files. | +| **Package AppImage** | `just build-appimage` | Builds a Linux AppImage. | +| **Package RPM** | `just build-rpm` | Builds a Linux RPM package. | ### Standard Flutter Commands * **Run:** `flutter run` diff --git a/justfile b/justfile index 430d36d..9064af2 100644 --- a/justfile +++ b/justfile @@ -12,3 +12,6 @@ count-codes: build-appimage: ./tools/build_appimage.sh + +build-rpm: + ./tools/build_rpm.sh diff --git a/linux/appimage/org.eu.mumulhl.ciyue.metainfo.xml b/linux/appimage/org.eu.mumulhl.ciyue.metainfo.xml deleted file mode 100644 index 563d035..0000000 --- a/linux/appimage/org.eu.mumulhl.ciyue.metainfo.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - org.eu.mumulhl.ciyue - - Ciyue - A simple mdict dictionary - - CC0-1.0 - MIT - - - mumu-lhl - - - https://github.com/mumu-lhl/Ciyue - https://github.com/mumu-lhl/Ciyue/issues - https://github.com/mumu-lhl/Ciyue - - -

- Ciyue is a comprehensive dictionary application built with Flutter. It supports MDX/MDD dictionary formats and offers a modern user experience with Material You design. -

- -
- - org.eu.mumulhl.ciyue.desktop - - ciyue - - - Education - Languages - - - - ciyue - - - -
diff --git a/linux/appimage/AppRun b/linux/packaging/appimage/AppRun similarity index 100% rename from linux/appimage/AppRun rename to linux/packaging/appimage/AppRun diff --git a/linux/packaging/deb/make_config.yaml b/linux/packaging/deb/make_config.yaml index 3f7c1e8..4b44427 100644 --- a/linux/packaging/deb/make_config.yaml +++ b/linux/packaging/deb/make_config.yaml @@ -20,6 +20,5 @@ categories: - Languages startup_notify: true -# You can also specify [metainfo](https://freedesktop.org/software/appstream/docs/chap-Quickstart.html) file -# which contains metadata of the app. + metainfo: linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml diff --git a/linux/appimage/org.eu.mumulhl.ciyue.desktop b/linux/packaging/org.eu.mumulhl.ciyue.desktop similarity index 100% rename from linux/appimage/org.eu.mumulhl.ciyue.desktop rename to linux/packaging/org.eu.mumulhl.ciyue.desktop diff --git a/linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml b/linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml index 511d1a9..563d035 100644 --- a/linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml +++ b/linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml @@ -7,11 +7,27 @@ CC0-1.0 MIT + + + mumu-lhl + + + https://github.com/mumu-lhl/Ciyue + https://github.com/mumu-lhl/Ciyue/issues + https://github.com/mumu-lhl/Ciyue

- 📄 Support MDX/MDD (not on Linux yet) 🔍 Support multiple dictionaries search and display 🎨 Support Material You 🌐 AI Translate (Support OpenAI, Gemini, Deepseek...) 🔈 Support reading aloud 🔖 Bookmarking words to the word book + Ciyue is a comprehensive dictionary application built with Flutter. It supports MDX/MDD dictionary formats and offers a modern user experience with Material You design.

+
org.eu.mumulhl.ciyue.desktop @@ -26,4 +42,6 @@ ciyue + + diff --git a/linux/packaging/rpm/ciyue.spec b/linux/packaging/rpm/ciyue.spec new file mode 100644 index 0000000..9e09292 --- /dev/null +++ b/linux/packaging/rpm/ciyue.spec @@ -0,0 +1,39 @@ +Name: ciyue +Version: @VERSION@ +Release: @RELEASE@ +Summary: A simple mdict dictionary +License: MIT +URL: https://github.com/mumu-lhl/Ciyue + +%description +A simple mdict dictionary with Android/Windows/Linux support. +Multi-dictionary support, AI integration, and Material You design. + +%install +mkdir -p %{buildroot}/usr/bin +mkdir -p %{buildroot}/opt/%{name} +cp -r @BUNDLE_DIR@/* %{buildroot}/opt/%{name}/ +ln -s /opt/%{name}/%{name} %{buildroot}/usr/bin/%{name} + +# Desktop file +mkdir -p %{buildroot}/usr/share/applications +cp @DESKTOP_FILE@ %{buildroot}/usr/share/applications/ + +# Icon +mkdir -p %{buildroot}/usr/share/icons/hicolor/256x256/apps +cp @ICON_PATH@ %{buildroot}/usr/share/icons/hicolor/256x256/apps/%{name}.png + +# Metainfo +mkdir -p %{buildroot}/usr/share/metainfo +cp @METAINFO_FILE@ %{buildroot}/usr/share/metainfo/org.eu.mumulhl.ciyue.appdata.xml + +%files +/opt/%{name}/ +/usr/bin/%{name} +/usr/share/applications/org.eu.mumulhl.ciyue.desktop +/usr/share/icons/hicolor/256x256/apps/%{name}.png +/usr/share/metainfo/org.eu.mumulhl.ciyue.appdata.xml + +%changelog +* @DATE@ Ciyue Maintainers - @VERSION@-@RELEASE@ +- Automated RPM build diff --git a/tools/build_appimage.sh b/tools/build_appimage.sh index 2266ba9..773e493 100755 --- a/tools/build_appimage.sh +++ b/tools/build_appimage.sh @@ -9,7 +9,8 @@ ICON_PATH="assets/icon.png" BUILD_DIR="build/linux/x64/release" BUNDLE_DIR="$BUILD_DIR/bundle" APPDIR="$BUILD_DIR/AppDir" -ASSETS_DIR="linux/appimage" +ASSETS_DIR="linux/packaging/appimage" +PACKAGING_DIR="linux/packaging" # Ensure we are in the project root cd "$(dirname "$0")/.." @@ -28,12 +29,12 @@ cp -r "$BUNDLE_DIR/"* "$APPDIR/" echo "=== 2. Copying Metadata Files ===" # Desktop file (Root for AppImage) -cp "$ASSETS_DIR/$APP_ID.desktop" "$APPDIR/" +cp "$PACKAGING_DIR/$APP_ID.desktop" "$APPDIR/" ln -sf "$APP_ID.desktop" "$APPDIR/$BINARY_NAME.desktop" # Desktop file (Standard path for AppStream validation) mkdir -p "$APPDIR/usr/share/applications" -cp "$ASSETS_DIR/$APP_ID.desktop" "$APPDIR/usr/share/applications/" +cp "$PACKAGING_DIR/$APP_ID.desktop" "$APPDIR/usr/share/applications/" # Icon (Standard path) mkdir -p "$APPDIR/usr/share/icons/hicolor/256x256/apps" @@ -47,7 +48,7 @@ chmod +x "$APPDIR/AppRun" # Metainfo mkdir -p "$APPDIR/usr/share/metainfo" -cp "$ASSETS_DIR/org.eu.mumulhl.ciyue.metainfo.xml" "$APPDIR/usr/share/metainfo/org.eu.mumulhl.ciyue.appdata.xml" +cp "linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml" "$APPDIR/usr/share/metainfo/org.eu.mumulhl.ciyue.appdata.xml" echo "=== 3. Getting appimagetool ===" if [ ! -x "appimagetool" ]; then @@ -58,7 +59,7 @@ fi echo "=== 4. Building AppImage ===" export ARCH=x86_64 -# -u defines the update information. +# -u defines the update information. # You can change this string to your actual update server/GitHub repo. UPDATE_INFO="gh-releases-zsync|mumu-lhl|Ciyue|latest|Ciyue-latest-x86_64.AppImage.zsync" diff --git a/tools/build_rpm.sh b/tools/build_rpm.sh new file mode 100755 index 0000000..8a0830e --- /dev/null +++ b/tools/build_rpm.sh @@ -0,0 +1,76 @@ +#!/bin/bash +set -e + +# Configuration +BINARY_NAME="ciyue" +APP_NAME="Ciyue" +APP_ID="org.eu.mumulhl.ciyue" +ICON_PATH="assets/icon.png" +BUILD_DIR="build/linux/x64/release" +BUNDLE_DIR="$BUILD_DIR/bundle" +RPM_ROOT="build/rpm" +RPM_ASSETS_DIR="linux/packaging/rpm" +DESKTOP_FILE="linux/packaging/org.eu.mumulhl.ciyue.desktop" +METAINFO_FILE="linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml" + +# Ensure we are in the project root +cd "$(dirname "$0")/.." + +# Check if flutter build has been run +if [ ! -d "$BUNDLE_DIR" ]; then + echo "Error: Bundle directory not found at $BUNDLE_DIR" + echo "Please run 'flutter build linux --release' first." + exit 1 +fi + +# Extract version from pubspec.yaml +VERSION_RAW=$(grep 'version: ' pubspec.yaml | sed 's/version: //') +# Normalize version for RPM (replace + with _, - with ~) +VERSION=$(echo $VERSION_RAW | cut -d'+' -f1 | sed 's/-/~/g') +RELEASE=$(echo $VERSION_RAW | cut -d'+' -f2) +[ "$RELEASE" == "$VERSION_RAW" ] && RELEASE=1 + +echo "=== 1. Preparing RPM Build Environment ===" +rm -rf "$RPM_ROOT" +mkdir -p "$RPM_ROOT"/{BUILD,RPMS,SOURCES,SPECS,SRPMS,BUILDROOT} + +echo "=== 2. Generating SPEC File from Template ===" +SPEC_TEMPLATE="$RPM_ASSETS_DIR/$BINARY_NAME.spec" +SPEC_FILE="$RPM_ROOT/SPECS/$BINARY_NAME.spec" +DESKTOP_FILE="$DESKTOP_FILE" +# Use C locale for standard date format in changelog (e.g., Sat Feb 14 2026) +CURRENT_DATE=$(LC_ALL=C date +"%a %b %d %Y") + +# Use absolute paths for the spec file replacements to avoid issues during rpmbuild +ABS_BUNDLE_DIR="$(pwd)/$BUNDLE_DIR" +ABS_DESKTOP_FILE="$(pwd)/$DESKTOP_FILE" +ABS_ICON_PATH="$(pwd)/$ICON_PATH" +ABS_METAINFO_FILE="$(pwd)/$METAINFO_FILE" + +sed -e "s|@VERSION@|$VERSION|g" \ + -e "s|@RELEASE@|$RELEASE|g" \ + -e "s|@BUNDLE_DIR@|$ABS_BUNDLE_DIR|g" \ + -e "s|@DESKTOP_FILE@|$ABS_DESKTOP_FILE|g" \ + -e "s|@ICON_PATH@|$ABS_ICON_PATH|g" \ + -e "s|@METAINFO_FILE@|$ABS_METAINFO_FILE|g" \ + -e "s|@DATE@|$CURRENT_DATE|g" \ + "$SPEC_TEMPLATE" > "$SPEC_FILE" + +echo "=== 3. Building RPM Package ===" +if ! command -v rpmbuild &> /dev/null; then + echo "Error: 'rpmbuild' not found. Please install 'rpm-build' (Fedora/RHEL) or equivalent." + exit 1 +fi + +# Define QA_RPATHS to ignore invalid RPATH errors (0x0002) which are common in Flutter builds +export QA_RPATHS=$(( 0x0002 )) + +rpmbuild --define "_topdir $(pwd)/$RPM_ROOT" -bb "$SPEC_FILE" + +echo "=== 4. Finalizing ===" +# Move resulting RPMs to root and cleanup +mv "$RPM_ROOT"/RPMS/*/*.rpm . +rm -rf "$RPM_ROOT" + +echo "=== Done! ===" +echo "RPM created: $(ls *.rpm)"