#!/bin/bash
# Change to this script directory
cd "$(dirname "$0")"
cd ..

# Win .msi installer
echo "Creating Windows MSI symlink..."
if [ -d "build/package/x86_64-pc-windows-gnu" ]; then
    pushd build/package/x86_64-pc-windows-gnu
    if ls *.msi >/dev/null 2>&1; then
        latest_msi=$(ls -t *.msi | head -n 1)
        if [ -n "$latest_msi" ]; then
            ln -sf "$latest_msi" tpnote-latest-x86_64.msi
            echo "Created symlink: tpnote-latest-x86_64.msi -> $latest_msi"
        fi
    fi
    popd
fi

# Debian package
echo "Creating Debian package symlink..."
if [ -d "build/package/x86_64-unknown-linux-gnu" ]; then
    pushd build/package/x86_64-unknown-linux-gnu
    if ls *.deb >/dev/null 2>&1; then
        latest_deb=$(ls -t *.deb | head -n 1)
        if [ -n "$latest_deb" ]; then
            ln -sf "$latest_deb" tpnote_latest_amd64.deb
            echo "Created symlink: tpnote_latest_amd64.deb -> $latest_deb"
        fi
    fi
    popd
fi
