microsoft/hve-core
Publicmirrored from https://github.com/microsoft/hve-coreAvailable
.github/skills/installer/hve-core-installer/scripts/eject.sh
26lines · modecode
| 1 | #!/usr/bin/env bash |
| 2 | # Copyright (c) Microsoft Corporation. |
| 3 | # SPDX-License-Identifier: MIT |
| 4 | # Ejects a tracked file from HVE-Core upgrade management. |
| 5 | # Marks the file as 'ejected' in .hve-tracking.json so future upgrades skip it. |
| 6 | # Usage: eject.sh <file_path> |
| 7 | set -euo pipefail |
| 8 | |
| 9 | file_path="${1:?Usage: $0 <file_path>}" |
| 10 | manifest_path=".hve-tracking.json" |
| 11 | |
| 12 | if [ ! -f "$manifest_path" ]; then |
| 13 | echo "❌ No .hve-tracking.json found" >&2 |
| 14 | exit 1 |
| 15 | fi |
| 16 | |
| 17 | if jq -e --arg fp "$file_path" '.files[$fp]' "$manifest_path" >/dev/null 2>&1; then |
| 18 | ejected_at=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 19 | jq --arg fp "$file_path" --arg ea "$ejected_at" \ |
| 20 | '.files[$fp].status = "ejected" | .files[$fp].ejectedAt = $ea' \ |
| 21 | "$manifest_path" > "${manifest_path}.tmp" && mv "${manifest_path}.tmp" "$manifest_path" |
| 22 | echo "✅ Ejected: $file_path" |
| 23 | echo " This file will never be updated by HVE-Core." |
| 24 | else |
| 25 | echo "❌ File not found in tracking manifest: $file_path" |
| 26 | fi |
| 27 | |