Files
imajviewer/dist/rebuild-deb.sh
T

51 lines
1.8 KiB
Bash
Raw 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…"
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))"