windows11-base / scripts /setup-win11.sh
NullVoider's picture
Upload folder using huggingface_hub
2134652 verified
raw
history blame
3.68 kB
#!/bin/bash
# =============================================================================
# setup-win11.sh
# One-command clone + automatic download of win11.qcow2 into win11-image/
# =============================================================================
set -e # Exit immediately if any command fails
GITHUB_REPO="https://github.com/nullvoider07/windows11-base"
REPO_NAME=$(basename "$GITHUB_REPO")
echo "πŸš€ Cloning GitHub repo: $GITHUB_REPO"
# ----------------------------- Clone with GitHub CLI -----------------------
echo "πŸ”§ Checking GitHub CLI..."
if ! command -v gh >/dev/null 2>&1; then
echo " GitHub CLI not found. Attempting to install..."
# Try Homebrew (macOS/Linux)
if command -v brew >/dev/null 2>&1; then
brew install gh
# Try APT (Debian/Ubuntu)
elif command -v apt-get >/dev/null 2>&1; then
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
sudo apt-get update && sudo apt-get install gh -y
else
echo "❌ Unsupported package manager. Please install GitHub CLI manually:"
echo " https://cli.github.com"
exit 1
fi
else
echo " βœ… GitHub CLI already available."
fi
gh repo clone "$GITHUB_REPO" "$REPO_NAME" -- --depth=1
# ----------------------------- Create folder -------------------------------
echo "πŸ“ Creating folder: win11-image/"
mkdir -p "$REPO_NAME/win11-image"
# ----------------------------- Ensure uv is available ---------------------
echo "πŸ”§ Checking uv..."
if command -v uv >/dev/null 2>&1; then
echo " uv already available β€” skipping installation."
else
echo " Installing uv package manager..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH"
hash -r
fi
# ----------------------------- Ephemeral venv for huggingface-cli ----------
# Create a temporary venv, install huggingface-hub into it, run the download,
# then delete the venv. This avoids all PATH/hash-cache/interpreter-mismatch
# issues caused by stale system-wide or tool-level installs.
echo "πŸ”§ Creating ephemeral venv for huggingface-cli..."
HF_VENV="$(mktemp -d)/hf-venv"
# uv venv picks the correct current Python automatically
uv venv "$HF_VENV" --quiet
# Install directly into the venv β€” no --system, no activation needed
uv pip install --python "$HF_VENV/bin/python" transformers --quiet
echo " βœ… huggingface-hub installed in ephemeral venv."
# ----------------------------- Download QCOW2 ------------------------------
echo "πŸ“₯ Downloading win11.qcow2 (large file) into $REPO_NAME/win11-image/ ..."
echo " (This may take a while β€” progress bar will show)"
# Call huggingface-cli directly by its venv path β€” no PATH lookup, no cache
"$HF_VENV/bin/hf" download NullVoider/windows11-base win11.qcow2 \
--local-dir "$REPO_NAME/win11-image"
# ----------------------------- Cleanup venv --------------------------------
echo "🧹 Cleaning up ephemeral venv..."
rm -rf "$HF_VENV"
# ----------------------------- Final message -------------------------------
echo ""
echo "βœ… SUCCESS!"
echo " Repository cloned β†’ $REPO_NAME/"
echo " QCOW2 image ready at: $REPO_NAME/win11-image/win11.qcow2"
echo ""
echo " Next time just run: cd $REPO_NAME && git pull"