From 8f634a5de021aa5cf47d35c83a774c138ec5b0db Mon Sep 17 00:00:00 2001 From: SamNet-dev Date: Wed, 4 Feb 2026 14:44:35 -0600 Subject: [PATCH] feat: add Windows update function and switch to upstream paqet repo Windows client (paqet-client.ps1): - Added Update-Paqet function with version tracking - Added Get-InstalledPaqetVersion and Save-PaqetVersion helpers - Creates backup before updating, restores on failure - Added menu option 7 for update, moved About to option 8 All platforms: - Switched paqet binary downloads from SamNet-dev/paqctl to hanselime/paqet - Updated paqctl.sh PAQET_REPO to hanselime/paqet - Updated README.md download URLs to hanselime/paqet - Users now get paqet updates directly from upstream source - Allows paqctl script releases without affecting paqet binary updates --- README.md | 12 +-- paqctl.sh | 4 +- windows/paqet-client.ps1 | 180 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 185 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 03dfe05..d3248ea 100644 --- a/README.md +++ b/README.md @@ -446,11 +446,11 @@ macOS requires manual setup since there's no automated script yet. mkdir -p ~/paqet && cd ~/paqet # Download latest release (Intel Mac) -curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz +curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz tar -xzf paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz # For Apple Silicon (M1/M2/M3): -# curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz +# curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz # tar -xzf paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz # Make executable @@ -644,7 +644,7 @@ Then run GFK from within the venv. ```bash # Download paqet mkdir -p ~/paqet && cd ~/paqet -curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-linux-amd64-v1.0.0-alpha.13.tar.gz +curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-linux-amd64-v1.0.0-alpha.13.tar.gz tar -xzf paqet-linux-amd64-v1.0.0-alpha.13.tar.gz chmod +x paqet_linux_amd64 @@ -1198,11 +1198,11 @@ macOS نیاز به راه‌اندازی دستی دارد. mkdir -p ~/paqet && cd ~/paqet # برای Intel Mac: -curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz +curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz tar -xzf paqet-darwin-amd64-v1.0.0-alpha.13.tar.gz # برای Apple Silicon (M1/M2/M3): -# curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz +# curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz # tar -xzf paqet-darwin-arm64-v1.0.0-alpha.13.tar.gz chmod +x paqet_darwin_amd64 @@ -1315,7 +1315,7 @@ sudo python3 mainclient.py ```bash # دانلود paqet mkdir -p ~/paqet && cd ~/paqet -curl -LO https://github.com/SamNet-dev/paqctl/releases/download/v1.0.0-alpha.13/paqet-linux-amd64-v1.0.0-alpha.13.tar.gz +curl -LO https://github.com/hanselime/paqet/releases/download/v1.0.0-alpha.13/paqet-linux-amd64-v1.0.0-alpha.13.tar.gz tar -xzf paqet-linux-amd64-v1.0.0-alpha.13.tar.gz chmod +x paqet_linux_amd64 diff --git a/paqctl.sh b/paqctl.sh index 0238e6c..c408536 100644 --- a/paqctl.sh +++ b/paqctl.sh @@ -36,7 +36,7 @@ PAQET_VERSION_PINNED="v1.0.0-alpha.13" XRAY_VERSION_PINNED="v26.2.4" GFK_VERSION_PINNED="v1.0.0" -PAQET_REPO="SamNet-dev/paqctl" +PAQET_REPO="hanselime/paqet" PAQET_API_URL="https://api.github.com/repos/${PAQET_REPO}/releases/latest" INSTALL_DIR="${INSTALL_DIR:-/opt/paqctl}" BACKUP_DIR="$INSTALL_DIR/backups" @@ -1880,7 +1880,7 @@ GFK_VERSION_PINNED="v1.0.0" INSTALL_DIR="REPLACE_ME_INSTALL_DIR" BACKUP_DIR="$INSTALL_DIR/backups" -PAQET_REPO="SamNet-dev/paqctl" +PAQET_REPO="hanselime/paqet" PAQET_API_URL="https://api.github.com/repos/${PAQET_REPO}/releases/latest" GFK_REPO="SamNet-dev/paqctl" GFK_BRANCH="main" diff --git a/windows/paqet-client.ps1 b/windows/paqet-client.ps1 index 814f57c..000454c 100644 --- a/windows/paqet-client.ps1 +++ b/windows/paqet-client.ps1 @@ -321,7 +321,7 @@ function Install-Paqet { return $true } - $zipUrl = "https://github.com/SamNet-dev/paqctl/releases/download/$PaqetVersion/paqet-windows-amd64-$PaqetVersion.zip" + $zipUrl = "https://github.com/hanselime/paqet/releases/download/$PaqetVersion/paqet-windows-amd64-$PaqetVersion.zip" $zipFile = "$env:TEMP\paqet.zip" Write-Info "Downloading paqet $PaqetVersion..." @@ -688,6 +688,178 @@ function Get-ClientStatus { Write-Host "" } +#═══════════════════════════════════════════════════════════════════════ +# Update Function +#═══════════════════════════════════════════════════════════════════════ + +function Get-InstalledPaqetVersion { + # Check settings file first for tracked version + if (Test-Path $SettingsFile) { + $content = Get-Content $SettingsFile -ErrorAction SilentlyContinue + foreach ($line in $content) { + if ($line -match '^PAQET_VERSION="?([^"]+)"?') { + return $Matches[1] + } + } + } + # Fall back to pinned version if paqet is installed + if (Test-Path $PaqetExe) { + return $PaqetVersion + } + return $null +} + +function Save-PaqetVersion { + param([string]$Version) + + if (-not (Test-Path $SettingsFile)) { + return + } + + $content = Get-Content $SettingsFile -Raw -ErrorAction SilentlyContinue + if ($content -match 'PAQET_VERSION=') { + # Update existing + $content = $content -replace 'PAQET_VERSION="[^"]*"', "PAQET_VERSION=`"$Version`"" + } else { + # Add new line + $content = $content.TrimEnd() + "`nPAQET_VERSION=`"$Version`"" + } + [System.IO.File]::WriteAllText($SettingsFile, $content) +} + +function Update-Paqet { + Write-Host "" + Write-Host " CHECKING FOR UPDATES" -ForegroundColor Cyan + Write-Host " ────────────────────" -ForegroundColor Cyan + Write-Host "" + + # Check if paqet is installed + if (-not (Test-Path $PaqetExe)) { + Write-Warn "Paqet is not installed. Use option 1 to install first." + return $false + } + + # Get installed version + $installedVersion = Get-InstalledPaqetVersion + if (-not $installedVersion) { + $installedVersion = $PaqetVersion + } + + # Query GitHub API for latest release + Write-Info "Querying GitHub for latest release..." + try { + $apiUrl = "https://api.github.com/repos/hanselime/paqet/releases/latest" + $response = Invoke-RestMethod -Uri $apiUrl -TimeoutSec 30 + $latestVersion = $response.tag_name + } catch { + Write-Err "Failed to check for updates: $_" + return $false + } + + # Show version info + Write-Host "" + Write-Host " Installed version: $installedVersion" -ForegroundColor White + Write-Host " Latest version: $latestVersion" -ForegroundColor White + Write-Host "" + + # Compare versions + if ($installedVersion -eq $latestVersion) { + Write-Success "You are already on the latest version!" + return $true + } + + # Confirm update + Write-Host " A new version is available!" -ForegroundColor Yellow + $confirm = Read-Host " Update to $latestVersion? [y/N]" + if ($confirm -notmatch "^[Yy]") { + Write-Info "Update cancelled" + return $false + } + + # Stop running paqet first + $paqetProc = Get-Process -Name "paqet_windows_amd64" -ErrorAction SilentlyContinue + if ($paqetProc) { + Write-Info "Stopping paqet..." + Stop-Process -Name "paqet_windows_amd64" -Force + Start-Sleep -Seconds 2 + } + + # Download new version + $zipUrl = "https://github.com/hanselime/paqet/releases/download/$latestVersion/paqet-windows-amd64-$latestVersion.zip" + $zipFile = "$env:TEMP\paqet-update.zip" + $extractDir = "$env:TEMP\paqet-update" + + Write-Info "Downloading paqet $latestVersion..." + try { + Invoke-WebRequest -Uri $zipUrl -OutFile $zipFile -TimeoutSec 120 + } catch { + Write-Err "Download failed: $_" + return $false + } + + # Validate download + if (-not (Test-Path $zipFile) -or (Get-Item $zipFile).Length -lt 1000) { + Write-Err "Downloaded file is invalid or too small" + return $false + } + + # Extract + Write-Info "Extracting..." + try { + if (Test-Path $extractDir) { Remove-Item $extractDir -Recurse -Force } + Expand-Archive -Path $zipFile -DestinationPath $extractDir -Force + } catch { + Write-Err "Extraction failed: $_" + Remove-Item $zipFile -Force -ErrorAction SilentlyContinue + return $false + } + + # Find the binary + $newBinary = Get-ChildItem -Path $extractDir -Filter "paqet_windows_amd64.exe" -Recurse | Select-Object -First 1 + if (-not $newBinary) { + Write-Err "Could not find paqet binary in archive" + Remove-Item $zipFile -Force -ErrorAction SilentlyContinue + Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue + return $false + } + + # Backup old binary + $backupPath = "$InstallDir\paqet_windows_amd64.exe.bak" + try { + Copy-Item $PaqetExe $backupPath -Force + Write-Info "Backed up old binary" + } catch { + Write-Warn "Could not backup old binary: $_" + } + + # Install new binary + try { + Copy-Item $newBinary.FullName $PaqetExe -Force + } catch { + Write-Err "Failed to install new binary: $_" + # Try to restore backup + if (Test-Path $backupPath) { + Copy-Item $backupPath $PaqetExe -Force -ErrorAction SilentlyContinue + } + return $false + } + + # Save version to settings + Save-PaqetVersion -Version $latestVersion + + # Cleanup + Remove-Item $zipFile -Force -ErrorAction SilentlyContinue + Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue + + Write-Host "" + Write-Success "Updated to $latestVersion!" + Write-Host "" + Write-Info "Restart the client to use the new version" + Write-Host "" + + return $true +} + #═══════════════════════════════════════════════════════════════════════ # Interactive Menu #═══════════════════════════════════════════════════════════════════════ @@ -722,7 +894,8 @@ function Show-Menu { Write-Host " 4. Start client" Write-Host " 5. Stop client" Write-Host " 6. Show status" - Write-Host " 7. About (how it works)" + Write-Host " 7. Update paqet" + Write-Host " 8. About (how it works)" Write-Host " 0. Exit" Write-Host "" @@ -780,7 +953,8 @@ function Show-Menu { } "5" { Stop-Client } "6" { Get-ClientStatus } - "7" { Show-About } + "7" { Update-Paqet } + "8" { Show-About } "0" { return } default { Write-Warn "Invalid option" } }