-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_deb.sh
More file actions
executable file
·71 lines (60 loc) · 2.16 KB
/
build_deb.sh
File metadata and controls
executable file
·71 lines (60 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
DIST_DIR="$ROOT_DIR/dist"
BUILD_DIR="$DIST_DIR/deb_build"
PACKAGE="sqliteview"
VERSION=$(grep -m1 '^version' "$ROOT_DIR/pyproject.toml" | sed 's/.*"\(.*\)"/\1/')
ARCH="all"
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR/DEBIAN"
mkdir -p "$BUILD_DIR/usr/lib/$PACKAGE"
mkdir -p "$BUILD_DIR/usr/bin"
mkdir -p "$BUILD_DIR/usr/share/applications"
mkdir -p "$BUILD_DIR/usr/share/icons/hicolor/256x256/apps"
if ! python3 -c 'import build' >/dev/null 2>&1; then
echo "Python package 'build' is required. Install it with 'pip install build'." >&2
exit 1
fi
python3 -m build --wheel --outdir "$DIST_DIR"
WHEEL_FILE=$(ls "$DIST_DIR"/${PACKAGE}-${VERSION}-*.whl | head -n 1)
if [[ -z "$WHEEL_FILE" ]]; then
echo "Wheel file not found. Aborting." >&2
exit 1
fi
python3 - "$WHEEL_FILE" "$BUILD_DIR/usr/lib/$PACKAGE" <<'PY'
import sys
import zipfile
import pathlib
wheel = pathlib.Path(sys.argv[1])
destination = pathlib.Path(sys.argv[2])
with zipfile.ZipFile(wheel, 'r') as archive:
archive.extractall(destination)
PY
cat <<EOF_CONTROL > "$BUILD_DIR/DEBIAN/control"
Package: $PACKAGE
Version: $VERSION
Section: utils
Priority: optional
Architecture: all
Maintainer: SQLite Viewer Team <dev@example.com>
Depends: python3 (>= 3.10), python3-pyqt6
Description: PyQt6-based SQLite database client for Ubuntu.
SQLiteView provides a desktop UI for browsing tables, running
ad-hoc queries, and exporting results. Packaged with its Python
dependencies.
EOF_CONTROL
cat <<EOF_EXEC > "$BUILD_DIR/usr/bin/$PACKAGE"
#!/usr/bin/env bash
set -euo pipefail
export PYTHONPATH="/usr/lib/$PACKAGE"
exec python3 -m sqliteviewer "\$@"
EOF_EXEC
chmod +x "$BUILD_DIR/usr/bin/$PACKAGE"
install -m 644 "$ROOT_DIR/src/sqliteviewer/resources/sqliteviewer.desktop" "$BUILD_DIR/usr/share/applications/sqliteviewer.desktop"
install -m 644 "$ROOT_DIR/src/sqliteviewer/resources/icon.png" "$BUILD_DIR/usr/share/icons/hicolor/256x256/apps/sqliteviewer.png"
OUTPUT_DEB="$DIST_DIR/${PACKAGE}_${VERSION}_${ARCH}.deb"
rm -f "$OUTPUT_DEB"
dpkg-deb --build "$BUILD_DIR" "$OUTPUT_DEB"
rm -rf "$BUILD_DIR"
echo "Built Debian package: $OUTPUT_DEB"