Skip to main content

max / audiofiles

2.5 KB · 76 lines History Blame Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
5 PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
6 DIST_DIR="$SCRIPT_DIR"
7 ARCH=$(dpkg --print-architecture 2>/dev/null || echo "amd64")
8
9 # Read version from Cargo.toml
10 VERSION=$(grep '^version' "$PROJECT_DIR/crates/audiofiles-app/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
11 echo "Building AudioFiles v${VERSION} .deb (${ARCH})"
12
13 # Step 1: Build release binary
14 echo "==> Building release binary..."
15 cd "$PROJECT_DIR"
16 cargo build --release -p audiofiles-app
17
18 # Step 2: Assemble deb tree
19 echo "==> Assembling package..."
20 PKG_DIR="$DIST_DIR/.deb-staging/audiofiles_${VERSION}_${ARCH}"
21 rm -rf "$DIST_DIR/.deb-staging"
22 mkdir -p "$PKG_DIR/DEBIAN"
23 mkdir -p "$PKG_DIR/usr/bin"
24 mkdir -p "$PKG_DIR/usr/share/applications"
25 mkdir -p "$PKG_DIR/usr/share/icons/hicolor/256x256/apps"
26
27 cp "$PROJECT_DIR/target/release/audiofiles-app" "$PKG_DIR/usr/bin/audiofiles-app"
28 cp "$DIST_DIR/audiofiles.desktop" "$PKG_DIR/usr/share/applications/audiofiles.desktop"
29 cp "$DIST_DIR/audiofiles.png" "$PKG_DIR/usr/share/icons/hicolor/256x256/apps/audiofiles.png"
30
31 # Compute installed size in KB
32 INSTALLED_SIZE=$(du -sk "$PKG_DIR" | cut -f1)
33
34 # Runtime deps:
35 # libasound2 - ALSA (cpal audio playback)
36 # libgl1 - OpenGL (eframe glow backend)
37 # libxcb1 - X11 connection (egui/winit)
38 # libxkbcommon0 - Keyboard input
39 # libssl3 - TLS (reqwest native-tls) -- libssl3 for Ubuntu 22.04+
40 # libgtk-3-0 - File dialogs (rfd/nfd)
41 cat > "$PKG_DIR/DEBIAN/control" << CONTROL
42 Package: audiofiles
43 Version: ${VERSION}
44 Section: sound
45 Priority: optional
46 Architecture: ${ARCH}
47 Depends: libasound2, libgl1, libxcb1, libxkbcommon0, libssl3, libgtk-3-0
48 Installed-Size: ${INSTALLED_SIZE}
49 Maintainer: Maxwell Morgan Johnson <max@makenot.work>
50 Homepage: https://makenot.work/p/audiofiles
51 Description: Sample manager with content-addressed storage
52 AudioFiles is a desktop sample manager with content-addressed storage,
53 virtual filesystem, and cloud sync. Supports WAV, FLAC, MP3, OGG, and
54 AIFF formats.
55 CONTROL
56
57 # Step 3: Set permissions
58 chmod 755 "$PKG_DIR/usr/bin/audiofiles-app"
59 chmod 644 "$PKG_DIR/usr/share/applications/audiofiles.desktop"
60 chmod 644 "$PKG_DIR/usr/share/icons/hicolor/256x256/apps/audiofiles.png"
61
62 # Step 4: Build .deb
63 echo "==> Building .deb..."
64 DEB_NAME="audiofiles_${VERSION}_${ARCH}.deb"
65 DEB_PATH="$DIST_DIR/$DEB_NAME"
66 rm -f "$DEB_PATH"
67
68 dpkg-deb --build --root-owner-group "$PKG_DIR" "$DEB_PATH"
69
70 # Cleanup
71 rm -rf "$DIST_DIR/.deb-staging"
72
73 echo ""
74 echo "Done: $DEB_PATH"
75 echo "Install with: sudo dpkg -i $DEB_NAME"
76