Files
imajviewer/dist/rebuild-deb.sh
Alhan 2592d5d3d3
Some checks failed
Build & Release / build-linux (push) Has been cancelled
Build & Release / build-windows (push) Has been cancelled
Build & Release / create-release (push) Has been cancelled
fix: rebuild-deb.sh — create target dir (deb/usr/lib/imajviewer no longer tracked)
2026-08-06 06:20:57 +03:00

52 lines
1.8 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
APP=imajviewer
DIST_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$DIST_DIR")"
# Versiyon tek kaynak: pubspec.yaml ("1.0.1+2" → "1.0.1")
VERSION=$(grep -m1 '^version:' "${PROJECT_DIR}/pubspec.yaml" | sed -E 's/^version:[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
RELEASE_DIR="${PROJECT_DIR}/build/linux/x64/release/bundle"
SRC_DIR="${PROJECT_DIR}/deb"
DEB="${DIST_DIR}/${APP}_${VERSION}_amd64.deb"
# ── Geçici çalışma dizini ──
TMPDIR=$(mktemp -d)
trap "rm -rf $TMPDIR" EXIT
echo "• Kaynak deb/ ağacı kopyalanıyor…"
cp -a "$SRC_DIR/." "$TMPDIR/pkg"
echo "• Kontrol dosyasındaki versiyon güncelleniyor…"
sed -i "s/^Version: .*/Version: ${VERSION}/" "$TMPDIR/pkg/DEBIAN/control"
chmod 755 "$TMPDIR/pkg/DEBIAN/postinst" "$TMPDIR/pkg/DEBIAN/prerm"
echo "• Yeni release binary ve kütüphaneler kopyalanıyor…"
mkdir -p "$TMPDIR/pkg/usr/lib/${APP}"
cp -r "$RELEASE_DIR"/* "$TMPDIR/pkg/usr/lib/${APP}/"
echo "• Symlink kontrol ediliyor…"
ln -sfn "/usr/lib/${APP}/${APP}" "$TMPDIR/pkg/usr/bin/${APP}"
echo "• .desktop dosyası izinleri…"
chmod 644 "$TMPDIR/pkg/usr/share/applications/${APP}.desktop"
echo "• MIME tanımı izinleri…"
chmod 644 "$TMPDIR/pkg/usr/share/mime/packages/${APP}.xml"
echo "• index.theme kaldırılıyor (hicolor-icon-theme sahipli)…"
rm -f "$TMPDIR/pkg/usr/share/icons/hicolor/index.theme"
find "$TMPDIR/pkg/usr/share/icons/hicolor" -type f -exec chmod 644 {} +
echo "• Plugin RUNPATH düzeltiliyor (\$ORIGIN)…"
for so in "$TMPDIR/pkg/usr/lib/${APP}/lib/"*.so; do
[ -f "$so" ] && patchelf --set-rpath '$ORIGIN' "$so" 2>/dev/null || true
done
echo "• Yeni .deb paketi oluşturuluyor…"
fakeroot dpkg-deb --build "$TMPDIR/pkg" "${DEB}.tmp" >/dev/null
mv "${DEB}.tmp" "$DEB"
echo "${DEB} oluşturuldu ($(du -h "$DEB" | cut -f1))"