File size: 3,651 Bytes
cf68e88 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # =============================================================================
# setup-win10.ps1
# One-command clone + automatic download of win10.qcow2 into win10-image/
# =============================================================================
$ErrorActionPreference = 'Stop' # Exit immediately if any command fails
$GithubRepo = "https://github.com/nullvoider07/windows10-base"
$RepoName = Split-Path $GithubRepo -Leaf
Write-Host "π Cloning GitHub repo: $GithubRepo"
# ----------------------------- Clone with GitHub CLI -----------------------
Write-Host "π§ Checking GitHub CLI..."
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
Write-Host " GitHub CLI not found. Installing via winget..."
# Install gh silently, accepting agreements automatically
winget install --id GitHub.cli --exact --accept-source-agreements --accept-package-agreements
# Refresh the PATH variables in the current session so 'gh' is recognized immediately
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# Verify installation succeeded
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
throw "β Failed to install GitHub CLI automatically. Please install it manually from https://cli.github.com"
}
Write-Host " β
GitHub CLI installed successfully."
} else {
Write-Host " β
GitHub CLI already available."
}
gh repo clone $GithubRepo $RepoName -- --depth=1
# ----------------------------- Create folder -------------------------------
Write-Host "π Creating folder: win10-image/"
$ImagePath = Join-Path $RepoName "win10-image"
New-Item -ItemType Directory -Force -Path $ImagePath | Out-Null
# ----------------------------- Ensure uv is available ---------------------
Write-Host "π§ Checking uv..."
if (Get-Command uv -ErrorAction SilentlyContinue) {
Write-Host " uv already available β skipping installation."
} else {
Write-Host " Installing uv package manager..."
Invoke-RestMethod -Uri https://astral.sh/uv/install.ps1 | Invoke-Expression
$env:Path += ";$HOME\.cargo\bin;$HOME\.local\bin"
}
# ----------------------------- Ephemeral venv for huggingface-cli ----------
Write-Host "π§ Creating ephemeral venv for huggingface-cli..."
$TempDir = [System.IO.Path]::GetTempPath()
$HfVenv = Join-Path $TempDir "hf-venv-$(New-Guid)"
# uv venv picks the correct current Python automatically
uv venv $HfVenv --quiet
# Install directly into the venv β no --system, no activation needed
uv pip install --python "$HfVenv\Scripts\python.exe" transformers --quiet
Write-Host " β
huggingface-hub installed in ephemeral venv."
# ----------------------------- Download QCOW2 ------------------------------
Write-Host "π₯ Downloading win10.qcow2 (large file) into $RepoName\win10-image\ ..."
Write-Host " (This may take a while β progress bar will show)"
# Call huggingface-cli directly by its venv path β no PATH lookup, no cache
& "$HfVenv\Scripts\hf.exe" download NullVoider/windows10-base win10.qcow2 --local-dir $ImagePath
# ----------------------------- Cleanup venv --------------------------------
Write-Host "π§Ή Cleaning up ephemeral venv..."
Remove-Item -Recurse -Force $HfVenv
# ----------------------------- Final message -------------------------------
Write-Host ""
Write-Host "β
SUCCESS!" -ForegroundColor Green
Write-Host " Repository cloned β $RepoName\"
Write-Host " QCOW2 image ready at: $RepoName\win10-image\win10.qcow2"
Write-Host ""
Write-Host " Next time just run: cd $RepoName ; git pull" |