Skip to content

Commit 491c7c6

Browse files
committed
chore(ci): deb packaging
1 parent 5c8ef5f commit 491c7c6

File tree

6 files changed

+103
-30
lines changed

6 files changed

+103
-30
lines changed

.github/workflows/linux-build.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,12 @@ jobs:
102102
mv Ciyue-x86_64.AppImage Ciyue-latest-x86_64.AppImage
103103
mv Ciyue-x86_64.AppImage.zsync Ciyue-latest-x86_64.AppImage.zsync
104104
105-
- name: Install fastforge
106-
run: dart pub global activate fastforge
107-
108105
- name: Build Deb
109106
if: ${{ inputs.package_release_artifacts }}
110107
run: |
111108
pacman -S --noconfirm dpkg
112-
fastforge package --platform linux --targets deb --skip-clean
113-
mv dist/*/*.deb .
109+
110+
./tools/build_deb.sh
114111
mv *.deb ciyue-x86_64.deb
115112
116113
- name: Install rpmdevtools
@@ -125,7 +122,7 @@ jobs:
125122
makepkg -si --noconfirm
126123
"
127124
128-
sudo -u builder bash -c "yay -S --noconfirm rpmdevtools"
125+
sudo -u builder bash -c "yay -S --noconfirm pod2man rpmdevtools"
129126
- name: Build rpm
130127
if: ${{ inputs.package_release_artifacts }}
131128
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ dist/
6262

6363
# rpm
6464
*.rpm
65+
66+
# deb
67+
*.deb

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ build-appimage:
1515

1616
build-rpm:
1717
./tools/build_rpm.sh
18+
19+
build-deb:
20+
./tools/build_deb.sh

linux/packaging/deb/control

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: @BINARY_NAME@
2+
Version: @VERSION@
3+
Section: utils
4+
Priority: optional
5+
Architecture: @ARCH@
6+
Maintainer: Mumulhl <mumulhl.666@gmail.com>
7+
Installed-Size: @INSTALLED_SIZE@
8+
Depends: libgtk-3-0, libglib2.0-0, libstdc++6, libayatana-appindicator3-1
9+
Description: A comprehensive dictionary application built with Flutter.
10+
Support MDX/MDD formats and offers a modern user experience with Material You design.

linux/packaging/deb/make_config.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

tools/build_deb.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Configuration
5+
BINARY_NAME="ciyue"
6+
APP_NAME="Ciyue"
7+
APP_ID="org.eu.mumulhl.ciyue"
8+
ICON_PATH="assets/icon.png"
9+
BUILD_DIR="build/linux/x64/release"
10+
BUNDLE_DIR="$BUILD_DIR/bundle"
11+
DEB_ROOT="build/deb"
12+
DEB_ASSETS_DIR="linux/packaging/deb"
13+
DESKTOP_FILE="linux/packaging/org.eu.mumulhl.ciyue.desktop"
14+
METAINFO_FILE="linux/packaging/org.eu.mumulhl.ciyue.metainfo.xml"
15+
16+
# Ensure we are in the project root
17+
cd "$(dirname "$0")/.."
18+
19+
# Check if flutter build has been run
20+
if [ ! -d "$BUNDLE_DIR" ]; then
21+
echo "Error: Bundle directory not found at $BUNDLE_DIR"
22+
echo "Please run 'flutter build linux --release' first."
23+
exit 1
24+
fi
25+
26+
# Extract version from pubspec.yaml
27+
VERSION_RAW=$(grep 'version: ' pubspec.yaml | sed 's/version: //')
28+
# Normalize version for DEB (replace + with -)
29+
VERSION=$(echo $VERSION_RAW | sed 's/+/-/')
30+
31+
echo "=== 1. Preparing DEB Build Environment ==="
32+
rm -rf "$DEB_ROOT"
33+
mkdir -p "$DEB_ROOT/usr/bin"
34+
mkdir -p "$DEB_ROOT/opt/$BINARY_NAME"
35+
mkdir -p "$DEB_ROOT/usr/share/applications"
36+
mkdir -p "$DEB_ROOT/usr/share/icons/hicolor/256x256/apps"
37+
mkdir -p "$DEB_ROOT/usr/share/metainfo"
38+
mkdir -p "$DEB_ROOT/DEBIAN"
39+
40+
echo "=== 2. Copying Files ==="
41+
# Copy bundle to /opt/ciyue
42+
cp -r "$BUNDLE_DIR/"* "$DEB_ROOT/opt/$BINARY_NAME/"
43+
44+
# Create symlink in /usr/bin
45+
ln -sf "/opt/$BINARY_NAME/$BINARY_NAME" "$DEB_ROOT/usr/bin/$BINARY_NAME"
46+
47+
# Desktop file
48+
cp "$DESKTOP_FILE" "$DEB_ROOT/usr/share/applications/$APP_ID.desktop"
49+
50+
# Icon
51+
cp "$ICON_PATH" "$DEB_ROOT/usr/share/icons/hicolor/256x256/apps/$BINARY_NAME.png"
52+
53+
# Metainfo
54+
cp "$METAINFO_FILE" "$DEB_ROOT/usr/share/metainfo/$APP_ID.appdata.xml"
55+
56+
echo "=== 3. Generating Control File from Template ==="
57+
# Determine Architecture
58+
ARCH=$(dpkg --print-architecture 2>/dev/null || echo "amd64")
59+
60+
# Calculate installed size in KB
61+
INSTALLED_SIZE=$(du -sk "$DEB_ROOT" | cut -f1)
62+
63+
CONTROL_TEMPLATE="$DEB_ASSETS_DIR/control"
64+
CONTROL_FILE="$DEB_ROOT/DEBIAN/control"
65+
66+
sed -e "s|@BINARY_NAME@|$BINARY_NAME|g" \
67+
-e "s|@VERSION@|$VERSION|g" \
68+
-e "s|@ARCH@|$ARCH|g" \
69+
-e "s|@INSTALLED_SIZE@|$INSTALLED_SIZE|g" \
70+
"$CONTROL_TEMPLATE" > "$CONTROL_FILE"
71+
72+
echo "=== 4. Building DEB Package ==="
73+
if ! command -v dpkg-deb &> /dev/null; then
74+
echo "Error: 'dpkg-deb' not found. Please install 'dpkg' or 'apt-utils'."
75+
exit 1
76+
fi
77+
78+
dpkg-deb --build "$DEB_ROOT" "${BINARY_NAME}_${VERSION}_${ARCH}.deb"
79+
80+
echo "=== 5. Cleanup ==="
81+
rm -rf "$DEB_ROOT"
82+
83+
echo "=== Done! ==="
84+
echo "DEB created: $(ls ${BINARY_NAME}_${VERSION}_${ARCH}.deb)"

0 commit comments

Comments
 (0)