Files
imajviewer/install.sh
Alhan a4567af902
Some checks failed
Build Windows / build-windows (push) Has been cancelled
chore: reorganize dist/, remove release/, update install paths
- Move all distribution binaries to dist/ (Linux .deb + Windows .exe)
- Remove release/ directory (redundant, merged into dist/)
- Remove root-level .deb and .tar.gz leftovers
- Update install.sh to reference dist/ instead of release/
- Update README.md with correct dist/ paths and .deb-first Linux install
- Update .gitignore: ignore root binaries, keep dist/*.deb and dist/*.exe
2026-07-27 17:11:34 +03:00

105 lines
3.8 KiB
Bash
Executable File
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
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/release/bundle"
INSTALL_DIR="${HOME}/.local/lib/${APP}"
BIN_LINK="${HOME}/.local/bin/${APP}"
DESKTOP_FILE="${HOME}/.local/share/applications/${APP}.desktop"
ICON_DIR="${HOME}/.local/share/icons/hicolor/64x64/apps"
ICON_FILE="${ICON_DIR}/${APP}.png"
# ── Renkler ──
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; NC='\033[0m'
info() { echo -e "${CYAN}${NC} $1"; }
ok() { echo -e "${GREEN}${NC} $1"; }
err() { echo -e "${RED}${NC} $1"; exit 1; }
# ── Ön koşul kontrol ──
command -v xdg-mime >/dev/null 2>&1 || err "xdg-mime bulunamadı (xdg-utils paketi gerekli)"
command -v xdg-desktop-menu >/dev/null 2>&1 || err "xdg-desktop-menu bulunamadı (xdg-utils paketi gerekli)"
if [ ! -f "$BUNDLE_DIR/${APP}" ]; then
info "Binary bulunamadı, Flutter build başlatılıyor…"
cd "$SCRIPT_DIR"
flutter build linux 2>&1 | tail -1 || err "Flutter build başarısız! Sistemde Flutter SDK kurulu olmalı veya dist/imajviewer_*.deb paketini kullanın."
BUNDLE_DIR="${SCRIPT_DIR}/build/linux/x64/release/bundle"
[ -f "$BUNDLE_DIR/${APP}" ] || err "Build başarısız!"
fi
# ── Kurulum dizinleri ──
mkdir -p "$INSTALL_DIR" "$(dirname "$BIN_LINK")" "$(dirname "$DESKTOP_FILE")" "$ICON_DIR"
# ── Binary + kütüphaneler ──
info "Binary ve kütüphaneler kopyalanıyor…"
cp -r "$BUNDLE_DIR"/* "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/${APP}"
# ── Symlink ──
ln -sf "$INSTALL_DIR/${APP}" "$BIN_LINK"
ok "Symlink: $BIN_LINK$INSTALL_DIR/${APP}"
# ── İkon (64×64 PNG) ──
if [ ! -f "$ICON_FILE" ]; then
info "İkon oluşturuluyor…"
python3 -c "
import struct, zlib, sys
w=h=64; r=g=b=0xff
raw=b''
for y in range(h):
raw+=b'\\x00'
for x in range(w):
d=abs(x-32)+abs(y-32)
if d<24: r,g,b=100,140,255
elif d<30: r,g,b=200,220,255
else: r,g,b=40,45,50
raw+=bytes([r,g,b,255])
def c(t,d):
c=t+d
return struct.pack('>I',len(d))+c+struct.pack('>I',zlib.crc32(c)&0xffffffff)
with open('$ICON_FILE','wb') as f:
f.write(b'\\x89PNG\\r\\n\\x1a\\n')
f.write(c(b'IHDR',struct.pack('>IIBBBBB',w,h,8,6,0,0,0)))
f.write(c(b'IDAT',zlib.compress(raw)))
f.write(c(b'IEND',b''))
print(' İkon: $ICON_FILE')
"
fi
ok "İkon hazır"
# ── .desktop dosyası ──
info ".desktop dosyası oluşturuluyor…"
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Type=Application
Name=${APP}
Comment=Ultra hafif görüntü izleyici
Exec=${BIN_LINK} %F
Icon=${APP}
Terminal=false
Categories=Graphics;Viewer;RasterGraphics;
MimeType=image/png;image/jpeg;image/webp;image/bmp;image/gif;image/jpg;
StartupNotify=false
EOF
ok "${DESKTOP_FILE}"
# ── MIME default ──
info "Varsayılan görüntü izleyici olarak ayarlanıyor…"
for mime in image/png image/jpeg image/jpg image/webp image/bmp image/gif; do
xdg-mime default "${APP}.desktop" "$mime" 2>/dev/null || true
done
# ── Masaüstü veritabanını güncelle ──
which update-desktop-database &>/dev/null && update-desktop-database "${HOME}/.local/share/applications/" 2>/dev/null || true
which gtk-update-icon-cache &>/dev/null && gtk-update-icon-cache "${HOME}/.local/share/icons/hicolor/" 2>/dev/null || true
echo ""
echo -e "${GREEN}══════════════════════════════════════════${NC}"
echo -e "${GREEN} ${APP} kuruldu!${NC}"
echo -e "${GREEN} Bir PNG/JPG/WebP dosyasına çift tıklayın${NC}"
echo -e "${GREEN} veya 'xdg-open <dosya>' ile test edin${NC}"
echo -e "${GREEN}══════════════════════════════════════════${NC}"
echo ""
echo "Kaldırmak için: rm -rf ${INSTALL_DIR} ${BIN_LINK} ${DESKTOP_FILE} ${ICON_FILE}"